From 5ac51ecd0d5c4739d0478bee88efb8fb06f0988e Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 3 Jul 2023 13:53:10 +0200 Subject: [PATCH] test: Fix unintentional ignoring of console errors Commit ccab5493311e9 broke the checking of browser errors, as with an unset `$TEST_ALLOW_JOURNAL_MESSAGES` (which is the case in our CI) it was adding the empty string as allowed pattern, which always matches. Ignore the React errors that happen with our current code, and add some explanations. We have so many of them that we can't fix all of them in one go, but we have to put a stop to introducing new ones. Some of them are test specific. Co-Authored-By: Martin Pitt --- test/common/testlib.py | 33 ++++++++++++++++++++-- test/verify/check-networkmanager-wireguard | 1 + test/verify/check-sosreport | 5 ++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/test/common/testlib.py b/test/common/testlib.py index 8a6c5bc7f164..3068ff2de057 100644 --- a/test/common/testlib.py +++ b/test/common/testlib.py @@ -1702,12 +1702,41 @@ def login_and_go(self, path: Optional[str] = None, user: Optional[str] = None, h # List of allowed console.error() messages during tests; these match substrings default_allowed_console_errors = [ + # HACK: Fix these ASAP, these are major bugs + "Warning: validateDOMNesting.*cannot appear as a", + "Warning: Encountered two children with the same key", + "Warning: Failed.*type.*prop Invalid prop", + "Warning: Failed.*type:.*is marked as required in.*but its value is `null`", + "Warning: Failed.*type:.*is marked as required in.*but its value is `undefined`", + "Warning: React does not recognize the.*prop on a DOM element", + "Warning: .*prop on .* should not be null", + # HACK: this should be fixed, it's completely expected on OSes without tracer + "Tracer failed:.*", # HACK: These should be fixed, but debugging these is not trivial, and the impact is very low "Warning: .* setState.*on an unmounted component", - "Warning: Can't perform a React state update on an unmounted component." + "Warning: Can't perform a React state update on an unmounted component", + "Warning: Cannot update a component.*while rendering a different component", + "Warning: A component is changing an uncontrolled input to be controlled", + "Warning: A component is changing a controlled input to be uncontrolled", + "Warning: Can't call.*on a component that is not yet mounted. This is a no-op", + "Warning: Cannot update during an existing state transition", + r"Warning: You are calling ReactDOMClient.createRoot\(\) on a container that has already been passed to createRoot", + + # FIXME: PatternFly complains about these, but https://www.a11y-collective.com/blog/the-first-rule-for-using-aria/ + # and https://www.accessibility-developer-guide.com/knowledge/aria/bad-practices/ + "aria-label", + # messages from our own pages + "CPU temperature metric closed.*", + "failed to call cockpit.Machines.Update().*", + "Failed to enable pmproxy in firewalld.*", + "Getting properties for problem.*", + "Channel for reportd D-Bus client closed.*", + "checkRealm failed.*", ] - default_allowed_console_errors += os.environ.get("TEST_ALLOW_BROWSER_ERRORS", "").split(",") + env_allow = os.environ.get("TEST_ALLOW_BROWSER_ERRORS") + if env_allow: + default_allowed_console_errors += env_allow.split(",") def allow_journal_messages(self, *patterns: str): """Don't fail if the journal contains a entry completely matching the given regexp""" diff --git a/test/verify/check-networkmanager-wireguard b/test/verify/check-networkmanager-wireguard index b3b3f82f59d3..5a4c52678dbf 100755 --- a/test/verify/check-networkmanager-wireguard +++ b/test/verify/check-networkmanager-wireguard @@ -59,6 +59,7 @@ class TestWireGuard(packagelib.PackageCase, netlib.NetworkCase): # Validate each field, enter the right value, and then proceed to the next field # # check private-key + self.allow_browser_errors("wg: Key is not the correct length or format") b.click("#network-wireguard-settings-paste-key") b.set_input_text("#network-wireguard-settings-private-key-input", "incorrect key") b.set_input_text("#network-wireguard-settings-addresses-input", m1_ip4) diff --git a/test/verify/check-sosreport b/test/verify/check-sosreport index c401a38952d1..1b1edb068135 100755 --- a/test/verify/check-sosreport +++ b/test/verify/check-sosreport @@ -121,6 +121,8 @@ exit 1""", perm="755") b.wait_not_present("#sos-dialog") self.allow_journal_messages('.*comm="sosreport".*') + # HACK: Fix this in the code, this is useless + self.allow_browser_errors('error: {"problem":null,"exit_status":1,"exit_signal":null') def testWithUrlRoot(self): self.testBasic(urlroot="/webcon") @@ -173,6 +175,9 @@ only-plugins=release,date,host,cgroups,networking m.execute("while pgrep -a -x sos; do sleep 1; done", timeout=10) self.assertEqual(m.execute("ls /var/tmp/sosreport* 2>/dev/null || true"), "") + # HACK: Fix this in the code, this is useless + self.allow_browser_errors('error: {"problem":"cancelled","exit_status":null') + def testAppStream(self): b = self.browser m = self.machine