From 2de78f7b7de6ab3882b20b4a188d376d9572e234 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 21 Aug 2024 11:20:41 +0200 Subject: [PATCH 1/4] test: Fix pixel test race in testCreateContainer*() Wait for the registry search to show the expected value *before* doing the pixel test. Also, the dialog's filter is already set to "Local", that was done just a few lines above. Drop the redundant click. --- test/check-application | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/check-application b/test/check-application index 4ebd8a7cb..4dc4e664a 100755 --- a/test/check-application +++ b/test/check-application @@ -1732,10 +1732,9 @@ class TestApplication(testlib.MachineCase): # Local results found b.set_input_text("#create-image-image-select-typeahead", "registry") + b.wait_text("button.pf-v5-c-select__menu-item", IMG_REGISTRY_LATEST) if auth: b.assert_pixels(".pf-v5-c-modal-box", "image-select", skip_layouts=["rtl"]) - b.click('button.pf-v5-c-toggle-group__button:contains("Local")') - b.wait_text("button.pf-v5-c-select__menu-item", IMG_REGISTRY_LATEST) # Local registry b.set_input_text("#create-image-image-select-typeahead", "my-busybox") From fa4ced872849ee6680c3c4de7cb310ab21d4c2ba Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 21 Aug 2024 07:55:22 +0200 Subject: [PATCH 2/4] test: Fix registry switch race in testCreateContainer* That dialog switches between the "All" and "Local" filter of images. The busybox image is shown in both views; however, it gets re-rendered on switch, so clicking on it is a race condition -- without waiting the click often goes to the *old* "All" result. We can't directly wait on that transition. So switch to a different registry filter first, wait for the "No images found", and then switch to "Local", so that our `wait_visible()` can take over. --- test/check-application | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/check-application b/test/check-application index 4dc4e664a..5f70efa2e 100755 --- a/test/check-application +++ b/test/check-application @@ -1737,8 +1737,8 @@ class TestApplication(testlib.MachineCase): b.assert_pixels(".pf-v5-c-modal-box", "image-select", skip_layouts=["rtl"]) # Local registry - b.set_input_text("#create-image-image-select-typeahead", "my-busybox") b.click('button.pf-v5-c-toggle-group__button:contains("localhost:5000")') + b.set_input_text("#create-image-image-select-typeahead", "my-busybox") b.wait_text("button.pf-v5-c-select__menu-item:not(.pf-m-disabled)", "localhost:5000/my-busybox") # Select image @@ -1798,6 +1798,11 @@ class TestApplication(testlib.MachineCase): b.set_input_text("#run-image-dialog-name", container_name) b.set_input_text("#create-image-image-select-typeahead", IMG_BUSYBOX) + # we want to switch to "Local", but to make waiting for IMG_BUSYBOX race-free, we first need to + # switch to another view; different images have different registries, so don't assume their name, just + # that at least one more exists + b.click('.image-search-footer .pf-v5-c-toggle-group__item:nth-of-type(3) button') + b.wait_in_text(".pf-v5-c-select__menu-list", "No images found") b.click('button.pf-v5-c-toggle-group__button:contains("Local")') b.click(f'button.pf-v5-c-select__menu-item:contains("{IMG_BUSYBOX}")') @@ -2733,6 +2738,11 @@ class TestApplication(testlib.MachineCase): b.set_input_text("#run-image-dialog-name", container_name) b.set_input_text("#create-image-image-select-typeahead", IMG_BUSYBOX_LATEST) + # we want to switch to "Local", but to make waiting for IMG_BUSYBOX race-free, we first need to + # switch to another view; different images have different registries, so don't assume their name, just + # that at least one more exists + b.click('.image-search-footer .pf-v5-c-toggle-group__item:nth-of-type(3) button') + b.wait_in_text(".pf-v5-c-select__menu-list", "No images found") b.click('button.pf-v5-c-toggle-group__button:contains("Local")') b.click(f'button.pf-v5-c-select__menu-item:contains("{IMG_BUSYBOX_LATEST}")') b.click('.pf-v5-c-modal-box__footer #create-image-create-run-btn') From 2c786501a496fca36b04a564d4fe9cd8727de00c Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 21 Aug 2024 06:47:29 +0200 Subject: [PATCH 3/4] test: Drop stray Enter key presses from testRunImage These were introduced in commit a47c18616b0e70 without justification, and it's not clear what they were meant to do. Depending on the timing they change/mess up the value in the file choosers, leading to random test failures. --- test/check-application | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/check-application b/test/check-application index 5f70efa2e..691c5e51d 100755 --- a/test/check-application +++ b/test/check-application @@ -1956,10 +1956,8 @@ class TestApplication(testlib.MachineCase): b.wait_not_present('#run-image-dialog-volume-0-selinux') b.set_file_autocomplete_val("#run-image-dialog-volume-0 .pf-v5-c-select", rodir) - b.key("Enter") b.set_input_text('#run-image-dialog-volume-0-container-path', '/tmp/ro') ro_label = m.execute(f"ls -dZ {rodir}").split(" ")[0] - b.key("Enter") b.click('.volume-form .btn-add') b.wait_visible('#run-image-dialog-volume-1') b.click('#run-image-dialog-volume-1-btn-close') @@ -1977,7 +1975,6 @@ class TestApplication(testlib.MachineCase): b.wait_not_present('#run-image-dialog-volume-2-selinux') b.set_file_autocomplete_val("#run-image-dialog-volume-2 .pf-v5-c-select", rwdir) - b.key("Enter") b.set_input_text('#run-image-dialog-volume-2-container-path', '/tmp/rw') rw_label = m.execute(f"ls -dZ {rwdir}").split(" ")[0] From bb0a44946048b7842384824e7349676ff6ef7f02 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 21 Aug 2024 07:00:33 +0200 Subject: [PATCH 4/4] test: More precise click on CPU shares number input Enabling the disabled element only works when clicking on the [ - ] or [ + ] buttons, not the number itself. With Firefox the test will soon click into the center of the element, which is the number. Make the selector more specific to ensure it goes to the [ - ] button. Also circumvent the "element must be not enabled" restriction by directly using `Browser.mouse()`. This has always been a race condition, as we expect the number input to be disabled by default. --- test/check-application | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/check-application b/test/check-application index 691c5e51d..0c6bd26af 100755 --- a/test/check-application +++ b/test/check-application @@ -1869,7 +1869,7 @@ class TestApplication(testlib.MachineCase): if auth: # Check that the checkbox is enabled when clicked on the field b.wait_visible("#run-image-dialog-cpu-priority-checkbox:not(:checked)") - b.click('#run-image-cpu-priority') + b.mouse('#run-image-cpu-priority button[aria-label="Decrease CPU shares"]', "click") b.wait_visible("#run-image-dialog-cpu-priority-checkbox:checked") b.set_checked("#run-image-dialog-cpu-priority-checkbox", False)