diff --git a/coverage/summary.json b/coverage/summary.json index 8449633..90a2913 100644 --- a/coverage/summary.json +++ b/coverage/summary.json @@ -1,16 +1,16 @@ { - "generatedAt": "2026-05-19T21:20:25.856Z", - "commit": "de17803", + "generatedAt": "2026-05-19T21:23:46.645Z", + "commit": "1b6f2d1", "repo": { - "statements": 97.34, - "branches": 91.98, + "statements": 97.38, + "branches": 92.08, "functions": 97.09, - "lines": 97.34, + "lines": 97.38, "counts": { - "lf": 5742, - "lh": 5589, - "brf": 1147, - "brh": 1055, + "lf": 5758, + "lh": 5607, + "brf": 1149, + "brh": 1058, "fnf": 344, "fnh": 334 } @@ -115,15 +115,15 @@ } }, "@repo/core-ui": { - "statements": 99.49, - "branches": 90.2, + "statements": 100, + "branches": 91.35, "functions": 100, - "lines": 99.49, + "lines": 100, "counts": { - "lf": 396, - "lh": 394, - "brf": 102, - "brh": 92, + "lf": 412, + "lh": 412, + "brf": 104, + "brh": 95, "fnf": 18, "fnh": 18 } diff --git a/packages/core-ui/src/cookie-consent-banner/cookie-consent-banner-unexpected-error.test.tsx b/packages/core-ui/src/cookie-consent-banner/cookie-consent-banner-unexpected-error.test.tsx new file mode 100644 index 0000000..83a7287 --- /dev/null +++ b/packages/core-ui/src/cookie-consent-banner/cookie-consent-banner-unexpected-error.test.tsx @@ -0,0 +1,61 @@ +/** + * Isolated test file for the error-re-throw path in useOptionalConsent. + * Uses vi.mock to make useConsent throw a non-ConsentContextError so that + * lines 52-53 (the `throw e` branch) are exercised. + */ +import { describe, it, expect, vi } from "vitest"; +import { Component, type ReactNode } from "react"; +import { render, screen } from "@testing-library/react"; + +vi.mock("@repo/core-consent/react", () => ({ + useConsent: vi.fn(() => { + throw new Error("unexpected-non-consent-error"); + }), + ConsentContextError: class ConsentContextError extends Error { + constructor() { + super("no provider"); + this.name = "ConsentContextError"; + } + }, +})); + +import { CookieConsentBanner } from "./cookie-consent-banner"; + +class ErrorBoundary extends Component< + { children: ReactNode }, + { caught: string | null } +> { + constructor(props: { children: ReactNode }) { + super(props); + this.state = { caught: null }; + } + + static getDerivedStateFromError(error: Error) { + return { caught: error.message }; + } + + render() { + if (this.state.caught) { + return