import { type Locator } from "@playwright/test"; import { type SessionData } from "contexts/session/types"; declare global { // eslint-disable-next-line vars-on-top, no-var var capturedConsoleLogs: string[] | undefined; interface Window { DEBUG_DEFAULT_SESSION?: SessionData; } } export const EXCLUDED_CONSOLE_LOGS = ( browserName: string, testName?: string ): string[] => { // Generic messages const excludedConsoleLogs = [ "[HMR] connected", "No available adapters.", "not used within a few seconds", "[Fast Refresh] rebuilding", "[Fast Refresh] done in", "[Fast Refresh] performing full reload", "Cannot update a component (`Unknown`) while rendering a different component", "browserContext.", "Web browser doesn't support Web Audio API", "Slow execution detected", ]; if (browserName === "webkit") { excludedConsoleLogs.push( // sandbox=allow-presentation is not supported in webkit "Error while parsing the 'sandbox' attribute: 'allow-presentation' is an invalid sandbox flag.", 'Viewport argument key "interactive-widget" not recognized and ignored.' ); } else if (browserName === "firefox") { excludedConsoleLogs.push( "Found a sectioned h1 element with no specified font-size or margin properties." ); } if (process.env.CI) { if (browserName === "chromium") { excludedConsoleLogs.push( "Failed to create WebGPU Context Provider", "WebGPU is experimental on this platform" ); } else if (browserName === "firefox") { excludedConsoleLogs.push( "WebGL warning", "Failed to create WebGL context", "A WebGL context could not be created", "Error creating WebGL context", "'experimental-webgl' (value of argument 1) is not a valid value" ); } else if (browserName === "webkit") { excludedConsoleLogs.push( 'THREE.WebGLRenderer: Argument 1 (\'contextType\') to OffscreenCanvas.getContext must be one of: "2d", "webgl", "webgl2", "bitmaprenderer", "webgpu"' ); } } if (testName === "apps") { excludedConsoleLogs.push( // Browser "Cookie “AEC” has been rejected because it is in a cross-site context and its “SameSite” is “Lax” or “Strict”.", "Blocked autofocusing on a form control in a cross-origin subframe.", "Failed to load resource: the server responded with a status of 404 (Not Found)", 'Error: "Content-Security-Policy:', "an ancestor violates the following Content Security Policy directive", // Messenger "WebSocket connection to 'wss://public.relaying.io/' failed:" ); if (browserName === "firefox") { excludedConsoleLogs.push( // Messenger "Firefox can’t establish a connection to the server at wss://" ); } else if (browserName === "webkit") { excludedConsoleLogs.push( // TIC-80 "Unable to initialize SDL Audio: -1, No audio context available", "Unable to initialize SDL Game Controller: -1, Gamepads not supported", // Quake 3 "WebGL: INVALID_ENUM: texParameter: invalid parameter name" ); } else if (browserName === "chromium") { excludedConsoleLogs.push( // Browser "Blocked autofocusing on a