From ea9685380aceb8fc1db6ef311f80809987d67862 Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 13 Nov 2026 20:24:25 -0500 Subject: [PATCH 01/11] test(probe): temporary GNOME 51 audit probe 3 for #827 rows 4, 5, 6 and 10 Assisted-by: Claude Opus 5.5 via Claude Code Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WcWm7qQa538Zjcuvv8jBtn Signed-off-by: Danathar --- .../steps/gnome51_audit_probe3_steps.py | 148 ++++++++++++++++++ .../features/zz_gnome51_audit_probe_3.feature | 22 +++ 2 files changed, 170 insertions(+) create mode 100644 tests/smoke/features/steps/gnome51_audit_probe3_steps.py create mode 100644 tests/smoke/features/zz_gnome51_audit_probe_3.feature diff --git a/tests/smoke/features/steps/gnome51_audit_probe3_steps.py b/tests/smoke/features/steps/gnome51_audit_probe3_steps.py new file mode 100644 index 000000000..1a8132d24 --- /dev/null +++ b/tests/smoke/features/steps/gnome51_audit_probe3_steps.py @@ -0,0 +1,148 @@ +"""Temporary #827 probe 3: are audit rows 4, 5, 6 and 10 still needed on 51? + +Records, and never asserts, what each workaround guards, read on the path the +workaround replaced. Prints one ``GNOME51_AUDIT_PROBE3`` JSON line per reading. +Dropped before the PR is ready. + +- Row 4: toplevel roles of each app. The pre-workaround code accepted only + ``frame``; a ``filler`` toplevel, or a bare childless ``filler`` next to the + real window, keeps the workaround. +- Row 5: roles of the Files sidebar's Home item. Pre-GNOME 50 it was + ``list item``; GNOME 50 made it ``button``. +- Row 6: the AT-SPI application names. Pre-GNOME 50 Files registered as + ``nautilus``. +- Row 10: after CloseNotification, how long the pre-GNOME 50 check + (``Main.messageTray._banner`` null) takes to pass, against the 4 s it allowed. +""" + +import json +import time +from time import sleep + +from behave import step + +from steps.steps import _shell_eval + +try: + from dogtail import tree +except Exception: # noqa: BLE001 + tree = None # type: ignore[assignment] + + +def _emit(row: str, **data) -> None: + print("GNOME51_AUDIT_PROBE3 " + json.dumps({"row": row, **data}, sort_keys=True), flush=True) + + +def _guarded(row: str): + """Record any exception instead of failing: later readings still run.""" + def wrap(fn): + def inner(context): + try: + fn(context) + except Exception as exc: # diagnostic only + _emit(row, error=repr(exc)) + inner.__name__ = fn.__name__ + return inner + return wrap + + +def _attr(node, name, default=None): + try: + value = getattr(node, name) + except Exception: # noqa: BLE001 + return default + return value + + +def _desc_count(node, limit=400) -> int: + """Descendants of node, capped so a large tree does not stall the probe.""" + seen, stack = 0, list(_attr(node, "children", []) or []) + while stack and seen < limit: + child = stack.pop() + seen += 1 + stack.extend(_attr(child, "children", []) or []) + return seen + + +@step("Record GNOME 51 audit probe 3 rows 4 and 6 application toplevels") +@_guarded("4+6") +def probe_rows_4_6(context) -> None: + sleep(8) # let the three apps map their windows + names = [] + for app in tree.root.applications(): + name = (_attr(app, "name", "") or "").strip("'\" ") + names.append(name) + low = name.lower() + if not any(k in low for k in ("nautilus", "files", "calculator", "texteditor", "text editor", "gnome-text-editor")): + continue + tops = [] + for child in _attr(app, "children", []) or []: + tops.append({ + "role": _attr(child, "roleName"), + "name": _attr(child, "name"), + "showing": _attr(child, "showing"), + "children": len(_attr(child, "children", []) or []), + "descendants": _desc_count(child), + }) + _emit("4", app=name, toplevels=tops) + _emit("6", applications=names) + + +@step("Record GNOME 51 audit probe 3 row 5 Files sidebar roles") +@_guarded("5") +def probe_row_5(context) -> None: + for app in tree.root.applications(): + name = (_attr(app, "name", "") or "").strip("'\" ") + if name in ("org.gnome.Nautilus", "Files", "nautilus") or "nautilus" in name.lower(): + items = app.findChildren( + lambda n: bool(_attr(n, "name")) + and ("Home" in n.name or "Personal Folder" in n.name) + ) + _emit("5", app=name, home_items=[ + {"role": _attr(i, "roleName"), "name": _attr(i, "name"), "showing": _attr(i, "showing"), + "parent_role": _attr(_attr(i, "parent"), "roleName")} + for i in items[:20] + ]) + return + _emit("5", error="Files application not found") + + +_BANNER_JS = ( + "JSON.stringify({" + "banner_type: typeof Main.messageTray._banner," + "banner_null: Main.messageTray._banner === null || Main.messageTray._banner === undefined," + "banner_visible: !!(Main.messageTray._banner && Main.messageTray._banner.visible)," + "bannerbin_type: typeof Main.messageTray._bannerBin," + "bannerbin_visible: !!(Main.messageTray._bannerBin && Main.messageTray._bannerBin.visible)" + "})" +) + + +def _banner() -> str: + try: + return _shell_eval(_BANNER_JS).strip() + except AssertionError as exc: + return f"error: {exc}" + + +@step("Record GNOME 51 audit probe 3 row 10 banner while showing") +@_guarded("10") +def probe_row_10_showing(context) -> None: + sleep(1.0) + _emit("10", phase="showing", state=_banner()) + + +@step("Record GNOME 51 audit probe 3 row 10 banner after dismissal") +@_guarded("10") +def probe_row_10_dismissed(context) -> None: + start = time.monotonic() + readings = [] + first_null = None + while time.monotonic() - start < 20: + state = _banner() + t = round(time.monotonic() - start, 2) + readings.append({"t": t, "state": state}) + if first_null is None and '"banner_null":true' in state.replace(" ", ""): + first_null = t + sleep(0.5) + _emit("10", phase="after-close", first_banner_null_s=first_null, readings=readings[:12], last=readings[-1]) diff --git a/tests/smoke/features/zz_gnome51_audit_probe_3.feature b/tests/smoke/features/zz_gnome51_audit_probe_3.feature new file mode 100644 index 000000000..7d29a121d --- /dev/null +++ b/tests/smoke/features/zz_gnome51_audit_probe_3.feature @@ -0,0 +1,22 @@ +@smoke_suite +Feature: GNOME 51 audit probe 3 (#827, temporary) + Records, without asserting them, the readings that decide whether audit rows + 4, 5, 6 and 10 are still needed on GNOME 51: what each workaround guards, + measured on the path the workaround replaced. + + @gnome51_audit_probe + Scenario: Record GNOME 51 audit probe 3 app readings + * GNOME Shell is accessible via AT-SPI + * Launch Files via command + * Launch Calculator via command + * Launch Text Editor via command + * Record GNOME 51 audit probe 3 rows 4 and 6 application toplevels + * Record GNOME 51 audit probe 3 row 5 Files sidebar roles + + @gnome51_audit_probe + Scenario: Record GNOME 51 audit probe 3 notification banner + * GNOME Shell is accessible via AT-SPI + * A test desktop notification is sent via gdbus + * Record GNOME 51 audit probe 3 row 10 banner while showing + * Dismiss the notification via gdbus CloseNotification + * Record GNOME 51 audit probe 3 row 10 banner after dismissal From d4b49782e7dd5e6d472ae7b4fd011a67cfee884e Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 13 Nov 2026 20:25:49 -0500 Subject: [PATCH 02/11] test(probe): record qecore, dogtail and behave versions with GNOME Shell's Assisted-by: Claude Opus 5.5 via Claude Code Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WcWm7qQa538Zjcuvv8jBtn Signed-off-by: Danathar --- .../features/steps/gnome51_audit_probe3_steps.py | 15 +++++++++++++++ .../features/zz_gnome51_audit_probe_3.feature | 1 + 2 files changed, 16 insertions(+) diff --git a/tests/smoke/features/steps/gnome51_audit_probe3_steps.py b/tests/smoke/features/steps/gnome51_audit_probe3_steps.py index 1a8132d24..6a4fc44da 100644 --- a/tests/smoke/features/steps/gnome51_audit_probe3_steps.py +++ b/tests/smoke/features/steps/gnome51_audit_probe3_steps.py @@ -64,6 +64,21 @@ def _desc_count(node, limit=400) -> int: return seen +@step("Record GNOME 51 audit probe 3 qecore version") +@_guarded("qecore") +def probe_qecore(context) -> None: + from importlib import metadata + + versions = {} + for pkg in ("qecore", "dogtail", "behave"): + try: + versions[pkg] = metadata.version(pkg) + except Exception as exc: # noqa: BLE001 + versions[pkg] = repr(exc) + shell = _shell_eval("Config.PACKAGE_VERSION").strip() + _emit("qecore", versions=versions, shell=shell) + + @step("Record GNOME 51 audit probe 3 rows 4 and 6 application toplevels") @_guarded("4+6") def probe_rows_4_6(context) -> None: diff --git a/tests/smoke/features/zz_gnome51_audit_probe_3.feature b/tests/smoke/features/zz_gnome51_audit_probe_3.feature index 7d29a121d..4013030f3 100644 --- a/tests/smoke/features/zz_gnome51_audit_probe_3.feature +++ b/tests/smoke/features/zz_gnome51_audit_probe_3.feature @@ -7,6 +7,7 @@ Feature: GNOME 51 audit probe 3 (#827, temporary) @gnome51_audit_probe Scenario: Record GNOME 51 audit probe 3 app readings * GNOME Shell is accessible via AT-SPI + * Record GNOME 51 audit probe 3 qecore version * Launch Files via command * Launch Calculator via command * Launch Text Editor via command From fe4f01163fa1adade4cfeafb0cc7f0f0f50e1729 Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 13 Nov 2026 21:07:14 -0500 Subject: [PATCH 03/11] fix(smoke): notification banner check fails when the banner stays "Notification banner is no longer showing via Shell.Eval" also required Main.messageTray._bannerBin to be hidden. On GNOME 51 the bin stays visible with no banner in it (#827 probe 3: _banner is null 0.2 s after CloseNotification while _bannerBin.visible stays true for 20 s), so the check never passed; the step then force-destroyed the banner and, failing that, only printed a warning. It could not fail, on GNOME 50 or 51, whether or not CloseNotification worked. Check only the banner (null, undefined or hidden, which also covers GNOME 50 keeping a hidden ref), keep the 20 s allowance for slow QEMU banners, and fail with the last Shell.Eval output instead of force-dismissing. Assisted-by: Claude Opus 5.5 via Claude Code Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WcWm7qQa538Zjcuvv8jBtn Signed-off-by: Danathar --- .../steps/gnome51_audit_probe3_steps.py | 36 ++++++- .../steps/gnome_notifications_steps.py | 99 +++++++------------ .../features/zz_gnome51_audit_probe_3.feature | 4 +- tests/unit/test_gnome_notifications_steps.py | 39 ++++++++ 4 files changed, 106 insertions(+), 72 deletions(-) diff --git a/tests/smoke/features/steps/gnome51_audit_probe3_steps.py b/tests/smoke/features/steps/gnome51_audit_probe3_steps.py index 6a4fc44da..eaa22ee18 100644 --- a/tests/smoke/features/steps/gnome51_audit_probe3_steps.py +++ b/tests/smoke/features/steps/gnome51_audit_probe3_steps.py @@ -21,6 +21,7 @@ from behave import step +from app_support import launch_background from steps.steps import _shell_eval try: @@ -79,6 +80,32 @@ def probe_qecore(context) -> None: _emit("qecore", versions=versions, shell=shell) +# Whatever of these the image ships; a missing app is recorded, not fatal. +_PROBE_APPS = { + "files": ((("command", "nautilus"), ("desktop", "org.gnome.Nautilus.desktop")), None), + "settings": ( + (("command", "gnome-control-center"), ("desktop", "org.gnome.Settings.desktop")), + {"XDG_CURRENT_DESKTOP": "GNOME", "GNOME_ACCESSIBILITY": "1"}, + ), + "calculator": ((("command", "gnome-calculator"), ("desktop", "org.gnome.Calculator.desktop")), None), + "text-editor": ((("command", "gnome-text-editor"), ("desktop", "org.gnome.TextEditor.desktop")), None), + "clocks": ((("desktop", "org.gnome.clocks.desktop"), ("flatpak", "org.gnome.clocks")), None), +} + + +@step("Launch GNOME 51 audit probe 3 apps") +@_guarded("launch") +def probe_launch(context) -> None: + launched = {} + for key, (targets, env) in _PROBE_APPS.items(): + try: + launched[key] = launch_background(targets, env=env) if env else launch_background(targets) + except Exception as exc: # noqa: BLE001 + launched[key] = f"not launched: {exc}" + sleep(1.0) + _emit("launch", launched=launched) + + @step("Record GNOME 51 audit probe 3 rows 4 and 6 application toplevels") @_guarded("4+6") def probe_rows_4_6(context) -> None: @@ -87,8 +114,7 @@ def probe_rows_4_6(context) -> None: for app in tree.root.applications(): name = (_attr(app, "name", "") or "").strip("'\" ") names.append(name) - low = name.lower() - if not any(k in low for k in ("nautilus", "files", "calculator", "texteditor", "text editor", "gnome-text-editor")): + if name in ("gnome-shell", "") or name.startswith(("ibus", "xdg-desktop-portal")): continue tops = [] for child in _attr(app, "children", []) or []: @@ -99,7 +125,8 @@ def probe_rows_4_6(context) -> None: "children": len(_attr(child, "children", []) or []), "descendants": _desc_count(child), }) - _emit("4", app=name, toplevels=tops) + if any(t["role"] in ("frame", "filler", "window", "dialog") for t in tops): + _emit("4", app=name, toplevels=tops) _emit("6", applications=names) @@ -157,7 +184,8 @@ def probe_row_10_dismissed(context) -> None: state = _banner() t = round(time.monotonic() - start, 2) readings.append({"t": t, "state": state}) - if first_null is None and '"banner_null":true' in state.replace(" ", ""): + flat = state.replace("\\", "").replace('"', "").replace("'", "") + if first_null is None and "banner_null:true" in flat: first_null = t sleep(0.5) _emit("10", phase="after-close", first_banner_null_s=first_null, readings=readings[:12], last=readings[-1]) diff --git a/tests/smoke/features/steps/gnome_notifications_steps.py b/tests/smoke/features/steps/gnome_notifications_steps.py index 6fcb66e50..d41424c85 100644 --- a/tests/smoke/features/steps/gnome_notifications_steps.py +++ b/tests/smoke/features/steps/gnome_notifications_steps.py @@ -96,78 +96,47 @@ def dismiss_notification_via_gdbus(context) -> None: assert returncode == 0, f"CloseNotification failed for id={notification_id}: {stderr}" -@step("Notification banner is no longer showing via Shell.Eval") -def notification_banner_no_longer_showing(context) -> None: +# True once no notification banner is on screen. The banner ref goes null +# when Shell finishes the dismiss animation (GNOME 50 may keep it but hidden). +# Do not also require Main.messageTray._bannerBin to be hidden: on GNOME 51 +# the bin stays visible with no banner in it, so that check never passed and +# the step only ever "passed" through a force-dismiss and a warning, whether or +# not CloseNotification worked (#827 audit row 10, probe 3). +BANNER_GONE_JS = ( + "(Main.messageTray._banner === null || " + "Main.messageTray._banner === undefined || " + "!Main.messageTray._banner.visible).toString()" +) +BANNER_DISMISS_TIMEOUT_S = 20 # GNOME 50 banners can linger in QEMU + + +def _banner_gone(run=subprocess.run) -> tuple[bool, str]: import re - # Wait up to 20 s for the banner to be dismissed from the message tray. - # The banner ref becomes null once Shell finishes the dismiss animation. - # GNOME 50 changed the banner API — check both _banner property and banner visibility. - # Use a compound expression that returns 'false' when no banner is showing. - banner_js = ( - "((Main.messageTray._banner === null || " - "Main.messageTray._banner === undefined || " - "!Main.messageTray._banner.visible) && " - "(typeof Main.messageTray._bannerBin === 'undefined' || " - "Main.messageTray._bannerBin === null || " - "!Main.messageTray._bannerBin.visible)).toString()" - ) - last_out = "" - for _ in range(40): # 20s — GNOME 50 banners can linger longer in QEMU - result = subprocess.run( - ["gdbus", "call", "--session", - "--dest", "org.gnome.Shell", - "--object-path", "/org/gnome/Shell", - "--method", "org.gnome.Shell.Eval", - banner_js], - capture_output=True, text=True, timeout=5, - ) - last_out = result.stdout - m = re.search(r",\s*'\"?(true|false)\"?'\s*\)", last_out, re.IGNORECASE) - if m and m.group(1).lower() == "true": - return - sleep(0.5) - - # Banner still showing after 20s — force-dismiss via Shell.Eval. - dismiss_js = ( - "try {" - " if (Main.messageTray._banner && Main.messageTray._banner.destroy) {" - " Main.messageTray._banner.destroy();" - " } else if (Main.messageTray._bannerBin) {" - " Main.messageTray._bannerBin.hide();" - " }" - "} catch(e) {}; 'dismissed'" - ) - subprocess.run( - ["gdbus", "call", "--session", - "--dest", "org.gnome.Shell", - "--object-path", "/org/gnome/Shell", - "--method", "org.gnome.Shell.Eval", - dismiss_js], - capture_output=True, text=True, timeout=5, - ) - sleep(1) - # Final check after explicit dismiss - result = subprocess.run( + + result = run( ["gdbus", "call", "--session", "--dest", "org.gnome.Shell", "--object-path", "/org/gnome/Shell", "--method", "org.gnome.Shell.Eval", - banner_js], + BANNER_GONE_JS], capture_output=True, text=True, timeout=5, ) - last_out = result.stdout - m = re.search(r",\s*'\"?(true|false)\"?'\s*\)", last_out, re.IGNORECASE) - if m and m.group(1).lower() == "true": - return - # In headless GNOME 50 QEMU, the banner visibility JS check can return - # "false" (still visible) even after a successful CloseNotification call. - # This is a known environment limitation — not a functional regression. - # Treat as a warning rather than a hard failure to avoid blocking the suite. - print( - f"WARNING: Notification banner still showing after explicit dismiss " - f"(headless GNOME 50 QEMU limitation) — Shell.Eval returned: {last_out!r}. " - "Skipping hard assertion.", - flush=True, + out = result.stdout + m = re.search(r",\s*'\"?(true|false)\"?'\s*\)", out, re.IGNORECASE) + return bool(m and m.group(1).lower() == "true"), out + + +@step("Notification banner is no longer showing via Shell.Eval") +def notification_banner_no_longer_showing(context, run=subprocess.run, pause=sleep) -> None: + last_out = "" + for _ in range(BANNER_DISMISS_TIMEOUT_S * 2): + gone, last_out = _banner_gone(run) + if gone: + return + pause(0.5) + raise AssertionError( + f"Notification banner still showing {BANNER_DISMISS_TIMEOUT_S}s after " + f"CloseNotification; Shell.Eval returned: {last_out!r}" ) diff --git a/tests/smoke/features/zz_gnome51_audit_probe_3.feature b/tests/smoke/features/zz_gnome51_audit_probe_3.feature index 4013030f3..6bb3abc36 100644 --- a/tests/smoke/features/zz_gnome51_audit_probe_3.feature +++ b/tests/smoke/features/zz_gnome51_audit_probe_3.feature @@ -8,9 +8,7 @@ Feature: GNOME 51 audit probe 3 (#827, temporary) Scenario: Record GNOME 51 audit probe 3 app readings * GNOME Shell is accessible via AT-SPI * Record GNOME 51 audit probe 3 qecore version - * Launch Files via command - * Launch Calculator via command - * Launch Text Editor via command + * Launch GNOME 51 audit probe 3 apps * Record GNOME 51 audit probe 3 rows 4 and 6 application toplevels * Record GNOME 51 audit probe 3 row 5 Files sidebar roles diff --git a/tests/unit/test_gnome_notifications_steps.py b/tests/unit/test_gnome_notifications_steps.py index 958bdc9ac..5f794e45e 100644 --- a/tests/unit/test_gnome_notifications_steps.py +++ b/tests/unit/test_gnome_notifications_steps.py @@ -46,3 +46,42 @@ def test_parse_notification_id_raises_on_unparseable_output(output): with pytest.raises(AssertionError, match="Could not parse"): module._parse_notification_id(output) + + +class _Done: + def __init__(self, stdout): + self.stdout = stdout + + +def _runner(outputs): + calls = [] + + def run(cmd, **kwargs): + calls.append(cmd) + return _Done(outputs[min(len(calls) - 1, len(outputs) - 1)]) + + return run, calls + + +def test_banner_check_does_not_require_the_banner_bin_hidden(): + # GNOME 51 keeps Main.messageTray._bannerBin visible with no banner in it + # (#827 audit row 10), so requiring it hidden made the check never pass. + module = _import_gnome_notifications_steps() + assert "_bannerBin" not in module.BANNER_GONE_JS + assert "Main.messageTray._banner === null" in module.BANNER_GONE_JS + + +def test_banner_gone_returns_as_soon_as_shell_says_so(): + module = _import_gnome_notifications_steps() + run, calls = _runner(["(true, 'false')", "(true, 'true')"]) + module.notification_banner_no_longer_showing(None, run=run, pause=lambda s: None) + assert len(calls) == 2 + + +def test_banner_still_showing_fails_instead_of_force_dismissing(): + module = _import_gnome_notifications_steps() + run, calls = _runner(["(true, 'false')"]) + with pytest.raises(AssertionError, match="still showing"): + module.notification_banner_no_longer_showing(None, run=run, pause=lambda s: None) + assert all("destroy" not in " ".join(c) and "hide()" not in " ".join(c) for c in calls) + assert len(calls) == module.BANNER_DISMISS_TIMEOUT_S * 2 From 00289dbd0a98699a57bfe5d33ac4c5874a201c0c Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 13 Nov 2026 21:31:00 -0500 Subject: [PATCH 04/11] test(probe): banner state after an immediate CloseNotification, as the smoke scenario does Assisted-by: Claude Opus 5.5 via Claude Code Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WcWm7qQa538Zjcuvv8jBtn Signed-off-by: Danathar --- tests/smoke/features/zz_gnome51_audit_probe_3.feature | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/smoke/features/zz_gnome51_audit_probe_3.feature b/tests/smoke/features/zz_gnome51_audit_probe_3.feature index 6bb3abc36..301d1e026 100644 --- a/tests/smoke/features/zz_gnome51_audit_probe_3.feature +++ b/tests/smoke/features/zz_gnome51_audit_probe_3.feature @@ -19,3 +19,11 @@ Feature: GNOME 51 audit probe 3 (#827, temporary) * Record GNOME 51 audit probe 3 row 10 banner while showing * Dismiss the notification via gdbus CloseNotification * Record GNOME 51 audit probe 3 row 10 banner after dismissal + + @gnome51_audit_probe + Scenario: Record GNOME 51 audit probe 3 banner after an immediate close + * GNOME Shell is accessible via AT-SPI + * A test desktop notification is sent via gdbus + * Notification request returns a positive notification ID + * Dismiss the notification via gdbus CloseNotification + * Record GNOME 51 audit probe 3 row 10 banner after dismissal From 30628f42afb7a6a61ba2046e3f5088ff3644b574 Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 13 Nov 2026 21:33:10 -0500 Subject: [PATCH 05/11] test(probe): banner owner and idle hold, Firefox toplevel, sidebar parents Assisted-by: Claude Opus 5.5 via Claude Code Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WcWm7qQa538Zjcuvv8jBtn Signed-off-by: Danathar --- .../steps/gnome51_audit_probe3_steps.py | 37 ++++++++++++++++++- .../features/zz_gnome51_audit_probe_3.feature | 10 +++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/tests/smoke/features/steps/gnome51_audit_probe3_steps.py b/tests/smoke/features/steps/gnome51_audit_probe3_steps.py index eaa22ee18..99fe8ad45 100644 --- a/tests/smoke/features/steps/gnome51_audit_probe3_steps.py +++ b/tests/smoke/features/steps/gnome51_audit_probe3_steps.py @@ -90,6 +90,11 @@ def probe_qecore(context) -> None: "calculator": ((("command", "gnome-calculator"), ("desktop", "org.gnome.Calculator.desktop")), None), "text-editor": ((("command", "gnome-text-editor"), ("desktop", "org.gnome.TextEditor.desktop")), None), "clocks": ((("desktop", "org.gnome.clocks.desktop"), ("flatpak", "org.gnome.clocks")), None), + "firefox": ( + (("command", "firefox"), ("desktop", "firefox.desktop"), ("flatpak", "org.mozilla.firefox"), + ("desktop", "org.mozilla.firefox.desktop")), + {"GNOME_ACCESSIBILITY": "1", "ACCESSIBILITY_ENABLED": "1", "GTK_A11Y": "atk-bridge", "ATSPI_DISABLE_P2P": "1"}, + ), } @@ -109,7 +114,7 @@ def probe_launch(context) -> None: @step("Record GNOME 51 audit probe 3 rows 4 and 6 application toplevels") @_guarded("4+6") def probe_rows_4_6(context) -> None: - sleep(8) # let the three apps map their windows + sleep(15) # let the apps (Firefox is slow) map their windows names = [] for app in tree.root.applications(): name = (_attr(app, "name", "") or "").strip("'\" ") @@ -142,7 +147,10 @@ def probe_row_5(context) -> None: ) _emit("5", app=name, home_items=[ {"role": _attr(i, "roleName"), "name": _attr(i, "name"), "showing": _attr(i, "showing"), - "parent_role": _attr(_attr(i, "parent"), "roleName")} + "parent_role": _attr(_attr(i, "parent"), "roleName"), + "parent_name": _attr(_attr(i, "parent"), "name"), + "grandparent": [_attr(_attr(_attr(i, "parent"), "parent"), "roleName"), + _attr(_attr(_attr(i, "parent"), "parent"), "name")]} for i in items[:20] ]) return @@ -189,3 +197,28 @@ def probe_row_10_dismissed(context) -> None: first_null = t sleep(0.5) _emit("10", phase="after-close", first_banner_null_s=first_null, readings=readings[:12], last=readings[-1]) + + +_OWNER_JS = ( + "(() => { const t = Main.messageTray; const b = t._banner;" + " let idle = null;" + " try { idle = global.backend.get_core_idle_monitor().get_idletime(); } catch (e) {}" + " let tray = [];" + " try { tray = t.getSources().map(s => s.notifications.map(n => n.title)).flat(); } catch (e) { tray = String(e); }" + " return JSON.stringify({" + " banner: b ? { visible: b.visible, title: (b.notification && b.notification.title) || null } : null," + " tray: tray, idle_ms: idle }); })()" +) + + +@step('Record GNOME 51 audit probe 3 row 10 banner owner "{phase}"') +@_guarded("10b") +def probe_row_10_owner(context, phase) -> None: + readings = [] + for _ in range(6 if phase != "sent" else 1): + sleep(1.0) + try: + readings.append(_shell_eval(_OWNER_JS).strip()) + except AssertionError as exc: + readings.append(f"error: {exc}") + _emit("10b", phase=phase, readings=readings) diff --git a/tests/smoke/features/zz_gnome51_audit_probe_3.feature b/tests/smoke/features/zz_gnome51_audit_probe_3.feature index 301d1e026..9a71ab6d0 100644 --- a/tests/smoke/features/zz_gnome51_audit_probe_3.feature +++ b/tests/smoke/features/zz_gnome51_audit_probe_3.feature @@ -27,3 +27,13 @@ Feature: GNOME 51 audit probe 3 (#827, temporary) * Notification request returns a positive notification ID * Dismiss the notification via gdbus CloseNotification * Record GNOME 51 audit probe 3 row 10 banner after dismissal + + @gnome51_audit_probe + Scenario: Record GNOME 51 audit probe 3 banner owner and idle hold + * GNOME Shell is accessible via AT-SPI + * A test desktop notification is sent via gdbus + * Record GNOME 51 audit probe 3 row 10 banner owner "sent" + * Dismiss the notification via gdbus CloseNotification + * Record GNOME 51 audit probe 3 row 10 banner owner "closed" + * Key combo: "" with uinput + * Record GNOME 51 audit probe 3 row 10 banner owner "after-input" From 102d1b870d374520ae84621d33201c2bd3cc0a90 Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 13 Nov 2026 22:03:17 -0500 Subject: [PATCH 06/11] test(probe): pass step arguments through the guard; replay the sidebar step's search Assisted-by: Claude Opus 5.5 via Claude Code Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WcWm7qQa538Zjcuvv8jBtn Signed-off-by: Danathar --- .../steps/gnome51_audit_probe3_steps.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/smoke/features/steps/gnome51_audit_probe3_steps.py b/tests/smoke/features/steps/gnome51_audit_probe3_steps.py index 99fe8ad45..f0d1e49da 100644 --- a/tests/smoke/features/steps/gnome51_audit_probe3_steps.py +++ b/tests/smoke/features/steps/gnome51_audit_probe3_steps.py @@ -37,9 +37,9 @@ def _emit(row: str, **data) -> None: def _guarded(row: str): """Record any exception instead of failing: later readings still run.""" def wrap(fn): - def inner(context): + def inner(context, *args, **kwargs): try: - fn(context) + fn(context, *args, **kwargs) except Exception as exc: # diagnostic only _emit(row, error=repr(exc)) inner.__name__ = fn.__name__ @@ -145,6 +145,21 @@ def probe_row_5(context) -> None: lambda n: bool(_attr(n, "name")) and ("Home" in n.name or "Personal Folder" in n.name) ) + # Exactly the search home_folder_is_in_the_sidebar does. + matched = [] + for frame in app.findChildren(lambda n: _attr(n, "roleName") in ("frame", "filler") and _attr(n, "showing")): + for sidebar in frame.findChildren( + lambda n: _attr(n, "roleName") in ("tree", "list") and _attr(n, "showing") + and (_attr(n, "name") or "").strip() in ("Sidebar", "") + ): + for item in sidebar.findChildren( + lambda n: _attr(n, "roleName") in ("list item", "button") and _attr(n, "showing") + and bool(_attr(n, "name")) + and ("Home" in n.name or "Personal Folder" in n.name) + ): + matched.append({"role": _attr(item, "roleName"), "name": _attr(item, "name"), + "sidebar_role": _attr(sidebar, "roleName")}) + _emit("5", app=name, step_matches=matched) _emit("5", app=name, home_items=[ {"role": _attr(i, "roleName"), "name": _attr(i, "name"), "showing": _attr(i, "showing"), "parent_role": _attr(_attr(i, "parent"), "roleName"), From f720c87b8d9ce13ba38500a69daf706c64563d92 Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 13 Nov 2026 22:26:50 -0500 Subject: [PATCH 07/11] fix(smoke): check that the test notification is gone, not that no banner shows Probe 3 (#827 row 10) showed why the stricter check failed: after CloseNotification our notification leaves the message tray at once, but the visible banner is an earlier, unrelated one ("Settings") that GNOME Shell holds on screen while the session is idle; a headless VM is always idle (idle time ~4 min), and one keypress clears it in ~2 s. The old "no banner at all" check therefore tracked the wrong notification. Check that "Test Notification" is neither the visible banner nor queued in the tray, using one shared title constant for the send step. Assisted-by: Claude Opus 5.5 via Claude Code Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WcWm7qQa538Zjcuvv8jBtn Signed-off-by: Danathar --- .../steps/gnome_notifications_steps.py | 35 ++++++++++++------- tests/unit/test_gnome_notifications_steps.py | 24 +++++++++---- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/tests/smoke/features/steps/gnome_notifications_steps.py b/tests/smoke/features/steps/gnome_notifications_steps.py index d41424c85..ae224aad2 100644 --- a/tests/smoke/features/steps/gnome_notifications_steps.py +++ b/tests/smoke/features/steps/gnome_notifications_steps.py @@ -6,6 +6,10 @@ from behave import step from tests.shared.ssh_config import ssh_argv + +# Summary of the notification the smoke scenarios send and dismiss. +TEST_NOTIFICATION_TITLE = "Test Notification" + try: from qecore.common_steps import * # noqa: F401,F403 except Exception: # noqa: BLE001 @@ -50,7 +54,7 @@ def send_test_desktop_notification(context) -> None: "--dest org.freedesktop.Notifications " "--object-path /org/freedesktop/Notifications " "--method org.freedesktop.Notifications.Notify " - "'' 0 '' 'Test Notification' 'Testsuite notification body' '[]' '{}' 3000" + f"'' 0 '' '{TEST_NOTIFICATION_TITLE}' 'Testsuite notification body' '[]' '{{}}' 3000" ) if returncode != 0: combined = (stderr + output).lower() @@ -96,16 +100,23 @@ def dismiss_notification_via_gdbus(context) -> None: assert returncode == 0, f"CloseNotification failed for id={notification_id}: {stderr}" -# True once no notification banner is on screen. The banner ref goes null -# when Shell finishes the dismiss animation (GNOME 50 may keep it but hidden). -# Do not also require Main.messageTray._bannerBin to be hidden: on GNOME 51 -# the bin stays visible with no banner in it, so that check never passed and -# the step only ever "passed" through a force-dismiss and a warning, whether or -# not CloseNotification worked (#827 audit row 10, probe 3). +# True once the test notification is gone: not the visible banner and not in +# the message tray. Do not test "no banner at all": GNOME Shell holds a banner +# on screen while the session is idle, and a headless VM is always idle, so an +# unrelated earlier banner ("Settings") stayed up for minutes after our +# notification was already closed. The GNOME 50 version also required +# Main.messageTray._bannerBin hidden, which GNOME 51 never does with no banner +# in it, so it only ever "passed" through a force-dismiss and a warning, closed +# or not (#827 audit row 10, probe 3: our notification leaves the tray at once; +# the held banner clears ~2 s after any input). BANNER_GONE_JS = ( - "(Main.messageTray._banner === null || " - "Main.messageTray._banner === undefined || " - "!Main.messageTray._banner.visible).toString()" + "(() => { const t = Main.messageTray; const title = '" + TEST_NOTIFICATION_TITLE + "';" + " const b = t._banner;" + " const shown = !!(b && b.visible && b.notification && b.notification.title === title);" + " let queued = false;" + " try { queued = t.getSources().some(s => s.notifications.some(n => n.title === title)); }" + " catch (e) { queued = false; }" + " return (!shown && !queued).toString(); })()" ) BANNER_DISMISS_TIMEOUT_S = 20 # GNOME 50 banners can linger in QEMU @@ -135,8 +146,8 @@ def notification_banner_no_longer_showing(context, run=subprocess.run, pause=sle return pause(0.5) raise AssertionError( - f"Notification banner still showing {BANNER_DISMISS_TIMEOUT_S}s after " - f"CloseNotification; Shell.Eval returned: {last_out!r}" + f"'{TEST_NOTIFICATION_TITLE}' is still shown or queued " + f"{BANNER_DISMISS_TIMEOUT_S}s after CloseNotification; Shell.Eval returned: {last_out!r}" ) diff --git a/tests/unit/test_gnome_notifications_steps.py b/tests/unit/test_gnome_notifications_steps.py index 5f794e45e..c945f0437 100644 --- a/tests/unit/test_gnome_notifications_steps.py +++ b/tests/unit/test_gnome_notifications_steps.py @@ -63,12 +63,24 @@ def run(cmd, **kwargs): return run, calls -def test_banner_check_does_not_require_the_banner_bin_hidden(): - # GNOME 51 keeps Main.messageTray._bannerBin visible with no banner in it - # (#827 audit row 10), so requiring it hidden made the check never pass. +def test_banner_check_tracks_the_test_notification_not_any_banner(): + # GNOME Shell holds an unrelated banner on screen while the session is + # idle, and GNOME 51 keeps _bannerBin visible with no banner (#827 audit + # row 10), so the check is about our notification only. module = _import_gnome_notifications_steps() - assert "_bannerBin" not in module.BANNER_GONE_JS - assert "Main.messageTray._banner === null" in module.BANNER_GONE_JS + js = module.BANNER_GONE_JS + assert "_bannerBin" not in js + assert f"const title = '{module.TEST_NOTIFICATION_TITLE}'" in js + assert "b.notification.title === title" in js + assert "getSources()" in js + + +def test_sent_notification_uses_the_checked_title(monkeypatch): + module = _import_gnome_notifications_steps() + sent = [] + monkeypatch.setattr(module, "_run", lambda cmd: (sent.append(cmd) or "(uint32 7,)", 0, "")) + module.send_test_desktop_notification(type("C", (), {})()) + assert f"'{module.TEST_NOTIFICATION_TITLE}'" in sent[0] def test_banner_gone_returns_as_soon_as_shell_says_so(): @@ -81,7 +93,7 @@ def test_banner_gone_returns_as_soon_as_shell_says_so(): def test_banner_still_showing_fails_instead_of_force_dismissing(): module = _import_gnome_notifications_steps() run, calls = _runner(["(true, 'false')"]) - with pytest.raises(AssertionError, match="still showing"): + with pytest.raises(AssertionError, match="still shown or queued"): module.notification_banner_no_longer_showing(None, run=run, pause=lambda s: None) assert all("destroy" not in " ".join(c) and "hide()" not in " ".join(c) for c in calls) assert len(calls) == module.BANNER_DISMISS_TIMEOUT_S * 2 From 9638e9c7ff524e7819aa426259baf198bb20ea85 Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 13 Nov 2026 22:56:30 -0500 Subject: [PATCH 08/11] fix(smoke): report what the dismissal check saw; probe the banner in smoke-a Assisted-by: Claude Opus 5.5 via Claude Code Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WcWm7qQa538Zjcuvv8jBtn Signed-off-by: Danathar --- tests/smoke/features/gnome_notifications.feature | 11 +++++++++++ .../features/steps/gnome_notifications_steps.py | 13 ++++++++----- tests/unit/test_gnome_notifications_steps.py | 9 ++++++--- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/tests/smoke/features/gnome_notifications.feature b/tests/smoke/features/gnome_notifications.feature index 450de1c54..e999b16ef 100644 --- a/tests/smoke/features/gnome_notifications.feature +++ b/tests/smoke/features/gnome_notifications.feature @@ -25,3 +25,14 @@ Feature: GNOME notification smoke tests Scenario: No gnome-shell journal errors after notification * A test desktop notification is sent via gdbus * No gnome-shell notification journal errors are present + + # Temporary #827 probe 3 (removed before merge): the banner after close, + # in the same shard and session state as the scenario above. + @gnome51_audit_probe + Scenario: Probe 3 banner owner after CloseNotification and one keypress + * A test desktop notification is sent via gdbus + * Record GNOME 51 audit probe 3 row 10 banner owner "sent" + * Dismiss the notification via gdbus CloseNotification + * Record GNOME 51 audit probe 3 row 10 banner owner "closed" + * Key combo: "" with uinput + * Record GNOME 51 audit probe 3 row 10 banner owner "after-input" diff --git a/tests/smoke/features/steps/gnome_notifications_steps.py b/tests/smoke/features/steps/gnome_notifications_steps.py index ae224aad2..b47e4ac5e 100644 --- a/tests/smoke/features/steps/gnome_notifications_steps.py +++ b/tests/smoke/features/steps/gnome_notifications_steps.py @@ -116,14 +116,17 @@ def dismiss_notification_via_gdbus(context) -> None: " let queued = false;" " try { queued = t.getSources().some(s => s.notifications.some(n => n.title === title)); }" " catch (e) { queued = false; }" - " return (!shown && !queued).toString(); })()" + " let idle = null;" + " try { idle = global.backend.get_core_idle_monitor().get_idletime(); } catch (e) {}" + " return JSON.stringify({ gone: !shown && !queued, shown: shown, queued: queued," + " banner: b ? ((b.notification && b.notification.title) || '?') : null," + " destroyed: !!(b && b.notification && b.notification._destroyed), idle_ms: idle }); })()" ) BANNER_DISMISS_TIMEOUT_S = 20 # GNOME 50 banners can linger in QEMU def _banner_gone(run=subprocess.run) -> tuple[bool, str]: - import re - + """(test notification gone?, Shell.Eval output) for one read.""" result = run( ["gdbus", "call", "--session", "--dest", "org.gnome.Shell", @@ -133,8 +136,8 @@ def _banner_gone(run=subprocess.run) -> tuple[bool, str]: capture_output=True, text=True, timeout=5, ) out = result.stdout - m = re.search(r",\s*'\"?(true|false)\"?'\s*\)", out, re.IGNORECASE) - return bool(m and m.group(1).lower() == "true"), out + flat = out.replace("\\", "").replace('"', "").replace(" ", "") + return "gone:true" in flat, out @step("Notification banner is no longer showing via Shell.Eval") diff --git a/tests/unit/test_gnome_notifications_steps.py b/tests/unit/test_gnome_notifications_steps.py index c945f0437..228813fab 100644 --- a/tests/unit/test_gnome_notifications_steps.py +++ b/tests/unit/test_gnome_notifications_steps.py @@ -85,15 +85,18 @@ def test_sent_notification_uses_the_checked_title(monkeypatch): def test_banner_gone_returns_as_soon_as_shell_says_so(): module = _import_gnome_notifications_steps() - run, calls = _runner(["(true, 'false')", "(true, 'true')"]) + run, calls = _runner([ + '(true, \'"{\\\\"gone\\\\":false,\\\\"shown\\\\":true}"\')', + '(true, \'"{\\\\"gone\\\\":true,\\\\"shown\\\\":false}"\')', + ]) module.notification_banner_no_longer_showing(None, run=run, pause=lambda s: None) assert len(calls) == 2 def test_banner_still_showing_fails_instead_of_force_dismissing(): module = _import_gnome_notifications_steps() - run, calls = _runner(["(true, 'false')"]) + run, calls = _runner(['(true, \'"{\\\\"gone\\\\":false,\\\\"shown\\\\":true}"\')']) with pytest.raises(AssertionError, match="still shown or queued"): module.notification_banner_no_longer_showing(None, run=run, pause=lambda s: None) - assert all("destroy" not in " ".join(c) and "hide()" not in " ".join(c) for c in calls) + assert all("destroy()" not in " ".join(c) and "hide()" not in " ".join(c) for c in calls) assert len(calls) == module.BANNER_DISMISS_TIMEOUT_S * 2 From e4aa74e5734978c1bcb7840bcc88414ce32e9a27 Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 13 Nov 2026 23:24:08 -0500 Subject: [PATCH 09/11] fix(smoke): give each test notification a unique title for the dismissal check Smoke-a runs 43554149449/43554157456 showed the tray holding several "Test Notification" entries: other scenarios and retries send the same title and never close theirs, so a title match could not tell whether this scenario's notification was dismissed (CloseNotification did remove one). Each send now adds a short unique suffix, stored on the context, and the dismissal check looks for that title only. Assisted-by: Claude Opus 5.5 via Claude Code Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WcWm7qQa538Zjcuvv8jBtn Signed-off-by: Danathar --- .../steps/gnome_notifications_steps.py | 50 ++++++++++++------- tests/unit/test_gnome_notifications_steps.py | 22 +++++--- 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/tests/smoke/features/steps/gnome_notifications_steps.py b/tests/smoke/features/steps/gnome_notifications_steps.py index b47e4ac5e..abb4fc3b8 100644 --- a/tests/smoke/features/steps/gnome_notifications_steps.py +++ b/tests/smoke/features/steps/gnome_notifications_steps.py @@ -1,13 +1,18 @@ """Custom step definitions for GNOME notification smoke tests.""" +import json import os import re import subprocess +import uuid from time import sleep from behave import step from tests.shared.ssh_config import ssh_argv -# Summary of the notification the smoke scenarios send and dismiss. +# Summary prefix of the notifications the smoke scenarios send. Each send adds +# a unique suffix: scenarios that send without closing (and retries) leave +# same-titled notifications in the tray, so a bare title cannot say whether +# this scenario's notification was dismissed. TEST_NOTIFICATION_TITLE = "Test Notification" try: @@ -49,12 +54,14 @@ def _parse_notification_id(output: str) -> int: @step("A test desktop notification is sent via gdbus") def send_test_desktop_notification(context) -> None: + title = f"{TEST_NOTIFICATION_TITLE} {uuid.uuid4().hex[:8]}" + context.test_notification_title = title output, returncode, stderr = _run( "gdbus call --session " "--dest org.freedesktop.Notifications " "--object-path /org/freedesktop/Notifications " "--method org.freedesktop.Notifications.Notify " - f"'' 0 '' '{TEST_NOTIFICATION_TITLE}' 'Testsuite notification body' '[]' '{{}}' 3000" + f"'' 0 '' '{title}' 'Testsuite notification body' '[]' '{{}}' 3000" ) if returncode != 0: combined = (stderr + output).lower() @@ -109,30 +116,34 @@ def dismiss_notification_via_gdbus(context) -> None: # in it, so it only ever "passed" through a force-dismiss and a warning, closed # or not (#827 audit row 10, probe 3: our notification leaves the tray at once; # the held banner clears ~2 s after any input). -BANNER_GONE_JS = ( - "(() => { const t = Main.messageTray; const title = '" + TEST_NOTIFICATION_TITLE + "';" - " const b = t._banner;" - " const shown = !!(b && b.visible && b.notification && b.notification.title === title);" - " let queued = false;" - " try { queued = t.getSources().some(s => s.notifications.some(n => n.title === title)); }" - " catch (e) { queued = false; }" - " let idle = null;" - " try { idle = global.backend.get_core_idle_monitor().get_idletime(); } catch (e) {}" - " return JSON.stringify({ gone: !shown && !queued, shown: shown, queued: queued," - " banner: b ? ((b.notification && b.notification.title) || '?') : null," - " destroyed: !!(b && b.notification && b.notification._destroyed), idle_ms: idle }); })()" -) +def banner_gone_js(title: str) -> str: + """Shell.Eval JS: is the notification titled ``title`` neither the visible + banner nor in the tray? Returns a JSON object with the details.""" + return ( + "(() => { const t = Main.messageTray; const title = " + json.dumps(title) + ";" + " const b = t._banner;" + " const shown = !!(b && b.visible && b.notification && b.notification.title === title);" + " let queued = false;" + " try { queued = t.getSources().some(s => s.notifications.some(n => n.title === title)); }" + " catch (e) { queued = false; }" + " let idle = null;" + " try { idle = global.backend.get_core_idle_monitor().get_idletime(); } catch (e) {}" + " return JSON.stringify({ gone: !shown && !queued, shown: shown, queued: queued," + " banner: b ? ((b.notification && b.notification.title) || '?') : null, idle_ms: idle }); })()" + ) + + BANNER_DISMISS_TIMEOUT_S = 20 # GNOME 50 banners can linger in QEMU -def _banner_gone(run=subprocess.run) -> tuple[bool, str]: +def _banner_gone(title: str, run=subprocess.run) -> tuple[bool, str]: """(test notification gone?, Shell.Eval output) for one read.""" result = run( ["gdbus", "call", "--session", "--dest", "org.gnome.Shell", "--object-path", "/org/gnome/Shell", "--method", "org.gnome.Shell.Eval", - BANNER_GONE_JS], + banner_gone_js(title)], capture_output=True, text=True, timeout=5, ) out = result.stdout @@ -142,14 +153,15 @@ def _banner_gone(run=subprocess.run) -> tuple[bool, str]: @step("Notification banner is no longer showing via Shell.Eval") def notification_banner_no_longer_showing(context, run=subprocess.run, pause=sleep) -> None: + title = getattr(context, "test_notification_title", TEST_NOTIFICATION_TITLE) last_out = "" for _ in range(BANNER_DISMISS_TIMEOUT_S * 2): - gone, last_out = _banner_gone(run) + gone, last_out = _banner_gone(title, run) if gone: return pause(0.5) raise AssertionError( - f"'{TEST_NOTIFICATION_TITLE}' is still shown or queued " + f"'{title}' is still shown or queued " f"{BANNER_DISMISS_TIMEOUT_S}s after CloseNotification; Shell.Eval returned: {last_out!r}" ) diff --git a/tests/unit/test_gnome_notifications_steps.py b/tests/unit/test_gnome_notifications_steps.py index 228813fab..6b2a1f5e7 100644 --- a/tests/unit/test_gnome_notifications_steps.py +++ b/tests/unit/test_gnome_notifications_steps.py @@ -66,21 +66,27 @@ def run(cmd, **kwargs): def test_banner_check_tracks_the_test_notification_not_any_banner(): # GNOME Shell holds an unrelated banner on screen while the session is # idle, and GNOME 51 keeps _bannerBin visible with no banner (#827 audit - # row 10), so the check is about our notification only. + # row 10), so the check is about this scenario's notification only. module = _import_gnome_notifications_steps() - js = module.BANNER_GONE_JS + js = module.banner_gone_js("Test Notification ab12cd34") assert "_bannerBin" not in js - assert f"const title = '{module.TEST_NOTIFICATION_TITLE}'" in js + assert 'const title = "Test Notification ab12cd34"' in js assert "b.notification.title === title" in js assert "getSources()" in js -def test_sent_notification_uses_the_checked_title(monkeypatch): +def test_each_sent_notification_gets_a_unique_checked_title(monkeypatch): + # Other scenarios (and retries) leave same-titled notifications in the + # tray, so the dismissal check needs this send's own title. module = _import_gnome_notifications_steps() sent = [] monkeypatch.setattr(module, "_run", lambda cmd: (sent.append(cmd) or "(uint32 7,)", 0, "")) - module.send_test_desktop_notification(type("C", (), {})()) - assert f"'{module.TEST_NOTIFICATION_TITLE}'" in sent[0] + first, second = type("C", (), {})(), type("C", (), {})() + module.send_test_desktop_notification(first) + module.send_test_desktop_notification(second) + assert first.test_notification_title != second.test_notification_title + assert first.test_notification_title.startswith(module.TEST_NOTIFICATION_TITLE + " ") + assert f"'{first.test_notification_title}'" in sent[0] def test_banner_gone_returns_as_soon_as_shell_says_so(): @@ -89,7 +95,7 @@ def test_banner_gone_returns_as_soon_as_shell_says_so(): '(true, \'"{\\\\"gone\\\\":false,\\\\"shown\\\\":true}"\')', '(true, \'"{\\\\"gone\\\\":true,\\\\"shown\\\\":false}"\')', ]) - module.notification_banner_no_longer_showing(None, run=run, pause=lambda s: None) + module.notification_banner_no_longer_showing(type("C", (), {"test_notification_title": "Test Notification x"})(), run=run, pause=lambda s: None) assert len(calls) == 2 @@ -97,6 +103,6 @@ def test_banner_still_showing_fails_instead_of_force_dismissing(): module = _import_gnome_notifications_steps() run, calls = _runner(['(true, \'"{\\\\"gone\\\\":false,\\\\"shown\\\\":true}"\')']) with pytest.raises(AssertionError, match="still shown or queued"): - module.notification_banner_no_longer_showing(None, run=run, pause=lambda s: None) + module.notification_banner_no_longer_showing(type("C", (), {"test_notification_title": "Test Notification x"})(), run=run, pause=lambda s: None) assert all("destroy()" not in " ".join(c) and "hide()" not in " ".join(c) for c in calls) assert len(calls) == module.BANNER_DISMISS_TIMEOUT_S * 2 From 74eb60d3a04ab60397013baf9bfea05dc26df439 Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 13 Nov 2026 23:46:00 -0500 Subject: [PATCH 10/11] docs(gnome-51-audit): verdicts for rows 4, 5, 6 and 10, qecore on 51, GNOME 51 skill section; drop probe 3 Probe 3 (removed here) measured each workaround's guarded property on the pre-workaround path, on dakota:testing and utah:testing (GNOME Shell 51.1): - Row 4: Files, Settings and Firefox expose a populated `frame` toplevel; no `filler` occurred. Obsolete on 51 for every app measured. - Row 5: the sidebar step's only match is a `list item` "Open Personal Folder" (the pre-GNOME 50 role). Obsolete on 51. - Row 6: Files registers as `org.gnome.Nautilus`. Still required. - Row 10: broken on 51 and fixed earlier in this branch. - qecore 4.19.3 (with dogtail 2.0.3, behave 1.3.3) is what the GNOME 51 runs use, and works there; releases since name no GNOME 51 change. The Calculator and Text Editor divergence write-up moves to its own reference (gnome-51-app-divergences.md) to keep the audit under 200 lines. SKILL.md's two GNOME 51 audit sections become one GNOME 51 section. Assisted-by: Claude Opus 5.5 via Claude Code Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WcWm7qQa538Zjcuvv8jBtn Signed-off-by: Danathar --- docs/skills/test-authoring/gnome/SKILL.md | 39 +-- .../references/gnome-51-app-divergences.md | 55 ++++ .../gnome/references/gnome-51-audit.md | 124 ++++----- .../features/gnome_notifications.feature | 11 - .../steps/gnome51_audit_probe3_steps.py | 239 ------------------ .../features/zz_gnome51_audit_probe_3.feature | 39 --- 6 files changed, 131 insertions(+), 376 deletions(-) create mode 100644 docs/skills/test-authoring/gnome/references/gnome-51-app-divergences.md delete mode 100644 tests/smoke/features/steps/gnome51_audit_probe3_steps.py delete mode 100644 tests/smoke/features/zz_gnome51_audit_probe_3.feature diff --git a/docs/skills/test-authoring/gnome/SKILL.md b/docs/skills/test-authoring/gnome/SKILL.md index eeeae1e60..036802e61 100644 --- a/docs/skills/test-authoring/gnome/SKILL.md +++ b/docs/skills/test-authoring/gnome/SKILL.md @@ -49,13 +49,13 @@ metadata: ## Stack -| Layer | Component | Install | -|---|---|---| -| BDD runner | behave | pip | -| Session bridge | qecore-headless | pip | -| GUI automation | dogtail (AT-SPI) | pip | -| Wayland coord bridge | gnome-ponytail-daemon | `sudo dnf install gnome-ponytail-daemon` inside VM | -| Shell bridge | `org.gnome.Shell.Eval` | built-in (requires `unsafe_mode=true`) | +| Layer | Component | Install | +| -------------------- | ---------------------- | -------------------------------------------------- | +| BDD runner | behave | pip | +| Session bridge | qecore-headless | pip | +| GUI automation | dogtail (AT-SPI) | pip | +| Wayland coord bridge | gnome-ponytail-daemon | `sudo dnf install gnome-ponytail-daemon` inside VM | +| Shell bridge | `org.gnome.Shell.Eval` | built-in (requires `unsafe_mode=true`) | ## Screen Lock/Unlock D-Bus calls (GNOME 50) @@ -91,9 +91,18 @@ test manual session locking via `loginctl lock-session` / `loginctl unlock-sessi and logind `LockedHint`, which remain fully operational even when automatic idle lock is disabled. -## GNOME 51 workarounds audit (issue #827) +## GNOME 51 (issue #827) -GNOME 51 (GA 2026-09-16) is Wayland-only and freezes the extension API. Keep every GNOME 50 workaround until a `gnomeos-51` run proves it obsolete — inventory, ground rules and validation procedure in [`references/gnome-51-audit.md`](references/gnome-51-audit.md). +`dakota:testing` and `utah:testing` run GNOME Shell 51.1 (qecore 4.19.3 works). +Each GNOME 50 workaround's GNOME 51 verdict, with probe evidence, is in +[`references/gnome-51-audit.md`](references/gnome-51-audit.md). Still needed on +51: the Files AT-SPI name `org.gnome.Nautilus`, and Ptyxis's `Terminal` title +where Ptyxis ships. The rest are obsolete on 51; keep their GNOME 50 paths while +any tested image runs GNOME 50. Notification dismissal checks that the test +notification is gone, not that no banner shows: Shell holds earlier banners on +screen while the session is idle, as a headless VM always is. Calculator and +Text Editor divergences on plain GNOME OS 51: +[`references/gnome-51-app-divergences.md`](references/gnome-51-app-divergences.md). ## Remote session commands from the runner container @@ -474,15 +483,6 @@ helper; key contract points: Reuse this helper rather than a new `gdbus`-poll loop. See `docs/skills/ci-ops/ops/references/qecore-headless-restarts-gdm-bus-socket-churn.md`. -## GNOME 51 workarounds audit - -`dakota:testing` runs GNOME 51.1; its e2e smoke runs exercise workarounds on -GNOME 51. Keep GNOME 50 workarounds while any tested image still needs them. -See `references/gnome-51-audit.md` for run evidence and per-workaround verdicts. -Calculator display lookup and Text Editor new-document/quit diverged on plain -GNOME OS 51. When the PR validation plan selects VM-covered suites, the check -runs `dakota:testing`; it cannot capture AT-SPI trees for apps that image lacks. - ## On-demand references Load these when you hit the specific topic: @@ -491,7 +491,8 @@ Load these when you hit the specific topic: - [Top-bar interactions and Shell.Eval parsing on GNOME 50+.](references/top-bar.md) - [MIME, display, and session configuration in containerized tests.](references/display-config.md) - [Deep dive: Preinstalled Flatpak desktop app launch checks](references/preinstalled-flatpak-desktop-app-launch-checks.md) -- [GNOME 50 → 51 workaround audit, live run evidence, and the Calculator / Text Editor divergences.](references/gnome-51-audit.md) +- [GNOME 50 → 51 workaround audit and its targeted probe evidence.](references/gnome-51-audit.md) +- [Calculator and Text Editor divergences on plain GNOME OS 51.](references/gnome-51-app-divergences.md) ## Overview, clone paint, and helper fault injection (issue #919) diff --git a/docs/skills/test-authoring/gnome/references/gnome-51-app-divergences.md b/docs/skills/test-authoring/gnome/references/gnome-51-app-divergences.md new file mode 100644 index 000000000..e74c2f438 --- /dev/null +++ b/docs/skills/test-authoring/gnome/references/gnome-51-app-divergences.md @@ -0,0 +1,55 @@ +--- +name: gnome-51-app-divergences +description: "Calculator display lookup and Text Editor new-document/quit failures found in the plain gnomeos-51 run; documented, not fixed. Not among the twelve audited GNOME 50 workarounds." +metadata: + type: reference + audience: agents + maturity: stable +--- +# GNOME 51 app divergences: Calculator and Text Editor + +These are **not** among the twelve workarounds above. In the plain `gnomeos-51` +run ([gnome-51-audit.md](gnome-51-audit.md) §Run evidence), Calculator and Text Editor scenarios diverged. In the `dakota:testing` +v1 gate run (same section), both apps were absent and their scenarios skipped; that run +does not show them passing or failing. When the PR validation plan selects +VM-covered suites, the check runs `dakota:testing`; it cannot capture AT-SPI +trees for apps that image does not ship. +The findings below are **documented here, not fixed**. + +### Calculator display lookup — broken on 51 + +- **Failing:** `basic_multiplication` ("display shows 42"), + `subtracting_to_a_negative_result` ("display shows -5"). +- **Passing (decoys):** `basic_addition` (3), `basic_division` (3), + `basic_subtraction` (5), `clear_button_resets_display` (0), + `decimal_arithmetic` (3), `calculator_launches`. +- **Root cause:** `click_calculator_button` / `Calculator display shows` in + `tests/smoke/features/steps/gnome_calculator_steps.py` resolve the display via + `_display_candidates()`, which walks the window for nodes with role in + `{text, entry, label, static}` and a non-empty value. On GNOME 51 the display + node is **not** located, so the step falls back to the keypad **buttons** + (7, 8, 9, `×`, `÷`, `−`, `+`, `=`, …). A single positive digit that happens to + equal a button label (`3`, `5`, `0`) matches by accident and passes; `42` and + `-5` match no button and fail. The screenshot + `screenshot_smoke_failed_basic_multiplication.png` shows the calculator with + no display value matching. +- **What the run proves:** the step did not locate the display node on this + `gnomeos-51` image. Capture the app's GNOME 51 AT-SPI tree to identify the + real display node or distinguish it from the keypad buttons. +- **Also failing:** `calculator_closes_cleanly_via_ctrl_q` — `Ctrl+Q` did not + quit (see Text Editor below; shared key-combo path). + +### Text Editor new-document / quit — broken on 51 + +- **Failing:** `text_editor_creates_new_empty_document_buffer` (`Ctrl+N`), + `text_editor_save_dialog_is_open` (`Ctrl+S`), `text_editor_discard_dialog_is_open` + (`Ctrl+Shift+S`), and the Text Editor coredump/quited scenarios. +- **Passing:** `text_editor` `@input` ("Type text") — plain typing works. +- **Root cause:** after `Ctrl+N` the buffer still shows the previous scenario's + content (`"Bluefin smoke testPrevious document content"`) instead of a new + empty buffer. `Ctrl+N` is not creating a new document on GNOME 51. Plain + character entry via uinput works, so the input layer is fine — the failure is + specific to the `Key combo` path (`Ctrl+N`/`Ctrl+S`/`Ctrl+Shift+S`). +- **What the run shows:** the `Key combo` step did not drive the expected + accelerator for Text Editor on this `gnomeos-51` image. A run with `qecore` + debug logging is needed to establish whether the combo is dropped or mis-routed. diff --git a/docs/skills/test-authoring/gnome/references/gnome-51-audit.md b/docs/skills/test-authoring/gnome/references/gnome-51-audit.md index 04279931c..5a57bf590 100644 --- a/docs/skills/test-authoring/gnome/references/gnome-51-audit.md +++ b/docs/skills/test-authoring/gnome/references/gnome-51-audit.md @@ -1,6 +1,6 @@ --- name: gnome-51-audit -description: "Audit of GNOME 50-specific workarounds against GNOME 51 — per-workaround verdict, the live gnomeos-51 run evidence, and the Calculator / Text Editor divergences found in that run." +description: "Audit of GNOME 50-specific workarounds against GNOME 51 — per-workaround verdict, the live gnomeos-51 run evidence, the targeted probes behind each verdict, and qecore on GNOME 51." metadata: type: reference audience: agents @@ -36,28 +36,26 @@ Version-branch or fix a workaround only after a run proves behavior diverges. ## The twelve GNOME 50 workarounds -| # | Workaround | Status (GNOME 51) | Where | -|---|---|---|---| -| 1 | Re-prepend `global.context.unsafe_mode = true` before every `Shell.Eval` (GNOME 50 reset it) | **OBSOLETE ON 51** — §Targeted probes (round 2): `global.context.unsafe_mode`, read by a raw `Shell.Eval` that does not re-enable it, stayed `true` after a 3 s idle, an overview open and close over D-Bus, a notification, a GNOME Text Editor window opening and closing, and both screen-lock paths with their unlocks, on `dakota:testing` and `utah:testing`. GNOME 50's reset did not happen. Keep the prepend while any tested image runs GNOME 50; it is harmless. Modal dialogs other than the lock screen were not exercised | `tests/smoke/features/steps/steps.py`; documented in `SKILL.md` "Screen Lock/Unlock" / "Overview search entry" | -| 2 | Double-quoted `Shell.Eval` results `(true, '"true"')` | **OBSOLETE ON 51 as a version quirk** — §Targeted probes (round 2): `Shell.Eval` returns the result JSON-encoded on both images: `true` → `(true, 'true')`, `'abc'` → `(true, '"abc"')`, objects and arrays as JSON, `undefined` → `''`. A quoted `'"true"'` only appears when the expression evaluates to the string `"true"`. Keep `_eval_bool`'s optional quotes for string results | `tests/smoke/features/steps/steps.py` | -| 3 | Extension `state=6` via `Shell.Eval` → use `GetExtensionInfo` D-Bus | **OBSOLETE ON 51** — §Targeted probes (round 2): for the 12 extensions sampled on each image (all `ACTIVE`), `Main.extensionManager.lookup(uuid).state` via `Shell.Eval` returned `1`, matching `GetExtensionInfo` (`1`) and `gnome-extensions show` (`ACTIVE`); GNOME 50's constant `6` did not occur. Keep `GetExtensionInfo`: it is the public API and needs no unsafe mode | `tests/smoke/features/steps/steps.py`; `SKILL.md` "Extension state via D-Bus" | -| 4 | `filler`/`frame` toplevel-role fallback + require populated subtree | **WORKS ON 51** — Files, Calculator, Text Editor, and fractional/integer scale windows resolved their toplevels; the run does not prove which fallback was needed | `tests/shared/gnome_shell_steps.py`; `SKILL.md` "Window-role checks must prove the subtree is populated" | -| 5 | Nautilus sidebar role (`home_folder_is_in_the_sidebar`) | **WORKS ON 51** — `home_folder_is_in_the_sidebar` passed; necessity remains unproven | `tests/smoke/features/steps/gnome_files_steps.py` | -| 6 | Nautilus AT-SPI app-name handling (`FILES_APP_NAMES`, `_nautilus_app`) | **WORKS ON 51** — Files launched, navigated, and closed; necessity remains unproven | `tests/smoke/features/steps/gnome_files_steps.py` | -| 7 | Ptyxis window title (`user@host:~`) | **STILL REQUIRED on `utah:testing`; not testable on `dakota:testing`** — §Targeted probes (round 2): on utah (`/usr/bin/ptyxis`) a new window was titled `Terminal` (WM class `org.gnome.Ptyxis`) and its AT-SPI frame was named `Terminal`, so a check for a `Ptyxis` title would fail. `dakota:testing` ships no Ptyxis (its terminal is Ghostty), which is why smoke-a skipped the scenario | `tests/smoke/features/steps/gnome_apps_steps.py:34-38` | -| 8 | ScreenSaver D-Bus `Lock` (not `screenShield.lock(true)`) | **OBSOLETE ON 51** — §Targeted probes (round 2): `Main.screenShield.lock(true)` via `Shell.Eval` locked the session on both images (`org.gnome.ScreenSaver.GetActive` → `true`), and `SetActive false` unlocked it; `org.gnome.ScreenSaver.Lock` behaved the same. GNOME 50's "deprecated and fails" no longer holds. Keep the D-Bus `Lock`: it is the public API and needs no unsafe mode | `tests/smoke/features/steps/steps.py`; `SKILL.md` "Screen Lock/Unlock D-Bus calls" | -| 9 | `Main.overview.visible` reads `false` in QEMU; do not assert it | **OBSOLETE ON 51** — the targeted probe (§Targeted probes) read `Main.overview.visible` as `false`, `true`, `false` across an overview open and close in QEMU on GNOME Shell 51.1, matching `OverviewActive` each time, on `dakota:testing` and `utah:testing`. Keep checking `OverviewActive`: it needs no `Shell.Eval` or unsafe mode | `tests/smoke/features/steps/steps.py`; `SKILL.md` "Activities overview (GNOME 50 QEMU)" | -| 10 | Notification banner dismissal check | **WORKS ON 51** — `toast_notification_banner_can_be_dismissed` passed; necessity remains unproven | `tests/smoke/features/steps/gnome_notifications_steps.py` | -| 11 | Panel buttons `showing=False` before overview toggle | **OBSOLETE ON 51** — the first probe read the Activities toggle as `showing=True`; §Targeted probes (round 2) found the clock (a `menu` with no accessible name, holding the date and time label) and the `System` menu in the same top-bar panel, and both read `showing=True` before, during and after an overview toggle on both images. GNOME 50's "every panel button reports `showing=False`" holds for none of the three | `tests/shared/gnome_shell_steps.py` | -| 12 | keyring skip on GDM restart | **WORKS ON 51** — §Targeted probes (round 2): with qecore's keyring setup skipped, every smoke-b scenario passed on both images. The login keyring is unusable without it: on dakota the `login` collection exists but is locked; on utah `gnome-keyring-daemon` runs with no `login` collection (default alias `/`); a `secret-tool store` blocked until a 15 s timeout on both. No smoke scenario stores a secret. Whether qecore's setup, which restarts GDM, would still break the run is not measured: it would restart the session under test | `tests/smoke/features/environment.py` | - -Rows 4, 5, 6, and 10 worked in the run in §Run evidence; a passing scenario -does not prove that the workaround is required. Rows 1, 2, 3, 7, 8, 9, 11 and -12 were measured by targeted probes (§Targeted probes and §Targeted probes -(round 2)). Row 7 is still required where Ptyxis ships (`utah:testing`); -`dakota:testing` has no Ptyxis. **This audit is incomplete**: issue #827 still -needs targeted comparisons for rows 4, 5, 6 and 10, which passed but have not -been run without their workarounds. +| # | Workaround | Status (GNOME 51) | Where | +| --- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | +| 1 | Re-prepend `global.context.unsafe_mode = true` before every `Shell.Eval` (GNOME 50 reset it) | **OBSOLETE ON 51** — §Targeted probes (round 2): `global.context.unsafe_mode`, read by a raw `Shell.Eval` that does not re-enable it, stayed `true` after a 3 s idle, an overview open and close over D-Bus, a notification, a GNOME Text Editor window opening and closing, and both screen-lock paths with their unlocks, on `dakota:testing` and `utah:testing`. GNOME 50's reset did not happen. Keep the prepend while any tested image runs GNOME 50; it is harmless. Modal dialogs other than the lock screen were not exercised | `tests/smoke/features/steps/steps.py`; documented in `SKILL.md` "Screen Lock/Unlock" / "Overview search entry" | +| 2 | Double-quoted `Shell.Eval` results `(true, '"true"')` | **OBSOLETE ON 51 as a version quirk** — §Targeted probes (round 2): `Shell.Eval` returns the result JSON-encoded on both images: `true` → `(true, 'true')`, `'abc'` → `(true, '"abc"')`, objects and arrays as JSON, `undefined` → `''`. A quoted `'"true"'` only appears when the expression evaluates to the string `"true"`. Keep `_eval_bool`'s optional quotes for string results | `tests/smoke/features/steps/steps.py` | +| 3 | Extension `state=6` via `Shell.Eval` → use `GetExtensionInfo` D-Bus | **OBSOLETE ON 51** — §Targeted probes (round 2): for the 12 extensions sampled on each image (all `ACTIVE`), `Main.extensionManager.lookup(uuid).state` via `Shell.Eval` returned `1`, matching `GetExtensionInfo` (`1`) and `gnome-extensions show` (`ACTIVE`); GNOME 50's constant `6` did not occur. Keep `GetExtensionInfo`: it is the public API and needs no unsafe mode | `tests/smoke/features/steps/steps.py`; `SKILL.md` "Extension state via D-Bus" | +| 4 | `filler`/`frame` toplevel-role fallback + require populated subtree | **OBSOLETE ON 51 for every app measured** — §Targeted probes (round 3): on both images the toplevel of Files (`org.gnome.Nautilus`, 172 descendants) and Settings (`gnome-control-center`, 150), and on utah Firefox (29 children), was a populated `frame`; no `filler` toplevel and no bare childless `filler` occurred. Calculator, Text Editor and Clocks ship on neither image, so were not measured. Keep `{frame, filler}` and the populated-subtree check while any tested image runs GNOME 50 | `tests/shared/gnome_shell_steps.py`; `SKILL.md` "Window-role checks must prove the subtree is populated" | +| 5 | Nautilus sidebar role (`home_folder_is_in_the_sidebar`) | **OBSOLETE ON 51** — §Targeted probes (round 3): replaying the step's own search, its only match on both images was a `list item` named `Open Personal Folder` in the unnamed sidebar `list`: the pre-GNOME 50 role. GNOME 50's `button` did not occur in the sidebar (the `Home` `button` is the path bar's). The `Personal Folder` name match is what finds it. Keep accepting `button` while any tested image runs GNOME 50 | `tests/smoke/features/steps/gnome_files_steps.py` | +| 6 | Nautilus AT-SPI app-name handling (`FILES_APP_NAMES`, `_nautilus_app`) | **STILL REQUIRED** — §Targeted probes (round 3): Files registers in AT-SPI as `org.gnome.Nautilus` on both images, not the pre-GNOME 50 `nautilus`, so a lookup by `nautilus` alone finds nothing | `tests/smoke/features/steps/gnome_files_steps.py` | +| 7 | Ptyxis window title (`user@host:~`) | **STILL REQUIRED on `utah:testing`; not testable on `dakota:testing`** — §Targeted probes (round 2): on utah (`/usr/bin/ptyxis`) a new window was titled `Terminal` (WM class `org.gnome.Ptyxis`) and its AT-SPI frame was named `Terminal`, so a check for a `Ptyxis` title would fail. `dakota:testing` ships no Ptyxis (its terminal is Ghostty), which is why smoke-a skipped the scenario | `tests/smoke/features/steps/gnome_apps_steps.py:34-38` | +| 8 | ScreenSaver D-Bus `Lock` (not `screenShield.lock(true)`) | **OBSOLETE ON 51** — §Targeted probes (round 2): `Main.screenShield.lock(true)` via `Shell.Eval` locked the session on both images (`org.gnome.ScreenSaver.GetActive` → `true`), and `SetActive false` unlocked it; `org.gnome.ScreenSaver.Lock` behaved the same. GNOME 50's "deprecated and fails" no longer holds. Keep the D-Bus `Lock`: it is the public API and needs no unsafe mode | `tests/smoke/features/steps/steps.py`; `SKILL.md` "Screen Lock/Unlock D-Bus calls" | +| 9 | `Main.overview.visible` reads `false` in QEMU; do not assert it | **OBSOLETE ON 51** — the targeted probe (§Targeted probes) read `Main.overview.visible` as `false`, `true`, `false` across an overview open and close in QEMU on GNOME Shell 51.1, matching `OverviewActive` each time, on `dakota:testing` and `utah:testing`. Keep checking `OverviewActive`: it needs no `Shell.Eval` or unsafe mode | `tests/smoke/features/steps/steps.py`; `SKILL.md` "Activities overview (GNOME 50 QEMU)" | +| 10 | Notification banner dismissal check | **BROKEN ON 51 — fixed** — §Targeted probes (round 3): the GNOME 50 check also required `Main.messageTray._bannerBin` hidden, which GNOME 51 never does, and treated any visible banner as ours, so it always fell through to a force-dismiss and a warning and could not fail. After `CloseNotification` this scenario's notification leaves the tray; the banner still on screen is an earlier one (other scenarios and retries send without closing) that Shell holds while the session is idle. Each sent notification now gets a unique title, and the step checks that this one is neither the visible banner nor in the tray: it passes on both images ([43556476178](https://github.com/projectbluefin/testsuite/actions/runs/43556476178), [43556485608](https://github.com/projectbluefin/testsuite/actions/runs/43556485608)) | `tests/smoke/features/steps/gnome_notifications_steps.py` | +| 11 | Panel buttons `showing=False` before overview toggle | **OBSOLETE ON 51** — the first probe read the Activities toggle as `showing=True`; §Targeted probes (round 2) found the clock (a `menu` with no accessible name, holding the date and time label) and the `System` menu in the same top-bar panel, and both read `showing=True` before, during and after an overview toggle on both images. GNOME 50's "every panel button reports `showing=False`" holds for none of the three | `tests/shared/gnome_shell_steps.py` | +| 12 | keyring skip on GDM restart | **WORKS ON 51** — §Targeted probes (round 2): with qecore's keyring setup skipped, every smoke-b scenario passed on both images. The login keyring is unusable without it: on dakota the `login` collection exists but is locked; on utah `gnome-keyring-daemon` runs with no `login` collection (default alias `/`); a `secret-tool store` blocked until a 15 s timeout on both. No smoke scenario stores a secret. Whether qecore's setup, which restarts GDM, would still break the run is not measured: it would restart the session under test | `tests/smoke/features/environment.py` | + +Every row now has a GNOME 51 verdict from a targeted probe (§Targeted probes, +rounds 1–3). Still required on 51: row 6, and row 7 where Ptyxis ships +(`utah:testing`). Row 10 was broken and is fixed. The rest are obsolete on 51 +or, for row 12, work without the workaround; keep their GNOME 50 paths while +any tested image runs GNOME 50. ## Run target @@ -139,53 +137,43 @@ What each reading did: Every probe scenario passed. Both utah runs failed only at the SELinux denial gate, on utah#1198's `chcon` `mac_admin` denials. +### Targeted probes (round 3) + +A third temporary smoke scenario (commits `ea968538` to `e4aa74e5`, removed +before merge) read, in `smoke-b` on GNOME Shell 51.1 with qecore 4.19.3: each +app's AT-SPI toplevels (row 4), the sidebar matches of the step's own search +(row 5), the application names (row 6), and for row 10 the message tray, the +visible banner's notification and the session idle time around +`CloseNotification`, before and after one uinput keypress. + +| Image | Run | +| ---------------- | ----------------------------------------------------------------------------------- | +| `dakota:testing` | [43549588532](https://github.com/projectbluefin/testsuite/actions/runs/43549588532) | +| `utah:testing` | [43549598764](https://github.com/projectbluefin/testsuite/actions/runs/43549598764) | + +Row 10 in numbers: the visible banner was never this scenario's notification +but an earlier one (`Settings`, or another test notification left open); this +scenario's notification left the tray within 1 s of `CloseNotification`; the +session had been idle 34–282 s; one `` reset the idle time and the held +banner cleared within 2.3 s. The same hold showed with the close sent at once or +after 1 s (runs 43540402711, 43544509681, 43546740107, 43554149449, +43554157456). The fixed step passed in smoke-a on both images (runs above). + +### qecore on GNOME 51 + +Every GNOME 51 run above used qecore 4.19.3 (the pin in +`container/Containerfile.runner`, `container/Containerfile.gnomeos-harness` +and the gnome-e2e action), with dogtail 2.0.3 and behave 1.3.3, read from the +test process on both images. qecore-headless and its common steps work there: +smoke-a, smoke-b and the GNOME OS canary pass. qecore's releases since (4.20 to +4.22.1) name no GNOME 51 change; 4.22 adds handling for a missing keyring, +which matches row 12 on utah. + ## Run findings — Calculator and Text Editor divergences -These are **not** among the twelve workarounds above. In the plain `gnomeos-51` -run above, Calculator and Text Editor scenarios diverged. In the `dakota:testing` -v1 gate run above, both apps were absent and their scenarios skipped; that run -does not show them passing or failing. When the PR validation plan selects -VM-covered suites, the check runs `dakota:testing`; it cannot capture AT-SPI -trees for apps that image does not ship. -The findings below are **documented here, not fixed**. - -### Calculator display lookup — broken on 51 - -- **Failing:** `basic_multiplication` ("display shows 42"), - `subtracting_to_a_negative_result` ("display shows -5"). -- **Passing (decoys):** `basic_addition` (3), `basic_division` (3), - `basic_subtraction` (5), `clear_button_resets_display` (0), - `decimal_arithmetic` (3), `calculator_launches`. -- **Root cause:** `click_calculator_button` / `Calculator display shows` in - `tests/smoke/features/steps/gnome_calculator_steps.py` resolve the display via - `_display_candidates()`, which walks the window for nodes with role in - `{text, entry, label, static}` and a non-empty value. On GNOME 51 the display - node is **not** located, so the step falls back to the keypad **buttons** - (7, 8, 9, `×`, `÷`, `−`, `+`, `=`, …). A single positive digit that happens to - equal a button label (`3`, `5`, `0`) matches by accident and passes; `42` and - `-5` match no button and fail. The screenshot - `screenshot_smoke_failed_basic_multiplication.png` shows the calculator with - no display value matching. -- **What the run proves:** the step did not locate the display node on this - `gnomeos-51` image. Capture the app's GNOME 51 AT-SPI tree to identify the - real display node or distinguish it from the keypad buttons. -- **Also failing:** `calculator_closes_cleanly_via_ctrl_q` — `Ctrl+Q` did not - quit (see Text Editor below; shared key-combo path). - -### Text Editor new-document / quit — broken on 51 - -- **Failing:** `text_editor_creates_new_empty_document_buffer` (`Ctrl+N`), - `text_editor_save_dialog_is_open` (`Ctrl+S`), `text_editor_discard_dialog_is_open` - (`Ctrl+Shift+S`), and the Text Editor coredump/quited scenarios. -- **Passing:** `text_editor` `@input` ("Type text") — plain typing works. -- **Root cause:** after `Ctrl+N` the buffer still shows the previous scenario's - content (`"Bluefin smoke testPrevious document content"`) instead of a new - empty buffer. `Ctrl+N` is not creating a new document on GNOME 51. Plain - character entry via uinput works, so the input layer is fine — the failure is - specific to the `Key combo` path (`Ctrl+N`/`Ctrl+S`/`Ctrl+Shift+S`). -- **What the run shows:** the `Key combo` step did not drive the expected - accelerator for Text Editor on this `gnomeos-51` image. A run with `qecore` - debug logging is needed to establish whether the combo is dropped or mis-routed. +These are not among the twelve workarounds. The plain `gnomeos-51` run's +Calculator display lookup and Text Editor `Ctrl+N`/`Ctrl+Q` failures are in +[gnome-51-app-divergences.md](gnome-51-app-divergences.md) (documented, not fixed). ## Bluefin-only failures (expected on gnomeos-51 — not divergences) diff --git a/tests/smoke/features/gnome_notifications.feature b/tests/smoke/features/gnome_notifications.feature index e999b16ef..450de1c54 100644 --- a/tests/smoke/features/gnome_notifications.feature +++ b/tests/smoke/features/gnome_notifications.feature @@ -25,14 +25,3 @@ Feature: GNOME notification smoke tests Scenario: No gnome-shell journal errors after notification * A test desktop notification is sent via gdbus * No gnome-shell notification journal errors are present - - # Temporary #827 probe 3 (removed before merge): the banner after close, - # in the same shard and session state as the scenario above. - @gnome51_audit_probe - Scenario: Probe 3 banner owner after CloseNotification and one keypress - * A test desktop notification is sent via gdbus - * Record GNOME 51 audit probe 3 row 10 banner owner "sent" - * Dismiss the notification via gdbus CloseNotification - * Record GNOME 51 audit probe 3 row 10 banner owner "closed" - * Key combo: "" with uinput - * Record GNOME 51 audit probe 3 row 10 banner owner "after-input" diff --git a/tests/smoke/features/steps/gnome51_audit_probe3_steps.py b/tests/smoke/features/steps/gnome51_audit_probe3_steps.py deleted file mode 100644 index f0d1e49da..000000000 --- a/tests/smoke/features/steps/gnome51_audit_probe3_steps.py +++ /dev/null @@ -1,239 +0,0 @@ -"""Temporary #827 probe 3: are audit rows 4, 5, 6 and 10 still needed on 51? - -Records, and never asserts, what each workaround guards, read on the path the -workaround replaced. Prints one ``GNOME51_AUDIT_PROBE3`` JSON line per reading. -Dropped before the PR is ready. - -- Row 4: toplevel roles of each app. The pre-workaround code accepted only - ``frame``; a ``filler`` toplevel, or a bare childless ``filler`` next to the - real window, keeps the workaround. -- Row 5: roles of the Files sidebar's Home item. Pre-GNOME 50 it was - ``list item``; GNOME 50 made it ``button``. -- Row 6: the AT-SPI application names. Pre-GNOME 50 Files registered as - ``nautilus``. -- Row 10: after CloseNotification, how long the pre-GNOME 50 check - (``Main.messageTray._banner`` null) takes to pass, against the 4 s it allowed. -""" - -import json -import time -from time import sleep - -from behave import step - -from app_support import launch_background -from steps.steps import _shell_eval - -try: - from dogtail import tree -except Exception: # noqa: BLE001 - tree = None # type: ignore[assignment] - - -def _emit(row: str, **data) -> None: - print("GNOME51_AUDIT_PROBE3 " + json.dumps({"row": row, **data}, sort_keys=True), flush=True) - - -def _guarded(row: str): - """Record any exception instead of failing: later readings still run.""" - def wrap(fn): - def inner(context, *args, **kwargs): - try: - fn(context, *args, **kwargs) - except Exception as exc: # diagnostic only - _emit(row, error=repr(exc)) - inner.__name__ = fn.__name__ - return inner - return wrap - - -def _attr(node, name, default=None): - try: - value = getattr(node, name) - except Exception: # noqa: BLE001 - return default - return value - - -def _desc_count(node, limit=400) -> int: - """Descendants of node, capped so a large tree does not stall the probe.""" - seen, stack = 0, list(_attr(node, "children", []) or []) - while stack and seen < limit: - child = stack.pop() - seen += 1 - stack.extend(_attr(child, "children", []) or []) - return seen - - -@step("Record GNOME 51 audit probe 3 qecore version") -@_guarded("qecore") -def probe_qecore(context) -> None: - from importlib import metadata - - versions = {} - for pkg in ("qecore", "dogtail", "behave"): - try: - versions[pkg] = metadata.version(pkg) - except Exception as exc: # noqa: BLE001 - versions[pkg] = repr(exc) - shell = _shell_eval("Config.PACKAGE_VERSION").strip() - _emit("qecore", versions=versions, shell=shell) - - -# Whatever of these the image ships; a missing app is recorded, not fatal. -_PROBE_APPS = { - "files": ((("command", "nautilus"), ("desktop", "org.gnome.Nautilus.desktop")), None), - "settings": ( - (("command", "gnome-control-center"), ("desktop", "org.gnome.Settings.desktop")), - {"XDG_CURRENT_DESKTOP": "GNOME", "GNOME_ACCESSIBILITY": "1"}, - ), - "calculator": ((("command", "gnome-calculator"), ("desktop", "org.gnome.Calculator.desktop")), None), - "text-editor": ((("command", "gnome-text-editor"), ("desktop", "org.gnome.TextEditor.desktop")), None), - "clocks": ((("desktop", "org.gnome.clocks.desktop"), ("flatpak", "org.gnome.clocks")), None), - "firefox": ( - (("command", "firefox"), ("desktop", "firefox.desktop"), ("flatpak", "org.mozilla.firefox"), - ("desktop", "org.mozilla.firefox.desktop")), - {"GNOME_ACCESSIBILITY": "1", "ACCESSIBILITY_ENABLED": "1", "GTK_A11Y": "atk-bridge", "ATSPI_DISABLE_P2P": "1"}, - ), -} - - -@step("Launch GNOME 51 audit probe 3 apps") -@_guarded("launch") -def probe_launch(context) -> None: - launched = {} - for key, (targets, env) in _PROBE_APPS.items(): - try: - launched[key] = launch_background(targets, env=env) if env else launch_background(targets) - except Exception as exc: # noqa: BLE001 - launched[key] = f"not launched: {exc}" - sleep(1.0) - _emit("launch", launched=launched) - - -@step("Record GNOME 51 audit probe 3 rows 4 and 6 application toplevels") -@_guarded("4+6") -def probe_rows_4_6(context) -> None: - sleep(15) # let the apps (Firefox is slow) map their windows - names = [] - for app in tree.root.applications(): - name = (_attr(app, "name", "") or "").strip("'\" ") - names.append(name) - if name in ("gnome-shell", "") or name.startswith(("ibus", "xdg-desktop-portal")): - continue - tops = [] - for child in _attr(app, "children", []) or []: - tops.append({ - "role": _attr(child, "roleName"), - "name": _attr(child, "name"), - "showing": _attr(child, "showing"), - "children": len(_attr(child, "children", []) or []), - "descendants": _desc_count(child), - }) - if any(t["role"] in ("frame", "filler", "window", "dialog") for t in tops): - _emit("4", app=name, toplevels=tops) - _emit("6", applications=names) - - -@step("Record GNOME 51 audit probe 3 row 5 Files sidebar roles") -@_guarded("5") -def probe_row_5(context) -> None: - for app in tree.root.applications(): - name = (_attr(app, "name", "") or "").strip("'\" ") - if name in ("org.gnome.Nautilus", "Files", "nautilus") or "nautilus" in name.lower(): - items = app.findChildren( - lambda n: bool(_attr(n, "name")) - and ("Home" in n.name or "Personal Folder" in n.name) - ) - # Exactly the search home_folder_is_in_the_sidebar does. - matched = [] - for frame in app.findChildren(lambda n: _attr(n, "roleName") in ("frame", "filler") and _attr(n, "showing")): - for sidebar in frame.findChildren( - lambda n: _attr(n, "roleName") in ("tree", "list") and _attr(n, "showing") - and (_attr(n, "name") or "").strip() in ("Sidebar", "") - ): - for item in sidebar.findChildren( - lambda n: _attr(n, "roleName") in ("list item", "button") and _attr(n, "showing") - and bool(_attr(n, "name")) - and ("Home" in n.name or "Personal Folder" in n.name) - ): - matched.append({"role": _attr(item, "roleName"), "name": _attr(item, "name"), - "sidebar_role": _attr(sidebar, "roleName")}) - _emit("5", app=name, step_matches=matched) - _emit("5", app=name, home_items=[ - {"role": _attr(i, "roleName"), "name": _attr(i, "name"), "showing": _attr(i, "showing"), - "parent_role": _attr(_attr(i, "parent"), "roleName"), - "parent_name": _attr(_attr(i, "parent"), "name"), - "grandparent": [_attr(_attr(_attr(i, "parent"), "parent"), "roleName"), - _attr(_attr(_attr(i, "parent"), "parent"), "name")]} - for i in items[:20] - ]) - return - _emit("5", error="Files application not found") - - -_BANNER_JS = ( - "JSON.stringify({" - "banner_type: typeof Main.messageTray._banner," - "banner_null: Main.messageTray._banner === null || Main.messageTray._banner === undefined," - "banner_visible: !!(Main.messageTray._banner && Main.messageTray._banner.visible)," - "bannerbin_type: typeof Main.messageTray._bannerBin," - "bannerbin_visible: !!(Main.messageTray._bannerBin && Main.messageTray._bannerBin.visible)" - "})" -) - - -def _banner() -> str: - try: - return _shell_eval(_BANNER_JS).strip() - except AssertionError as exc: - return f"error: {exc}" - - -@step("Record GNOME 51 audit probe 3 row 10 banner while showing") -@_guarded("10") -def probe_row_10_showing(context) -> None: - sleep(1.0) - _emit("10", phase="showing", state=_banner()) - - -@step("Record GNOME 51 audit probe 3 row 10 banner after dismissal") -@_guarded("10") -def probe_row_10_dismissed(context) -> None: - start = time.monotonic() - readings = [] - first_null = None - while time.monotonic() - start < 20: - state = _banner() - t = round(time.monotonic() - start, 2) - readings.append({"t": t, "state": state}) - flat = state.replace("\\", "").replace('"', "").replace("'", "") - if first_null is None and "banner_null:true" in flat: - first_null = t - sleep(0.5) - _emit("10", phase="after-close", first_banner_null_s=first_null, readings=readings[:12], last=readings[-1]) - - -_OWNER_JS = ( - "(() => { const t = Main.messageTray; const b = t._banner;" - " let idle = null;" - " try { idle = global.backend.get_core_idle_monitor().get_idletime(); } catch (e) {}" - " let tray = [];" - " try { tray = t.getSources().map(s => s.notifications.map(n => n.title)).flat(); } catch (e) { tray = String(e); }" - " return JSON.stringify({" - " banner: b ? { visible: b.visible, title: (b.notification && b.notification.title) || null } : null," - " tray: tray, idle_ms: idle }); })()" -) - - -@step('Record GNOME 51 audit probe 3 row 10 banner owner "{phase}"') -@_guarded("10b") -def probe_row_10_owner(context, phase) -> None: - readings = [] - for _ in range(6 if phase != "sent" else 1): - sleep(1.0) - try: - readings.append(_shell_eval(_OWNER_JS).strip()) - except AssertionError as exc: - readings.append(f"error: {exc}") - _emit("10b", phase=phase, readings=readings) diff --git a/tests/smoke/features/zz_gnome51_audit_probe_3.feature b/tests/smoke/features/zz_gnome51_audit_probe_3.feature deleted file mode 100644 index 9a71ab6d0..000000000 --- a/tests/smoke/features/zz_gnome51_audit_probe_3.feature +++ /dev/null @@ -1,39 +0,0 @@ -@smoke_suite -Feature: GNOME 51 audit probe 3 (#827, temporary) - Records, without asserting them, the readings that decide whether audit rows - 4, 5, 6 and 10 are still needed on GNOME 51: what each workaround guards, - measured on the path the workaround replaced. - - @gnome51_audit_probe - Scenario: Record GNOME 51 audit probe 3 app readings - * GNOME Shell is accessible via AT-SPI - * Record GNOME 51 audit probe 3 qecore version - * Launch GNOME 51 audit probe 3 apps - * Record GNOME 51 audit probe 3 rows 4 and 6 application toplevels - * Record GNOME 51 audit probe 3 row 5 Files sidebar roles - - @gnome51_audit_probe - Scenario: Record GNOME 51 audit probe 3 notification banner - * GNOME Shell is accessible via AT-SPI - * A test desktop notification is sent via gdbus - * Record GNOME 51 audit probe 3 row 10 banner while showing - * Dismiss the notification via gdbus CloseNotification - * Record GNOME 51 audit probe 3 row 10 banner after dismissal - - @gnome51_audit_probe - Scenario: Record GNOME 51 audit probe 3 banner after an immediate close - * GNOME Shell is accessible via AT-SPI - * A test desktop notification is sent via gdbus - * Notification request returns a positive notification ID - * Dismiss the notification via gdbus CloseNotification - * Record GNOME 51 audit probe 3 row 10 banner after dismissal - - @gnome51_audit_probe - Scenario: Record GNOME 51 audit probe 3 banner owner and idle hold - * GNOME Shell is accessible via AT-SPI - * A test desktop notification is sent via gdbus - * Record GNOME 51 audit probe 3 row 10 banner owner "sent" - * Dismiss the notification via gdbus CloseNotification - * Record GNOME 51 audit probe 3 row 10 banner owner "closed" - * Key combo: "" with uinput - * Record GNOME 51 audit probe 3 row 10 banner owner "after-input" From b21b5bb8a107e888075e22a57f106f4aec7af93b Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 13 Nov 2026 23:55:33 -0500 Subject: [PATCH 11/11] fix(smoke): a tray read error or an unseen notification never counts as dismissed Fresh-context review of #1209 found two ways the dismissal check could still pass without proving anything: - banner_gone_js caught a tray-read error as `queued = false`, so an API change in GNOME Shell would read as "gone". The JS now reports the error, and any error, failed Shell.Eval or unparseable reply counts as not gone. - With no send step the title defaulted to the bare "Test Notification", which nothing sends any more, so the check always passed. It now fails unless a send recorded a title. The close step also requires Shell to hold the notification (queued or shown) before closing it, so the check can only credit CloseNotification with removing something that was there. Unit tests now drive the step with Shell.Eval replies encoded as Shell sends them: an error reply, a `(false, '')` reply, no send, not seen, and a close refused when the tray cannot be read. Assisted-by: Claude Opus 5.5 via Claude Code Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WcWm7qQa538Zjcuvv8jBtn Signed-off-by: Danathar --- .../gnome/references/gnome-51-audit.md | 28 ++-- .../steps/gnome_notifications_steps.py | 123 +++++++++++++----- tests/unit/test_gnome_notifications_steps.py | 101 ++++++++++++-- 3 files changed, 197 insertions(+), 55 deletions(-) diff --git a/docs/skills/test-authoring/gnome/references/gnome-51-audit.md b/docs/skills/test-authoring/gnome/references/gnome-51-audit.md index 5a57bf590..6c5b14512 100644 --- a/docs/skills/test-authoring/gnome/references/gnome-51-audit.md +++ b/docs/skills/test-authoring/gnome/references/gnome-51-audit.md @@ -36,20 +36,20 @@ Version-branch or fix a workaround only after a run proves behavior diverges. ## The twelve GNOME 50 workarounds -| # | Workaround | Status (GNOME 51) | Where | -| --- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -| 1 | Re-prepend `global.context.unsafe_mode = true` before every `Shell.Eval` (GNOME 50 reset it) | **OBSOLETE ON 51** — §Targeted probes (round 2): `global.context.unsafe_mode`, read by a raw `Shell.Eval` that does not re-enable it, stayed `true` after a 3 s idle, an overview open and close over D-Bus, a notification, a GNOME Text Editor window opening and closing, and both screen-lock paths with their unlocks, on `dakota:testing` and `utah:testing`. GNOME 50's reset did not happen. Keep the prepend while any tested image runs GNOME 50; it is harmless. Modal dialogs other than the lock screen were not exercised | `tests/smoke/features/steps/steps.py`; documented in `SKILL.md` "Screen Lock/Unlock" / "Overview search entry" | -| 2 | Double-quoted `Shell.Eval` results `(true, '"true"')` | **OBSOLETE ON 51 as a version quirk** — §Targeted probes (round 2): `Shell.Eval` returns the result JSON-encoded on both images: `true` → `(true, 'true')`, `'abc'` → `(true, '"abc"')`, objects and arrays as JSON, `undefined` → `''`. A quoted `'"true"'` only appears when the expression evaluates to the string `"true"`. Keep `_eval_bool`'s optional quotes for string results | `tests/smoke/features/steps/steps.py` | -| 3 | Extension `state=6` via `Shell.Eval` → use `GetExtensionInfo` D-Bus | **OBSOLETE ON 51** — §Targeted probes (round 2): for the 12 extensions sampled on each image (all `ACTIVE`), `Main.extensionManager.lookup(uuid).state` via `Shell.Eval` returned `1`, matching `GetExtensionInfo` (`1`) and `gnome-extensions show` (`ACTIVE`); GNOME 50's constant `6` did not occur. Keep `GetExtensionInfo`: it is the public API and needs no unsafe mode | `tests/smoke/features/steps/steps.py`; `SKILL.md` "Extension state via D-Bus" | -| 4 | `filler`/`frame` toplevel-role fallback + require populated subtree | **OBSOLETE ON 51 for every app measured** — §Targeted probes (round 3): on both images the toplevel of Files (`org.gnome.Nautilus`, 172 descendants) and Settings (`gnome-control-center`, 150), and on utah Firefox (29 children), was a populated `frame`; no `filler` toplevel and no bare childless `filler` occurred. Calculator, Text Editor and Clocks ship on neither image, so were not measured. Keep `{frame, filler}` and the populated-subtree check while any tested image runs GNOME 50 | `tests/shared/gnome_shell_steps.py`; `SKILL.md` "Window-role checks must prove the subtree is populated" | -| 5 | Nautilus sidebar role (`home_folder_is_in_the_sidebar`) | **OBSOLETE ON 51** — §Targeted probes (round 3): replaying the step's own search, its only match on both images was a `list item` named `Open Personal Folder` in the unnamed sidebar `list`: the pre-GNOME 50 role. GNOME 50's `button` did not occur in the sidebar (the `Home` `button` is the path bar's). The `Personal Folder` name match is what finds it. Keep accepting `button` while any tested image runs GNOME 50 | `tests/smoke/features/steps/gnome_files_steps.py` | -| 6 | Nautilus AT-SPI app-name handling (`FILES_APP_NAMES`, `_nautilus_app`) | **STILL REQUIRED** — §Targeted probes (round 3): Files registers in AT-SPI as `org.gnome.Nautilus` on both images, not the pre-GNOME 50 `nautilus`, so a lookup by `nautilus` alone finds nothing | `tests/smoke/features/steps/gnome_files_steps.py` | -| 7 | Ptyxis window title (`user@host:~`) | **STILL REQUIRED on `utah:testing`; not testable on `dakota:testing`** — §Targeted probes (round 2): on utah (`/usr/bin/ptyxis`) a new window was titled `Terminal` (WM class `org.gnome.Ptyxis`) and its AT-SPI frame was named `Terminal`, so a check for a `Ptyxis` title would fail. `dakota:testing` ships no Ptyxis (its terminal is Ghostty), which is why smoke-a skipped the scenario | `tests/smoke/features/steps/gnome_apps_steps.py:34-38` | -| 8 | ScreenSaver D-Bus `Lock` (not `screenShield.lock(true)`) | **OBSOLETE ON 51** — §Targeted probes (round 2): `Main.screenShield.lock(true)` via `Shell.Eval` locked the session on both images (`org.gnome.ScreenSaver.GetActive` → `true`), and `SetActive false` unlocked it; `org.gnome.ScreenSaver.Lock` behaved the same. GNOME 50's "deprecated and fails" no longer holds. Keep the D-Bus `Lock`: it is the public API and needs no unsafe mode | `tests/smoke/features/steps/steps.py`; `SKILL.md` "Screen Lock/Unlock D-Bus calls" | -| 9 | `Main.overview.visible` reads `false` in QEMU; do not assert it | **OBSOLETE ON 51** — the targeted probe (§Targeted probes) read `Main.overview.visible` as `false`, `true`, `false` across an overview open and close in QEMU on GNOME Shell 51.1, matching `OverviewActive` each time, on `dakota:testing` and `utah:testing`. Keep checking `OverviewActive`: it needs no `Shell.Eval` or unsafe mode | `tests/smoke/features/steps/steps.py`; `SKILL.md` "Activities overview (GNOME 50 QEMU)" | -| 10 | Notification banner dismissal check | **BROKEN ON 51 — fixed** — §Targeted probes (round 3): the GNOME 50 check also required `Main.messageTray._bannerBin` hidden, which GNOME 51 never does, and treated any visible banner as ours, so it always fell through to a force-dismiss and a warning and could not fail. After `CloseNotification` this scenario's notification leaves the tray; the banner still on screen is an earlier one (other scenarios and retries send without closing) that Shell holds while the session is idle. Each sent notification now gets a unique title, and the step checks that this one is neither the visible banner nor in the tray: it passes on both images ([43556476178](https://github.com/projectbluefin/testsuite/actions/runs/43556476178), [43556485608](https://github.com/projectbluefin/testsuite/actions/runs/43556485608)) | `tests/smoke/features/steps/gnome_notifications_steps.py` | -| 11 | Panel buttons `showing=False` before overview toggle | **OBSOLETE ON 51** — the first probe read the Activities toggle as `showing=True`; §Targeted probes (round 2) found the clock (a `menu` with no accessible name, holding the date and time label) and the `System` menu in the same top-bar panel, and both read `showing=True` before, during and after an overview toggle on both images. GNOME 50's "every panel button reports `showing=False`" holds for none of the three | `tests/shared/gnome_shell_steps.py` | -| 12 | keyring skip on GDM restart | **WORKS ON 51** — §Targeted probes (round 2): with qecore's keyring setup skipped, every smoke-b scenario passed on both images. The login keyring is unusable without it: on dakota the `login` collection exists but is locked; on utah `gnome-keyring-daemon` runs with no `login` collection (default alias `/`); a `secret-tool store` blocked until a 15 s timeout on both. No smoke scenario stores a secret. Whether qecore's setup, which restarts GDM, would still break the run is not measured: it would restart the session under test | `tests/smoke/features/environment.py` | +| # | Workaround | Status (GNOME 51) | Where | +| --- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | +| 1 | Re-prepend `global.context.unsafe_mode = true` before every `Shell.Eval` (GNOME 50 reset it) | **OBSOLETE ON 51** — §Targeted probes (round 2): `global.context.unsafe_mode`, read by a raw `Shell.Eval` that does not re-enable it, stayed `true` after a 3 s idle, an overview open and close over D-Bus, a notification, a GNOME Text Editor window opening and closing, and both screen-lock paths with their unlocks, on `dakota:testing` and `utah:testing`. GNOME 50's reset did not happen. Keep the prepend while any tested image runs GNOME 50; it is harmless. Modal dialogs other than the lock screen were not exercised | `tests/smoke/features/steps/steps.py`; documented in `SKILL.md` "Screen Lock/Unlock" / "Overview search entry" | +| 2 | Double-quoted `Shell.Eval` results `(true, '"true"')` | **OBSOLETE ON 51 as a version quirk** — §Targeted probes (round 2): `Shell.Eval` returns the result JSON-encoded on both images: `true` → `(true, 'true')`, `'abc'` → `(true, '"abc"')`, objects and arrays as JSON, `undefined` → `''`. A quoted `'"true"'` only appears when the expression evaluates to the string `"true"`. Keep `_eval_bool`'s optional quotes for string results | `tests/smoke/features/steps/steps.py` | +| 3 | Extension `state=6` via `Shell.Eval` → use `GetExtensionInfo` D-Bus | **OBSOLETE ON 51** — §Targeted probes (round 2): for the 12 extensions sampled on each image (all `ACTIVE`), `Main.extensionManager.lookup(uuid).state` via `Shell.Eval` returned `1`, matching `GetExtensionInfo` (`1`) and `gnome-extensions show` (`ACTIVE`); GNOME 50's constant `6` did not occur. Keep `GetExtensionInfo`: it is the public API and needs no unsafe mode | `tests/smoke/features/steps/steps.py`; `SKILL.md` "Extension state via D-Bus" | +| 4 | `filler`/`frame` toplevel-role fallback + require populated subtree | **OBSOLETE ON 51 for every app measured** — §Targeted probes (round 3): on both images the toplevel of Files (`org.gnome.Nautilus`, 172 descendants) and Settings (`gnome-control-center`, 150), and on utah Firefox (29 children), was a populated `frame`; no `filler` toplevel and no bare childless `filler` occurred. Calculator, Text Editor and Clocks ship on neither image, so were not measured. Keep `{frame, filler}` and the populated-subtree check while any tested image runs GNOME 50 | `tests/shared/gnome_shell_steps.py`; `SKILL.md` "Window-role checks must prove the subtree is populated" | +| 5 | Nautilus sidebar role (`home_folder_is_in_the_sidebar`) | **OBSOLETE ON 51** — §Targeted probes (round 3): replaying the step's own search, its only match on both images was a `list item` named `Open Personal Folder` in the unnamed sidebar `list`: the pre-GNOME 50 role. GNOME 50's `button` did not occur in the sidebar (the `Home` `button` is the path bar's). The `Personal Folder` name match is what finds it. Keep accepting `button` while any tested image runs GNOME 50 | `tests/smoke/features/steps/gnome_files_steps.py` | +| 6 | Nautilus AT-SPI app-name handling (`FILES_APP_NAMES`, `_nautilus_app`) | **STILL REQUIRED** — §Targeted probes (round 3): Files registers in AT-SPI as `org.gnome.Nautilus` on both images, not the pre-GNOME 50 `nautilus`, so a lookup by `nautilus` alone finds nothing | `tests/smoke/features/steps/gnome_files_steps.py` | +| 7 | Ptyxis window title (`user@host:~`) | **STILL REQUIRED on `utah:testing`; not testable on `dakota:testing`** — §Targeted probes (round 2): on utah (`/usr/bin/ptyxis`) a new window was titled `Terminal` (WM class `org.gnome.Ptyxis`) and its AT-SPI frame was named `Terminal`, so a check for a `Ptyxis` title would fail. `dakota:testing` ships no Ptyxis (its terminal is Ghostty), which is why smoke-a skipped the scenario | `tests/smoke/features/steps/gnome_apps_steps.py:34-38` | +| 8 | ScreenSaver D-Bus `Lock` (not `screenShield.lock(true)`) | **OBSOLETE ON 51** — §Targeted probes (round 2): `Main.screenShield.lock(true)` via `Shell.Eval` locked the session on both images (`org.gnome.ScreenSaver.GetActive` → `true`), and `SetActive false` unlocked it; `org.gnome.ScreenSaver.Lock` behaved the same. GNOME 50's "deprecated and fails" no longer holds. Keep the D-Bus `Lock`: it is the public API and needs no unsafe mode | `tests/smoke/features/steps/steps.py`; `SKILL.md` "Screen Lock/Unlock D-Bus calls" | +| 9 | `Main.overview.visible` reads `false` in QEMU; do not assert it | **OBSOLETE ON 51** — the targeted probe (§Targeted probes) read `Main.overview.visible` as `false`, `true`, `false` across an overview open and close in QEMU on GNOME Shell 51.1, matching `OverviewActive` each time, on `dakota:testing` and `utah:testing`. Keep checking `OverviewActive`: it needs no `Shell.Eval` or unsafe mode | `tests/smoke/features/steps/steps.py`; `SKILL.md` "Activities overview (GNOME 50 QEMU)" | +| 10 | Notification banner dismissal check | **BROKEN ON 51 — fixed** — §Targeted probes (round 3): the GNOME 50 check also required `Main.messageTray._bannerBin` hidden, which GNOME 51 never does, and treated any visible banner as ours, so it always fell through to a force-dismiss and a warning and could not fail. After `CloseNotification` this scenario's notification leaves the tray; the banner still on screen is an earlier one (other scenarios and retries send without closing) that Shell holds while the session is idle. Each sent notification now gets a unique title; the close step first requires Shell to hold it, and the check then requires it to be neither the visible banner nor in the tray (a tray read error never counts as gone). It passes on both images ([43556476178](https://github.com/projectbluefin/testsuite/actions/runs/43556476178), [43556485608](https://github.com/projectbluefin/testsuite/actions/runs/43556485608)) | `tests/smoke/features/steps/gnome_notifications_steps.py` | +| 11 | Panel buttons `showing=False` before overview toggle | **OBSOLETE ON 51** — the first probe read the Activities toggle as `showing=True`; §Targeted probes (round 2) found the clock (a `menu` with no accessible name, holding the date and time label) and the `System` menu in the same top-bar panel, and both read `showing=True` before, during and after an overview toggle on both images. GNOME 50's "every panel button reports `showing=False`" holds for none of the three | `tests/shared/gnome_shell_steps.py` | +| 12 | keyring skip on GDM restart | **WORKS ON 51** — §Targeted probes (round 2): with qecore's keyring setup skipped, every smoke-b scenario passed on both images. The login keyring is unusable without it: on dakota the `login` collection exists but is locked; on utah `gnome-keyring-daemon` runs with no `login` collection (default alias `/`); a `secret-tool store` blocked until a 15 s timeout on both. No smoke scenario stores a secret. Whether qecore's setup, which restarts GDM, would still break the run is not measured: it would restart the session under test | `tests/smoke/features/environment.py` | Every row now has a GNOME 51 verdict from a targeted probe (§Targeted probes, rounds 1–3). Still required on 51: row 6, and row 7 where Ptyxis ships diff --git a/tests/smoke/features/steps/gnome_notifications_steps.py b/tests/smoke/features/steps/gnome_notifications_steps.py index abb4fc3b8..4cd229f6e 100644 --- a/tests/smoke/features/steps/gnome_notifications_steps.py +++ b/tests/smoke/features/steps/gnome_notifications_steps.py @@ -92,11 +92,28 @@ def notification_request_returns_positive_id(context) -> None: @step("Dismiss the notification via gdbus CloseNotification") -def dismiss_notification_via_gdbus(context) -> None: +def dismiss_notification_via_gdbus(context, run=subprocess.run, pause=sleep) -> None: notification_id = getattr(context, "notification_id", None) assert notification_id is not None, ( "No notification ID captured — run 'A test desktop notification is sent via gdbus' first" ) + # The dismissal check can only prove CloseNotification removed the + # notification if Shell was seen holding it first; otherwise a tray API + # change (or a notification that never arrived) would read as "gone". + title = _sent_title(context) + state = {} + for _ in range(NOTIFICATION_SEEN_TIMEOUT_S * 2): + state = _tray_state(title, run) + if not state.get("error") and (state.get("queued") or state.get("shown")): + break + pause(0.5) + else: + raise AssertionError( + f"'{title}' was never seen in the message tray or as the banner within " + f"{NOTIFICATION_SEEN_TIMEOUT_S}s of sending, so its dismissal cannot be " + f"checked; last tray state: {state}" + ) + context.test_notification_seen = True _, returncode, stderr = _run( f"gdbus call --session " f"--dest org.freedesktop.Notifications " @@ -117,52 +134,98 @@ def dismiss_notification_via_gdbus(context) -> None: # or not (#827 audit row 10, probe 3: our notification leaves the tray at once; # the held banner clears ~2 s after any input). def banner_gone_js(title: str) -> str: - """Shell.Eval JS: is the notification titled ``title`` neither the visible - banner nor in the tray? Returns a JSON object with the details.""" + """Shell.Eval JS: where is the notification titled ``title``? + + Returns a JSON object: ``shown`` (it is the visible banner), ``queued`` (it + is in the message tray) and ``error`` (the tray could not be read). An + error is never reported as gone. + """ return ( - "(() => { const t = Main.messageTray; const title = " + json.dumps(title) + ";" - " const b = t._banner;" - " const shown = !!(b && b.visible && b.notification && b.notification.title === title);" - " let queued = false;" - " try { queued = t.getSources().some(s => s.notifications.some(n => n.title === title)); }" - " catch (e) { queued = false; }" - " let idle = null;" + "(() => { const title = " + json.dumps(title) + ";" + " let shown = false, queued = false, error = null, banner = null, idle = null;" + " try { const t = Main.messageTray; const b = t._banner;" + " shown = !!(b && b.visible && b.notification && b.notification.title === title);" + " banner = b ? ((b.notification && b.notification.title) || '?') : null;" + " queued = t.getSources().some(s => s.notifications.some(n => n.title === title)); }" + " catch (e) { error = String(e); }" " try { idle = global.backend.get_core_idle_monitor().get_idletime(); } catch (e) {}" - " return JSON.stringify({ gone: !shown && !queued, shown: shown, queued: queued," - " banner: b ? ((b.notification && b.notification.title) || '?') : null, idle_ms: idle }); })()" + " return JSON.stringify({ shown: shown, queued: queued, error: error," + " banner: banner, idle_ms: idle }); })()" ) BANNER_DISMISS_TIMEOUT_S = 20 # GNOME 50 banners can linger in QEMU +NOTIFICATION_SEEN_TIMEOUT_S = 5 + + +def _parse_eval_json(out: str): + """The object a JSON-returning Shell.Eval call produced, or None. + + Shell.Eval answers ``(true, '""')``: a GVariant string holding + the JSON encoding of the string the expression returned. + """ + m = re.match(r"\(\s*(true|false)\s*,\s*'(.*)'\s*\)\s*$", out.strip(), re.S) + if not m or m.group(1) != "true": + return None + literal = m.group(2).replace("\\\\", "\x00").replace("\\'", "'").replace("\x00", "\\") + try: + value = json.loads(literal) + return json.loads(value) if isinstance(value, str) else None + except ValueError: + return None + + +def _tray_state(title: str, run=subprocess.run) -> dict: + """Shell's view of the notification titled ``title``; ``error`` set on any failure.""" + try: + result = run( + ["gdbus", "call", "--session", + "--dest", "org.gnome.Shell", + "--object-path", "/org/gnome/Shell", + "--method", "org.gnome.Shell.Eval", + banner_gone_js(title)], + capture_output=True, text=True, timeout=5, + ) + except (OSError, subprocess.SubprocessError) as exc: + return {"error": f"gdbus failed: {exc}"} + state = _parse_eval_json(result.stdout) + if not isinstance(state, dict): + return {"error": f"unusable Shell.Eval reply: {result.stdout!r}"} + return state + + +def _sent_title(context) -> str: + title = getattr(context, "test_notification_title", None) + assert title, ( + "No test notification was sent in this scenario — run 'A test desktop " + "notification is sent via gdbus' first" + ) + return title -def _banner_gone(title: str, run=subprocess.run) -> tuple[bool, str]: - """(test notification gone?, Shell.Eval output) for one read.""" - result = run( - ["gdbus", "call", "--session", - "--dest", "org.gnome.Shell", - "--object-path", "/org/gnome/Shell", - "--method", "org.gnome.Shell.Eval", - banner_gone_js(title)], - capture_output=True, text=True, timeout=5, - ) - out = result.stdout - flat = out.replace("\\", "").replace('"', "").replace(" ", "") - return "gone:true" in flat, out +def _banner_gone(title: str, run=subprocess.run) -> tuple[bool, dict]: + """(test notification gone?, tray state) for one read; an error is not gone.""" + state = _tray_state(title, run) + gone = not state.get("error") and not state.get("shown") and not state.get("queued") + return gone, state @step("Notification banner is no longer showing via Shell.Eval") def notification_banner_no_longer_showing(context, run=subprocess.run, pause=sleep) -> None: - title = getattr(context, "test_notification_title", TEST_NOTIFICATION_TITLE) - last_out = "" + title = _sent_title(context) + assert getattr(context, "test_notification_seen", False), ( + f"'{title}' was not seen before CloseNotification, so its dismissal cannot be " + "checked — run 'Dismiss the notification via gdbus CloseNotification' first" + ) + state = {} for _ in range(BANNER_DISMISS_TIMEOUT_S * 2): - gone, last_out = _banner_gone(title, run) + gone, state = _banner_gone(title, run) if gone: return pause(0.5) raise AssertionError( - f"'{title}' is still shown or queued " - f"{BANNER_DISMISS_TIMEOUT_S}s after CloseNotification; Shell.Eval returned: {last_out!r}" + f"'{title}' is still shown or queued, or the tray could not be read, " + f"{BANNER_DISMISS_TIMEOUT_S}s after CloseNotification; last tray state: {state}" ) diff --git a/tests/unit/test_gnome_notifications_steps.py b/tests/unit/test_gnome_notifications_steps.py index 6b2a1f5e7..3ebbc99d7 100644 --- a/tests/unit/test_gnome_notifications_steps.py +++ b/tests/unit/test_gnome_notifications_steps.py @@ -48,11 +48,20 @@ def test_parse_notification_id_raises_on_unparseable_output(output): module._parse_notification_id(output) + class _Done: def __init__(self, stdout): self.stdout = stdout +def _reply(state: dict) -> str: + """A Shell.Eval reply carrying ``state`` the way GNOME Shell encodes it.""" + import json + + literal = json.dumps(json.dumps(state)).replace("\\", "\\\\").replace("'", "\\'") + return f"(true, '{literal}')\n" + + def _runner(outputs): calls = [] @@ -63,6 +72,24 @@ def run(cmd, **kwargs): return run, calls +def _context(**attrs): + return type("C", (), dict({"test_notification_title": "Test Notification ab12cd34", + "test_notification_seen": True, "notification_id": 7}, **attrs))() + + +GONE = {"shown": False, "queued": False, "error": None} +SHOWN = {"shown": True, "queued": True, "error": None} +QUEUED = {"shown": False, "queued": True, "error": None} +BROKEN = {"shown": False, "queued": False, "error": "TypeError: t.getSources is not a function"} + + +def test_parse_reads_the_reply_shell_sends(): + module = _import_gnome_notifications_steps() + assert module._parse_eval_json(_reply(QUEUED)) == QUEUED + assert module._parse_eval_json("(false, '')") is None + assert module._parse_eval_json("(true, '\"not json\"')") is None + + def test_banner_check_tracks_the_test_notification_not_any_banner(): # GNOME Shell holds an unrelated banner on screen while the session is # idle, and GNOME 51 keeps _bannerBin visible with no banner (#827 audit @@ -71,8 +98,7 @@ def test_banner_check_tracks_the_test_notification_not_any_banner(): js = module.banner_gone_js("Test Notification ab12cd34") assert "_bannerBin" not in js assert 'const title = "Test Notification ab12cd34"' in js - assert "b.notification.title === title" in js - assert "getSources()" in js + assert "catch (e) { error = String(e); }" in js def test_each_sent_notification_gets_a_unique_checked_title(monkeypatch): @@ -81,6 +107,7 @@ def test_each_sent_notification_gets_a_unique_checked_title(monkeypatch): module = _import_gnome_notifications_steps() sent = [] monkeypatch.setattr(module, "_run", lambda cmd: (sent.append(cmd) or "(uint32 7,)", 0, "")) + monkeypatch.setattr(module, "sleep", lambda s: None) first, second = type("C", (), {})(), type("C", (), {})() module.send_test_desktop_notification(first) module.send_test_desktop_notification(second) @@ -89,20 +116,72 @@ def test_each_sent_notification_gets_a_unique_checked_title(monkeypatch): assert f"'{first.test_notification_title}'" in sent[0] -def test_banner_gone_returns_as_soon_as_shell_says_so(): +def test_check_passes_once_the_notification_is_gone(): module = _import_gnome_notifications_steps() - run, calls = _runner([ - '(true, \'"{\\\\"gone\\\\":false,\\\\"shown\\\\":true}"\')', - '(true, \'"{\\\\"gone\\\\":true,\\\\"shown\\\\":false}"\')', - ]) - module.notification_banner_no_longer_showing(type("C", (), {"test_notification_title": "Test Notification x"})(), run=run, pause=lambda s: None) + run, calls = _runner([_reply(SHOWN), _reply(GONE)]) + module.notification_banner_no_longer_showing(_context(), run=run, pause=lambda s: None) assert len(calls) == 2 -def test_banner_still_showing_fails_instead_of_force_dismissing(): +def test_check_fails_instead_of_force_dismissing(): module = _import_gnome_notifications_steps() - run, calls = _runner(['(true, \'"{\\\\"gone\\\\":false,\\\\"shown\\\\":true}"\')']) + run, calls = _runner([_reply(SHOWN)]) with pytest.raises(AssertionError, match="still shown or queued"): - module.notification_banner_no_longer_showing(type("C", (), {"test_notification_title": "Test Notification x"})(), run=run, pause=lambda s: None) + module.notification_banner_no_longer_showing(_context(), run=run, pause=lambda s: None) assert all("destroy()" not in " ".join(c) and "hide()" not in " ".join(c) for c in calls) assert len(calls) == module.BANNER_DISMISS_TIMEOUT_S * 2 + + +def test_a_tray_read_error_is_never_gone(): + # The JS reports the error rather than shown/queued false: an API change in + # Shell must not read as "dismissed" (fresh-context review of #1209). + module = _import_gnome_notifications_steps() + run, _ = _runner([_reply(BROKEN)]) + with pytest.raises(AssertionError, match="getSources is not a function"): + module.notification_banner_no_longer_showing(_context(), run=run, pause=lambda s: None) + + +def test_a_failed_shell_eval_is_never_gone(): + module = _import_gnome_notifications_steps() + run, _ = _runner(["(false, '')\n"]) + with pytest.raises(AssertionError, match="unusable Shell.Eval reply"): + module.notification_banner_no_longer_showing(_context(), run=run, pause=lambda s: None) + + +def test_check_without_a_sent_notification_fails(): + # Nothing sends the bare prefix any more, so defaulting to it always passed. + module = _import_gnome_notifications_steps() + run, calls = _runner([_reply(GONE)]) + with pytest.raises(AssertionError, match="No test notification was sent"): + module.notification_banner_no_longer_showing(type("C", (), {})(), run=run, pause=lambda s: None) + assert calls == [] + + +def test_check_without_seeing_the_notification_first_fails(): + module = _import_gnome_notifications_steps() + run, _ = _runner([_reply(GONE)]) + with pytest.raises(AssertionError, match="not seen before CloseNotification"): + module.notification_banner_no_longer_showing( + _context(test_notification_seen=False), run=run, pause=lambda s: None + ) + + +def test_dismiss_closes_only_after_seeing_the_notification(monkeypatch): + module = _import_gnome_notifications_steps() + closed = [] + monkeypatch.setattr(module, "_run", lambda cmd: (closed.append(cmd) or "", 0, "")) + run, calls = _runner([_reply(GONE), _reply(QUEUED)]) + context = _context(test_notification_seen=False) + module.dismiss_notification_via_gdbus(context, run=run, pause=lambda s: None) + assert len(calls) == 2 and context.test_notification_seen is True + assert closed and "CloseNotification 7" in closed[0] + + +def test_dismiss_refuses_when_the_tray_cannot_be_read(monkeypatch): + module = _import_gnome_notifications_steps() + closed = [] + monkeypatch.setattr(module, "_run", lambda cmd: (closed.append(cmd) or "", 0, "")) + run, _ = _runner([_reply(BROKEN)]) + with pytest.raises(AssertionError, match="was never seen"): + module.dismiss_notification_via_gdbus(_context(test_notification_seen=False), run=run, pause=lambda s: None) + assert closed == []