diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2019-07-03 22:39:10 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2019-07-03 22:39:10 +0100 |
commit | 50be7237f41b0ac44b9aaf8b73c57993548d4c35 (patch) | |
tree | ecfeeae58829dadbd90de4f834c730d1d8c55e74 /qa | |
parent | 35331c435196ea1155eb15161f3f9a481a01501d (diff) | |
parent | 2ad75a4f96c4d377e18788966e7eefee4d78b6d2 (diff) | |
download | gitlab-ce-update-todo-in-ui.tar.gz |
Merge branch 'master' into update-todo-in-uiupdate-todo-in-ui
* master: (435 commits)
Change occurrence of Sidekiq::Testing.inline!
Fix order-dependent spec failure in appearance_spec.rb
Put a failed example from appearance_spec in quarantine
Cache PerformanceBar.allowed_user_ids list locally and in Redis
Add Grafana to Admin > Monitoring menu when enabled
Add changelog entry
Add salesforce logo
Move error_tracking_frontend specs to Jest
Only save Peek session in Redis when Peek is enabled
Migrate markdown header_spec.js to Jest
Fix golint command in Go guide doc to be recursive
Move images to their own dirs
Gitlab -> GitLab
Re-align CE and EE API docs
Rename Release groups in issue_workflow.md
Update api docs to finish aligning EE and CE docs
Update locale.pot
Update TODO: allow_collaboration column renaming
Show upcoming status for releases
Rebased and squashed commits
...
Diffstat (limited to 'qa')
29 files changed, 387 insertions, 62 deletions
@@ -162,9 +162,12 @@ module QA module File autoload :Form, 'qa/page/file/form' autoload :Show, 'qa/page/file/show' + autoload :Edit, 'qa/page/file/edit' module Shared autoload :CommitMessage, 'qa/page/file/shared/commit_message' + autoload :CommitButton, 'qa/page/file/shared/commit_button' + autoload :Editor, 'qa/page/file/shared/editor' end end @@ -218,6 +221,7 @@ module QA autoload :Operations, 'qa/page/project/sub_menus/operations' autoload :Repository, 'qa/page/project/sub_menus/repository' autoload :Settings, 'qa/page/project/sub_menus/settings' + autoload :Project, 'qa/page/project/sub_menus/project' end module Issue @@ -323,6 +327,7 @@ module QA autoload :DropdownFilter, 'qa/page/component/dropdown_filter' autoload :UsersSelect, 'qa/page/component/users_select' autoload :Note, 'qa/page/component/note' + autoload :ConfirmModal, 'qa/page/component/confirm_modal' module Issuable autoload :Common, 'qa/page/component/issuable/common' diff --git a/qa/qa/page/component/confirm_modal.rb b/qa/qa/page/component/confirm_modal.rb new file mode 100644 index 00000000000..355e2783fb7 --- /dev/null +++ b/qa/qa/page/component/confirm_modal.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module QA + module Page + module Component + module ConfirmModal + def self.included(base) + base.view 'app/views/shared/_confirm_modal.html.haml' do + element :confirm_modal + element :confirm_input + element :confirm_button + end + end + + def fill_confirmation_text(text) + fill_element :confirm_input, text + end + + def click_confirm_button + click_element :confirm_button + end + end + end + end +end diff --git a/qa/qa/page/component/select2.rb b/qa/qa/page/component/select2.rb index e40bc4b1d3e..85d4abcde9b 100644 --- a/qa/qa/page/component/select2.rb +++ b/qa/qa/page/component/select2.rb @@ -18,6 +18,10 @@ module QA find('.select2-input').set(item_text) select_item(item_text) end + + def expand_select_list + find('span.select2-arrow').click + end end end end diff --git a/qa/qa/page/file/edit.rb b/qa/qa/page/file/edit.rb new file mode 100644 index 00000000000..3a4a1837b1c --- /dev/null +++ b/qa/qa/page/file/edit.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module QA + module Page + module File + class Edit < Page::Base + include Shared::CommitMessage + include Shared::CommitButton + include Shared::Editor + end + end + end +end diff --git a/qa/qa/page/file/form.rb b/qa/qa/page/file/form.rb index e42de7d65c5..a6251f185f9 100644 --- a/qa/qa/page/file/form.rb +++ b/qa/qa/page/file/form.rb @@ -6,14 +6,11 @@ module QA class Form < Page::Base include Shared::CommitMessage include Page::Component::DropdownFilter + include Shared::CommitButton + include Shared::Editor view 'app/views/projects/blob/_editor.html.haml' do element :file_name, "text_field_tag 'file_name'" # rubocop:disable QA/ElementWithPattern - element :editor, '#editor' # rubocop:disable QA/ElementWithPattern - end - - view 'app/views/projects/_commit_button.html.haml' do - element :commit_changes, "button_tag 'Commit changes'" # rubocop:disable QA/ElementWithPattern end view 'app/views/projects/blob/_template_selectors.html.haml' do @@ -28,20 +25,6 @@ module QA fill_in 'file_name', with: name end - def add_content(content) - text_area.set content - end - - def remove_content - text_area.send_keys([:command, 'a'], :backspace) - end - - def commit_changes - click_on 'Commit changes' - - finished_loading? - end - def select_template(template_type, template) click_element :template_type_dropdown click_link template_type @@ -60,12 +43,6 @@ module QA end filter_and_select template end - - private - - def text_area - find('#editor>textarea', visible: false) - end end end end diff --git a/qa/qa/page/file/shared/commit_button.rb b/qa/qa/page/file/shared/commit_button.rb new file mode 100644 index 00000000000..d8e751dd7b6 --- /dev/null +++ b/qa/qa/page/file/shared/commit_button.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module QA + module Page + module File + module Shared + module CommitButton + def self.included(base) + base.view 'app/views/projects/_commit_button.html.haml' do + element :commit_button + end + end + + def commit_changes + click_element(:commit_button) + end + end + end + end + end +end diff --git a/qa/qa/page/file/shared/editor.rb b/qa/qa/page/file/shared/editor.rb new file mode 100644 index 00000000000..448c09cfbca --- /dev/null +++ b/qa/qa/page/file/shared/editor.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module QA + module Page + module File + module Shared + module Editor + def self.included(base) + base.view 'app/views/projects/blob/_editor.html.haml' do + element :editor + end + end + + def add_content(content) + text_area.set content + end + + def remove_content + text_area.send_keys([:command, 'a'], :backspace) + end + + private + + def text_area + within_element :editor do + find('textarea', visible: false) + end + end + end + end + end + end +end diff --git a/qa/qa/page/file/show.rb b/qa/qa/page/file/show.rb index eaf88c6e69e..92f9181f99d 100644 --- a/qa/qa/page/file/show.rb +++ b/qa/qa/page/file/show.rb @@ -5,6 +5,8 @@ module QA module File class Show < Page::Base include Shared::CommitMessage + include Project::SubMenus::Settings + include Project::SubMenus::Common view 'app/helpers/blob_helper.rb' do element :edit_button, "_('Edit')" # rubocop:disable QA/ElementWithPattern diff --git a/qa/qa/page/project/operations/kubernetes/show.rb b/qa/qa/page/project/operations/kubernetes/show.rb index c81e13e9b91..4f625c5f0f0 100644 --- a/qa/qa/page/project/operations/kubernetes/show.rb +++ b/qa/qa/page/project/operations/kubernetes/show.rb @@ -28,12 +28,16 @@ module QA end end - def await_installed(application_name) + def await_installed(application_name, button_text: 'Installed') within(".js-cluster-application-row-#{application_name}") do - page.has_text?('Installed', wait: 300) + page.has_text?(button_text, wait: 300) end end + def await_uninstallable(application_name) + await_installed(application_name, button_text: 'Uninstall') + end + def ingress_ip # We need to wait longer since it can take some time before the # ip address is assigned for the ingress controller diff --git a/qa/qa/page/project/settings/advanced.rb b/qa/qa/page/project/settings/advanced.rb index 75530832860..ab4e3d757b6 100644 --- a/qa/qa/page/project/settings/advanced.rb +++ b/qa/qa/page/project/settings/advanced.rb @@ -5,9 +5,13 @@ module QA module Project module Settings class Advanced < Page::Base + include Component::Select2 + include Component::ConfirmModal + view 'app/views/projects/edit.html.haml' do element :project_path_field element :change_path_button + element :transfer_button end def update_project_path_to(path) @@ -22,6 +26,18 @@ module QA def click_change_path_button click_element :change_path_button end + + def select_transfer_option(namespace) + search_and_select(namespace) + end + + def transfer_project!(project_name, namespace) + expand_select_list + select_transfer_option(namespace) + click_element(:transfer_button) + fill_confirmation_text(project_name) + click_confirm_button + end end end end diff --git a/qa/qa/page/project/settings/main.rb b/qa/qa/page/project/settings/main.rb index d1f3b15f950..dbbe62e3b1d 100644 --- a/qa/qa/page/project/settings/main.rb +++ b/qa/qa/page/project/settings/main.rb @@ -6,6 +6,8 @@ module QA module Settings class Main < Page::Base include Common + include Component::Select2 + include SubMenus::Project view 'app/views/projects/edit.html.haml' do element :advanced_settings diff --git a/qa/qa/page/project/sub_menus/project.rb b/qa/qa/page/project/sub_menus/project.rb new file mode 100644 index 00000000000..5e0ee3c274a --- /dev/null +++ b/qa/qa/page/project/sub_menus/project.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module QA + module Page + module Project + module SubMenus + module Project + include Common + + def self.included(base) + base.class_eval do + view 'app/views/layouts/nav/sidebar/_project.html.haml' do + element :link_project + end + end + end + + def click_project + retry_on_exception do + within_sidebar do + click_element(:link_project) + end + end + end + end + end + end + end +end diff --git a/qa/qa/page/project/sub_menus/settings.rb b/qa/qa/page/project/sub_menus/settings.rb index 22743ebd0a1..88b45ec55ae 100644 --- a/qa/qa/page/project/sub_menus/settings.rb +++ b/qa/qa/page/project/sub_menus/settings.rb @@ -10,6 +10,7 @@ module QA view 'app/views/layouts/nav/sidebar/_project.html.haml' do element :settings_item element :link_members_settings + element :general_settings_link end end end @@ -38,6 +39,14 @@ module QA end end + def go_to_general_settings + hover_settings do + within_submenu do + click_element :general_settings_link + end + end + end + def click_settings within_sidebar do click_on 'Settings' diff --git a/qa/qa/page/settings/common.rb b/qa/qa/page/settings/common.rb index 8cd0b6bb49c..bede3fde105 100644 --- a/qa/qa/page/settings/common.rb +++ b/qa/qa/page/settings/common.rb @@ -11,7 +11,7 @@ module QA within_element(element_name) do # Because it is possible to click the button before the JS toggle code is bound wait(reload: false) do - click_button 'Expand' unless first('button', text: 'Collapse') + click_button 'Expand' unless has_css?('button', text: 'Collapse') has_content?('Collapse') end diff --git a/qa/qa/resource/api_fabricator.rb b/qa/qa/resource/api_fabricator.rb index de04467ff5b..d1d75b6179e 100644 --- a/qa/qa/resource/api_fabricator.rb +++ b/qa/qa/resource/api_fabricator.rb @@ -13,6 +13,8 @@ module QA ResourceURLMissingError = Class.new(RuntimeError) attr_reader :api_resource, :api_response + attr_writer :api_client + attr_accessor :user def api_support? respond_to?(:api_get_path) && @@ -29,9 +31,12 @@ module QA end def eager_load_api_client! + return unless api_client.nil? + api_client.tap do |client| # Eager-load the API client so that the personal token creation isn't # taken in account in the actual resource creation timing. + client.user = user client.personal_access_token end end @@ -76,7 +81,7 @@ module QA def api_client @api_client ||= begin - Runtime::API::Client.new(:gitlab, is_new_session: !current_url.start_with?('http')) + Runtime::API::Client.new(:gitlab, is_new_session: !current_url.start_with?('http'), user: user) end end diff --git a/qa/qa/resource/group.rb b/qa/qa/resource/group.rb index 0b567a474c8..44d9dc8f296 100644 --- a/qa/qa/resource/group.rb +++ b/qa/qa/resource/group.rb @@ -67,6 +67,10 @@ module QA visibility: 'public' } end + + def full_path + sandbox.path + ' / ' + path + end end end end diff --git a/qa/qa/resource/kubernetes_cluster.rb b/qa/qa/resource/kubernetes_cluster.rb index 27ab7b60211..1dd93dd5b88 100644 --- a/qa/qa/resource/kubernetes_cluster.rb +++ b/qa/qa/resource/kubernetes_cluster.rb @@ -47,7 +47,7 @@ module QA page.install!(:runner) if @install_runner page.await_installed(:ingress) if @install_ingress - page.await_installed(:prometheus) if @install_prometheus + page.await_uninstallable(:prometheus) if @install_prometheus page.await_installed(:runner) if @install_runner if @install_ingress diff --git a/qa/qa/resource/merge_request_from_fork.rb b/qa/qa/resource/merge_request_from_fork.rb index 5d20a6e9c75..6c9a096289b 100644 --- a/qa/qa/resource/merge_request_from_fork.rb +++ b/qa/qa/resource/merge_request_from_fork.rb @@ -21,7 +21,7 @@ module QA def fabricate! populate(:push) - fork.visit! + fork.project.visit! Page::Project::Show.perform(&:new_merge_request) Page::MergeRequest::New.perform(&:create_merge_request) diff --git a/qa/qa/resource/project.rb b/qa/qa/resource/project.rb index e8ea947581a..c0a6004fe27 100644 --- a/qa/qa/resource/project.rb +++ b/qa/qa/resource/project.rb @@ -11,7 +11,9 @@ module QA attribute :id attribute :name + attribute :add_name_uuid attribute :description + attribute :standalone attribute :group do Group.fabricate! @@ -38,18 +40,21 @@ module QA end def initialize + @add_name_uuid = true + @standalone = false @description = 'My awesome project' @initialize_with_readme = false end def name=(raw_name) - @name = "#{raw_name}-#{SecureRandom.hex(8)}" + @name = @add_name_uuid ? "#{raw_name}-#{SecureRandom.hex(8)}" : raw_name end def fabricate! - group.visit! - - Page::Group::Show.perform(&:go_to_new_project) + unless @standalone + group.visit! + Page::Group::Show.perform(&:go_to_new_project) + end Page::Project::New.perform do |page| page.choose_test_namespace @@ -71,19 +76,28 @@ module QA "/projects/#{CGI.escape(path_with_namespace)}" end + def api_get_archive_path(type = 'tar.gz') + "#{api_get_path}/repository/archive.#{type}" + end + def api_post_path '/projects' end def api_post_body - { - namespace_id: group.id, - path: name, + post_body = { name: name, description: description, visibility: 'public', initialize_with_readme: @initialize_with_readme } + + unless @standalone + post_body[:namespace_id] = group.id + post_body[:path] = name + end + + post_body end private diff --git a/qa/qa/resource/user.rb b/qa/qa/resource/user.rb index 6c5e91b6488..eec46f46d99 100644 --- a/qa/qa/resource/user.rb +++ b/qa/qa/resource/user.rb @@ -88,7 +88,7 @@ module QA }.merge(ldap_post_body) end - def self.fabricate_or_use(username, password) + def self.fabricate_or_use(username = nil, password = nil) if Runtime::Env.signup_disabled? self.new.tap do |user| user.username = username diff --git a/qa/qa/runtime/api/client.rb b/qa/qa/runtime/api/client.rb index 40a3bc85195..663be27a849 100644 --- a/qa/qa/runtime/api/client.rb +++ b/qa/qa/runtime/api/client.rb @@ -6,31 +6,34 @@ module QA module Runtime module API class Client - attr_reader :address + attr_reader :address, :user - def initialize(address = :gitlab, personal_access_token: nil, is_new_session: true) + def initialize(address = :gitlab, personal_access_token: nil, is_new_session: true, user: nil) @address = address @personal_access_token = personal_access_token @is_new_session = is_new_session + @user = user end def personal_access_token @personal_access_token ||= begin # you can set the environment variable GITLAB_QA_ACCESS_TOKEN # to use a specific access token rather than create one from the UI - Runtime::Env.personal_access_token ||= create_personal_access_token + # unless a specific user has been passed + @user.nil? ? Runtime::Env.personal_access_token ||= create_personal_access_token : create_personal_access_token end end private def create_personal_access_token - Runtime::Browser.visit(@address, Page::Main::Login) if @is_new_session - do_create_personal_access_token - end + Page::Main::Menu.perform(&:sign_out) if @is_new_session && Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) } + + unless Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) } + Runtime::Browser.visit(@address, Page::Main::Login) + Page::Main::Login.perform { |login| login.sign_in_using_credentials(@user) } + end - def do_create_personal_access_token - Page::Main::Login.perform(&:sign_in_using_credentials) Resource::PersonalAccessToken.fabricate!.access_token end end diff --git a/qa/qa/service/shellout.rb b/qa/qa/service/shellout.rb index 7065ab0e7f3..217df669db3 100644 --- a/qa/qa/service/shellout.rb +++ b/qa/qa/service/shellout.rb @@ -19,7 +19,7 @@ module QA Open3.popen2e(*command) do |stdin, out, wait| stdin.puts(stdin_data) if stdin_data stdin.close if stdin_data - out.each { |line| puts line } + out.each_char { |char| print char } if wait.value.exited? && wait.value.exitstatus.nonzero? raise CommandError, "Command `#{command}` failed!" diff --git a/qa/qa/specs/features/api/3_create/repository/project_archive_compare_spec.rb b/qa/qa/specs/features/api/3_create/repository/project_archive_compare_spec.rb new file mode 100644 index 00000000000..3fe04e8b835 --- /dev/null +++ b/qa/qa/specs/features/api/3_create/repository/project_archive_compare_spec.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true + +require 'securerandom' +require 'digest' + +module QA + context 'Create' do + describe 'Compare archives of different user projects with the same name and check they\'re different' do + include Support::Api + + before(:all) do + @project_name = "project-archive-download-#{SecureRandom.hex(8)}" + @archive_types = %w(tar.gz tar.bz2 tar zip) + @users = { + user1: { username: Runtime::Env.gitlab_qa_username_1, password: Runtime::Env.gitlab_qa_password_1 }, + user2: { username: Runtime::Env.gitlab_qa_username_2, password: Runtime::Env.gitlab_qa_password_2 } + } + + @users.each do |_, user_info| + user_info[:user] = Resource::User.fabricate_or_use(user_info[:username], user_info[:password]) + user_info[:api_client] = Runtime::API::Client.new(:gitlab, user: user_info[:user]) + user_info[:api_client].personal_access_token + user_info[:project] = create_project(user_info[:user], user_info[:api_client], @project_name) + Page::Main::Menu.perform(&:sign_out) + end + end + + it 'download archives of each user project then check they are different' do + archive_checksums = {} + + @users.each do |user_key, user_info| + archive_checksums[user_key] = {} + + @archive_types.each do |type| + archive_path = download_project_archive_via_api(user_info[:api_client], user_info[:project], type).path + archive_checksums[user_key][type] = Digest::MD5.hexdigest(File.read(archive_path)) + end + end + + QA::Runtime::Logger.debug("Archive checksums are #{archive_checksums}") + + expect(archive_checksums[:user1]).not_to include(archive_checksums[:user2]) + end + + def create_project(user, api_client, project_name) + project = Resource::Project.fabricate! do |project| + project.standalone = true + project.add_name_uuid = false + project.name = project_name + project.path_with_namespace = "#{user.name}/#{project_name}" + project.user = user + project.api_client = api_client + end + + Resource::Repository::ProjectPush.fabricate! do |push| + push.project = project + push.file_name = 'README.md' + push.file_content = '# This is a test project' + push.commit_message = 'Add README.md' + push.user = user + end + + project + end + + def download_project_archive_via_api(api_client, project, type = 'tar.gz') + get_project_archive_zip = Runtime::API::Request.new(api_client, project.api_get_archive_path(type)) + project_archive_download = get(get_project_archive_zip.url, raw_response: true) + expect(project_archive_download.code).to eq(200) + + project_archive_download.file + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/1_manage/group/transfer_project_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/group/transfer_project_spec.rb new file mode 100644 index 00000000000..a9de64e357a --- /dev/null +++ b/qa/qa/specs/features/browser_ui/1_manage/group/transfer_project_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module QA + context 'Manage' do + describe 'Project transfer between groups' do + it 'user transfers a project between groups' do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.act { sign_in_using_credentials } + + source_group = Resource::Group.fabricate! do |group| + group.path = 'source-group' + end + + target_group = Resource::Group.fabricate! do |group| + group.path = 'target-group' + end + + project = Resource::Project.fabricate! do |project| + project.group = source_group + project.name = 'transfer-project' + project.initialize_with_readme = true + end + + project.visit! + + Page::Project::Show.perform do |project| + project.click_file('README.md') + end + + Page::File::Show.perform(&:click_edit) + + edited_readme_content = 'Here is the edited content.' + + Page::File::Edit.perform do |file| + file.remove_content + file.add_content(edited_readme_content) + file.commit_changes + end + + Page::File::Show.perform(&:go_to_general_settings) + + Page::Project::Settings::Main.perform(&:expand_advanced_settings) + + Page::Project::Settings::Advanced.perform do |advanced| + advanced.transfer_project!(project.name, target_group.full_path) + end + + Page::Project::Settings::Main.perform(&:click_project) + + Page::Project::Show.perform do |project| + expect(project).to have_text(target_group.path) + expect(project).to have_text(edited_readme_content) + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb index 2750b171a85..567c6a83ddf 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb @@ -2,8 +2,7 @@ module QA context 'Create' do - # Issue: https://gitlab.com/gitlab-org/quality/nightly/issues/97 - describe 'File templates', :quarantine do + describe 'File templates' do include Runtime::Fixtures def login diff --git a/qa/qa/specs/features/browser_ui/3_create/snippet/create_snippet_spec.rb b/qa/qa/specs/features/browser_ui/3_create/snippet/create_snippet_spec.rb index f6f0468e76e..796de44a012 100644 --- a/qa/qa/specs/features/browser_ui/3_create/snippet/create_snippet_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/snippet/create_snippet_spec.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true module QA - # Failure issue: https://gitlab.com/gitlab-org/quality/staging/issues/49 - context 'Create', :smoke, :quarantine do + context 'Create', :smoke do describe 'Snippet creation' do it 'User creates a snippet' do Runtime::Browser.visit(:gitlab, Page::Main::Login) @@ -13,7 +12,7 @@ module QA Resource::Snippet.fabricate_via_browser_ui! do |snippet| snippet.title = 'Snippet title' snippet.description = 'Snippet description' - snippet.visibility = 'Public' + snippet.visibility = 'Private' snippet.file_name = 'New snippet file name' snippet.file_content = 'Snippet file text' end @@ -21,8 +20,7 @@ module QA Page::Dashboard::Snippet::Show.perform do |snippet| expect(snippet).to have_snippet_title('Snippet title') expect(snippet).to have_snippet_description('Snippet description') - expect(snippet).to have_embed_type('Embed') - expect(snippet).to have_visibility_type('Public') + expect(snippet).to have_visibility_type('Private') expect(snippet).to have_file_name('New snippet file name') expect(snippet).to have_file_content('Snippet file text') end diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb index 078d3b2b5b1..c09c65a57a5 100644 --- a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true module QA - # Failure issue: https://gitlab.com/gitlab-org/quality/staging/issues/46 - context 'Create', :quarantine do + context 'Create' do describe 'Web IDE file templates' do include Runtime::Fixtures diff --git a/qa/qa/support/api.rb b/qa/qa/support/api.rb index a5c86425465..203064b2665 100644 --- a/qa/qa/support/api.rb +++ b/qa/qa/support/api.rb @@ -16,11 +16,12 @@ module QA e.response end - def get(url) + def get(url, raw_response: false) RestClient::Request.execute( method: :get, url: url, - verify_ssl: false) + verify_ssl: false, + raw_response: raw_response) rescue RestClient::ExceptionWithResponse => e e.response end diff --git a/qa/spec/runtime/api/client_spec.rb b/qa/spec/runtime/api/client_spec.rb index cf19b52700b..6f7020d6595 100644 --- a/qa/spec/runtime/api/client_spec.rb +++ b/qa/spec/runtime/api/client_spec.rb @@ -16,26 +16,56 @@ describe QA::Runtime::API::Client do end describe '#personal_access_token' do - context 'when QA::Runtime::Env.personal_access_token is present' do + context 'when user is nil and QA::Runtime::Env.personal_access_token is present' do before do allow(QA::Runtime::Env).to receive(:personal_access_token).and_return('a_token') end it 'returns specified token from env' do - expect(described_class.new.personal_access_token).to eq 'a_token' + expect(subject.personal_access_token).to eq 'a_token' end end - context 'when QA::Runtime::Env.personal_access_token is nil' do + context 'when user is present and QA::Runtime::Env.personal_access_token is nil' do before do allow(QA::Runtime::Env).to receive(:personal_access_token).and_return(nil) end it 'returns a created token' do + subject { described_class.new(user: { username: 'foo' }) } + expect(subject).to receive(:create_personal_access_token).and_return('created_token') expect(subject.personal_access_token).to eq 'created_token' end end + + context 'when user is nil and QA::Runtime::Env.personal_access_token is nil' do + before do + allow(QA::Runtime::Env).to receive(:personal_access_token).and_return(nil) + end + + it 'returns a created token' do + client = described_class.new + + expect(client).to receive(:create_personal_access_token).and_return('created_token') + + expect(client.personal_access_token).to eq 'created_token' + end + end + + context 'when user is present and QA::Runtime::Env.personal_access_token is present' do + before do + allow(QA::Runtime::Env).to receive(:personal_access_token).and_return('a_token') + end + + it 'returns a created token' do + client = described_class.new(user: { username: 'foo' }) + + expect(client).to receive(:create_personal_access_token).and_return('created_token') + + expect(client.personal_access_token).to eq 'created_token' + end + end end end |