diff options
author | Mark Lapierre <mlapierre@gitlab.com> | 2019-01-10 16:53:06 -0500 |
---|---|---|
committer | Mark Lapierre <mlapierre@gitlab.com> | 2019-01-11 09:31:57 -0500 |
commit | 501a43199e85cc77b15986096717067d47290e80 (patch) | |
tree | 3aa58f0ebc06da3e48e2cd89d56c4c324a4baee5 /qa | |
parent | 6b2f81f6078e96f081154c50dc25e54fe7c09d6f (diff) | |
download | gitlab-ce-501a43199e85cc77b15986096717067d47290e80.tar.gz |
Fix deploy key test
Fetch a specific key's fingerprint instead of all fingerprints.
Check for the specific key by title and expected fingerprint.
This avoids the use of `all`, which can be unreliable.
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/page/project/settings/deploy_keys.rb | 33 | ||||
-rw-r--r-- | qa/qa/resource/deploy_key.rb | 6 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/6_release/deploy_key/add_deploy_key_spec.rb | 10 |
3 files changed, 27 insertions, 22 deletions
diff --git a/qa/qa/page/project/settings/deploy_keys.rb b/qa/qa/page/project/settings/deploy_keys.rb index 3c8c0cbdf7c..5da8d352e74 100644 --- a/qa/qa/page/project/settings/deploy_keys.rb +++ b/qa/qa/page/project/settings/deploy_keys.rb @@ -14,8 +14,13 @@ module QA end view 'app/assets/javascripts/deploy_keys/components/key.vue' do - element :key_title, /class=".*qa-key-title.*"/ # rubocop:disable QA/ElementWithPattern - element :key_fingerprint, /class=".*qa-key-fingerprint.*"/ # rubocop:disable QA/ElementWithPattern + element :key + element :key_title + element :key_fingerprint + end + + def add_key + click_on 'Add key' end def fill_key_title(title) @@ -26,31 +31,29 @@ module QA fill_in 'deploy_key_key', with: key end - def add_key - click_on 'Add key' - end - - def key_title + def find_fingerprint(title) within_project_deploy_keys do - find_element(:key_title).text + find_element(:key, title) + .find(element_selector_css(:key_fingerprint)).text end end - def key_fingerprint + def has_key?(title, fingerprint) within_project_deploy_keys do - find_element(:key_fingerprint).text + find_element(:key, title) + .has_css?(element_selector_css(:key_fingerprint), text: fingerprint) end end - def key_titles + def key_title within_project_deploy_keys do - all_elements(:key_title) + find_element(:key_title).text end end - def key_fingerprints + def key_fingerprint within_project_deploy_keys do - all_elements(:key_fingerprint) + find_element(:key_fingerprint).text end end @@ -58,7 +61,7 @@ module QA def within_project_deploy_keys wait(reload: false) do - has_css?(element_selector_css(:project_deploy_keys)) + has_element?(:project_deploy_keys) end within_element(:project_deploy_keys) do diff --git a/qa/qa/resource/deploy_key.rb b/qa/qa/resource/deploy_key.rb index 9ed8fb7726e..9565598efb0 100644 --- a/qa/qa/resource/deploy_key.rb +++ b/qa/qa/resource/deploy_key.rb @@ -8,11 +8,7 @@ module QA attribute :fingerprint do Page::Project::Settings::Repository.perform do |setting| setting.expand_deploy_keys do |key| - key_offset = key.key_titles.index do |key_title| - key_title.text == title - end - - key.key_fingerprints[key_offset].text + key.find_fingerprint(title) end end end diff --git a/qa/qa/specs/features/browser_ui/6_release/deploy_key/add_deploy_key_spec.rb b/qa/qa/specs/features/browser_ui/6_release/deploy_key/add_deploy_key_spec.rb index 84757f25379..6f39a755392 100644 --- a/qa/qa/specs/features/browser_ui/6_release/deploy_key/add_deploy_key_spec.rb +++ b/qa/qa/specs/features/browser_ui/6_release/deploy_key/add_deploy_key_spec.rb @@ -5,7 +5,7 @@ module QA describe 'Deploy key creation' do it 'user adds a deploy key' do Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.act { sign_in_using_credentials } + Page::Main::Login.perform(&:sign_in_using_credentials) key = Runtime::Key::RSA.new deploy_key_title = 'deploy key title' @@ -16,7 +16,13 @@ module QA resource.key = deploy_key_value end - expect(deploy_key.fingerprint).to eq(key.fingerprint) + expect(deploy_key.fingerprint).to eq key.fingerprint + + Page::Project::Settings::Repository.perform do |setting| + setting.expand_deploy_keys do |keys| + expect(keys).to have_key(deploy_key_title, key.fingerprint) + end + end end end end |