diff --git a/qa/qa/specs/features/ee/browser_ui/3_create/web_ide/code_suggestions_in_web_ide_spec.rb b/qa/qa/specs/features/ee/browser_ui/3_create/web_ide/code_suggestions_in_web_ide_spec.rb index d633d5ed8ad04d78214319941837495b1dfec299..c0417929b76201c2c93b43ecb6a3c5e9311022a0 100644 --- a/qa/qa/specs/features/ee/browser_ui/3_create/web_ide/code_suggestions_in_web_ide_spec.rb +++ b/qa/qa/specs/features/ee/browser_ui/3_create/web_ide/code_suggestions_in_web_ide_spec.rb @@ -3,9 +3,7 @@ module QA # This test requires several feature flags, user settings, and instance configuration. # See https://docs.gitlab.com/ee/development/code_suggestions/#code-suggestions-development-setup - RSpec.describe( - 'Create', :smoke, only: { pipeline: %i[staging staging-canary canary production] }, product_group: :ide - ) do + RSpec.describe 'Create', product_group: :ide do describe 'Code Suggestions in Web IDE' do let(:project) { create(:project, :with_readme, name: 'webide-code-suggestions-project') } let(:file_name) { 'new_file.rb' } @@ -22,11 +20,10 @@ module QA Page::Project::WebIDE::VSCode.perform(&:wait_for_ide_to_load) end - context 'when requesting code generation' do + shared_examples 'a code generation suggestion' do |testcase| let(:prompt_data) { 'def reverse_string' } - it 'returns a suggestion which can be accepted', - testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/425756' do + it 'returns a code generation suggestion which can be accepted', testcase: testcase do Page::Project::WebIDE::VSCode.perform do |ide| ide.add_prompt_into_a_file(file_name, prompt_data) previous_content_length = ide.editor_content_length @@ -44,11 +41,16 @@ module QA end end - context 'when requesting code completion' do - let(:prompt_data) { "def set_name(whitespace_name)\n this.name = whitespace_name." } + shared_examples 'a code completion suggestion' do |testcase| + # We should avoid the use of . in the prompt since the remote Selenium WebDriver + # also uses send_keys to upload files if it finds the text matches a potential file name, + # which can cause unintended behavior in the test. + # + # The remote WebDriver is used in orchestrated tests that make use of Selenoid video recording. + # https://www.selenium.dev/documentation/webdriver/elements/file_upload/ + let(:prompt_data) { "def set_name(whitespace_name)\n @name = " } - it 'returns a suggestion which can be accepted', - testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/437111' do + it 'returns a code completion suggestion which can be accepted', testcase: testcase do Page::Project::WebIDE::VSCode.perform do |ide| ide.add_prompt_into_a_file(file_name, prompt_data) previous_content_length = ide.editor_content_length @@ -65,6 +67,19 @@ module QA end end end + + context 'on GitLab.com', :smoke, only: { pipeline: %i[staging staging-canary canary production] } do + it_behaves_like 'a code generation suggestion', + 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/425756' + + it_behaves_like 'a code completion suggestion', + 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/437111' + end + + context 'on Self-managed', :orchestrated, :ai_gateway do + it_behaves_like 'a code completion suggestion', + 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/439625' + end end end end