2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'IDE', :js do
|
2023-01-13 00:05:48 +05:30
|
|
|
include WebIdeSpecHelpers
|
|
|
|
|
|
|
|
let_it_be(:ide_iframe_selector) { '#ide iframe' }
|
|
|
|
let_it_be(:normal_project) { create(:project, :repository) }
|
|
|
|
|
|
|
|
let(:project) { normal_project }
|
|
|
|
let(:vscode_ff) { false }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_maintainer(user)
|
|
|
|
stub_feature_flags(vscode_web_ide: vscode_ff)
|
|
|
|
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples "legacy Web IDE" do
|
|
|
|
it 'loads legacy Web IDE', :aggregate_failures do
|
|
|
|
expect(page).to have_selector('.context-header', text: project.name)
|
|
|
|
|
|
|
|
# Assert new Web IDE is not loaded
|
|
|
|
expect(page).not_to have_selector(ide_iframe_selector)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples "new Web IDE" do
|
|
|
|
it 'loads new Web IDE', :aggregate_failures do
|
|
|
|
expect(page).not_to have_selector('.context-header')
|
|
|
|
|
|
|
|
iframe = find(ide_iframe_selector)
|
|
|
|
|
|
|
|
page.within_frame(iframe) do
|
|
|
|
expect(page).to have_selector('.title', text: project.name.upcase)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
context 'with vscode feature flag off' do
|
2018-05-09 12:01:36 +05:30
|
|
|
before do
|
2023-01-13 00:05:48 +05:30
|
|
|
ide_visit(project)
|
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it_behaves_like 'legacy Web IDE'
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it 'does not show switch button' do
|
|
|
|
expect(page).not_to have_button('Switch to new Web IDE')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with vscode feature flag on and use_legacy_web_ide=true' do
|
|
|
|
let(:vscode_ff) { true }
|
|
|
|
let(:user) { create(:user, use_legacy_web_ide: true) }
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
before do
|
|
|
|
ide_visit(project)
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it_behaves_like 'legacy Web IDE'
|
2022-10-11 01:57:18 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
describe 'when user switches to new Web IDE' do
|
|
|
|
before do
|
|
|
|
click_button('Switch to new Web IDE')
|
2022-10-11 01:57:18 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
# Confirm modal
|
|
|
|
page.within('#confirmationModal') do
|
|
|
|
click_button('Switch editors')
|
2022-10-11 01:57:18 +05:30
|
|
|
end
|
|
|
|
end
|
2023-01-13 00:05:48 +05:30
|
|
|
|
|
|
|
it_behaves_like 'new Web IDE'
|
2022-10-11 01:57:18 +05:30
|
|
|
end
|
2023-01-13 00:05:48 +05:30
|
|
|
end
|
2022-10-11 01:57:18 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
describe 'sub-groups' do
|
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:subgroup) { create(:group, parent: group) }
|
|
|
|
let_it_be(:subgroup_project) { create(:project, :repository, namespace: subgroup) }
|
2022-10-11 01:57:18 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
let(:project) { subgroup_project }
|
2022-10-11 01:57:18 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
before do
|
|
|
|
ide_visit(project)
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
2023-01-13 00:05:48 +05:30
|
|
|
|
|
|
|
it_behaves_like 'legacy Web IDE'
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
end
|