From cf45a43a371e254b8bf5336fb8ee5421285f86a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sun, 8 Mar 2026 19:16:50 +0800 Subject: [PATCH] Remove obsolete uncaught-exception policy helper and its unit test Co-Authored-By: Codex --- cypress/support/uncaughtExceptionPolicy.js | 26 ---------------- .../cypress/uncaughtExceptionPolicy.test.js | 31 ------------------- 2 files changed, 57 deletions(-) delete mode 100644 cypress/support/uncaughtExceptionPolicy.js delete mode 100644 tests/unit/cypress/uncaughtExceptionPolicy.test.js diff --git a/cypress/support/uncaughtExceptionPolicy.js b/cypress/support/uncaughtExceptionPolicy.js deleted file mode 100644 index e02a6b1..0000000 --- a/cypress/support/uncaughtExceptionPolicy.js +++ /dev/null @@ -1,26 +0,0 @@ -// The Lucia project. -// Copyright 2026-2026 DSP, inc. All rights reserved. -// Authors: -// imacat.yang@dsp.im (imacat), 2026/03/08 -/** - * Returns whether an uncaught exception should be ignored in Cypress. - * @param {unknown} error - The thrown uncaught exception. - * @returns {boolean} True when the exception is known-benign and safe to ignore. - */ -export function shouldIgnoreUncaughtException(error) { - const message = error instanceof Error ? error.message : String(error); - const ignorePatterns = [ - /ResizeObserver loop limit exceeded/i, - /ResizeObserver loop completed with undelivered notifications/i, - ]; - return ignorePatterns.some((pattern) => pattern.test(message)); -} - -/** - * Converts ignore policy into Cypress uncaught-exception callback return value. - * @param {unknown} error - The thrown uncaught exception. - * @returns {false|undefined} False to ignore, undefined to let Cypress fail the test. - */ -export function getCypressUncaughtExceptionDecision(error) { - return shouldIgnoreUncaughtException(error) ? false : undefined; -} diff --git a/tests/unit/cypress/uncaughtExceptionPolicy.test.js b/tests/unit/cypress/uncaughtExceptionPolicy.test.js deleted file mode 100644 index 34c4c12..0000000 --- a/tests/unit/cypress/uncaughtExceptionPolicy.test.js +++ /dev/null @@ -1,31 +0,0 @@ -import { describe, expect, it } from "vitest"; -import { - getCypressUncaughtExceptionDecision, - shouldIgnoreUncaughtException, -} from "../../../cypress/support/uncaughtExceptionPolicy"; - -describe("shouldIgnoreUncaughtException", () => { - it("returns true for known benign ResizeObserver errors", () => { - expect( - shouldIgnoreUncaughtException(new Error("ResizeObserver loop limit exceeded")), - ).toBe(true); - }); - - it("returns false for unknown runtime errors", () => { - expect(shouldIgnoreUncaughtException(new Error("TypeError: x is undefined"))).toBe(false); - }); - - it("returns false for Cypress handler when the error should be ignored", () => { - expect( - getCypressUncaughtExceptionDecision( - new Error("ResizeObserver loop completed with undelivered notifications."), - ), - ).toBe(false); - }); - - it("returns undefined for Cypress handler when the error should fail the test", () => { - expect( - getCypressUncaughtExceptionDecision(new Error("TypeError: x is undefined")), - ).toBeUndefined(); - }); -});