@c15t/react 1.8.6 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/cookie-banner/__tests__/cookie-banner.e2e.test.cjs +1 -1
- package/dist/components/cookie-banner/__tests__/cookie-banner.e2e.test.js +1 -1
- package/dist/hooks/__tests__/use-consent-manager.test.cjs +1 -1
- package/dist/hooks/__tests__/use-consent-manager.test.js +1 -1
- package/dist/hooks/__tests__/use-translations.test.cjs +1 -1
- package/dist/hooks/__tests__/use-translations.test.js +1 -1
- package/dist/providers/__tests__/provider-basic.test.cjs +1 -1
- package/dist/providers/__tests__/provider-basic.test.js +1 -1
- package/dist/providers/__tests__/provider-context.test.cjs +1 -1
- package/dist/providers/__tests__/provider-context.test.js +1 -1
- package/dist/providers/__tests__/provider-hydration.test.cjs +1 -1
- package/dist/providers/__tests__/provider-hydration.test.js +1 -1
- package/dist/providers/__tests__/provider-offline-warning.test.cjs +1 -0
- package/dist/providers/__tests__/provider-offline-warning.test.d.ts +2 -0
- package/dist/providers/__tests__/provider-offline-warning.test.d.ts.map +1 -0
- package/dist/providers/__tests__/provider-offline-warning.test.js +1 -0
- package/dist/providers/consent-manager-provider.cjs +1 -1
- package/dist/providers/consent-manager-provider.d.ts.map +1 -1
- package/dist/providers/consent-manager-provider.js +1 -1
- package/dist/utils/test-helpers.cjs +1 -1
- package/dist/utils/test-helpers.d.ts.map +1 -1
- package/dist/utils/test-helpers.js +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
- package/readme.json +0 -37
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_exports__={};const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),consent_manager_dialog_cjs_namespaceObject=require("../../consent-manager-dialog/consent-manager-dialog.cjs"),consent_manager_provider_cjs_namespaceObject=require("../../../providers/consent-manager-provider.cjs"),external_cookie_banner_cjs_namespaceObject=require("../cookie-banner.cjs");let mockShowPopup=!0,mockIsPrivacyDialogOpen=!1;external_vitest_namespaceObject.vi.mock("~/hooks/use-consent-manager",async e=>{let t=await e();return{useConsentManager:()=>({...t.useConsentManager(),showPopup:mockShowPopup,isPrivacyDialogOpen:mockIsPrivacyDialogOpen,setShowPopup:e=>{mockShowPopup=e},setIsPrivacyDialogOpen:e=>{mockIsPrivacyDialogOpen=e}})}});const localStorageMock=(()=>{let e={};return{getItem:t=>e[t]||null,setItem:(t,n)=>{e[t]=n.toString()},removeItem:t=>{delete e[t]},clear:()=>{e={}}}})();Object.defineProperty(window,"localStorage",{value:localStorageMock});const defaultOptions={mode:"offline"};for(var __rspack_i in(0,external_vitest_namespaceObject.describe)("CookieBanner E2E Tests",()=>{(0,external_vitest_namespaceObject.beforeEach)(()=>{window.localStorage.clear(),mockShowPopup=!0,external_vitest_namespaceObject.vi.clearAllMocks(),(0,consent_manager_provider_cjs_namespaceObject.clearConsentManagerCache)()}),(0,external_vitest_namespaceObject.test)("should show cookie banner on first visit",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsxs)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:[(0,jsx_runtime_namespaceObject.jsx)(external_cookie_banner_cjs_namespaceObject.CookieBanner,{}),(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{})]}));let e=document.body.querySelector('[data-testid="cookie-banner-root"]');(0,external_vitest_namespaceObject.expect)(e).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(mockShowPopup).toBe(!0),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-title"]')).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-description"]')).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-reject-button"]')).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-customize-button"]')).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-accept-button"]')).toBeInTheDocument()}),(0,external_vitest_namespaceObject.test)("should accept all cookies when clicking Accept All",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsxs)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:[(0,jsx_runtime_namespaceObject.jsx)(external_cookie_banner_cjs_namespaceObject.CookieBanner,{}),(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{})]}));let e=document.querySelector('[data-testid="cookie-banner-accept-button"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),(0,external_vitest_namespaceObject.expect)(mockShowPopup).toBe(!1),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument();let t=JSON.parse(window.localStorage.getItem("c15t")||"{}");(0,external_vitest_namespaceObject.expect)(t.consents.necessary).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(t.consents.marketing).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(t.consents.experience).toBeFalsy()}),(0,external_vitest_namespaceObject.test)("should reject non-essential cookies when clicking Reject All",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsxs)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:[(0,jsx_runtime_namespaceObject.jsx)(external_cookie_banner_cjs_namespaceObject.CookieBanner,{}),(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{})]}));let e=document.querySelector('[data-testid="cookie-banner-reject-button"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),(0,external_vitest_namespaceObject.expect)(mockShowPopup).toBe(!1),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument();let t=JSON.parse(window.localStorage.getItem("c15t")||"{}");(0,external_vitest_namespaceObject.expect)(t.consents).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(t.consents.necessary).toBe(!0),(0,external_vitest_namespaceObject.expect)(t.consents.experience).toBe(!1),(0,external_vitest_namespaceObject.expect)(t.consents.functionality).toBe(!1),(0,external_vitest_namespaceObject.expect)(t.consents.marketing).toBe(!1),(0,external_vitest_namespaceObject.expect)(t.consents.measurement).toBe(!1)}),(0,external_vitest_namespaceObject.test)("should open consent manager dialog when clicking Customize",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsxs)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:[(0,jsx_runtime_namespaceObject.jsx)(external_cookie_banner_cjs_namespaceObject.CookieBanner,{}),(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{})]}));let e=document.querySelector('[data-testid="cookie-banner-customize-button"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),(0,external_vitest_namespaceObject.expect)(mockShowPopup).toBe(!1),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(mockIsPrivacyDialogOpen).toBe(!0)}),(0,external_vitest_namespaceObject.test)("should render consent manager dialog with switches when open",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{open:!0})})),await new Promise(e=>setTimeout(e,100));let e=document.querySelector('[data-testid="consent-manager-dialog-root"]');(0,external_vitest_namespaceObject.expect)(e).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="consent-manager-widget-switch-necessary"]')).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="consent-manager-widget-switch-marketing"]')).toBeInTheDocument()}),(0,external_vitest_namespaceObject.test)("should save custom preferences from consent manager dialog",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{open:!0})})),await new Promise(e=>setTimeout(e,100));let e=document.querySelector('[data-testid="consent-manager-widget-switch-marketing"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0}));let t=document.querySelector('[data-testid="consent-manager-widget-footer-save-button"]');t?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100));let n=JSON.parse(window.localStorage.getItem("c15t")||"{}");(0,external_vitest_namespaceObject.expect)(n.consents).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(n.consents.marketing).toBe(!0)}),(0,external_vitest_namespaceObject.test)("should be keyboard accessible",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsxs)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:[(0,jsx_runtime_namespaceObject.jsx)(external_cookie_banner_cjs_namespaceObject.CookieBanner,{}),(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{})]}));let e=document.querySelector('[data-testid="cookie-banner-reject-button"]'),t=document.querySelector('[data-testid="cookie-banner-customize-button"]'),n=document.querySelector('[data-testid="cookie-banner-accept-button"]');e.focus(),(0,external_vitest_namespaceObject.expect)(document.activeElement).toBe(e),t.focus(),(0,external_vitest_namespaceObject.expect)(document.activeElement).toBe(t),n.focus(),(0,external_vitest_namespaceObject.expect)(document.activeElement).toBe(n)}),(0,external_vitest_namespaceObject.test)("should handle scroll lock properly",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsxs)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:[(0,jsx_runtime_namespaceObject.jsx)(external_cookie_banner_cjs_namespaceObject.CookieBanner,{scrollLock:!0}),(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{})]})),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-overlay"]')).toBeInTheDocument();let e=document.querySelector('[data-testid="cookie-banner-accept-button"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-overlay"]')).not.toBeInTheDocument()})}),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_exports__={};const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),consent_manager_dialog_cjs_namespaceObject=require("../../consent-manager-dialog/consent-manager-dialog.cjs"),consent_manager_provider_cjs_namespaceObject=require("../../../providers/consent-manager-provider.cjs"),external_cookie_banner_cjs_namespaceObject=require("../cookie-banner.cjs");let mockShowPopup=!0,mockIsPrivacyDialogOpen=!1;external_vitest_namespaceObject.vi.mock("~/hooks/use-consent-manager",async e=>{let t=await e();return{useConsentManager:()=>({...t.useConsentManager(),showPopup:mockShowPopup,isPrivacyDialogOpen:mockIsPrivacyDialogOpen,setShowPopup:e=>{mockShowPopup=e},setIsPrivacyDialogOpen:e=>{mockIsPrivacyDialogOpen=e}})}});const localStorageMock=(()=>{let e={};return{getItem:t=>e[t]||null,setItem:(t,n)=>{e[t]=n.toString()},removeItem:t=>{delete e[t]},clear:()=>{e={}}}})();Object.defineProperty(window,"localStorage",{value:localStorageMock});const defaultOptions={mode:"offline",acknowledgeNoRecords:!0};for(var __rspack_i in(0,external_vitest_namespaceObject.describe)("CookieBanner E2E Tests",()=>{(0,external_vitest_namespaceObject.beforeEach)(()=>{window.localStorage.clear(),mockShowPopup=!0,external_vitest_namespaceObject.vi.clearAllMocks(),(0,consent_manager_provider_cjs_namespaceObject.clearConsentManagerCache)()}),(0,external_vitest_namespaceObject.test)("should show cookie banner on first visit",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsxs)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:[(0,jsx_runtime_namespaceObject.jsx)(external_cookie_banner_cjs_namespaceObject.CookieBanner,{}),(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{})]}));let e=document.body.querySelector('[data-testid="cookie-banner-root"]');(0,external_vitest_namespaceObject.expect)(e).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(mockShowPopup).toBe(!0),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-title"]')).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-description"]')).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-reject-button"]')).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-customize-button"]')).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-accept-button"]')).toBeInTheDocument()}),(0,external_vitest_namespaceObject.test)("should accept all cookies when clicking Accept All",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsxs)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:[(0,jsx_runtime_namespaceObject.jsx)(external_cookie_banner_cjs_namespaceObject.CookieBanner,{}),(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{})]}));let e=document.querySelector('[data-testid="cookie-banner-accept-button"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),(0,external_vitest_namespaceObject.expect)(mockShowPopup).toBe(!1),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument();let t=JSON.parse(window.localStorage.getItem("c15t")||"{}");(0,external_vitest_namespaceObject.expect)(t.consents.necessary).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(t.consents.marketing).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(t.consents.experience).toBeFalsy()}),(0,external_vitest_namespaceObject.test)("should reject non-essential cookies when clicking Reject All",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsxs)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:[(0,jsx_runtime_namespaceObject.jsx)(external_cookie_banner_cjs_namespaceObject.CookieBanner,{}),(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{})]}));let e=document.querySelector('[data-testid="cookie-banner-reject-button"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),(0,external_vitest_namespaceObject.expect)(mockShowPopup).toBe(!1),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument();let t=JSON.parse(window.localStorage.getItem("c15t")||"{}");(0,external_vitest_namespaceObject.expect)(t.consents).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(t.consents.necessary).toBe(!0),(0,external_vitest_namespaceObject.expect)(t.consents.experience).toBe(!1),(0,external_vitest_namespaceObject.expect)(t.consents.functionality).toBe(!1),(0,external_vitest_namespaceObject.expect)(t.consents.marketing).toBe(!1),(0,external_vitest_namespaceObject.expect)(t.consents.measurement).toBe(!1)}),(0,external_vitest_namespaceObject.test)("should open consent manager dialog when clicking Customize",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsxs)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:[(0,jsx_runtime_namespaceObject.jsx)(external_cookie_banner_cjs_namespaceObject.CookieBanner,{}),(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{})]}));let e=document.querySelector('[data-testid="cookie-banner-customize-button"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),(0,external_vitest_namespaceObject.expect)(mockShowPopup).toBe(!1),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(mockIsPrivacyDialogOpen).toBe(!0)}),(0,external_vitest_namespaceObject.test)("should render consent manager dialog with switches when open",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{open:!0})})),await new Promise(e=>setTimeout(e,100));let e=document.querySelector('[data-testid="consent-manager-dialog-card"]');(0,external_vitest_namespaceObject.expect)(e).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="consent-manager-widget-switch-necessary"]')).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="consent-manager-widget-switch-marketing"]')).toBeInTheDocument()}),(0,external_vitest_namespaceObject.test)("should save custom preferences from consent manager dialog",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{open:!0})})),await new Promise(e=>setTimeout(e,100));let e=document.querySelector('[data-testid="consent-manager-widget-switch-marketing"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0}));let t=document.querySelector('[data-testid="consent-manager-widget-footer-save-button"]');t?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100));let n=JSON.parse(window.localStorage.getItem("c15t")||"{}");(0,external_vitest_namespaceObject.expect)(n.consents).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(n.consents.marketing).toBe(!0)}),(0,external_vitest_namespaceObject.test)("should be keyboard accessible",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsxs)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:[(0,jsx_runtime_namespaceObject.jsx)(external_cookie_banner_cjs_namespaceObject.CookieBanner,{}),(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{})]}));let e=document.querySelector('[data-testid="cookie-banner-reject-button"]'),t=document.querySelector('[data-testid="cookie-banner-customize-button"]'),n=document.querySelector('[data-testid="cookie-banner-accept-button"]');e.focus(),(0,external_vitest_namespaceObject.expect)(document.activeElement).toBe(e),t.focus(),(0,external_vitest_namespaceObject.expect)(document.activeElement).toBe(t),n.focus(),(0,external_vitest_namespaceObject.expect)(document.activeElement).toBe(n)}),(0,external_vitest_namespaceObject.test)("should handle scroll lock properly",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsxs)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:defaultOptions,children:[(0,jsx_runtime_namespaceObject.jsx)(external_cookie_banner_cjs_namespaceObject.CookieBanner,{scrollLock:!0}),(0,jsx_runtime_namespaceObject.jsx)(consent_manager_dialog_cjs_namespaceObject.ConsentManagerDialog,{})]})),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-overlay"]')).toBeInTheDocument();let e=document.querySelector('[data-testid="cookie-banner-accept-button"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),(0,external_vitest_namespaceObject.expect)(document.querySelector('[data-testid="cookie-banner-overlay"]')).not.toBeInTheDocument()})}),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let e;import{jsx as t,jsxs as o}from"react/jsx-runtime";import{beforeEach as n,describe as c,expect as a,test as s,vi as r}from"vitest";import{render as i}from"vitest-browser-react";import{ConsentManagerDialog as u}from"../../consent-manager-dialog/consent-manager-dialog.js";import{ConsentManagerProvider as d,clearConsentManagerCache as l}from"../../../providers/consent-manager-provider.js";import{CookieBanner as m}from"../cookie-banner.js";let b=!0,h=!1;r.mock("~/hooks/use-consent-manager",async e=>{let t=await e();return{useConsentManager:()=>({...t.useConsentManager(),showPopup:b,isPrivacyDialogOpen:h,setShowPopup:e=>{b=e},setIsPrivacyDialogOpen:e=>{h=e}})}}),Object.defineProperty(window,"localStorage",{value:(e={},{getItem:t=>e[t]||null,setItem:(t,o)=>{e[t]=o.toString()},removeItem:t=>{delete e[t]},clear:()=>{e={}}})});let
|
|
1
|
+
let e;import{jsx as t,jsxs as o}from"react/jsx-runtime";import{beforeEach as n,describe as c,expect as a,test as s,vi as r}from"vitest";import{render as i}from"vitest-browser-react";import{ConsentManagerDialog as u}from"../../consent-manager-dialog/consent-manager-dialog.js";import{ConsentManagerProvider as d,clearConsentManagerCache as l}from"../../../providers/consent-manager-provider.js";import{CookieBanner as m}from"../cookie-banner.js";let b=!0,h=!1;r.mock("~/hooks/use-consent-manager",async e=>{let t=await e();return{useConsentManager:()=>({...t.useConsentManager(),showPopup:b,isPrivacyDialogOpen:h,setShowPopup:e=>{b=e},setIsPrivacyDialogOpen:e=>{h=e}})}}),Object.defineProperty(window,"localStorage",{value:(e={},{getItem:t=>e[t]||null,setItem:(t,o)=>{e[t]=o.toString()},removeItem:t=>{delete e[t]},clear:()=>{e={}}})});let w={mode:"offline",acknowledgeNoRecords:!0};c("CookieBanner E2E Tests",()=>{n(()=>{window.localStorage.clear(),b=!0,r.clearAllMocks(),l()}),s("should show cookie banner on first visit",async()=>{i(o(d,{options:w,children:[t(m,{}),t(u,{})]})),a(document.body.querySelector('[data-testid="cookie-banner-root"]')).toBeInTheDocument(),a(b).toBe(!0),a(document.querySelector('[data-testid="cookie-banner-title"]')).toBeInTheDocument(),a(document.querySelector('[data-testid="cookie-banner-description"]')).toBeInTheDocument(),a(document.querySelector('[data-testid="cookie-banner-reject-button"]')).toBeInTheDocument(),a(document.querySelector('[data-testid="cookie-banner-customize-button"]')).toBeInTheDocument(),a(document.querySelector('[data-testid="cookie-banner-accept-button"]')).toBeInTheDocument()}),s("should accept all cookies when clicking Accept All",async()=>{i(o(d,{options:w,children:[t(m,{}),t(u,{})]}));let e=document.querySelector('[data-testid="cookie-banner-accept-button"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),a(b).toBe(!1),a(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument();let n=JSON.parse(window.localStorage.getItem("c15t")||"{}");a(n.consents.necessary).toBeTruthy(),a(n.consents.marketing).toBeTruthy(),a(n.consents.experience).toBeFalsy()}),s("should reject non-essential cookies when clicking Reject All",async()=>{i(o(d,{options:w,children:[t(m,{}),t(u,{})]}));let e=document.querySelector('[data-testid="cookie-banner-reject-button"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),a(b).toBe(!1),a(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument();let n=JSON.parse(window.localStorage.getItem("c15t")||"{}");a(n.consents).toBeTruthy(),a(n.consents.necessary).toBe(!0),a(n.consents.experience).toBe(!1),a(n.consents.functionality).toBe(!1),a(n.consents.marketing).toBe(!1),a(n.consents.measurement).toBe(!1)}),s("should open consent manager dialog when clicking Customize",async()=>{i(o(d,{options:w,children:[t(m,{}),t(u,{})]}));let e=document.querySelector('[data-testid="cookie-banner-customize-button"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),a(b).toBe(!1),a(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument(),a(h).toBe(!0)}),s("should render consent manager dialog with switches when open",async()=>{i(t(d,{options:w,children:t(u,{open:!0})})),await new Promise(e=>setTimeout(e,100)),a(document.querySelector('[data-testid="consent-manager-dialog-card"]')).toBeInTheDocument(),a(document.querySelector('[data-testid="consent-manager-widget-switch-necessary"]')).toBeInTheDocument(),a(document.querySelector('[data-testid="consent-manager-widget-switch-marketing"]')).toBeInTheDocument()}),s("should save custom preferences from consent manager dialog",async()=>{i(t(d,{options:w,children:t(u,{open:!0})})),await new Promise(e=>setTimeout(e,100));let e=document.querySelector('[data-testid="consent-manager-widget-switch-marketing"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0}));let o=document.querySelector('[data-testid="consent-manager-widget-footer-save-button"]');o?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100));let n=JSON.parse(window.localStorage.getItem("c15t")||"{}");a(n.consents).toBeTruthy(),a(n.consents.marketing).toBe(!0)}),s("should be keyboard accessible",async()=>{i(o(d,{options:w,children:[t(m,{}),t(u,{})]}));let e=document.querySelector('[data-testid="cookie-banner-reject-button"]'),n=document.querySelector('[data-testid="cookie-banner-customize-button"]'),c=document.querySelector('[data-testid="cookie-banner-accept-button"]');e.focus(),a(document.activeElement).toBe(e),n.focus(),a(document.activeElement).toBe(n),c.focus(),a(document.activeElement).toBe(c)}),s("should handle scroll lock properly",async()=>{i(o(d,{options:w,children:[t(m,{scrollLock:!0}),t(u,{})]})),a(document.querySelector('[data-testid="cookie-banner-overlay"]')).toBeInTheDocument();let e=document.querySelector('[data-testid="cookie-banner-accept-button"]');e?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),a(document.querySelector('[data-testid="cookie-banner-overlay"]')).not.toBeInTheDocument()})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_exports__={};const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_c15t_namespaceObject=require("c15t"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),consent_manager_provider_cjs_namespaceObject=require("../../providers/consent-manager-provider.cjs"),external_use_consent_manager_cjs_namespaceObject=require("../use-consent-manager.cjs");for(var __rspack_i in external_vitest_namespaceObject.vi.mock("c15t",async()=>({...await external_vitest_namespaceObject.vi.importActual("c15t"),configureConsentManager:()=>({getCallbacks:()=>({}),setCallbacks:()=>({}),showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0,jurisdiction:{code:"GDPR"},translations:{language:"en",translations:external_c15t_namespaceObject.defaultTranslationConfig.translations.en}},error:null,response:null}),setConsent:async()=>({ok:!0,data:{success:!0},error:null,response:null}),verifyConsent:async()=>({ok:!0,data:{valid:!0},error:null,response:null})})})),(0,external_vitest_namespaceObject.describe)("useConsentManager",()=>{(0,external_vitest_namespaceObject.test)("returns consent state and methods when used within provider",()=>{let{result:e}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_consent_manager_cjs_namespaceObject.useConsentManager)(),{wrapper:({children:e})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1}},children:e})});(0,external_vitest_namespaceObject.expect)(e.current).toBeDefined(),(0,external_vitest_namespaceObject.expect)(typeof e.current.showPopup).toBe("boolean")}),(0,external_vitest_namespaceObject.test)("provides manager object when configured",()=>{let{result:e}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_consent_manager_cjs_namespaceObject.useConsentManager)(),{wrapper:({children:e})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1}},children:e})});(0,external_vitest_namespaceObject.expect)(e.current.manager).toBeDefined()})}),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_exports__={};const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_c15t_namespaceObject=require("c15t"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),consent_manager_provider_cjs_namespaceObject=require("../../providers/consent-manager-provider.cjs"),external_use_consent_manager_cjs_namespaceObject=require("../use-consent-manager.cjs");for(var __rspack_i in external_vitest_namespaceObject.vi.mock("c15t",async()=>({...await external_vitest_namespaceObject.vi.importActual("c15t"),configureConsentManager:()=>({getCallbacks:()=>({}),setCallbacks:()=>({}),showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0,jurisdiction:{code:"GDPR"},translations:{language:"en",translations:external_c15t_namespaceObject.defaultTranslationConfig.translations.en}},error:null,response:null}),setConsent:async()=>({ok:!0,data:{success:!0},error:null,response:null}),verifyConsent:async()=>({ok:!0,data:{valid:!0},error:null,response:null})})})),(0,external_vitest_namespaceObject.describe)("useConsentManager",()=>{(0,external_vitest_namespaceObject.test)("returns consent state and methods when used within provider",()=>{let{result:e}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_consent_manager_cjs_namespaceObject.useConsentManager)(),{wrapper:({children:e})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1}},children:e})});(0,external_vitest_namespaceObject.expect)(e.current).toBeDefined(),(0,external_vitest_namespaceObject.expect)(typeof e.current.showPopup).toBe("boolean")}),(0,external_vitest_namespaceObject.test)("provides manager object when configured",()=>{let{result:e}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_consent_manager_cjs_namespaceObject.useConsentManager)(),{wrapper:({children:e})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1}},children:e})});(0,external_vitest_namespaceObject.expect)(e.current.manager).toBeDefined()})}),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{defaultTranslationConfig as n}from"c15t";import{describe as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{defaultTranslationConfig as n}from"c15t";import{describe as o,expect as r,test as t,vi as s}from"vitest";import{renderHook as a}from"vitest-browser-react";import{ConsentManagerProvider as i}from"../../providers/consent-manager-provider.js";import{useConsentManager as c}from"../use-consent-manager.js";s.mock("c15t",async()=>({...await s.importActual("c15t"),configureConsentManager:()=>({getCallbacks:()=>({}),setCallbacks:()=>({}),showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0,jurisdiction:{code:"GDPR"},translations:{language:"en",translations:n.translations.en}},error:null,response:null}),setConsent:async()=>({ok:!0,data:{success:!0},error:null,response:null}),verifyConsent:async()=>({ok:!0,data:{valid:!0},error:null,response:null})})})),o("useConsentManager",()=>{t("returns consent state and methods when used within provider",()=>{let{result:n}=a(()=>c(),{wrapper:({children:n})=>e(i,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1}},children:n})});r(n.current).toBeDefined(),r(typeof n.current.showPopup).toBe("boolean")}),t("provides manager object when configured",()=>{let{result:n}=a(()=>c(),{wrapper:({children:n})=>e(i,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1}},children:n})});r(n.current.manager).toBeDefined()})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_exports__={};const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),consent_manager_provider_cjs_namespaceObject=require("../../providers/consent-manager-provider.cjs"),external_use_translations_cjs_namespaceObject=require("../use-translations.cjs");for(var __rspack_i in(0,external_vitest_namespaceObject.describe)("useTranslations",()=>{(0,external_vitest_namespaceObject.beforeEach)(()=>{(0,consent_manager_provider_cjs_namespaceObject.clearConsentManagerCache)()}),(0,external_vitest_namespaceObject.test)("returns English translations by default",async()=>{let{result:e}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_translations_cjs_namespaceObject.useTranslations)(),{wrapper:({children:e})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1}},children:e})});await new Promise(e=>setTimeout(e,10)),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.title).toBe("We value your privacy"),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.description).toBe("This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content."),(0,external_vitest_namespaceObject.expect)(e.current.consentManagerDialog.title).toBe("Privacy Settings"),(0,external_vitest_namespaceObject.expect)(e.current.common.acceptAll).toBe("Accept All"),(0,external_vitest_namespaceObject.expect)(e.current.common.rejectAll).toBe("Reject All"),(0,external_vitest_namespaceObject.expect)(e.current.common.customize).toBe("Customize"),(0,external_vitest_namespaceObject.expect)(e.current.common.save).toBe("Save Settings"),(0,external_vitest_namespaceObject.expect)(e.current.consentTypes?.necessary?.title).toBe("Strictly Necessary")}),(0,external_vitest_namespaceObject.test)("returns German translations instead of English when German is selected",async()=>{let{result:e}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_translations_cjs_namespaceObject.useTranslations)(),{wrapper:({children:e})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1},translations:{defaultLanguage:"de",disableAutoLanguageSwitch:!0,translations:{de:{common:{acceptAll:"German Accept All",rejectAll:"German Reject All",customize:"German Customize",save:"German Save"},cookieBanner:{title:"German Title",description:"German Description"},consentManagerDialog:{title:"German Dialog Title"},consentTypes:{necessary:{title:"German Necessary",description:"German Necessary Description"}}}}}},children:e})});await new Promise(e=>setTimeout(e,10)),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.title).toBe("German Title"),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.description).toBe("German Description"),(0,external_vitest_namespaceObject.expect)(e.current.consentManagerDialog.title).toBe("German Dialog Title"),(0,external_vitest_namespaceObject.expect)(e.current.common.acceptAll).toBe("German Accept All"),(0,external_vitest_namespaceObject.expect)(e.current.common.rejectAll).toBe("German Reject All"),(0,external_vitest_namespaceObject.expect)(e.current.common.customize).toBe("German Customize"),(0,external_vitest_namespaceObject.expect)(e.current.common.save).toBe("German Save"),(0,external_vitest_namespaceObject.expect)(e.current.consentTypes?.necessary?.title).toBe("German Necessary")}),(0,external_vitest_namespaceObject.test)("merges custom translations with defaults",async()=>{let e={translations:{en:{cookieBanner:{title:"Custom Cookie Settings",description:"Custom Description"}}}},{result:t}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_translations_cjs_namespaceObject.useTranslations)(),{wrapper:({children:t})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1},translations:e},children:t})});await new Promise(e=>setTimeout(e,10)),(0,external_vitest_namespaceObject.expect)(t.current.cookieBanner.title).toBe("Custom Cookie Settings"),(0,external_vitest_namespaceObject.expect)(t.current.cookieBanner.description).toBe("Custom Description"),(0,external_vitest_namespaceObject.expect)(t.current.consentManagerDialog.title).toBe("Privacy Settings"),(0,external_vitest_namespaceObject.expect)(t.current.common.acceptAll).toBe("Accept All"),(0,external_vitest_namespaceObject.expect)(t.current.common.rejectAll).toBe("Reject All"),(0,external_vitest_namespaceObject.expect)(t.current.common.customize).toBe("Customize"),(0,external_vitest_namespaceObject.expect)(t.current.common.save).toBe("Save Settings")}),(0,external_vitest_namespaceObject.test)("falls back to English when selected language is not available",async()=>{let{result:e}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_translations_cjs_namespaceObject.useTranslations)(),{wrapper:({children:e})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1},translations:{defaultLanguage:"fr"}},children:e})});await new Promise(e=>setTimeout(e,10)),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.title).toBe("We value your privacy"),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.description).toBe("This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content."),(0,external_vitest_namespaceObject.expect)(e.current.consentManagerDialog.title).toBe("Privacy Settings"),(0,external_vitest_namespaceObject.expect)(e.current.common.acceptAll).toBe("Accept All"),(0,external_vitest_namespaceObject.expect)(e.current.common.rejectAll).toBe("Reject All"),(0,external_vitest_namespaceObject.expect)(e.current.common.customize).toBe("Customize"),(0,external_vitest_namespaceObject.expect)(e.current.common.save).toBe("Save Settings")}),(0,external_vitest_namespaceObject.test)("Custom English instead of English when German is selected",async()=>{let{result:e}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_translations_cjs_namespaceObject.useTranslations)(),{wrapper:({children:e})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1},translations:{defaultLanguage:"en",disableAutoLanguageSwitch:!0,translations:{en:{common:{acceptAll:"Custom English Accept All",rejectAll:"Custom English Reject All",customize:"Custom English Customize",save:"Custom English Save"},cookieBanner:{title:"Custom English Title",description:"Custom English Description"},consentManagerDialog:{title:"Custom English Dialog Title"},consentTypes:{necessary:{title:"Custom English Necessary",description:"Custom English Necessary Description"}}}}}},children:e})});await new Promise(e=>setTimeout(e,20)),(0,external_vitest_namespaceObject.expect)(e.current.common.acceptAll).toBe("Custom English Accept All"),(0,external_vitest_namespaceObject.expect)(e.current.common.rejectAll).toBe("Custom English Reject All"),(0,external_vitest_namespaceObject.expect)(e.current.common.customize).toBe("Custom English Customize"),(0,external_vitest_namespaceObject.expect)(e.current.common.save).toBe("Custom English Save"),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.title).toBe("Custom English Title"),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.description).toBe("Custom English Description"),(0,external_vitest_namespaceObject.expect)(e.current.consentManagerDialog.title).toBe("Custom English Dialog Title"),(0,external_vitest_namespaceObject.expect)(e.current.consentTypes?.necessary?.title).toBe("Custom English Necessary")})}),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_exports__={};const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),consent_manager_provider_cjs_namespaceObject=require("../../providers/consent-manager-provider.cjs"),external_use_translations_cjs_namespaceObject=require("../use-translations.cjs");for(var __rspack_i in(0,external_vitest_namespaceObject.describe)("useTranslations",()=>{(0,external_vitest_namespaceObject.beforeEach)(()=>{(0,consent_manager_provider_cjs_namespaceObject.clearConsentManagerCache)()}),(0,external_vitest_namespaceObject.test)("returns English translations by default",async()=>{let{result:e}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_translations_cjs_namespaceObject.useTranslations)(),{wrapper:({children:e})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1}},children:e})});await new Promise(e=>setTimeout(e,10)),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.title).toBe("We value your privacy"),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.description).toBe("This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content."),(0,external_vitest_namespaceObject.expect)(e.current.consentManagerDialog.title).toBe("Privacy Settings"),(0,external_vitest_namespaceObject.expect)(e.current.common.acceptAll).toBe("Accept All"),(0,external_vitest_namespaceObject.expect)(e.current.common.rejectAll).toBe("Reject All"),(0,external_vitest_namespaceObject.expect)(e.current.common.customize).toBe("Customize"),(0,external_vitest_namespaceObject.expect)(e.current.common.save).toBe("Save Settings"),(0,external_vitest_namespaceObject.expect)(e.current.consentTypes?.necessary?.title).toBe("Strictly Necessary")}),(0,external_vitest_namespaceObject.test)("returns German translations instead of English when German is selected",async()=>{let{result:e}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_translations_cjs_namespaceObject.useTranslations)(),{wrapper:({children:e})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1},translations:{defaultLanguage:"de",disableAutoLanguageSwitch:!0,translations:{de:{common:{acceptAll:"German Accept All",rejectAll:"German Reject All",customize:"German Customize",save:"German Save"},cookieBanner:{title:"German Title",description:"German Description"},consentManagerDialog:{title:"German Dialog Title"},consentTypes:{necessary:{title:"German Necessary",description:"German Necessary Description"}}}}}},children:e})});await new Promise(e=>setTimeout(e,10)),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.title).toBe("German Title"),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.description).toBe("German Description"),(0,external_vitest_namespaceObject.expect)(e.current.consentManagerDialog.title).toBe("German Dialog Title"),(0,external_vitest_namespaceObject.expect)(e.current.common.acceptAll).toBe("German Accept All"),(0,external_vitest_namespaceObject.expect)(e.current.common.rejectAll).toBe("German Reject All"),(0,external_vitest_namespaceObject.expect)(e.current.common.customize).toBe("German Customize"),(0,external_vitest_namespaceObject.expect)(e.current.common.save).toBe("German Save"),(0,external_vitest_namespaceObject.expect)(e.current.consentTypes?.necessary?.title).toBe("German Necessary")}),(0,external_vitest_namespaceObject.test)("merges custom translations with defaults",async()=>{let e={translations:{en:{cookieBanner:{title:"Custom Cookie Settings",description:"Custom Description"}}}},{result:t}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_translations_cjs_namespaceObject.useTranslations)(),{wrapper:({children:t})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1},translations:e},children:t})});await new Promise(e=>setTimeout(e,10)),(0,external_vitest_namespaceObject.expect)(t.current.cookieBanner.title).toBe("Custom Cookie Settings"),(0,external_vitest_namespaceObject.expect)(t.current.cookieBanner.description).toBe("Custom Description"),(0,external_vitest_namespaceObject.expect)(t.current.consentManagerDialog.title).toBe("Privacy Settings"),(0,external_vitest_namespaceObject.expect)(t.current.common.acceptAll).toBe("Accept All"),(0,external_vitest_namespaceObject.expect)(t.current.common.rejectAll).toBe("Reject All"),(0,external_vitest_namespaceObject.expect)(t.current.common.customize).toBe("Customize"),(0,external_vitest_namespaceObject.expect)(t.current.common.save).toBe("Save Settings")}),(0,external_vitest_namespaceObject.test)("falls back to English when selected language is not available",async()=>{let{result:e}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_translations_cjs_namespaceObject.useTranslations)(),{wrapper:({children:e})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1},translations:{defaultLanguage:"fr"}},children:e})});await new Promise(e=>setTimeout(e,10)),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.title).toBe("We value your privacy"),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.description).toBe("This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content."),(0,external_vitest_namespaceObject.expect)(e.current.consentManagerDialog.title).toBe("Privacy Settings"),(0,external_vitest_namespaceObject.expect)(e.current.common.acceptAll).toBe("Accept All"),(0,external_vitest_namespaceObject.expect)(e.current.common.rejectAll).toBe("Reject All"),(0,external_vitest_namespaceObject.expect)(e.current.common.customize).toBe("Customize"),(0,external_vitest_namespaceObject.expect)(e.current.common.save).toBe("Save Settings")}),(0,external_vitest_namespaceObject.test)("Custom English instead of English when German is selected",async()=>{let{result:e}=(0,external_vitest_browser_react_namespaceObject.renderHook)(()=>(0,external_use_translations_cjs_namespaceObject.useTranslations)(),{wrapper:({children:e})=>(0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1},translations:{defaultLanguage:"en",disableAutoLanguageSwitch:!0,translations:{en:{common:{acceptAll:"Custom English Accept All",rejectAll:"Custom English Reject All",customize:"Custom English Customize",save:"Custom English Save"},cookieBanner:{title:"Custom English Title",description:"Custom English Description"},consentManagerDialog:{title:"Custom English Dialog Title"},consentTypes:{necessary:{title:"Custom English Necessary",description:"Custom English Necessary Description"}}}}}},children:e})});await new Promise(e=>setTimeout(e,20)),(0,external_vitest_namespaceObject.expect)(e.current.common.acceptAll).toBe("Custom English Accept All"),(0,external_vitest_namespaceObject.expect)(e.current.common.rejectAll).toBe("Custom English Reject All"),(0,external_vitest_namespaceObject.expect)(e.current.common.customize).toBe("Custom English Customize"),(0,external_vitest_namespaceObject.expect)(e.current.common.save).toBe("Custom English Save"),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.title).toBe("Custom English Title"),(0,external_vitest_namespaceObject.expect)(e.current.cookieBanner.description).toBe("Custom English Description"),(0,external_vitest_namespaceObject.expect)(e.current.consentManagerDialog.title).toBe("Custom English Dialog Title"),(0,external_vitest_namespaceObject.expect)(e.current.consentTypes?.necessary?.title).toBe("Custom English Necessary")})}),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{beforeEach as t,describe as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{beforeEach as t,describe as o,expect as n,test as r}from"vitest";import{renderHook as s}from"vitest-browser-react";import{ConsentManagerProvider as i,clearConsentManagerCache as c}from"../../providers/consent-manager-provider.js";import{useTranslations as a}from"../use-translations.js";o("useTranslations",()=>{t(()=>{c()}),r("returns English translations by default",async()=>{let{result:t}=s(()=>a(),{wrapper:({children:t})=>e(i,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1}},children:t})});await new Promise(e=>setTimeout(e,10)),n(t.current.cookieBanner.title).toBe("We value your privacy"),n(t.current.cookieBanner.description).toBe("This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content."),n(t.current.consentManagerDialog.title).toBe("Privacy Settings"),n(t.current.common.acceptAll).toBe("Accept All"),n(t.current.common.rejectAll).toBe("Reject All"),n(t.current.common.customize).toBe("Customize"),n(t.current.common.save).toBe("Save Settings"),n(t.current.consentTypes?.necessary?.title).toBe("Strictly Necessary")}),r("returns German translations instead of English when German is selected",async()=>{let{result:t}=s(()=>a(),{wrapper:({children:t})=>e(i,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1},translations:{defaultLanguage:"de",disableAutoLanguageSwitch:!0,translations:{de:{common:{acceptAll:"German Accept All",rejectAll:"German Reject All",customize:"German Customize",save:"German Save"},cookieBanner:{title:"German Title",description:"German Description"},consentManagerDialog:{title:"German Dialog Title"},consentTypes:{necessary:{title:"German Necessary",description:"German Necessary Description"}}}}}},children:t})});await new Promise(e=>setTimeout(e,10)),n(t.current.cookieBanner.title).toBe("German Title"),n(t.current.cookieBanner.description).toBe("German Description"),n(t.current.consentManagerDialog.title).toBe("German Dialog Title"),n(t.current.common.acceptAll).toBe("German Accept All"),n(t.current.common.rejectAll).toBe("German Reject All"),n(t.current.common.customize).toBe("German Customize"),n(t.current.common.save).toBe("German Save"),n(t.current.consentTypes?.necessary?.title).toBe("German Necessary")}),r("merges custom translations with defaults",async()=>{let t={translations:{en:{cookieBanner:{title:"Custom Cookie Settings",description:"Custom Description"}}}},{result:o}=s(()=>a(),{wrapper:({children:o})=>e(i,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1},translations:t},children:o})});await new Promise(e=>setTimeout(e,10)),n(o.current.cookieBanner.title).toBe("Custom Cookie Settings"),n(o.current.cookieBanner.description).toBe("Custom Description"),n(o.current.consentManagerDialog.title).toBe("Privacy Settings"),n(o.current.common.acceptAll).toBe("Accept All"),n(o.current.common.rejectAll).toBe("Reject All"),n(o.current.common.customize).toBe("Customize"),n(o.current.common.save).toBe("Save Settings")}),r("falls back to English when selected language is not available",async()=>{let{result:t}=s(()=>a(),{wrapper:({children:t})=>e(i,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1},translations:{defaultLanguage:"fr"}},children:t})});await new Promise(e=>setTimeout(e,10)),n(t.current.cookieBanner.title).toBe("We value your privacy"),n(t.current.cookieBanner.description).toBe("This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content."),n(t.current.consentManagerDialog.title).toBe("Privacy Settings"),n(t.current.common.acceptAll).toBe("Accept All"),n(t.current.common.rejectAll).toBe("Reject All"),n(t.current.common.customize).toBe("Customize"),n(t.current.common.save).toBe("Save Settings")}),r("Custom English instead of English when German is selected",async()=>{let{result:t}=s(()=>a(),{wrapper:({children:t})=>e(i,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:!1},translations:{defaultLanguage:"en",disableAutoLanguageSwitch:!0,translations:{en:{common:{acceptAll:"Custom English Accept All",rejectAll:"Custom English Reject All",customize:"Custom English Customize",save:"Custom English Save"},cookieBanner:{title:"Custom English Title",description:"Custom English Description"},consentManagerDialog:{title:"Custom English Dialog Title"},consentTypes:{necessary:{title:"Custom English Necessary",description:"Custom English Necessary Description"}}}}}},children:t})});await new Promise(e=>setTimeout(e,20)),n(t.current.common.acceptAll).toBe("Custom English Accept All"),n(t.current.common.rejectAll).toBe("Custom English Reject All"),n(t.current.common.customize).toBe("Custom English Customize"),n(t.current.common.save).toBe("Custom English Save"),n(t.current.cookieBanner.title).toBe("Custom English Title"),n(t.current.cookieBanner.description).toBe("Custom English Description"),n(t.current.consentManagerDialog.title).toBe("Custom English Dialog Title"),n(t.current.consentTypes?.necessary?.title).toBe("Custom English Necessary")})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_exports__={};const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_c15t_namespaceObject=require("c15t"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),external_index_cjs_namespaceObject=require("../../index.cjs"),mockFetch=external_vitest_namespaceObject.vi.fn();for(var __rspack_i in window.fetch=mockFetch,(0,external_vitest_namespaceObject.describe)("ConsentManagerProvider Basic Request Behavior",()=>{(0,external_vitest_namespaceObject.beforeEach)(()=>{external_vitest_namespaceObject.vi.resetAllMocks(),external_vitest_namespaceObject.vi.useFakeTimers(),mockFetch.mockResolvedValue(new Response(JSON.stringify({showConsentBanner:!0,jurisdiction:{code:"GDPR"},translations:{language:"en",translations:external_c15t_namespaceObject.defaultTranslationConfig.translations.en}}),{status:200,headers:{"Content-Type":"application/json"}}))}),(0,external_vitest_namespaceObject.afterEach)(()=>{external_vitest_namespaceObject.vi.clearAllMocks(),external_vitest_namespaceObject.vi.useRealTimers()}),(0,external_vitest_namespaceObject.it)("should only make one initial request for consent banner status",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"c15t",backendURL:"/api/c15t"},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"Test Component"})})),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(mockFetch).toHaveBeenCalledTimes(1),(0,external_vitest_namespaceObject.expect)(mockFetch).toHaveBeenCalledWith(external_vitest_namespaceObject.expect.stringContaining("/api/c15t/show-consent-banner"),external_vitest_namespaceObject.expect.any(Object))}),(0,external_vitest_namespaceObject.it)("should not make additional requests when props change but core options remain same",async()=>{mockFetch.mockClear();let{rerender:e}=(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",react:{theme:{"banner.root":"light"}}},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"Light theme"})}));await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(mockFetch).not.toHaveBeenCalled(),e((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",react:{theme:{"banner.root":"dark"}}},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"Dark theme"})})),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(mockFetch).not.toHaveBeenCalled()}),(0,external_vitest_namespaceObject.it)("should make a new request when core options change",async()=>{let{rerender:e}=(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"c15t",backendURL:"/api/c15t-1"},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"First URL"})}));await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(mockFetch).toHaveBeenCalledTimes(1),(0,external_vitest_namespaceObject.expect)(mockFetch).toHaveBeenCalledWith(external_vitest_namespaceObject.expect.stringContaining("/api/c15t-1/show-consent-banner"),external_vitest_namespaceObject.expect.any(Object)),mockFetch.mockClear(),e((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"c15t",backendURL:"/api/c15t-2"},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"Second URL"})})),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(mockFetch).toHaveBeenCalledWith(external_vitest_namespaceObject.expect.stringContaining("/api/c15t-2/show-consent-banner"),external_vitest_namespaceObject.expect.any(Object))}),(0,external_vitest_namespaceObject.it)("should handle rapid re-renders without making duplicate requests",async()=>{mockFetch.mockClear();let{rerender:e}=(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline"},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"Counter: 0"})}));await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(mockFetch).not.toHaveBeenCalled();for(let t=1;t<=5;t++)e((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline"},children:(0,jsx_runtime_namespaceObject.jsxs)("div",{children:["Counter: ",t]})})),await external_vitest_namespaceObject.vi.runAllTimersAsync();(0,external_vitest_namespaceObject.expect)(mockFetch).not.toHaveBeenCalled()})}),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_exports__={};const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_c15t_namespaceObject=require("c15t"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),external_index_cjs_namespaceObject=require("../../index.cjs"),mockFetch=external_vitest_namespaceObject.vi.fn();for(var __rspack_i in window.fetch=mockFetch,(0,external_vitest_namespaceObject.describe)("ConsentManagerProvider Basic Request Behavior",()=>{(0,external_vitest_namespaceObject.beforeEach)(()=>{external_vitest_namespaceObject.vi.resetAllMocks(),external_vitest_namespaceObject.vi.useFakeTimers(),mockFetch.mockResolvedValue(new Response(JSON.stringify({showConsentBanner:!0,jurisdiction:{code:"GDPR"},translations:{language:"en",translations:external_c15t_namespaceObject.defaultTranslationConfig.translations.en}}),{status:200,headers:{"Content-Type":"application/json"}}))}),(0,external_vitest_namespaceObject.afterEach)(()=>{external_vitest_namespaceObject.vi.clearAllMocks(),external_vitest_namespaceObject.vi.useRealTimers()}),(0,external_vitest_namespaceObject.it)("should only make one initial request for consent banner status",async()=>{(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"c15t",backendURL:"/api/c15t"},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"Test Component"})})),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(mockFetch).toHaveBeenCalledTimes(1),(0,external_vitest_namespaceObject.expect)(mockFetch).toHaveBeenCalledWith(external_vitest_namespaceObject.expect.stringContaining("/api/c15t/show-consent-banner"),external_vitest_namespaceObject.expect.any(Object))}),(0,external_vitest_namespaceObject.it)("should not make additional requests when props change but core options remain same",async()=>{mockFetch.mockClear();let{rerender:e}=(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{theme:{"banner.root":"light"}}},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"Light theme"})}));await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(mockFetch).not.toHaveBeenCalled(),e((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{theme:{"banner.root":"dark"}}},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"Dark theme"})})),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(mockFetch).not.toHaveBeenCalled()}),(0,external_vitest_namespaceObject.it)("should make a new request when core options change",async()=>{let{rerender:e}=(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"c15t",backendURL:"/api/c15t-1"},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"First URL"})}));await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(mockFetch).toHaveBeenCalledTimes(1),(0,external_vitest_namespaceObject.expect)(mockFetch).toHaveBeenCalledWith(external_vitest_namespaceObject.expect.stringContaining("/api/c15t-1/show-consent-banner"),external_vitest_namespaceObject.expect.any(Object)),mockFetch.mockClear(),e((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"c15t",backendURL:"/api/c15t-2"},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"Second URL"})})),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(mockFetch).toHaveBeenCalledWith(external_vitest_namespaceObject.expect.stringContaining("/api/c15t-2/show-consent-banner"),external_vitest_namespaceObject.expect.any(Object))}),(0,external_vitest_namespaceObject.it)("should handle rapid re-renders without making duplicate requests",async()=>{mockFetch.mockClear();let{rerender:e}=(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"Counter: 0"})}));await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(mockFetch).not.toHaveBeenCalled();for(let t=1;t<=5;t++)e((0,jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0},children:(0,jsx_runtime_namespaceObject.jsxs)("div",{children:["Counter: ",t]})})),await external_vitest_namespaceObject.vi.runAllTimersAsync();(0,external_vitest_namespaceObject.expect)(mockFetch).not.toHaveBeenCalled()})}),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{defaultTranslationConfig as
|
|
1
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{defaultTranslationConfig as o}from"c15t";import{afterEach as t,beforeEach as a,describe as i,expect as r,it as s,vi as l}from"vitest";import{render as c}from"vitest-browser-react";import{ConsentManagerProvider as d}from"../../index.js";let m=l.fn();window.fetch=m,i("ConsentManagerProvider Basic Request Behavior",()=>{a(()=>{l.resetAllMocks(),l.useFakeTimers(),m.mockResolvedValue(new Response(JSON.stringify({showConsentBanner:!0,jurisdiction:{code:"GDPR"},translations:{language:"en",translations:o.translations.en}}),{status:200,headers:{"Content-Type":"application/json"}}))}),t(()=>{l.clearAllMocks(),l.useRealTimers()}),s("should only make one initial request for consent banner status",async()=>{c(e(d,{options:{mode:"c15t",backendURL:"/api/c15t"},children:e("div",{children:"Test Component"})})),await l.runAllTimersAsync(),r(m).toHaveBeenCalledTimes(1),r(m).toHaveBeenCalledWith(r.stringContaining("/api/c15t/show-consent-banner"),r.any(Object))}),s("should not make additional requests when props change but core options remain same",async()=>{m.mockClear();let{rerender:n}=c(e(d,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{theme:{"banner.root":"light"}}},children:e("div",{children:"Light theme"})}));await l.runAllTimersAsync(),r(m).not.toHaveBeenCalled(),n(e(d,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{theme:{"banner.root":"dark"}}},children:e("div",{children:"Dark theme"})})),await l.runAllTimersAsync(),r(m).not.toHaveBeenCalled()}),s("should make a new request when core options change",async()=>{let{rerender:n}=c(e(d,{options:{mode:"c15t",backendURL:"/api/c15t-1"},children:e("div",{children:"First URL"})}));await l.runAllTimersAsync(),r(m).toHaveBeenCalledTimes(1),r(m).toHaveBeenCalledWith(r.stringContaining("/api/c15t-1/show-consent-banner"),r.any(Object)),m.mockClear(),n(e(d,{options:{mode:"c15t",backendURL:"/api/c15t-2"},children:e("div",{children:"Second URL"})})),await l.runAllTimersAsync(),r(m).toHaveBeenCalledWith(r.stringContaining("/api/c15t-2/show-consent-banner"),r.any(Object))}),s("should handle rapid re-renders without making duplicate requests",async()=>{m.mockClear();let{rerender:o}=c(e(d,{options:{mode:"offline",acknowledgeNoRecords:!0},children:e("div",{children:"Counter: 0"})}));await l.runAllTimersAsync(),r(m).not.toHaveBeenCalled();for(let t=1;t<=5;t++)o(e(d,{options:{mode:"offline",acknowledgeNoRecords:!0},children:n("div",{children:["Counter: ",t]})})),await l.runAllTimersAsync();r(m).not.toHaveBeenCalled()})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_exports__={};const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_c15t_namespaceObject=require("c15t"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),use_consent_manager_cjs_namespaceObject=require("../../hooks/use-consent-manager.cjs"),external_consent_manager_provider_cjs_namespaceObject=require("../consent-manager-provider.cjs"),external_test_helpers_cjs_namespaceObject=require("./test-helpers.cjs"),{mockConfigureConsentManager:e}=(0,external_test_helpers_cjs_namespaceObject.setupMocks)();external_vitest_namespaceObject.vi.mock("c15t",async()=>({...await external_vitest_namespaceObject.vi.importActual("c15t"),configureConsentManager:t=>(e(t),{showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0,jurisdiction:{code:"GDPR"},translations:{language:"en",translations:external_c15t_namespaceObject.defaultTranslationConfig.translations.en}},error:null,response:null}),setConsent:async()=>({ok:!0,data:{success:!0},error:null,response:null}),verifyConsent:async()=>({ok:!0,data:{valid:!0},error:null,response:null})})}));const modifyContextShowPopup=external_vitest_namespaceObject.vi.fn();for(var __rspack_i in external_vitest_namespaceObject.vi.mock("../../hooks/use-consent-manager",async()=>{let e=await external_vitest_namespaceObject.vi.importActual("../../hooks/use-consent-manager");return{...e,useConsentManager:()=>{let t=e.useConsentManager();return t.showPopup=!0,modifyContextShowPopup(),t}}}),(0,external_vitest_namespaceObject.describe)("ConsentManagerProvider Context Values",()=>{(0,external_vitest_namespaceObject.beforeEach)(()=>{external_vitest_namespaceObject.vi.resetAllMocks(),external_vitest_namespaceObject.vi.useFakeTimers(),(0,external_consent_manager_provider_cjs_namespaceObject.clearConsentManagerCache)()}),(0,external_vitest_namespaceObject.afterEach)(()=>{external_vitest_namespaceObject.vi.clearAllMocks(),external_vitest_namespaceObject.vi.useRealTimers()}),(0,external_vitest_namespaceObject.it)("should provide correct context values to children",async()=>{let{getByTestId:e}=(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",react:{theme:{"banner.root":"dark"}}},children:(0,jsx_runtime_namespaceObject.jsx)(()=>{let e=(0,use_consent_manager_cjs_namespaceObject.useConsentManager)();return(0,jsx_runtime_namespaceObject.jsxs)("div",{children:[(0,jsx_runtime_namespaceObject.jsx)("div",{"data-testid":"has-manager",children:(!!e.manager).toString()}),(0,jsx_runtime_namespaceObject.jsx)("div",{"data-testid":"show-popup",children:e.showPopup?"true":"false"}),(0,jsx_runtime_namespaceObject.jsx)("div",{"data-testid":"debug-state",children:JSON.stringify({showPopup:e.showPopup})})]})},{})}));await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(modifyContextShowPopup).toHaveBeenCalled(),await external_vitest_namespaceObject.vi.waitFor(()=>{(0,external_vitest_namespaceObject.expect)(e("has-manager")).toHaveTextContent("true"),(0,external_vitest_namespaceObject.expect)(e("show-popup")).toHaveTextContent("true")},{timeout:3e3})})}),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_exports__={};const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_c15t_namespaceObject=require("c15t"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),use_consent_manager_cjs_namespaceObject=require("../../hooks/use-consent-manager.cjs"),external_consent_manager_provider_cjs_namespaceObject=require("../consent-manager-provider.cjs"),external_test_helpers_cjs_namespaceObject=require("./test-helpers.cjs"),{mockConfigureConsentManager:e}=(0,external_test_helpers_cjs_namespaceObject.setupMocks)();external_vitest_namespaceObject.vi.mock("c15t",async()=>({...await external_vitest_namespaceObject.vi.importActual("c15t"),configureConsentManager:t=>(e(t),{showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0,jurisdiction:{code:"GDPR"},translations:{language:"en",translations:external_c15t_namespaceObject.defaultTranslationConfig.translations.en}},error:null,response:null}),setConsent:async()=>({ok:!0,data:{success:!0},error:null,response:null}),verifyConsent:async()=>({ok:!0,data:{valid:!0},error:null,response:null})})}));const modifyContextShowPopup=external_vitest_namespaceObject.vi.fn();for(var __rspack_i in external_vitest_namespaceObject.vi.mock("../../hooks/use-consent-manager",async()=>{let e=await external_vitest_namespaceObject.vi.importActual("../../hooks/use-consent-manager");return{...e,useConsentManager:()=>{let t=e.useConsentManager();return t.showPopup=!0,modifyContextShowPopup(),t}}}),(0,external_vitest_namespaceObject.describe)("ConsentManagerProvider Context Values",()=>{(0,external_vitest_namespaceObject.beforeEach)(()=>{external_vitest_namespaceObject.vi.resetAllMocks(),external_vitest_namespaceObject.vi.useFakeTimers(),(0,external_consent_manager_provider_cjs_namespaceObject.clearConsentManagerCache)()}),(0,external_vitest_namespaceObject.afterEach)(()=>{external_vitest_namespaceObject.vi.clearAllMocks(),external_vitest_namespaceObject.vi.useRealTimers()}),(0,external_vitest_namespaceObject.it)("should provide correct context values to children",async()=>{let{getByTestId:e}=(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{theme:{"banner.root":"dark"}}},children:(0,jsx_runtime_namespaceObject.jsx)(()=>{let e=(0,use_consent_manager_cjs_namespaceObject.useConsentManager)();return(0,jsx_runtime_namespaceObject.jsxs)("div",{children:[(0,jsx_runtime_namespaceObject.jsx)("div",{"data-testid":"has-manager",children:(!!e.manager).toString()}),(0,jsx_runtime_namespaceObject.jsx)("div",{"data-testid":"show-popup",children:e.showPopup?"true":"false"}),(0,jsx_runtime_namespaceObject.jsx)("div",{"data-testid":"debug-state",children:JSON.stringify({showPopup:e.showPopup})})]})},{})}));await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(modifyContextShowPopup).toHaveBeenCalled(),await external_vitest_namespaceObject.vi.waitFor(()=>{(0,external_vitest_namespaceObject.expect)(e("has-manager")).toHaveTextContent("true"),(0,external_vitest_namespaceObject.expect)(e("show-popup")).toHaveTextContent("true")},{timeout:3e3})})}),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{defaultTranslationConfig as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{defaultTranslationConfig as o}from"c15t";import{afterEach as n,beforeEach as r,describe as s,expect as a,it as i,vi as l}from"vitest";import{render as c}from"vitest-browser-react";import{useConsentManager as u}from"../../hooks/use-consent-manager.js";import{ConsentManagerProvider as d,clearConsentManagerCache as m}from"../consent-manager-provider.js";import{setupMocks as p}from"./test-helpers.js";let{mockConfigureConsentManager:h}=p();l.mock("c15t",async()=>({...await l.importActual("c15t"),configureConsentManager:e=>(h(e),{showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0,jurisdiction:{code:"GDPR"},translations:{language:"en",translations:o.translations.en}},error:null,response:null}),setConsent:async()=>({ok:!0,data:{success:!0},error:null,response:null}),verifyConsent:async()=>({ok:!0,data:{valid:!0},error:null,response:null})})}));let g=l.fn();l.mock("../../hooks/use-consent-manager",async()=>{let e=await l.importActual("../../hooks/use-consent-manager");return{...e,useConsentManager:()=>{let t=e.useConsentManager();return t.showPopup=!0,g(),t}}}),s("ConsentManagerProvider Context Values",()=>{r(()=>{l.resetAllMocks(),l.useFakeTimers(),m()}),n(()=>{l.clearAllMocks(),l.useRealTimers()}),i("should provide correct context values to children",async()=>{let{getByTestId:o}=c(e(d,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{theme:{"banner.root":"dark"}}},children:e(()=>{let o=u();return t("div",{children:[e("div",{"data-testid":"has-manager",children:(!!o.manager).toString()}),e("div",{"data-testid":"show-popup",children:o.showPopup?"true":"false"}),e("div",{"data-testid":"debug-state",children:JSON.stringify({showPopup:o.showPopup})})]})},{})}));await l.runAllTimersAsync(),a(g).toHaveBeenCalled(),await l.waitFor(()=>{a(o("has-manager")).toHaveTextContent("true"),a(o("show-popup")).toHaveTextContent("true")},{timeout:3e3})})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_exports__={};const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),external_consent_manager_provider_cjs_namespaceObject=require("../consent-manager-provider.cjs"),MockSSRProvider=({children:e})=>(0,jsx_runtime_namespaceObject.jsx)("div",{"data-testid":"ssr-provider",children:e}),RenderTracker=({label:e})=>(0,jsx_runtime_namespaceObject.jsx)("div",{"data-testid":`render-${e}`,children:e});for(var __rspack_i in(0,external_vitest_namespaceObject.describe)("ConsentManagerProvider Hydration Behavior",()=>{(0,external_vitest_namespaceObject.beforeEach)(()=>{external_vitest_namespaceObject.vi.resetAllMocks(),external_vitest_namespaceObject.vi.useFakeTimers(),(0,external_consent_manager_provider_cjs_namespaceObject.clearConsentManagerCache)()}),(0,external_vitest_namespaceObject.afterEach)(()=>{external_vitest_namespaceObject.vi.clearAllMocks(),external_vitest_namespaceObject.vi.useRealTimers()}),(0,external_vitest_namespaceObject.it)("should render children immediately without blocking during hydration",async()=>{let{getByTestId:e}=await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",consentCategories:["necessary","marketing"]},children:(0,jsx_runtime_namespaceObject.jsx)(RenderTracker,{label:"child"})}));(0,external_vitest_namespaceObject.expect)(e("render-child")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-child")).toHaveTextContent("child"),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(e("render-child")).toBeInTheDocument()}),(0,external_vitest_namespaceObject.it)("should not block SSR provider content when ConsentManager wraps SSR provider",async()=>{let{getByTestId:e}=await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",consentCategories:["necessary","marketing"]},children:(0,jsx_runtime_namespaceObject.jsx)(MockSSRProvider,{children:(0,jsx_runtime_namespaceObject.jsx)(RenderTracker,{label:"ssr-content"})})}));(0,external_vitest_namespaceObject.expect)(e("ssr-provider")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-ssr-content")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-ssr-content")).toHaveTextContent("ssr-content"),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(e("ssr-provider")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-ssr-content")).toBeInTheDocument()}),(0,external_vitest_namespaceObject.it)("should not block SSR provider content when SSR provider wraps ConsentManager",async()=>{let{getByTestId:e}=await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(MockSSRProvider,{children:(0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",consentCategories:["necessary","marketing"]},children:(0,jsx_runtime_namespaceObject.jsx)(RenderTracker,{label:"nested-content"})})}));(0,external_vitest_namespaceObject.expect)(e("ssr-provider")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-nested-content")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-nested-content")).toHaveTextContent("nested-content"),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(e("ssr-provider")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-nested-content")).toBeInTheDocument()}),(0,external_vitest_namespaceObject.it)("should handle rapid re-renders without blocking children",async()=>{let{rerender:e,getByTestId:t}=await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",consentCategories:["necessary"]},children:(0,jsx_runtime_namespaceObject.jsx)(RenderTracker,{label:"rapid-render"})}));(0,external_vitest_namespaceObject.expect)(t("render-rapid-render")).toBeInTheDocument();for(let n=0;n<3;n++)e((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",consentCategories:["necessary","marketing"]},children:(0,jsx_runtime_namespaceObject.jsx)(RenderTracker,{label:"rapid-render"})})),(0,external_vitest_namespaceObject.expect)(t("render-rapid-render")).toBeInTheDocument(),await external_vitest_namespaceObject.vi.runAllTimersAsync()}),(0,external_vitest_namespaceObject.it)("should use startTransition for non-blocking state updates during hydration",async()=>{let e=!1,{getByTestId:t}=await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",consentCategories:["necessary"]},children:(0,jsx_runtime_namespaceObject.jsx)(()=>(e=!0,(0,jsx_runtime_namespaceObject.jsx)("div",{"data-testid":"hydration-test",children:"Content"})),{})}));(0,external_vitest_namespaceObject.expect)(e).toBe(!0),(0,external_vitest_namespaceObject.expect)(t("hydration-test")).toBeInTheDocument(),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(t("hydration-test")).toBeInTheDocument()})}),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_exports__={};const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),external_consent_manager_provider_cjs_namespaceObject=require("../consent-manager-provider.cjs"),MockSSRProvider=({children:e})=>(0,jsx_runtime_namespaceObject.jsx)("div",{"data-testid":"ssr-provider",children:e}),RenderTracker=({label:e})=>(0,jsx_runtime_namespaceObject.jsx)("div",{"data-testid":`render-${e}`,children:e});for(var __rspack_i in(0,external_vitest_namespaceObject.describe)("ConsentManagerProvider Hydration Behavior",()=>{(0,external_vitest_namespaceObject.beforeEach)(()=>{external_vitest_namespaceObject.vi.resetAllMocks(),external_vitest_namespaceObject.vi.useFakeTimers(),(0,external_consent_manager_provider_cjs_namespaceObject.clearConsentManagerCache)()}),(0,external_vitest_namespaceObject.afterEach)(()=>{external_vitest_namespaceObject.vi.clearAllMocks(),external_vitest_namespaceObject.vi.useRealTimers()}),(0,external_vitest_namespaceObject.it)("should render children immediately without blocking during hydration",async()=>{let{getByTestId:e}=await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,consentCategories:["necessary","marketing"]},children:(0,jsx_runtime_namespaceObject.jsx)(RenderTracker,{label:"child"})}));(0,external_vitest_namespaceObject.expect)(e("render-child")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-child")).toHaveTextContent("child"),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(e("render-child")).toBeInTheDocument()}),(0,external_vitest_namespaceObject.it)("should not block SSR provider content when ConsentManager wraps SSR provider",async()=>{let{getByTestId:e}=await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,consentCategories:["necessary","marketing"]},children:(0,jsx_runtime_namespaceObject.jsx)(MockSSRProvider,{children:(0,jsx_runtime_namespaceObject.jsx)(RenderTracker,{label:"ssr-content"})})}));(0,external_vitest_namespaceObject.expect)(e("ssr-provider")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-ssr-content")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-ssr-content")).toHaveTextContent("ssr-content"),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(e("ssr-provider")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-ssr-content")).toBeInTheDocument()}),(0,external_vitest_namespaceObject.it)("should not block SSR provider content when SSR provider wraps ConsentManager",async()=>{let{getByTestId:e}=await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(MockSSRProvider,{children:(0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,consentCategories:["necessary","marketing"]},children:(0,jsx_runtime_namespaceObject.jsx)(RenderTracker,{label:"nested-content"})})}));(0,external_vitest_namespaceObject.expect)(e("ssr-provider")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-nested-content")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-nested-content")).toHaveTextContent("nested-content"),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(e("ssr-provider")).toBeInTheDocument(),(0,external_vitest_namespaceObject.expect)(e("render-nested-content")).toBeInTheDocument()}),(0,external_vitest_namespaceObject.it)("should handle rapid re-renders without blocking children",async()=>{let{rerender:e,getByTestId:t}=await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,consentCategories:["necessary"]},children:(0,jsx_runtime_namespaceObject.jsx)(RenderTracker,{label:"rapid-render"})}));(0,external_vitest_namespaceObject.expect)(t("render-rapid-render")).toBeInTheDocument();for(let n=0;n<3;n++)e((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,consentCategories:["necessary","marketing"]},children:(0,jsx_runtime_namespaceObject.jsx)(RenderTracker,{label:"rapid-render"})})),(0,external_vitest_namespaceObject.expect)(t("render-rapid-render")).toBeInTheDocument(),await external_vitest_namespaceObject.vi.runAllTimersAsync()}),(0,external_vitest_namespaceObject.it)("should use startTransition for non-blocking state updates during hydration",async()=>{let e=!1,{getByTestId:t}=await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,consentCategories:["necessary"]},children:(0,jsx_runtime_namespaceObject.jsx)(()=>(e=!0,(0,jsx_runtime_namespaceObject.jsx)("div",{"data-testid":"hydration-test",children:"Content"})),{})}));(0,external_vitest_namespaceObject.expect)(e).toBe(!0),(0,external_vitest_namespaceObject.expect)(t("hydration-test")).toBeInTheDocument(),await external_vitest_namespaceObject.vi.runAllTimersAsync(),(0,external_vitest_namespaceObject.expect)(t("hydration-test")).toBeInTheDocument()})}),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{afterEach as n,beforeEach as t,describe as r,expect as o,it as s,vi as i}from"vitest";import{render as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{afterEach as n,beforeEach as t,describe as r,expect as o,it as s,vi as i}from"vitest";import{render as d}from"vitest-browser-react";import{ConsentManagerProvider as a,clearConsentManagerCache as c}from"../consent-manager-provider.js";let l=({children:n})=>e("div",{"data-testid":"ssr-provider",children:n}),h=({label:n})=>e("div",{"data-testid":`render-${n}`,children:n});r("ConsentManagerProvider Hydration Behavior",()=>{t(()=>{i.resetAllMocks(),i.useFakeTimers(),c()}),n(()=>{i.clearAllMocks(),i.useRealTimers()}),s("should render children immediately without blocking during hydration",async()=>{let{getByTestId:n}=await d(e(a,{options:{mode:"offline",acknowledgeNoRecords:!0,consentCategories:["necessary","marketing"]},children:e(h,{label:"child"})}));o(n("render-child")).toBeInTheDocument(),o(n("render-child")).toHaveTextContent("child"),await i.runAllTimersAsync(),o(n("render-child")).toBeInTheDocument()}),s("should not block SSR provider content when ConsentManager wraps SSR provider",async()=>{let{getByTestId:n}=await d(e(a,{options:{mode:"offline",acknowledgeNoRecords:!0,consentCategories:["necessary","marketing"]},children:e(l,{children:e(h,{label:"ssr-content"})})}));o(n("ssr-provider")).toBeInTheDocument(),o(n("render-ssr-content")).toBeInTheDocument(),o(n("render-ssr-content")).toHaveTextContent("ssr-content"),await i.runAllTimersAsync(),o(n("ssr-provider")).toBeInTheDocument(),o(n("render-ssr-content")).toBeInTheDocument()}),s("should not block SSR provider content when SSR provider wraps ConsentManager",async()=>{let{getByTestId:n}=await d(e(l,{children:e(a,{options:{mode:"offline",acknowledgeNoRecords:!0,consentCategories:["necessary","marketing"]},children:e(h,{label:"nested-content"})})}));o(n("ssr-provider")).toBeInTheDocument(),o(n("render-nested-content")).toBeInTheDocument(),o(n("render-nested-content")).toHaveTextContent("nested-content"),await i.runAllTimersAsync(),o(n("ssr-provider")).toBeInTheDocument(),o(n("render-nested-content")).toBeInTheDocument()}),s("should handle rapid re-renders without blocking children",async()=>{let{rerender:n,getByTestId:t}=await d(e(a,{options:{mode:"offline",acknowledgeNoRecords:!0,consentCategories:["necessary"]},children:e(h,{label:"rapid-render"})}));o(t("render-rapid-render")).toBeInTheDocument();for(let r=0;r<3;r++)n(e(a,{options:{mode:"offline",acknowledgeNoRecords:!0,consentCategories:["necessary","marketing"]},children:e(h,{label:"rapid-render"})})),o(t("render-rapid-render")).toBeInTheDocument(),await i.runAllTimersAsync()}),s("should use startTransition for non-blocking state updates during hydration",async()=>{let n=!1,{getByTestId:t}=await d(e(a,{options:{mode:"offline",acknowledgeNoRecords:!0,consentCategories:["necessary"]},children:e(()=>(n=!0,e("div",{"data-testid":"hydration-test",children:"Content"})),{})}));o(n).toBe(!0),o(t("hydration-test")).toBeInTheDocument(),await i.runAllTimersAsync(),o(t("hydration-test")).toBeInTheDocument()})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_exports__={};const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),external_consent_manager_provider_cjs_namespaceObject=require("../consent-manager-provider.cjs");external_vitest_namespaceObject.vi.mock("c15t",async e=>await e());const WARNED=Symbol.for("c15t.noRecordsWarned");let storageKey=0;const nextStorageConfig=()=>({storageKey:`react-no-records-${storageKey++}`}),isNoRecordsWarning=e=>"string"==typeof e[0]&&e[0].startsWith("[c15t] Offline mode keeps consent only in this browser.");for(var __rspack_i in(0,external_vitest_namespaceObject.describe)("ConsentManagerProvider offline no-records warning",()=>{let e;(0,external_vitest_namespaceObject.beforeEach)(()=>{(0,external_consent_manager_provider_cjs_namespaceObject.clearConsentManagerCache)(),delete globalThis[WARNED],e=external_vitest_namespaceObject.vi.spyOn(console,"warn").mockImplementation(()=>void 0)}),(0,external_vitest_namespaceObject.afterEach)(()=>{e.mockRestore()}),(0,external_vitest_namespaceObject.it)("warns once in development",async()=>{let t=await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",storageConfig:nextStorageConfig()},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"app"})}));await t.rerender((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",storageConfig:nextStorageConfig()},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"app"})})),(0,external_vitest_namespaceObject.expect)(e.mock.calls.filter(isNoRecordsWarning)).toHaveLength(1)}),(0,external_vitest_namespaceObject.it)("passes acknowledgeNoRecords through to core",async()=>{await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{acknowledgeNoRecords:!0,mode:"offline",storageConfig:nextStorageConfig()},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"app"})})),(0,external_vitest_namespaceObject.expect)(e.mock.calls.filter(isNoRecordsWarning)).toHaveLength(0)}),(0,external_vitest_namespaceObject.it)("warns a later unacknowledged provider that reuses a cached manager",async()=>{let t=nextStorageConfig(),n=await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{acknowledgeNoRecords:!0,mode:"offline",storageConfig:t},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"app"})}));await n.unmount(),await (0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",storageConfig:t},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"app"})})),(0,external_vitest_namespaceObject.expect)(e.mock.calls.filter(isNoRecordsWarning)).toHaveLength(1)})}),__webpack_exports__)exports[__rspack_i]=__webpack_exports__[__rspack_i];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-offline-warning.test.d.ts","sourceRoot":"","sources":["../../../src/providers/__tests__/provider-offline-warning.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{afterEach as o,beforeEach as n,describe as r,expect as t,it as a,vi as i}from"vitest";import{render as s}from"vitest-browser-react";import{ConsentManagerProvider as c,clearConsentManagerCache as l}from"../consent-manager-provider.js";i.mock("c15t",async e=>await e());let d=Symbol.for("c15t.noRecordsWarned"),m=0,p=()=>({storageKey:`react-no-records-${m++}`}),f=e=>"string"==typeof e[0]&&e[0].startsWith("[c15t] Offline mode keeps consent only in this browser.");r("ConsentManagerProvider offline no-records warning",()=>{let r;n(()=>{l(),delete globalThis[d],r=i.spyOn(console,"warn").mockImplementation(()=>void 0)}),o(()=>{r.mockRestore()}),a("warns once in development",async()=>{let o=await s(e(c,{options:{mode:"offline",storageConfig:p()},children:e("div",{children:"app"})}));await o.rerender(e(c,{options:{mode:"offline",storageConfig:p()},children:e("div",{children:"app"})})),t(r.mock.calls.filter(f)).toHaveLength(1)}),a("passes acknowledgeNoRecords through to core",async()=>{await s(e(c,{options:{acknowledgeNoRecords:!0,mode:"offline",storageConfig:p()},children:e("div",{children:"app"})})),t(r.mock.calls.filter(f)).toHaveLength(0)}),a("warns a later unacknowledged provider that reuses a cached manager",async()=>{let o=p(),n=await s(e(c,{options:{acknowledgeNoRecords:!0,mode:"offline",storageConfig:o},children:e("div",{children:"app"})}));await n.unmount(),await s(e(c,{options:{mode:"offline",storageConfig:o},children:e("div",{children:"app"})})),t(r.mock.calls.filter(f)).toHaveLength(1)})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,a)=>{for(var n in a)__webpack_require__.o(a,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:a[n]})},__webpack_require__.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{ConsentManagerProvider:()=>ConsentManagerProvider,clearConsentManagerCache:()=>clearConsentManagerCache});const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_c15t_namespaceObject=require("c15t"),external_react_namespaceObject=require("react"),consent_manager_context_cjs_namespaceObject=require("../context/consent-manager-context.cjs"),theme_context_cjs_namespaceObject=require("../context/theme-context.cjs"),use_color_scheme_cjs_namespaceObject=require("../hooks/use-color-scheme.cjs"),external_version_cjs_namespaceObject=require("../version.cjs"),storeCache=new Map,managerCache=new Map;function clearConsentManagerCache(){storeCache.clear(),managerCache.clear()}function generateCacheKey({mode:e,backendURL:a,endpointHandlers:n,storageConfig:r,enabled:t}){return`${e}:${a??"default"}:${n?"custom":"none"}:${r?.storageKey??"default"}:${!1===t?"disabled":"enabled"}`}function ConsentManagerProvider({children:e,options:a}){let{mode:n,backendURL:r,store:t={},translations:c,react:o={}}=a,{theme:s,disableAnimation:_=!1,scrollLock:i=!1,trapFocus:l=!0,colorScheme:g,noStyle:
|
|
2
|
+
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,a)=>{for(var n in a)__webpack_require__.o(a,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:a[n]})},__webpack_require__.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{ConsentManagerProvider:()=>ConsentManagerProvider,clearConsentManagerCache:()=>clearConsentManagerCache});const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_c15t_namespaceObject=require("c15t"),external_react_namespaceObject=require("react"),consent_manager_context_cjs_namespaceObject=require("../context/consent-manager-context.cjs"),theme_context_cjs_namespaceObject=require("../context/theme-context.cjs"),use_color_scheme_cjs_namespaceObject=require("../hooks/use-color-scheme.cjs"),external_version_cjs_namespaceObject=require("../version.cjs"),storeCache=new Map,managerCache=new Map;function clearConsentManagerCache(){storeCache.clear(),managerCache.clear()}function generateCacheKey({mode:e,backendURL:a,endpointHandlers:n,storageConfig:r,enabled:t}){return`${e}:${a??"default"}:${n?"custom":"none"}:${r?.storageKey??"default"}:${!1===t?"disabled":"enabled"}`}function ConsentManagerProvider({children:e,options:a}){let{mode:n,backendURL:r,store:t={},translations:c,react:o={}}=a,{theme:s,disableAnimation:_=!1,scrollLock:i=!1,trapFocus:l=!0,colorScheme:g,noStyle:p=!1}=o,u=(0,external_react_namespaceObject.useMemo)(()=>"undefined"!=typeof window&&!!(("c15t"===n||"offline"===n)&&(r?.includes("c15t.dev")||r?.includes("c15t.cloud")||window.location.hostname.includes("c15t.dev")||window.location.hostname.includes("c15t.cloud"))),[n,r]),d=generateCacheKey({mode:n||"c15t",backendURL:r||"/api/c15t",endpointHandlers:"endpointHandlers"in a?a.endpointHandlers:void 0,storageConfig:a.storageConfig,enabled:a.enabled}),m=(0,external_react_namespaceObject.useMemo)(()=>{let e;"offline"===n&&(0,external_c15t_namespaceObject.warnOfflineModeKeepsNoRecords)(a.acknowledgeNoRecords);let c=managerCache.get(d);return c||(e="offline"===n?(0,external_c15t_namespaceObject.configureConsentManager)({mode:"offline",store:t,storageConfig:a.storageConfig,acknowledgeNoRecords:a.acknowledgeNoRecords}):"custom"===n&&"endpointHandlers"in a?(0,external_c15t_namespaceObject.configureConsentManager)({mode:"custom",endpointHandlers:a.endpointHandlers,store:t,storageConfig:a.storageConfig}):(0,external_c15t_namespaceObject.configureConsentManager)({mode:"c15t",backendURL:r||"/api/c15t",store:t,storageConfig:a.storageConfig}),managerCache.set(d,e),e)},[d,n,r,t,a]),b=(0,external_react_namespaceObject.useMemo)(()=>{let e=storeCache.get(d);if(e)return e;let r=(0,external_c15t_namespaceObject.createConsentManagerStore)(m,{unstable_googleTagManager:a.unstable_googleTagManager,config:{pkg:"@c15t/react",version:external_version_cjs_namespaceObject.version,mode:n||"Unknown"},enabled:a.enabled,ignoreGeoLocation:a.ignoreGeoLocation,initialGdprTypes:a.consentCategories,callbacks:a.callbacks,trackingBlockerConfig:a.trackingBlockerConfig,scripts:a.scripts,legalLinks:a.legalLinks,storageConfig:a.storageConfig,user:a.user,overrides:a.overrides,experimental_globalPrivacyControl:a.experimental_globalPrivacyControl,...t,isConsentDomain:u,initialTranslationConfig:c});return storeCache.set(d,r),r},[d,m,n,a.callbacks,a.unstable_googleTagManager,a.ignoreGeoLocation,a.consentCategories,a.trackingBlockerConfig,a.scripts,a.legalLinks,a.user,a.overrides,t,u,c,a.storageConfig,a.experimental_globalPrivacyControl]),[f,C]=(0,external_react_namespaceObject.useState)(()=>b?b.getState():{}),j=(0,external_react_namespaceObject.useRef)(!1);(0,external_react_namespaceObject.useEffect)(()=>{if(!b)return;let e=b.subscribe(C);if(!j.current){let e=b.getState();(0,external_react_namespaceObject.startTransition)(()=>{C(a=>a!==e?(j.current=!0,e):(j.current=!0,a))})}return e},[b]);let x=(0,external_react_namespaceObject.useMemo)(()=>({theme:s,noStyle:p,disableAnimation:_,scrollLock:i,trapFocus:l,colorScheme:g}),[s,p,_,i,l,g]);(0,use_color_scheme_cjs_namespaceObject.useColorScheme)(g);let k=(0,external_react_namespaceObject.useMemo)(()=>{if(!b)throw Error("Consent store must be initialized before creating context value");return{state:f,store:b,manager:m}},[f,b,m]);return(0,jsx_runtime_namespaceObject.jsx)(consent_manager_context_cjs_namespaceObject.ConsentStateContext.Provider,{value:k,children:(0,jsx_runtime_namespaceObject.jsx)(theme_context_cjs_namespaceObject.GlobalThemeContext.Provider,{value:x,children:e})})}for(var __rspack_i in exports.ConsentManagerProvider=__webpack_exports__.ConsentManagerProvider,exports.clearConsentManagerCache=__webpack_exports__.clearConsentManagerCache,__webpack_exports__)-1===["ConsentManagerProvider","clearConsentManagerCache"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consent-manager-provider.d.ts","sourceRoot":"","sources":["../../src/providers/consent-manager-provider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"consent-manager-provider.d.ts","sourceRoot":"","sources":["../../src/providers/consent-manager-provider.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAa5E;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C;AAsBD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,sBAAsB,CAAC,EACtC,QAAQ,EACR,OAAO,GACP,EAAE,2BAA2B,2CAkN7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import{configureConsentManager as
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import{configureConsentManager as o,createConsentManagerStore as n,warnOfflineModeKeepsNoRecords as t}from"c15t";import{startTransition as r,useEffect as a,useMemo as i,useRef as l,useState as c}from"react";import{ConsentStateContext as s}from"../context/consent-manager-context.js";import{GlobalThemeContext as g}from"../context/theme-context.js";import{useColorScheme as d}from"../hooks/use-color-scheme.js";import{version as f}from"../version.js";let u=new Map,m=new Map;function p(){u.clear(),m.clear()}function C({children:p,options:C}){let{mode:b,backendURL:k,store:v={},translations:w,react:x={}}=C,{theme:h,disableAnimation:L=!1,scrollLock:M=!1,trapFocus:y=!0,colorScheme:H,noStyle:P=!1}=x,_=i(()=>"undefined"!=typeof window&&!!(("c15t"===b||"offline"===b)&&(k?.includes("c15t.dev")||k?.includes("c15t.cloud")||window.location.hostname.includes("c15t.dev")||window.location.hostname.includes("c15t.cloud"))),[b,k]),j=function({mode:e,backendURL:o,endpointHandlers:n,storageConfig:t,enabled:r}){return`${e}:${o??"default"}:${n?"custom":"none"}:${t?.storageKey??"default"}:${!1===r?"disabled":"enabled"}`}({mode:b||"c15t",backendURL:k||"/api/c15t",endpointHandlers:"endpointHandlers"in C?C.endpointHandlers:void 0,storageConfig:C.storageConfig,enabled:C.enabled}),R=i(()=>{let e;"offline"===b&&t(C.acknowledgeNoRecords);let n=m.get(j);return n||(e="offline"===b?o({mode:"offline",store:v,storageConfig:C.storageConfig,acknowledgeNoRecords:C.acknowledgeNoRecords}):"custom"===b&&"endpointHandlers"in C?o({mode:"custom",endpointHandlers:C.endpointHandlers,store:v,storageConfig:C.storageConfig}):o({mode:"c15t",backendURL:k||"/api/c15t",store:v,storageConfig:C.storageConfig}),m.set(j,e),e)},[j,b,k,v,C]),T=i(()=>{let e=u.get(j);if(e)return e;let o=n(R,{unstable_googleTagManager:C.unstable_googleTagManager,config:{pkg:"@c15t/react",version:f,mode:b||"Unknown"},enabled:C.enabled,ignoreGeoLocation:C.ignoreGeoLocation,initialGdprTypes:C.consentCategories,callbacks:C.callbacks,trackingBlockerConfig:C.trackingBlockerConfig,scripts:C.scripts,legalLinks:C.legalLinks,storageConfig:C.storageConfig,user:C.user,overrides:C.overrides,experimental_globalPrivacyControl:C.experimental_globalPrivacyControl,...v,isConsentDomain:_,initialTranslationConfig:w});return u.set(j,o),o},[j,R,b,C.callbacks,C.unstable_googleTagManager,C.ignoreGeoLocation,C.consentCategories,C.trackingBlockerConfig,C.scripts,C.legalLinks,C.user,C.overrides,v,_,w,C.storageConfig,C.experimental_globalPrivacyControl]),[$,G]=c(()=>T?T.getState():{}),B=l(!1);a(()=>{if(!T)return;let e=T.subscribe(G);if(!B.current){let e=T.getState();r(()=>{G(o=>o!==e?(B.current=!0,e):(B.current=!0,o))})}return e},[T]);let N=i(()=>({theme:h,noStyle:P,disableAnimation:L,scrollLock:M,trapFocus:y,colorScheme:H}),[h,P,L,M,y,H]);d(H);let U=i(()=>{if(!T)throw Error("Consent store must be initialized before creating context value");return{state:$,store:T,manager:R}},[$,T,R]);return e(s.Provider,{value:U,children:e(g.Provider,{value:N,children:p})})}export{C as ConsentManagerProvider,p as clearConsentManagerCache};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var _ in t)__webpack_require__.o(t,_)&&!__webpack_require__.o(e,_)&&Object.defineProperty(e,_,{enumerable:!0,get:t[_]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{testComponentStyles:()=>testComponentStyles,default:()=>test_helpers});const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),consent_manager_provider_cjs_namespaceObject=require("../providers/consent-manager-provider.cjs");async function testComponentStyles({component:e,testCases:t,noStyle:_=!1}){let{container:r}=(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:_}},children:e}));for(let{testId:e,styles:a}of(await new Promise(e=>setTimeout(e,50)),t)){let t=r.querySelector(`[data-testid="${e}"]`),s=document.body.querySelector(`[data-testid="${e}"]`),n=t||s;if(!n){console.warn(`Element with testId "${e}" not found in DOM`),(0,external_vitest_namespaceObject.expect)(!0).toBe(!0);continue}(0,external_vitest_namespaceObject.expect)(n).toBeTruthy(),"string"==typeof a&&a?_?(0,external_vitest_namespaceObject.expect)(n.className).toBe(a):(0,external_vitest_namespaceObject.expect)(n.className).toContain(a):"object"==typeof a&&a?.className&&(_?(0,external_vitest_namespaceObject.expect)(n.className).toBe(a.className):(0,external_vitest_namespaceObject.expect)(n.className).toContain(a.className))}}const test_helpers=testComponentStyles;for(var __rspack_i in exports.default=__webpack_exports__.default,exports.testComponentStyles=__webpack_exports__.testComponentStyles,__webpack_exports__)-1===["default","testComponentStyles"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var _ in t)__webpack_require__.o(t,_)&&!__webpack_require__.o(e,_)&&Object.defineProperty(e,_,{enumerable:!0,get:t[_]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{testComponentStyles:()=>testComponentStyles,default:()=>test_helpers});const jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_vitest_namespaceObject=require("vitest"),external_vitest_browser_react_namespaceObject=require("vitest-browser-react"),consent_manager_provider_cjs_namespaceObject=require("../providers/consent-manager-provider.cjs");async function testComponentStyles({component:e,testCases:t,noStyle:_=!1}){let{container:r}=(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:_}},children:e}));for(let{testId:e,styles:a}of(await new Promise(e=>setTimeout(e,50)),t)){let t=r.querySelector(`[data-testid="${e}"]`),s=document.body.querySelector(`[data-testid="${e}"]`),n=t||s;if(!n){console.warn(`Element with testId "${e}" not found in DOM`),(0,external_vitest_namespaceObject.expect)(!0).toBe(!0);continue}(0,external_vitest_namespaceObject.expect)(n).toBeTruthy(),"string"==typeof a&&a?_?(0,external_vitest_namespaceObject.expect)(n.className).toBe(a):(0,external_vitest_namespaceObject.expect)(n.className).toContain(a):"object"==typeof a&&a?.className&&(_?(0,external_vitest_namespaceObject.expect)(n.className).toBe(a.className):(0,external_vitest_namespaceObject.expect)(n.className).toContain(a.className))}}const test_helpers=testComponentStyles;for(var __rspack_i in exports.default=__webpack_exports__.default,exports.testComponentStyles=__webpack_exports__.testComponentStyles,__webpack_exports__)-1===["default","testComponentStyles"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/test-helpers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,UAAU,eAAe;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE;QACV,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;KAC5B,EAAE,CAAC;IACJ,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,mBAAmB,CAAC,EACzC,SAAS,EACT,SAAS,EACT,OAAe,GACf,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/test-helpers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,UAAU,eAAe;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE;QACV,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;KAC5B,EAAE,CAAC;IACJ,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,mBAAmB,CAAC,EACzC,SAAS,EACT,SAAS,EACT,OAAe,GACf,EAAE,eAAe,iBA6DjB;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{expect as t}from"vitest";import{render as o}from"vitest-browser-react";import{ConsentManagerProvider as s}from"../providers/consent-manager-provider.js";async function a({component:a,testCases:r,noStyle:n=!1}){let{container:i}=o(e(s,{options:{mode:"offline",react:{noStyle:n}},children:a}));for(let{testId:e,styles:o}of(await new Promise(e=>setTimeout(e,50)),r)){let s=i.querySelector(`[data-testid="${e}"]`),a=document.body.querySelector(`[data-testid="${e}"]`),r=s||a;if(!r){console.warn(`Element with testId "${e}" not found in DOM`),t(!0).toBe(!0);continue}t(r).toBeTruthy(),"string"==typeof o&&o?n?t(r.className).toBe(o):t(r.className).toContain(o):"object"==typeof o&&o?.className&&(n?t(r.className).toBe(o.className):t(r.className).toContain(o.className))}}let r=a;export{r as default,a as testComponentStyles};
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{expect as t}from"vitest";import{render as o}from"vitest-browser-react";import{ConsentManagerProvider as s}from"../providers/consent-manager-provider.js";async function a({component:a,testCases:r,noStyle:n=!1}){let{container:i}=o(e(s,{options:{mode:"offline",acknowledgeNoRecords:!0,react:{noStyle:n}},children:a}));for(let{testId:e,styles:o}of(await new Promise(e=>setTimeout(e,50)),r)){let s=i.querySelector(`[data-testid="${e}"]`),a=document.body.querySelector(`[data-testid="${e}"]`),r=s||a;if(!r){console.warn(`Element with testId "${e}" not found in DOM`),t(!0).toBe(!0);continue}t(r).toBeTruthy(),"string"==typeof o&&o?n?t(r.className).toBe(o):t(r.className).toContain(o):"object"==typeof o&&o?.className&&(n?t(r.className).toBe(o.className):t(r.className).toContain(o.className))}}let r=a;export{r as default,a as testComponentStyles};
|
package/dist/version.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,_)=>{for(var r in _)__webpack_require__.o(_,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:_[r]})},__webpack_require__.o=(e,_)=>Object.prototype.hasOwnProperty.call(e,_),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{version:()=>version});const version="1.
|
|
1
|
+
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,_)=>{for(var r in _)__webpack_require__.o(_,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:_[r]})},__webpack_require__.o=(e,_)=>Object.prototype.hasOwnProperty.call(e,_),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{version:()=>version});const version="1.9.0";for(var __rspack_i in exports.version=__webpack_exports__.version,__webpack_exports__)-1===["version"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.9.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e="1.
|
|
1
|
+
let e="1.9.0";export{e as version};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c15t/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Developer-first CMP for React: cookie banner, consent manager, preferences centre. GDPR ready with minimal setup and rich customization",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"@radix-ui/react-accordion": "1.2.12",
|
|
101
101
|
"@radix-ui/react-slot": "1.2.4",
|
|
102
102
|
"@radix-ui/react-switch": "1.1.4",
|
|
103
|
-
"c15t": "1.
|
|
103
|
+
"c15t": "1.9.0",
|
|
104
104
|
"clsx": "2.1.1",
|
|
105
105
|
"zustand": "^5.0.11"
|
|
106
106
|
},
|
|
@@ -115,6 +115,7 @@
|
|
|
115
115
|
"react-dom": "^19.0.0 || ^19.0.0-rc || ^18.0.0 || ^17.0.0 || ^16.8.0"
|
|
116
116
|
},
|
|
117
117
|
"publishConfig": {
|
|
118
|
-
"access": "public"
|
|
118
|
+
"access": "public",
|
|
119
|
+
"tag": "v1-legacy"
|
|
119
120
|
}
|
|
120
121
|
}
|
package/readme.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"title": "@c15t/react: React Consent Components",
|
|
3
|
-
"description": "Developer-first CMP for React: cookie banner, consent manager, preferences centre. GDPR ready with minimal setup and rich customization",
|
|
4
|
-
"features": [
|
|
5
|
-
"Works with React 19, 18, 17, and 16.8",
|
|
6
|
-
"Full 'use client' support for React Server Components",
|
|
7
|
-
"Headless and fully customizable UI components",
|
|
8
|
-
"Automatic GDPR compliance",
|
|
9
|
-
"Minimal configuration with TypeScript-first design",
|
|
10
|
-
"Comprehensive Consent Management Platform (CMP)",
|
|
11
|
-
"Flexible Cookie Banner and Consent Dialog components",
|
|
12
|
-
"Built-in internationalization support",
|
|
13
|
-
"Seamless consent storage and tracking"
|
|
14
|
-
],
|
|
15
|
-
"prerequisites": [
|
|
16
|
-
"React 16.8 or later",
|
|
17
|
-
"Node.js 18.17.0 or later",
|
|
18
|
-
"A hosted [c15t instance](https://consent.io) (free sign-up) or [self-hosted deployment](https://c15t.com/docs/self-host/v2)"
|
|
19
|
-
],
|
|
20
|
-
"manualInstallation": [
|
|
21
|
-
"",
|
|
22
|
-
"```bash\npnpm add @c15t/react\n```",
|
|
23
|
-
"",
|
|
24
|
-
"To manually install, follow the guide in our [docs – manual setup](https://c15t.com/docs/frameworks/react/quickstart#manual-setup)."
|
|
25
|
-
],
|
|
26
|
-
"usage": [
|
|
27
|
-
"Import `ConsentManagerProvider` in your app's root component",
|
|
28
|
-
"Add `CookieBanner` and `ConsentManagerDialog` components",
|
|
29
|
-
"Customise styling and behaviour to fit your app",
|
|
30
|
-
"For full implementation details, see the [React quickstart docs](https://c15t.com/docs/frameworks/react/quickstart)",
|
|
31
|
-
|
|
32
|
-
"```tsx\n// App.tsx\nimport { ConsentManagerProvider, CookieBanner } from '@c15t/react'\n\nfunction App() {\n return (\n <ConsentManagerProvider>\n <YourApp />\n <CookieBanner />\n </ConsentManagerProvider>\n )\n}\n```"
|
|
33
|
-
],
|
|
34
|
-
"docsLink": "https://c15t.com/docs/frameworks/react/quickstart",
|
|
35
|
-
"quickStartLink": "https://c15t.com/docs/frameworks/react/quickstart",
|
|
36
|
-
"showCLIGeneration": true
|
|
37
|
-
}
|