Skip to content

Commit

Permalink
packagekit: Add manifest condition
Browse files Browse the repository at this point in the history
We only want to show this page if Packagekit is installed, and the
system is not an OSTree.

Update `TestUpdates.testNoPackageKit` to test the new behaviour:
Previously, the page would just show "PackageKit is not installed", now
it does not get shown at all.

Test the old and new behaviour based on `$TEST_SCENARIO`, so that the
test will fail as soon as we make the Python bridge the default and drop
the C bridge. This will remind us of updating the test and docs,
instead of letting it silently break (with a simple skip).

First half of cockpit-project/cockpit-ostree#295
  • Loading branch information
martinpitt authored and allisonkarlitskaya committed Feb 13, 2023
1 parent d713f61 commit 0278284
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
5 changes: 5 additions & 0 deletions pkg/packagekit/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"name": "updates",
"priority": 0,
"conditions": [
{"path-exists": "/lib/systemd/system/packagekit.service"},
{"path-not-exists": "/sysroot/ostree"}
],

"tools": {
"index": {
"label": "Software updates",
Expand Down
32 changes: 24 additions & 8 deletions test/verify/check-packagekit
Original file line number Diff line number Diff line change
Expand Up @@ -1097,16 +1097,32 @@ ExecStart=/usr/local/bin/{packageName}
systemctl daemon-reload'''.format(system_service))

m.start_cockpit()
b.login_and_go("/updates")
if os.environ.get("TEST_SCENARIO") != "pybridge":
# TODO: conditions not implemented on C bridge; once we drop it, drop this special case and
# enable the manifest documentation for conditions in doc/guide/packages.xml
self.assertIn("\nupdates", m.execute("cockpit-bridge --packages"))
b.login_and_go("/updates")

# error message present
b.wait_in_text(".pf-c-page__main-section .pf-c-empty-state__body", "PackageKit is not installed")
# error message present
b.wait_in_text(".pf-c-page__main-section .pf-c-empty-state__body", "PackageKit is not installed")

# update status on front page should be invisible
b.go("/system")
b.enter_page("/system")
b.wait_text(self.update_text, "Loading available updates failed")
self.assertIn("exclamation", b.attr(self.update_icon, "class"))
# update status on front page should show error
b.go("/system")
b.enter_page("/system")
b.wait_text(self.update_text, "Loading available updates failed")
self.assertIn("exclamation", b.attr(self.update_icon, "class"))
else:
self.assertNotIn("\nupdates", m.execute("cockpit-bridge --packages"))
# should not appear in the menu at all
self.login_and_go(None)
b.wait_in_text("#host-apps .pf-m-current", "Overview")
self.assertNotIn("Updates", b.text("#host-apps .pf-m-current"))

# update status on front page should be invisible
b.go("/system")
b.enter_page("/system")
b.wait_visible(".system-health")
self.assertFalse(b.is_present(self.update_text))

@skipDistroPackage()
@nondestructive
Expand Down

0 comments on commit 0278284

Please sign in to comment.