diff --git a/qa/qa/page/project/web_ide/vscode.rb b/qa/qa/page/project/web_ide/vscode.rb index 6753b5dbd424bc7dcfe6e89d05f276610637fc69..6bdb1fb3927a44d2ef13c6918467ae546a54ce90 100644 --- a/qa/qa/page/project/web_ide/vscode.rb +++ b/qa/qa/page/project/web_ide/vscode.rb @@ -168,11 +168,16 @@ def create_new_file(file_name) create_item("New File...", file_name) end - def commit_and_push(file_name) + def commit_and_push_to_new_branch(file_name) commit_toggle(file_name) push_to_new_branch end + def commit_and_push_to_existing_branch(file_name) + commit_toggle(file_name) + push_to_existing_branch + end + def commit_toggle(message) within_vscode_editor do if has_commit_pending_tab? diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_first_file_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_first_file_in_web_ide_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..314585fd9e1e103db5632846f754abbaf9921bc6 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_first_file_in_web_ide_spec.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create', :skip_live_env, product_group: :ide do + describe 'Add first file in Web IDE' do + let(:project) { create(:project, :with_readme, name: 'webide-create-file-project') } + + before do + Flow::Login.sign_in + project.visit! + Page::Project::Show.perform(&:open_web_ide!) + Page::Project::WebIDE::VSCode.perform(&:wait_for_ide_to_load) + end + + context 'when a file with the same name already exists' do + let(:file_name) { 'README.md' } + + it 'throws an error', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/432899' do + Page::Project::WebIDE::VSCode.perform do |ide| + ide.create_new_file(file_name) + + expect(ide) + .to have_message("A file or folder README.md already exists at this location") + end + end + end + + context 'when user adds a new file' do + let(:file_name) { 'first_file.txt' } + + it 'shows successfully added and visible in project', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/432898' do + Page::Project::WebIDE::VSCode.perform do |ide| + ide.create_new_file(file_name) + ide.commit_and_push_to_existing_branch(file_name) + + expect(ide).to have_message('Success! Your changes have been committed.') + end + + project.visit! + + Page::Project::Show.perform do |project| + expect(project).to have_file(file_name) + end + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb index ac580fae087f5ac0b9be2cf1a639e546a2a826e4..5240dec2a4a2bf5c5f476001197a9e4bb96e5611 100644 --- a/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb @@ -30,9 +30,13 @@ module QA it "verifies it successfully uploads and commits to a MR" do Page::Project::WebIDE::VSCode.perform do |ide| ide.upload_file(file_path) - ide.commit_and_push(file_name) + ide.commit_and_push_to_new_branch(file_name) + + expect(ide).to have_message('Success! Your changes have been committed.') + ide.create_merge_request end + # Opens the MR in new tab and verify the file is in the MR page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)