diff --git a/src/ostree.jsx b/src/ostree.jsx index 6d1b5dd..21a33d6 100644 --- a/src/ostree.jsx +++ b/src/ostree.jsx @@ -538,7 +538,9 @@ const DeploymentActions = ({ deploymentIndex, deploymentIsPinned, isCurrent, isS const actions = []; if (!isStaged) { actions.push( - togglePin()} > {deploymentIsPinned ? _("Unpin") : _("Pin")} @@ -552,6 +554,7 @@ const DeploymentActions = ({ deploymentIndex, deploymentIsPinned, isCurrent, isS } actions.push( deleteDeployment()} > @@ -629,7 +632,7 @@ const OStreeSource = ({ ostreeState, refreshRemotes, onChangeBranch, onChangeRem const Dialogs = useDialogs(); const actions = [ - Dialogs.show( , , - Dialogs.show( )} > {_("Add repository")} , - Dialogs.show( {_("Edit repository")} , - Dialogs.show( Dialogs.show()}> {_("Clean up")} , , - Dialogs.show()}> {_("Reset")} diff --git a/test/check-ostree b/test/check-ostree index 2395cdc..6f1332f 100755 --- a/test/check-ostree +++ b/test/check-ostree @@ -34,6 +34,10 @@ CHECKOUT_LOCATION = "/var/local-tree" RPM_LOCATION = "/usr/share/rpm" KEY_ID = "95A8BA1754D0E95E2B3A98A7EE15015654780CBD" +TAB_TREE = 1 +TAB_PACKAGES = 2 +TAB_SIGNATURES = 3 + def switch_tab(b, index, tab): row_sel = f"#available-deployments > tbody:nth-of-type({index})" @@ -41,7 +45,7 @@ def switch_tab(b, index, tab): if not b.is_visible(f"{row_sel} .ct-listing-panel-tabs"): b.click(f"{row_sel} .pf-v5-c-table__toggle button") b.wait_visible(f"{row_sel} .ct-listing-panel-tabs") - b.click(f"{row_sel} button:contains({tab})") + b.click(f"{row_sel} .pf-v5-c-tabs__item:nth-of-type({tab}) button") def wait_deployment_details_prop(b, index, tab, prop, value): @@ -61,20 +65,20 @@ def wait_deployment_prop(b, index, prop, value): def wait_packages(b, index, packages): - switch_tab(b, index, "Packages") + switch_tab(b, index, TAB_PACKAGES) for group, pkgs in packages.items(): for pkg in pkgs: b.wait_in_text(f"#available-deployments > tbody:nth-of-type({index}) .{group}", pkg) def wait_not_packages(b, index, packages): - switch_tab(b, index, "Packages") + switch_tab(b, index, TAB_PACKAGES) for pkg in packages: b.wait_not_in_text(f"#available-deployments > tbody:nth-of-type({index})", pkg) def check_package_count(b, assertIn, index): - switch_tab(b, index, "Packages") + switch_tab(b, index, TAB_PACKAGES) for group in ['adds', 'removes']: b.call_js_func("ph_count_check", f"#available-deployments > tbody:nth-of-type({index}) .{group} dd", 1) # 1 or 2, in some scenarios cockpit-ostree gets up/downgraded as well @@ -84,9 +88,9 @@ def check_package_count(b, assertIn, index): def do_deployment_action(b, index, action): deployment_row = f"#available-deployments > tbody:nth-of-type({index})" - if action in ["Pin", "Unpin", "Delete"]: + if action in ["pin", "unpin", "delete"]: b.click(f"{deployment_row} #deployment-actions") - b.click(f"{deployment_row} button.pf-v5-c-menu__item:contains({action})") + b.click(f"{deployment_row} [data-action={action}] button") else: wait_deployment_prop(b, index, "Actions", action) b.click(f"{deployment_row} tr:nth-child(1) td:nth-child(6) button") @@ -172,7 +176,7 @@ def get_name(self): def do_card_action(browser, kebab, action): browser.click(f"{kebab}") browser.wait_visible("ul.pf-v5-c-menu__list") - browser.click(f"button.pf-v5-c-menu__item:contains({action})") + browser.click(f"[data-action={action}] button") @testlib.skipImage("No OSTree repo on bootc", "*-bootc") @@ -199,8 +203,8 @@ class OstreeRestartCase(testlib.MachineCase): wait_deployment_prop(b, 1, "Status", "Current") wait_deployment_prop(b, 1, "Actions", "") - wait_deployment_details_prop(b, 1, "Tree", ".os", get_name(self)) - wait_deployment_details_prop(b, 1, "Tree", ".version", "cockpit-base.1") + wait_deployment_details_prop(b, 1, TAB_TREE, ".os", get_name(self)) + wait_deployment_details_prop(b, 1, TAB_TREE, ".version", "cockpit-base.1") b.assert_pixels("#ostree-status", "status") b.assert_pixels("#ostree-source", "source") @@ -213,14 +217,14 @@ class OstreeRestartCase(testlib.MachineCase): wait_packages(b, 1, {"rpms-col2": [remove_pkg]}) wait_not_packages(b, 1, INSTALL_RPMS) - wait_deployment_details_prop(b, 1, "Signatures", ".no-signatures", "No signature available") + wait_deployment_details_prop(b, 1, TAB_SIGNATURES, ".no-signatures", "No signature available") # Require signatures m.execute("sed -i /gpg-verify/d /etc/ostree/remotes.d/local.conf") b.wait_not_in_text("#available-deployments > tbody:nth-of-type(2) td[data-label=Version]", "cockpit") wait_deployment_prop(b, 2, "Actions", "Roll back") - wait_deployment_details_prop(b, 2, "Tree", ".os", get_name(self)) + wait_deployment_details_prop(b, 2, TAB_TREE, ".os", get_name(self)) # Check for new commit, get error b.click("#check-for-updates-btn") @@ -254,8 +258,8 @@ class OstreeRestartCase(testlib.MachineCase): wait_deployment_prop(b, 2, "Status", "Current") # Check update data - wait_deployment_details_prop(b, 1, "Tree", ".os", get_name(self)) - wait_deployment_details_prop(b, 1, "Tree", ".version", "cockpit-base.2") + wait_deployment_details_prop(b, 1, TAB_TREE, ".os", get_name(self)) + wait_deployment_details_prop(b, 1, TAB_TREE, ".version", "cockpit-base.2") wait_packages(b, 1, {"up": ["tzdata-99999-2.noarch"], "down": ["chrony-0.1-2.noarch"], @@ -265,7 +269,7 @@ class OstreeRestartCase(testlib.MachineCase): check_package_count(b, self.assertIn, 1) # Check signatures - switch_tab(b, 1, "Signatures") + switch_tab(b, 1, TAB_SIGNATURES) sel = "#available-deployments > tbody:nth-of-type(1)" b.wait_in_text(sel, KEY_ID) b.wait_in_text(sel, "RSA") @@ -307,7 +311,7 @@ class OstreeRestartCase(testlib.MachineCase): wait_not_packages(b, 1, [remove_pkg]) # Check signatures - switch_tab(b, 1, "Signatures") + switch_tab(b, 1, TAB_SIGNATURES) sel = "#available-deployments > tbody:nth-of-type(1)" b.wait_in_text(sel, KEY_ID) b.wait_in_text(sel, "RSA") @@ -319,7 +323,7 @@ class OstreeRestartCase(testlib.MachineCase): wait_deployment_prop(b, 2, "Version", "cockpit-base.1") wait_deployment_prop(b, 2, "Actions", "Roll back") wait_deployment_prop(b, 2, "Status", "") - wait_deployment_details_prop(b, 2, "Tree", ".os", get_name(self)) + wait_deployment_details_prop(b, 2, TAB_TREE, ".os", get_name(self)) wait_packages(b, 2, {"down": [tzdata], "up": [chrony], @@ -330,7 +334,6 @@ class OstreeRestartCase(testlib.MachineCase): # Rollback do_deployment_action(b, 2, "Roll back") - b.wait_visible("button:contains('Roll back')") wait_deployment_prop(b, 2, "Status", "Updating") b.switch_to_top() @@ -376,7 +379,7 @@ class OstreeRestartCase(testlib.MachineCase): b.wait_in_text("#current-branch", branch) # open rebase modal - do_card_action(b, "#ostree-source-actions", "Rebase") + do_card_action(b, "#ostree-source-actions", "rebase") b.wait_visible("#rebase-repository-modal") b.wait_in_text("#change-repository .pf-v5-c-menu-toggle__text", "local") b.wait_in_text("#change-branch .pf-v5-c-menu-toggle__text", branch) @@ -392,15 +395,15 @@ class OstreeRestartCase(testlib.MachineCase): b.wait_in_text("#current-branch", "znew-branch") wait_deployment_prop(b, 1, "Version", "cockpit-base.1") wait_deployment_prop(b, 1, "Status", "Current") - wait_deployment_details_prop(b, 1, "Tree", ".origin", f"local:{branch}") + wait_deployment_details_prop(b, 1, TAB_TREE, ".origin", f"local:{branch}") b.click("#check-for-updates-btn") wait_deployment_prop(b, 1, "Version", "branch-version") wait_deployment_prop(b, 1, "Status", "New") wait_deployment_prop(b, 1, "Actions", "Rebase") - wait_deployment_details_prop(b, 1, "Tree", ".os", get_name(self)) - wait_deployment_details_prop(b, 1, "Tree", ".origin", "local:znew-branch") + wait_deployment_details_prop(b, 1, TAB_TREE, ".os", get_name(self)) + wait_deployment_details_prop(b, 1, TAB_TREE, ".origin", "local:znew-branch") # Apply update do_deployment_action(b, 1, "Rebase") @@ -419,7 +422,7 @@ class OstreeRestartCase(testlib.MachineCase): # After reboot, check commit wait_deployment_prop(b, 1, "Version", "branch-version") wait_deployment_prop(b, 1, "Status", "Current") - wait_deployment_details_prop(b, 1, "Tree", ".origin", "local:znew-branch") + wait_deployment_details_prop(b, 1, TAB_TREE, ".origin", "local:znew-branch") self.allow_restart_journal_messages() @@ -470,14 +473,14 @@ class OstreeRestartCase(testlib.MachineCase): wait_deployment_prop(b, 2, "Status", "") wait_packages(b, 1, {"rpms-col1": [OVERLAY_RPM]}) - do_card_action(b, "#deployments-actions", "Reset") + do_card_action(b, "#deployments-actions", "reset") b.wait_visible("#reset-modal") b.click("#remove-overlays-checkbox") b.click("#reset-modal button.pf-m-warning") with b.wait_timeout(60): b.wait_not_present("#reset-modal") - wait_deployment_details_prop(b, 1, "Packages", ".removes", "Removalsempty-1-0.noarch") + wait_deployment_details_prop(b, 1, TAB_PACKAGES, ".removes", "Removalsempty-1-0.noarch") m.reboot() m.start_cockpit() @@ -500,14 +503,14 @@ class OstreeRestartCase(testlib.MachineCase): wait_deployment_prop(b, 1, "Actions", "Update") # Pin rollback deployment - do_deployment_action(b, 3, "Pin") + do_deployment_action(b, 3, "pin") wait_deployment_prop(b, 3, "Status", "Pinned") # Kebab menu is not available for update b.wait_not_present("""#available-deployments > tbody:nth-of-type(1) tr:nth-child(1) td:last-child button.pf-v5-c-menu-toggle""") # Use clean up to remove pending and rollback deployments - do_card_action(b, "#deployments-actions", "Clean up") + do_card_action(b, "#deployments-actions", "clean-up") b.wait_visible("#cleanup-deployment-modal") b.click("#pending-deployment-checkbox") b.click("#rollback-deployment-checkbox") @@ -519,12 +522,12 @@ class OstreeRestartCase(testlib.MachineCase): # Manually delete base.1 deployment wait_deployment_prop(b, 2, "Status", "Pinned") - do_deployment_action(b, 2, "Unpin") + do_deployment_action(b, 2, "unpin") b.wait_not_present("#available-deployments .pf-v5-c-dropdown__menu") wait_deployment_prop(b, 2, "Version", "cockpit-base.1") wait_deployment_prop(b, 2, "Status", "") wait_deployment_prop(b, 2, "Actions", "Roll back") - do_deployment_action(b, 2, "Delete") + do_deployment_action(b, 2, "delete") # only one available deployment b.call_js_func("ph_count_check", "#available-deployments tbody tr", 1) @@ -545,7 +548,7 @@ class OstreeCase(testlib.MachineCase): b.wait_not_present('#ostree-status .pf-v5-u-warning-color-100') - do_card_action(b, "#ostree-source-actions", "Rebase") + do_card_action(b, "#ostree-source-actions", "rebase") b.wait_visible("#rebase-repository-modal") b.wait_in_text(".pf-v5-c-modal-box h1", "Rebase repository and branch") b.wait_in_text("#change-repository .pf-v5-c-menu-toggle__text", "local") @@ -554,7 +557,7 @@ class OstreeCase(testlib.MachineCase): b.click("#rebase-repository-modal button.pf-m-link") # Add new repository - do_card_action(b, "#ostree-source-actions", "Add repository") + do_card_action(b, "#ostree-source-actions", "add-repository") b.wait_visible("#add-repository-modal") b.set_input_text("#add-repository-modal #new-remote-name", "zremote test") b.set_input_text("#add-repository-modal #new-remote-url", "http://localhost:12344") @@ -569,7 +572,7 @@ class OstreeCase(testlib.MachineCase): b.wait_not_present("#add-repository-modal .pf-m-primary") # Try to add repository with same name - do_card_action(b, "#ostree-source-actions", "Add repository") + do_card_action(b, "#ostree-source-actions", "add-repository") b.wait_visible("#add-repository-modal") b.set_input_text("#add-repository-modal #new-remote-name", "zremote-test1") b.set_input_text("#add-repository-modal #new-remote-url", "http://localhost:12344") @@ -580,7 +583,7 @@ class OstreeCase(testlib.MachineCase): b.wait_not_present("#add-repository-modal .pf-m-primary") # rebase to newly added remote - do_card_action(b, "#ostree-source-actions", "Rebase") + do_card_action(b, "#ostree-source-actions", "rebase") b.wait_visible("#rebase-repository-modal") b.click("#change-repository button.pf-v5-c-menu-toggle") b.wait_in_text("#change-repository #zremote-test1", "zremote-test1") @@ -626,7 +629,7 @@ class OstreeCase(testlib.MachineCase): m.execute(["ostree", "summary", f"--repo={REPO_LOCATION}", "-u"]) # Edit zremote-test1 repository - do_card_action(b, "#ostree-source-actions", "Edit repository") + do_card_action(b, "#ostree-source-actions", "edit-repository") b.wait_visible("#edit-repository-modal") b.click("#edit-repository-modal #select-repository button.pf-v5-c-menu-toggle") b.click("#edit-repository-modal #zremote-test1") @@ -653,7 +656,7 @@ class OstreeCase(testlib.MachineCase): m.execute("ls /sysroot/ostree/repo/zremote-test1.trustedkeys.gpg") # disable gpg verification - do_card_action(b, "#ostree-source-actions", "Edit repository") + do_card_action(b, "#ostree-source-actions", "edit-repository") b.wait_visible("#edit-repository-modal") b.click("#edit-repository-modal #select-repository button.pf-v5-c-menu-toggle") b.click("#edit-repository-modal #zremote-test1") @@ -664,7 +667,7 @@ class OstreeCase(testlib.MachineCase): b.wait_not_present("#edit-repository-modal") # rebase to zremote-branch1 - do_card_action(b, "#ostree-source-actions", "Rebase") + do_card_action(b, "#ostree-source-actions", "rebase") b.wait_visible("#rebase-repository-modal") b.click("#rebase-repository-modal #change-repository button.pf-v5-c-menu-toggle") b.click("#rebase-repository-modal #zremote-test1") @@ -681,21 +684,21 @@ class OstreeCase(testlib.MachineCase): # Check updates display wait_deployment_prop(b, 1, "Version", "cockpit-base.1") - wait_deployment_details_prop(b, 1, "Tree", ".origin", f"local:{branch}") + wait_deployment_details_prop(b, 1, TAB_TREE, ".origin", f"local:{branch}") b.click("#check-for-updates-btn") wait_deployment_prop(b, 1, "Version", "zremote-branch1.1") wait_deployment_prop(b, 1, "Status", "New") wait_deployment_prop(b, 1, "Actions", "Rebase") - wait_deployment_details_prop(b, 1, "Tree", ".os", get_name(self)) - wait_deployment_details_prop(b, 1, "Tree", ".origin", "zremote-test1:zremote-branch1") + wait_deployment_details_prop(b, 1, TAB_TREE, ".os", get_name(self)) + wait_deployment_details_prop(b, 1, TAB_TREE, ".origin", "zremote-test1:zremote-branch1") - wait_deployment_details_prop(b, 1, "Packages", ".same-packages", + wait_deployment_details_prop(b, 1, TAB_PACKAGES, ".same-packages", "This deployment contains the same packages as your currently booted system") # Switching back shows pulled - do_card_action(b, "#ostree-source-actions", "Rebase") + do_card_action(b, "#ostree-source-actions", "rebase") b.wait_visible("#rebase-repository-modal") b.click("#rebase-repository-modal #change-branch button.pf-v5-c-menu-toggle") b.wait_in_text("#rebase-repository-modal #change-branch li:first-child button", "zremote-branch1") @@ -712,7 +715,7 @@ class OstreeCase(testlib.MachineCase): # Switching to branch shows pulled b.wait_in_text("#current-repository", "local") - do_card_action(b, "#ostree-source-actions", "Rebase") + do_card_action(b, "#ostree-source-actions", "rebase") b.wait_visible("#rebase-repository-modal") b.wait_in_text("#rebase-repository-modal #change-repository .pf-v5-c-menu-toggle__text", "local") b.click("#rebase-repository-modal #change-repository button.pf-v5-c-menu-toggle") @@ -728,7 +731,7 @@ class OstreeCase(testlib.MachineCase): wait_deployment_prop(b, 1, "Status", "New") # Remove zremote-test1 repository - do_card_action(b, "#ostree-source-actions", "Remove repository") + do_card_action(b, "#ostree-source-actions", "remove-repository") b.wait_visible("#remove-repository-modal") b.call_js_func("ph_count_check", "#remove-repository-modal .pf-v5-c-form__group-control input", 4) # Current repository checkbox is disabled @@ -736,7 +739,7 @@ class OstreeCase(testlib.MachineCase): b.click("#remove-repository-modal button.pf-m-link") # Change back to local repository - do_card_action(b, "#ostree-source-actions", "Rebase") + do_card_action(b, "#ostree-source-actions", "rebase") b.wait_visible("#rebase-repository-modal") b.click("#rebase-repository-modal #change-repository button.pf-v5-c-menu-toggle") b.click("#rebase-repository-modal #local") @@ -746,7 +749,7 @@ class OstreeCase(testlib.MachineCase): b.wait_not_present("#rebase-repository-modal") # Remove zremote-test1 repository - do_card_action(b, "#ostree-source-actions", "Remove repository") + do_card_action(b, "#ostree-source-actions", "remove-repository") b.wait_visible("#remove-repository-modal") b.call_js_func("ph_count_check", "#remove-repository-modal .pf-v5-c-form__group-control input", 4) b.wait_in_text("#remove-repository-modal #zremote-test1 + label", "zremote-test1") @@ -759,7 +762,7 @@ class OstreeCase(testlib.MachineCase): b.wait_not_present("#remove-repository-modal") # Verify that the repository is gone - do_card_action(b, "#ostree-source-actions", "Rebase") + do_card_action(b, "#ostree-source-actions", "rebase") b.wait_visible("#rebase-repository-modal") b.click("#rebase-repository-modal #change-repository button.pf-v5-c-menu-toggle") b.call_js_func("ph_count_check", "#rebase-repository-modal #change-repository .pf-v5-c-menu__list li", 3) @@ -774,7 +777,7 @@ class OstreeCase(testlib.MachineCase): b.wait_in_text("#current-branch", branch) wait_deployment_prop(b, 1, "Version", "bad-version") wait_deployment_prop(b, 1, "Status", "New") - wait_deployment_details_prop(b, 1, "Tree", ".origin", f"local:{branch}") + wait_deployment_details_prop(b, 1, TAB_TREE, ".origin", f"local:{branch}") @testlib.nondestructive def testPermission(self): @@ -867,7 +870,7 @@ class OstreeOCICase(testlib.MachineCase): b.wait_text("#current-branch .pf-v5-c-description-list__description", old_branch) wait_deployment_prop(b, 1, "Version", version) wait_deployment_prop(b, 1, "Status", "Current") - wait_deployment_details_prop(b, 1, "Tree", ".origin", f"{old_repo}:{old_branch}") + wait_deployment_details_prop(b, 1, TAB_TREE, ".origin", f"{old_repo}:{old_branch}") wait_packages(b, 1, {"rpms-col1": [bash_ver]}) # rebase to our new OCI repo @@ -887,20 +890,20 @@ class OstreeOCICase(testlib.MachineCase): wait_deployment_prop(b, 1, "Version", version) wait_deployment_prop(b, 1, "Status", "") wait_deployment_prop(b, 1, "Branch", new_repo_branch) - wait_deployment_details_prop(b, 1, "Tree", ".origin", new_repo_branch) + wait_deployment_details_prop(b, 1, TAB_TREE, ".origin", new_repo_branch) if m.image.endswith("-bootc"): # the new branch removes "less" - wait_deployment_details_prop(b, 1, "Packages", ".removes", "Removals" + less_ver) + wait_deployment_details_prop(b, 1, TAB_PACKAGES, ".removes", "Removals" + less_ver) else: # the repo is a straight rebuild of the OSTree, no package changes wait_deployment_details_prop( - b, 1, "Packages", ".same-packages", + b, 1, TAB_PACKAGES, ".same-packages", "This deployment contains the same packages as your currently booted system") # current deployment is now second wait_deployment_prop(b, 2, "Version", version) wait_deployment_prop(b, 2, "Status", "Current") - wait_deployment_details_prop(b, 2, "Tree", ".origin", old_repo_branch) + wait_deployment_details_prop(b, 2, TAB_TREE, ".origin", old_repo_branch) wait_packages(b, 2, {"rpms-col1": [bash_ver]}) # podman sometimes leaves the container behind after reboot despite --rm @@ -919,19 +922,19 @@ class OstreeOCICase(testlib.MachineCase): wait_deployment_prop(b, 1, "Version", version) wait_deployment_prop(b, 1, "Status", "Current") wait_deployment_prop(b, 1, "Branch", new_repo_branch) - wait_deployment_details_prop(b, 1, "Tree", ".origin", new_repo_branch) + wait_deployment_details_prop(b, 1, TAB_TREE, ".origin", new_repo_branch) wait_packages(b, 1, {"rpms-col1": [bash_ver]}) # ... and second deployment is the ostree repo one wait_deployment_prop(b, 2, "Version", version) wait_deployment_prop(b, 2, "Status", "") - wait_deployment_details_prop(b, 2, "Tree", ".origin", old_repo_branch) + wait_deployment_details_prop(b, 2, TAB_TREE, ".origin", old_repo_branch) if m.image.endswith("-bootc"): # the new branch removes "less", so the old one adds it - wait_deployment_details_prop(b, 2, "Packages", ".adds", "Additions" + less_ver) + wait_deployment_details_prop(b, 2, TAB_PACKAGES, ".adds", "Additions" + less_ver) else: # the repo is a straight rebuild of the OSTree, no package changes wait_deployment_details_prop( - b, 2, "Packages", ".same-packages", + b, 2, TAB_PACKAGES, ".same-packages", "This deployment contains the same packages as your currently booted system")