diff options
Diffstat (limited to 'spec/features/projects/files')
4 files changed, 20 insertions, 31 deletions
diff --git a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb index 6b1e60db5b1..0ad44f31a52 100644 --- a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb +++ b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb @@ -18,7 +18,7 @@ RSpec.describe 'Projects > Files > Project owner sees a link to create a license expect(page).to have_current_path("/-/ide/project/#{project.full_path}/edit/master/-/LICENSE", ignore_query: true) - expect(page).to have_selector('.qa-file-templates-bar') # rubocop:disable QA/SelectorUsage + expect(page).to have_selector('[data-testid="file-templates-bar"]') select_template('MIT License') diff --git a/spec/features/projects/files/user_browses_files_spec.rb b/spec/features/projects/files/user_browses_files_spec.rb index 53fdd5a15dd..0f3ce5a2bad 100644 --- a/spec/features/projects/files/user_browses_files_spec.rb +++ b/spec/features/projects/files/user_browses_files_spec.rb @@ -348,7 +348,7 @@ RSpec.describe "User browses files", :js do end it "shows raw file content in a new tab" do - new_tab = window_opened_by {click_link 'Open raw'} + new_tab = window_opened_by { click_link 'Open raw' } within_window new_tab do expect(page).to have_content("Test file") @@ -366,7 +366,7 @@ RSpec.describe "User browses files", :js do end it "shows raw file content in a new tab" do - new_tab = window_opened_by {click_link 'Open raw'} + new_tab = window_opened_by { click_link 'Open raw' } within_window new_tab do expect(page).to have_content("*.rbc") diff --git a/spec/features/projects/files/user_creates_files_spec.rb b/spec/features/projects/files/user_creates_files_spec.rb index 7344c91b6dc..a81f31d663e 100644 --- a/spec/features/projects/files/user_creates_files_spec.rb +++ b/spec/features/projects/files/user_creates_files_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' RSpec.describe 'Projects > Files > User creates files', :js do + include Spec::Support::Helpers::Features::SourceEditorSpecHelpers include BlobSpecHelpers let(:fork_message) do @@ -89,8 +90,7 @@ RSpec.describe 'Projects > Files > User creates files', :js do end it 'creates and commit a new file' do - find('#editor') - execute_script("monaco.editor.getModels()[0].setValue('*.rbca')") + editor_set_value('*.rbca') fill_in(:file_name, with: 'not_a_file.md') fill_in(:commit_message, with: 'New commit message', visible: true) click_button('Commit changes') @@ -107,8 +107,7 @@ RSpec.describe 'Projects > Files > User creates files', :js do it 'creates and commit a new file with new lines at the end of file' do set_default_button('edit') - find('#editor') - execute_script('monaco.editor.getModels()[0].setValue("Sample\n\n\n")') + editor_set_value('Sample\n\n\n') fill_in(:file_name, with: 'not_a_file.md') fill_in(:commit_message, with: 'New commit message', visible: true) click_button('Commit changes') @@ -119,8 +118,7 @@ RSpec.describe 'Projects > Files > User creates files', :js do click_link('Edit') - find('#editor') - expect(evaluate_script('monaco.editor.getModels()[0].getValue()')).to eq("Sample\n\n\n") + expect(find('.monaco-editor')).to have_content('Sample\n\n\n') end it 'creates and commit a new file with a directory name' do @@ -128,8 +126,7 @@ RSpec.describe 'Projects > Files > User creates files', :js do expect(page).to have_selector('.file-editor') - find('#editor') - execute_script("monaco.editor.getModels()[0].setValue('*.rbca')") + editor_set_value('*.rbca') fill_in(:commit_message, with: 'New commit message', visible: true) click_button('Commit changes') @@ -143,8 +140,7 @@ RSpec.describe 'Projects > Files > User creates files', :js do it 'creates and commit a new file specifying a new branch' do expect(page).to have_selector('.file-editor') - find('#editor') - execute_script("monaco.editor.getModels()[0].setValue('*.rbca')") + editor_set_value('*.rbca') fill_in(:file_name, with: 'not_a_file.md') fill_in(:commit_message, with: 'New commit message', visible: true) fill_in(:branch_name, with: 'new_branch_name', visible: true) @@ -178,8 +174,7 @@ RSpec.describe 'Projects > Files > User creates files', :js do it 'creates and commit new file in forked project' do expect(page).to have_selector('.file-editor') - find('#editor') - execute_script("monaco.editor.getModels()[0].setValue('*.rbca')") + editor_set_value('*.rbca') fill_in(:file_name, with: 'not_a_file.md') fill_in(:commit_message, with: 'New commit message', visible: true) diff --git a/spec/features/projects/files/user_edits_files_spec.rb b/spec/features/projects/files/user_edits_files_spec.rb index 1ac45970828..d7460538be9 100644 --- a/spec/features/projects/files/user_edits_files_spec.rb +++ b/spec/features/projects/files/user_edits_files_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' RSpec.describe 'Projects > Files > User edits files', :js do + include Spec::Support::Helpers::Features::SourceEditorSpecHelpers include ProjectForksHelper include BlobSpecHelpers @@ -50,10 +51,9 @@ RSpec.describe 'Projects > Files > User edits files', :js do click_link_or_button('Edit') find('.file-editor', match: :first) - find('#editor') - set_editor_value('*.rbca') + editor_set_value('*.rbca') - expect(editor_value).to eq('*.rbca') + expect(find('.monaco-editor')).to have_content('*.rbca') end it 'does not show the edit link if a file is binary' do @@ -72,8 +72,7 @@ RSpec.describe 'Projects > Files > User edits files', :js do click_link_or_button('Edit') find('.file-editor', match: :first) - find('#editor') - set_editor_value('*.rbca') + editor_set_value('*.rbca') fill_in(:commit_message, with: 'New commit message', visible: true) click_button('Commit changes') @@ -91,8 +90,7 @@ RSpec.describe 'Projects > Files > User edits files', :js do find('.file-editor', match: :first) - find('#editor') - set_editor_value('*.rbca') + editor_set_value('*.rbca') fill_in(:commit_message, with: 'New commit message', visible: true) fill_in(:branch_name, with: 'new_branch_name', visible: true) click_button('Commit changes') @@ -110,8 +108,7 @@ RSpec.describe 'Projects > Files > User edits files', :js do click_link_or_button('Edit') find('.file-editor', match: :first) - find('#editor') - set_editor_value('*.rbca') + editor_set_value('*.rbca') click_link('Preview changes') expect(page).to have_css('.line_holder.new') @@ -156,10 +153,9 @@ RSpec.describe 'Projects > Files > User edits files', :js do find('.file-editor', match: :first) - find('#editor') - set_editor_value('*.rbca') + editor_set_value('*.rbca') - expect(editor_value).to eq('*.rbca') + expect(find('.monaco-editor')).to have_content('*.rbca') end it 'opens the Web IDE in a forked project', :sidekiq_might_not_need_inline do @@ -187,8 +183,7 @@ RSpec.describe 'Projects > Files > User edits files', :js do find('.file-editor', match: :first) - find('#editor') - set_editor_value('*.rbca') + editor_set_value('*.rbca') fill_in(:commit_message, with: 'New commit message', visible: true) click_button('Commit changes') @@ -216,8 +211,7 @@ RSpec.describe 'Projects > Files > User edits files', :js do expect(page).not_to have_link('Fork') - find('#editor') - set_editor_value('*.rbca') + editor_set_value('*.rbca') fill_in(:commit_message, with: 'Another commit', visible: true) click_button('Commit changes') |