Use let to initialise key to avoid reusing same key name on retry
What does this MR do and why?
Fixes: #370107 (closed) #327651 (closed)
Currently if this spec fails for some reason, when it retries the test it will reuse the same key_title
.
While this may allow the 'user can add an SSH key'
spec to pass - it them causes failures in can delete an ssh key
Ambiguous match, found 2 elements matching visible link "E2E test key: key for ssh tests 1660046708.1086028"
We should instead use let to create this key_title
so if the test fails, we can rerun it with a new name to avoid the ambiguous errors.
How to set up and validate locally
We need to force the spec to fail the first time it runs - I found it easiest to test this by manually adding a sleep, and then when the test was waiting, I manually navigated away to a random page http://gdk.test/abc/def
so the assertion failed the first time. I then let it run as normal for the 'retry'.
it 'user can add an SSH key', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347819' do
key = Resource::SSHKey.fabricate_via_browser_ui! do |resource|
resource.title = key_title
end
sleep 10
expect(page).to have_content(key.title)
expect(page).to have_content(key.sha256_fingerprint)
end
-
export CI=true
(to allow rerunning tests) - Run the test with
export WEBDRIVER_HEADLESS=false
- Run with
bundle exec bin/qa Test::Instance::All http://gdk.test:3000 -- qa/specs/features/browser_ui/3_create/repository/ssh_key_support_spec.rb
- When the test fails, it should retry - note prior to this change the key title is reused causing Ambiguous errors. With this change a new key title is used for the retry attempt.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.