Skip to content

Commit

Permalink
test: Fix unintentional ignoring of console errors
Browse files Browse the repository at this point in the history
Commit ccab549 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 <[email protected]>
  • Loading branch information
jelly and martinpitt committed Oct 17, 2023
1 parent d8246f1 commit dedc93e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
33 changes: 31 additions & 2 deletions test/common/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 an 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"""
Expand Down
1 change: 1 addition & 0 deletions test/verify/check-networkmanager-wireguard
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions test/verify/check-sosreport
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dedc93e

Please sign in to comment.