Explicitly test for console warnings & errors (#6502)

# Description of Changes
Disallow warnings and errors from being thrown in the browser console
during tests unless explicitly expected in the test. Also adds a
Playwright test to prod around some main UI areas and checks that no
warnings/errors have been thrown.
This commit is contained in:
James Brunton
2026-06-09 08:34:02 +00:00
committed by GitHub
parent 002de06411
commit 0e3cbb3cf2
28 changed files with 544 additions and 213 deletions
@@ -1,6 +1,7 @@
import type { AxiosInstance } from "axios";
import { describe, expect, test, vi, beforeEach, afterEach } from "vitest";
import { OPEN_SIGN_IN_EVENT } from "@app/constants/signInEvents";
import { expectConsole } from "@app/tests/failOnConsole";
// Exercise the error-interceptor logic against a hand-rolled axios-like
// client; transitive imports are mocked out so this is a pure unit test.
@@ -120,6 +121,7 @@ describe("desktop apiClientSetup - 401 silent-path", () => {
});
test("POST 401 without Authorization dispatches sign-in modal event", async () => {
expectConsole.warn(/\[apiClientSetup\] 401 on path/);
const { client, handlers } = makeMockClient();
setupApiInterceptors(client as unknown as AxiosInstance);
await triggerErrorInterceptor(handlers, {
@@ -135,6 +137,7 @@ describe("desktop apiClientSetup - 401 silent-path", () => {
});
test("GET 401 without Authorization stays silent (background probe)", async () => {
expectConsole.warn(/\[apiClientSetup\] 401 on path/);
const { client, handlers } = makeMockClient();
setupApiInterceptors(client as unknown as AxiosInstance);
await triggerErrorInterceptor(handlers, {
@@ -159,6 +162,7 @@ describe("desktop apiClientSetup - 401 silent-path", () => {
});
test("401 with skipAuthRedirect set never dispatches the modal", async () => {
expectConsole.warn(/\[apiClientSetup\] 401 on path/);
const { client, handlers } = makeMockClient();
setupApiInterceptors(client as unknown as AxiosInstance);
await triggerErrorInterceptor(handlers, {