@c15t/react 1.4.1 → 1.4.2
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/components/cookie-banner/atoms/root.cjs +1 -1
- package/dist/components/cookie-banner/atoms/root.d.ts.map +1 -1
- package/dist/components/cookie-banner/atoms/root.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/consent-manager-provider.cjs +1 -1
- package/dist/providers/consent-manager-provider.d.ts +11 -0
- package/dist/providers/consent-manager-provider.d.ts.map +1 -1
- package/dist/providers/consent-manager-provider.js +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";let __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__={};let 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"),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}})}});let 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});let defaultOptions={mode:"offline"};for(var __webpack_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,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("privacy-consent-storage")||"{}");(0,external_vitest_namespaceObject.expect)(t.consents).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(t.consentInfo.type).toBe("all")}),(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("privacy-consent-storage")||"{}");(0,external_vitest_namespaceObject.expect)(t.consents).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(t.consentInfo.type).toBe("necessary"),(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);let t=document.querySelector('[data-testid="consent-manager-dialog-root"]');(0,external_vitest_namespaceObject.expect)(t).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();let n=document.querySelector('[data-testid="consent-manager-widget-switch-marketing"]');n?.dispatchEvent(new MouseEvent("click",{bubbles:!0}));let a=document.querySelector('[data-testid="consent-manager-widget-footer-save-button"]');a?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),(0,external_vitest_namespaceObject.expect)(mockIsPrivacyDialogOpen).toBe(!1);let c=JSON.parse(window.localStorage.getItem("privacy-consent-storage")||"{}");(0,external_vitest_namespaceObject.expect)(c.consents).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(c.consentInfo.type).toBe("custom"),(0,external_vitest_namespaceObject.expect)(c.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[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";let __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__={};let 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"),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}})}});let 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});let defaultOptions={mode:"offline"};for(var __webpack_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("privacy-consent-storage")||"{}");(0,external_vitest_namespaceObject.expect)(t.consents).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(t.consentInfo.type).toBe("all")}),(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("privacy-consent-storage")||"{}");(0,external_vitest_namespaceObject.expect)(t.consents).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(t.consentInfo.type).toBe("necessary"),(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);let t=document.querySelector('[data-testid="consent-manager-dialog-root"]');(0,external_vitest_namespaceObject.expect)(t).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();let n=document.querySelector('[data-testid="consent-manager-widget-switch-marketing"]');n?.dispatchEvent(new MouseEvent("click",{bubbles:!0}));let a=document.querySelector('[data-testid="consent-manager-widget-footer-save-button"]');a?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),(0,external_vitest_namespaceObject.expect)(mockIsPrivacyDialogOpen).toBe(!1);let c=JSON.parse(window.localStorage.getItem("privacy-consent-storage")||"{}");(0,external_vitest_namespaceObject.expect)(c.consents).toBeTruthy(),(0,external_vitest_namespaceObject.expect)(c.consentInfo.type).toBe("custom"),(0,external_vitest_namespaceObject.expect)(c.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[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let e;import*as t from"react/jsx-runtime";import*as o from"vitest";import*as n from"vitest-browser-react";import*as c from"../../consent-manager-dialog/consent-manager-dialog.js";import*as a from"../../../providers/consent-manager-provider.js";import*as s from"../cookie-banner.js";let r=!0,i=!1;o.vi.mock("~/hooks/use-consent-manager",async e=>{let t=await e();return{useConsentManager:()=>({...t.useConsentManager(),showPopup:r,isPrivacyDialogOpen:i,setShowPopup:e=>{r=e},setIsPrivacyDialogOpen:e=>{i=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 d={mode:"offline"};(0,o.describe)("CookieBanner E2E Tests",()=>{(0,o.beforeEach)(()=>{window.localStorage.clear(),r=!0,o.vi.clearAllMocks()}),(0,o.test)("should show cookie banner on first visit",async()=>{(0,n.render)((0,t.jsxs)(a.ConsentManagerProvider,{options:d,children:[(0,t.jsx)(s.CookieBanner,{}),(0,t.jsx)(c.ConsentManagerDialog,{})]}));let e=document.body.querySelector('[data-testid="cookie-banner-root"]');(0,o.expect)(e).toBeInTheDocument(),(0,o.expect)(r).toBe(!0),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-title"]')).toBeInTheDocument(),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-description"]')).toBeInTheDocument(),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-reject-button"]')).toBeInTheDocument(),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-customize-button"]')).toBeInTheDocument(),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-accept-button"]')).toBeInTheDocument()}),(0,o.test)("should accept all cookies when clicking Accept All",async()=>{(0,n.render)((0,t.jsxs)(a.ConsentManagerProvider,{options:d,children:[(0,t.jsx)(s.CookieBanner,{}),(0,t.jsx)(c.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,o.expect)(r).toBe(!1),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument();let i=JSON.parse(window.localStorage.getItem("privacy-consent-storage")||"{}");(0,o.expect)(i.consents).toBeTruthy(),(0,o.expect)(i.consentInfo.type).toBe("all")}),(0,o.test)("should reject non-essential cookies when clicking Reject All",async()=>{(0,n.render)((0,t.jsxs)(a.ConsentManagerProvider,{options:d,children:[(0,t.jsx)(s.CookieBanner,{}),(0,t.jsx)(c.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,o.expect)(r).toBe(!1),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument();let i=JSON.parse(window.localStorage.getItem("privacy-consent-storage")||"{}");(0,o.expect)(i.consents).toBeTruthy(),(0,o.expect)(i.consentInfo.type).toBe("necessary"),(0,o.expect)(i.consents.necessary).toBe(!0),(0,o.expect)(i.consents.experience).toBe(!1),(0,o.expect)(i.consents.functionality).toBe(!1),(0,o.expect)(i.consents.marketing).toBe(!1),(0,o.expect)(i.consents.measurement).toBe(!1)}),(0,o.test)("should open consent manager dialog when clicking Customize",async()=>{(0,n.render)((0,t.jsxs)(a.ConsentManagerProvider,{options:d,children:[(0,t.jsx)(s.CookieBanner,{}),(0,t.jsx)(c.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,o.expect)(r).toBe(!1),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument(),(0,o.expect)(i).toBe(!0);let l=document.querySelector('[data-testid="consent-manager-dialog-root"]');(0,o.expect)(l).toBeInTheDocument(),(0,o.expect)(document.querySelector('[data-testid="consent-manager-widget-switch-necessary"]')).toBeInTheDocument(),(0,o.expect)(document.querySelector('[data-testid="consent-manager-widget-switch-marketing"]')).toBeInTheDocument();let u=document.querySelector('[data-testid="consent-manager-widget-switch-marketing"]');u?.dispatchEvent(new MouseEvent("click",{bubbles:!0}));let m=document.querySelector('[data-testid="consent-manager-widget-footer-save-button"]');m?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),(0,o.expect)(i).toBe(!1);let p=JSON.parse(window.localStorage.getItem("privacy-consent-storage")||"{}");(0,o.expect)(p.consents).toBeTruthy(),(0,o.expect)(p.consentInfo.type).toBe("custom"),(0,o.expect)(p.consents.marketing).toBe(!0)}),(0,o.test)("should be keyboard accessible",async()=>{(0,n.render)((0,t.jsxs)(a.ConsentManagerProvider,{options:d,children:[(0,t.jsx)(s.CookieBanner,{}),(0,t.jsx)(c.ConsentManagerDialog,{})]}));let e=document.querySelector('[data-testid="cookie-banner-reject-button"]'),r=document.querySelector('[data-testid="cookie-banner-customize-button"]'),i=document.querySelector('[data-testid="cookie-banner-accept-button"]');e.focus(),(0,o.expect)(document.activeElement).toBe(e),r.focus(),(0,o.expect)(document.activeElement).toBe(r),i.focus(),(0,o.expect)(document.activeElement).toBe(i)}),(0,o.test)("should handle scroll lock properly",async()=>{(0,n.render)((0,t.jsxs)(a.ConsentManagerProvider,{options:d,children:[(0,t.jsx)(s.CookieBanner,{scrollLock:!0}),(0,t.jsx)(c.ConsentManagerDialog,{})]})),(0,o.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,o.expect)(document.querySelector('[data-testid="cookie-banner-overlay"]')).not.toBeInTheDocument()})});
|
|
1
|
+
let e;import*as t from"react/jsx-runtime";import*as o from"vitest";import*as n from"vitest-browser-react";import*as c from"../../consent-manager-dialog/consent-manager-dialog.js";import*as a from"../../../providers/consent-manager-provider.js";import*as s from"../cookie-banner.js";let r=!0,i=!1;o.vi.mock("~/hooks/use-consent-manager",async e=>{let t=await e();return{useConsentManager:()=>({...t.useConsentManager(),showPopup:r,isPrivacyDialogOpen:i,setShowPopup:e=>{r=e},setIsPrivacyDialogOpen:e=>{i=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 d={mode:"offline"};(0,o.describe)("CookieBanner E2E Tests",()=>{(0,o.beforeEach)(()=>{window.localStorage.clear(),r=!0,o.vi.clearAllMocks(),(0,a.clearConsentManagerCache)()}),(0,o.test)("should show cookie banner on first visit",async()=>{(0,n.render)((0,t.jsxs)(a.ConsentManagerProvider,{options:d,children:[(0,t.jsx)(s.CookieBanner,{}),(0,t.jsx)(c.ConsentManagerDialog,{})]}));let e=document.body.querySelector('[data-testid="cookie-banner-root"]');(0,o.expect)(e).toBeInTheDocument(),(0,o.expect)(r).toBe(!0),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-title"]')).toBeInTheDocument(),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-description"]')).toBeInTheDocument(),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-reject-button"]')).toBeInTheDocument(),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-customize-button"]')).toBeInTheDocument(),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-accept-button"]')).toBeInTheDocument()}),(0,o.test)("should accept all cookies when clicking Accept All",async()=>{(0,n.render)((0,t.jsxs)(a.ConsentManagerProvider,{options:d,children:[(0,t.jsx)(s.CookieBanner,{}),(0,t.jsx)(c.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,o.expect)(r).toBe(!1),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument();let i=JSON.parse(window.localStorage.getItem("privacy-consent-storage")||"{}");(0,o.expect)(i.consents).toBeTruthy(),(0,o.expect)(i.consentInfo.type).toBe("all")}),(0,o.test)("should reject non-essential cookies when clicking Reject All",async()=>{(0,n.render)((0,t.jsxs)(a.ConsentManagerProvider,{options:d,children:[(0,t.jsx)(s.CookieBanner,{}),(0,t.jsx)(c.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,o.expect)(r).toBe(!1),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument();let i=JSON.parse(window.localStorage.getItem("privacy-consent-storage")||"{}");(0,o.expect)(i.consents).toBeTruthy(),(0,o.expect)(i.consentInfo.type).toBe("necessary"),(0,o.expect)(i.consents.necessary).toBe(!0),(0,o.expect)(i.consents.experience).toBe(!1),(0,o.expect)(i.consents.functionality).toBe(!1),(0,o.expect)(i.consents.marketing).toBe(!1),(0,o.expect)(i.consents.measurement).toBe(!1)}),(0,o.test)("should open consent manager dialog when clicking Customize",async()=>{(0,n.render)((0,t.jsxs)(a.ConsentManagerProvider,{options:d,children:[(0,t.jsx)(s.CookieBanner,{}),(0,t.jsx)(c.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,o.expect)(r).toBe(!1),(0,o.expect)(document.querySelector('[data-testid="cookie-banner-root"]')).not.toBeInTheDocument(),(0,o.expect)(i).toBe(!0);let l=document.querySelector('[data-testid="consent-manager-dialog-root"]');(0,o.expect)(l).toBeInTheDocument(),(0,o.expect)(document.querySelector('[data-testid="consent-manager-widget-switch-necessary"]')).toBeInTheDocument(),(0,o.expect)(document.querySelector('[data-testid="consent-manager-widget-switch-marketing"]')).toBeInTheDocument();let u=document.querySelector('[data-testid="consent-manager-widget-switch-marketing"]');u?.dispatchEvent(new MouseEvent("click",{bubbles:!0}));let m=document.querySelector('[data-testid="consent-manager-widget-footer-save-button"]');m?.dispatchEvent(new MouseEvent("click",{bubbles:!0})),await new Promise(e=>setTimeout(e,100)),(0,o.expect)(i).toBe(!1);let p=JSON.parse(window.localStorage.getItem("privacy-consent-storage")||"{}");(0,o.expect)(p.consents).toBeTruthy(),(0,o.expect)(p.consentInfo.type).toBe("custom"),(0,o.expect)(p.consents.marketing).toBe(!0)}),(0,o.test)("should be keyboard accessible",async()=>{(0,n.render)((0,t.jsxs)(a.ConsentManagerProvider,{options:d,children:[(0,t.jsx)(s.CookieBanner,{}),(0,t.jsx)(c.ConsentManagerDialog,{})]}));let e=document.querySelector('[data-testid="cookie-banner-reject-button"]'),r=document.querySelector('[data-testid="cookie-banner-customize-button"]'),i=document.querySelector('[data-testid="cookie-banner-accept-button"]');e.focus(),(0,o.expect)(document.activeElement).toBe(e),r.focus(),(0,o.expect)(document.activeElement).toBe(r),i.focus(),(0,o.expect)(document.activeElement).toBe(i)}),(0,o.test)("should handle scroll lock properly",async()=>{(0,n.render)((0,t.jsxs)(a.ConsentManagerProvider,{options:d,children:[(0,t.jsx)(s.CookieBanner,{scrollLock:!0}),(0,t.jsx)(c.ConsentManagerDialog,{})]})),(0,o.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,o.expect)(document.querySelector('[data-testid="cookie-banner-overlay"]')).not.toBeInTheDocument()})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";let __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__.n=e=>{var _=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(_,{a:_}),_},__webpack_require__.d=(e,_)=>{for(var
|
|
2
|
+
"use strict";let __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__.n=e=>{var _=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(_,{a:_}),_},__webpack_require__.d=(e,_)=>{for(var t in _)__webpack_require__.o(_,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:_[t]})},__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__,{Root:()=>Root,CookieBannerRoot:()=>CookieBannerRoot});let jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_react_namespaceObject=require("react"),external_react_dom_namespaceObject=require("react-dom"),external_overlay_cjs_namespaceObject=require("./overlay.cjs"),theme_context_cjs_namespaceObject=require("../../../context/theme-context.cjs"),use_consent_manager_cjs_namespaceObject=require("../../../hooks/use-consent-manager.cjs"),use_styles_cjs_namespaceObject=require("../../../hooks/use-styles.cjs"),external_cookie_banner_module_cjs_namespaceObject=require("../cookie-banner.module.cjs");var external_cookie_banner_module_cjs_default=__webpack_require__.n(external_cookie_banner_module_cjs_namespaceObject);let CookieBannerRoot=({children:e,className:_,noStyle:t,disableAnimation:a,theme:r,scrollLock:n,trapFocus:o=!0,...c})=>(0,jsx_runtime_namespaceObject.jsx)(theme_context_cjs_namespaceObject.LocalThemeContext.Provider,{value:{disableAnimation:a,noStyle:t,theme:r,scrollLock:n,trapFocus:o},children:(0,jsx_runtime_namespaceObject.jsx)(CookieBannerRootChildren,{disableAnimation:a,className:_,noStyle:t,...c,children:e})}),CookieBannerRootChildren=(0,external_react_namespaceObject.forwardRef)(({asChild:e,children:_,className:t,style:a,className:r,disableAnimation:n,noStyle:o,...c},s)=>{let{showPopup:l}=(0,use_consent_manager_cjs_namespaceObject.useConsentManager)(),[i,u]=(0,external_react_namespaceObject.useState)(!1),[m,b]=(0,external_react_namespaceObject.useState)(!1),[p,j]=(0,external_react_namespaceObject.useState)(200);(0,external_react_namespaceObject.useEffect)(()=>{j(Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue("--banner-animation-duration")||"200",10))},[]),(0,external_react_namespaceObject.useEffect)(()=>{if(l)if(m)u(!0);else{let e=setTimeout(()=>{u(!0),b(!0)},10);return()=>clearTimeout(e)}else if(b(!1),n)u(!1);else{let e=setTimeout(()=>{u(!1)},p);return()=>clearTimeout(e)}},[l,n,m,p]);let d=(0,use_styles_cjs_namespaceObject.useStyles)("banner.root",{baseClassName:[external_cookie_banner_module_cjs_default().root,external_cookie_banner_module_cjs_default().bottomLeft],style:a,className:t||r,noStyle:o}),[x,k]=(0,external_react_namespaceObject.useState)(!1);if((0,external_react_namespaceObject.useEffect)(()=>{k(!0)},[]),!x)return null;let O=o?d.className||"":`${d.className||""} ${i?external_cookie_banner_module_cjs_default().bannerVisible:external_cookie_banner_module_cjs_default().bannerHidden}`;return l?(0,external_react_dom_namespaceObject.createPortal)((0,jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment,{children:[(0,jsx_runtime_namespaceObject.jsx)(external_overlay_cjs_namespaceObject.Overlay,{}),(0,jsx_runtime_namespaceObject.jsx)("div",{ref:s,...c,...d,className:O,"data-testid":"cookie-banner-root",children:_})]}),document.body):null});CookieBannerRootChildren.displayName="CookieBannerRootChildren";let Root=CookieBannerRoot;for(var __webpack_i__ in exports.CookieBannerRoot=__webpack_exports__.CookieBannerRoot,exports.Root=__webpack_exports__.Root,__webpack_exports__)-1===["CookieBannerRoot","Root"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../../../src/components/cookie-banner/atoms/root.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEN,KAAK,EAAE,EACP,KAAK,cAAc,EACnB,KAAK,SAAS,EAId,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAIlD;;;;;;;;;GASG;AACH,UAAU,qBAAsB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACrE;;;;OAIG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEnC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,QAAA,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAkC/C,CAAC;
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../../../src/components/cookie-banner/atoms/root.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEN,KAAK,EAAE,EACP,KAAK,cAAc,EACnB,KAAK,SAAS,EAId,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAIlD;;;;;;;;;GASG;AACH,UAAU,qBAAsB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACrE;;;;OAIG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEnC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,QAAA,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAkC/C,CAAC;AAyLF,QAAA,MAAM,IAAI,2BAAmB,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import*as e from"react/jsx-runtime";import*as t from"react";import*as o from"react-dom";import*as a from"./overlay.js";import*as r from"../../../context/theme-context.js";import*as s from"../../../hooks/use-consent-manager.js";import*as n from"../../../hooks/use-styles.js";import*as l from"../cookie-banner.module.js";let m=({children:t,className:o,noStyle:a,disableAnimation:s,theme:n,scrollLock:l,trapFocus:m=!0,...u})=>(0,e.jsx)(r.LocalThemeContext.Provider,{value:{disableAnimation:s,noStyle:a,theme:n,scrollLock:l,trapFocus:m},children:(0,e.jsx)(i,{disableAnimation:s,className:o,noStyle:a,...u,children:t})}),i=(0,t.forwardRef)(({asChild:r,children:m,className:i,style:u,className:c,disableAnimation:d,noStyle:f,...p},b)=>{let{showPopup:j}=(0,s.useConsentManager)(),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(j)y(!0);else if(d)y(!1);else{let e=setTimeout(()=>{y(!1)},
|
|
2
|
+
import*as e from"react/jsx-runtime";import*as t from"react";import*as o from"react-dom";import*as a from"./overlay.js";import*as r from"../../../context/theme-context.js";import*as s from"../../../hooks/use-consent-manager.js";import*as n from"../../../hooks/use-styles.js";import*as l from"../cookie-banner.module.js";let m=({children:t,className:o,noStyle:a,disableAnimation:s,theme:n,scrollLock:l,trapFocus:m=!0,...u})=>(0,e.jsx)(r.LocalThemeContext.Provider,{value:{disableAnimation:s,noStyle:a,theme:n,scrollLock:l,trapFocus:m},children:(0,e.jsx)(i,{disableAnimation:s,className:o,noStyle:a,...u,children:t})}),i=(0,t.forwardRef)(({asChild:r,children:m,className:i,style:u,className:c,disableAnimation:d,noStyle:f,...p},b)=>{let{showPopup:j}=(0,s.useConsentManager)(),[x,y]=(0,t.useState)(!1),[h,N]=(0,t.useState)(!1),[C,S]=(0,t.useState)(200);(0,t.useEffect)(()=>{S(Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue("--banner-animation-duration")||"200",10))},[]),(0,t.useEffect)(()=>{if(j)if(h)y(!0);else{let e=setTimeout(()=>{y(!0),N(!0)},10);return()=>clearTimeout(e)}else if(N(!1),d)y(!1);else{let e=setTimeout(()=>{y(!1)},C);return()=>clearTimeout(e)}},[j,d,h,C]);let k=(0,n.useStyles)("banner.root",{baseClassName:[l.default.root,l.default.bottomLeft],style:u,className:i||c,noStyle:f}),[g,v]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{v(!0)},[]),!g)return null;let T=f?k.className||"":`${k.className||""} ${x?l.default.bannerVisible:l.default.bannerHidden}`;return j?(0,o.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(a.Overlay,{}),(0,e.jsx)("div",{ref:b,...p,...k,className:T,"data-testid":"cookie-banner-root",children:m})]}),document.body):null});i.displayName="CookieBannerRootChildren";let u=m;export{m as CookieBannerRoot,u as Root};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";let __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__={};let 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 __webpack_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,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[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";let __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__={};let 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 __webpack_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[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react/jsx-runtime";import*as n from"c15t";import*as r from"vitest";import*as o from"vitest-browser-react";import*as t from"../../providers/consent-manager-provider.js";import*as s from"../use-consent-manager.js";r.vi.mock("c15t",async()=>({...await r.vi.importActual("c15t"),configureConsentManager:()=>({getCallbacks:()=>({}),setCallbacks:()=>({}),showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0,translations:{language:"en",translations:n.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,r.describe)("useConsentManager",()=>{(0,r.test)("returns consent state and methods when used within provider",()=>{let{result:n}=(0,o.renderHook)(()=>(0,s.useConsentManager)(),{wrapper:({children:n})=>(0,e.jsx)(t.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1}},children:n})});(0,r.expect)(n.current).toBeDefined(),(0,r.expect)(typeof n.current.showPopup).toBe("boolean")}),(0,r.test)("provides manager object when configured",()=>{let{result:n}=(0,o.renderHook)(()=>(0,s.useConsentManager)(),{wrapper:({children:n})=>(0,e.jsx)(t.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1}},children:n})});(0,r.expect)(n.current.manager).toBeDefined()})});
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as n from"c15t";import*as r from"vitest";import*as o from"vitest-browser-react";import*as t from"../../providers/consent-manager-provider.js";import*as s from"../use-consent-manager.js";r.vi.mock("c15t",async()=>({...await r.vi.importActual("c15t"),configureConsentManager:()=>({getCallbacks:()=>({}),setCallbacks:()=>({}),showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0,jurisdiction:{code:"GDPR"},translations:{language:"en",translations:n.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,r.describe)("useConsentManager",()=>{(0,r.test)("returns consent state and methods when used within provider",()=>{let{result:n}=(0,o.renderHook)(()=>(0,s.useConsentManager)(),{wrapper:({children:n})=>(0,e.jsx)(t.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1}},children:n})});(0,r.expect)(n.current).toBeDefined(),(0,r.expect)(typeof n.current.showPopup).toBe("boolean")}),(0,r.test)("provides manager object when configured",()=>{let{result:n}=(0,o.renderHook)(()=>(0,s.useConsentManager)(),{wrapper:({children:n})=>(0,e.jsx)(t.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1}},children:n})});(0,r.expect)(n.current.manager).toBeDefined()})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";let __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__={};let 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 __webpack_i__ in(0,external_vitest_namespaceObject.describe)("useTranslations",()=>{(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[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";let __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__={};let 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 __webpack_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[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react/jsx-runtime";import*as t from"vitest";import*as n from"vitest-browser-react";import*as o from"../../providers/consent-manager-provider.js";import*as r from"../use-translations.js";(0,t.describe)("useTranslations",()=>{(0,t.test)("returns English translations by default",async()=>{let{result:s}=(0,n.renderHook)(()=>(0,r.useTranslations)(),{wrapper:({children:t})=>(0,e.jsx)(o.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1}},children:t})});await new Promise(e=>setTimeout(e,10)),(0,t.expect)(s.current.cookieBanner.title).toBe("We value your privacy"),(0,t.expect)(s.current.cookieBanner.description).toBe("This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content."),(0,t.expect)(s.current.consentManagerDialog.title).toBe("Privacy Settings"),(0,t.expect)(s.current.common.acceptAll).toBe("Accept All"),(0,t.expect)(s.current.common.rejectAll).toBe("Reject All"),(0,t.expect)(s.current.common.customize).toBe("Customize"),(0,t.expect)(s.current.common.save).toBe("Save Settings"),(0,t.expect)(s.current.consentTypes?.necessary?.title).toBe("Strictly Necessary")}),(0,t.test)("returns German translations instead of English when German is selected",async()=>{let{result:s}=(0,n.renderHook)(()=>(0,r.useTranslations)(),{wrapper:({children:t})=>(0,e.jsx)(o.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:t})});await new Promise(e=>setTimeout(e,10)),(0,t.expect)(s.current.cookieBanner.title).toBe("German Title"),(0,t.expect)(s.current.cookieBanner.description).toBe("German Description"),(0,t.expect)(s.current.consentManagerDialog.title).toBe("German Dialog Title"),(0,t.expect)(s.current.common.acceptAll).toBe("German Accept All"),(0,t.expect)(s.current.common.rejectAll).toBe("German Reject All"),(0,t.expect)(s.current.common.customize).toBe("German Customize"),(0,t.expect)(s.current.common.save).toBe("German Save"),(0,t.expect)(s.current.consentTypes?.necessary?.title).toBe("German Necessary")}),(0,t.test)("merges custom translations with defaults",async()=>{let s={translations:{en:{cookieBanner:{title:"Custom Cookie Settings",description:"Custom Description"}}}},{result:c}=(0,n.renderHook)(()=>(0,r.useTranslations)(),{wrapper:({children:t})=>(0,e.jsx)(o.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1},translations:s},children:t})});await new Promise(e=>setTimeout(e,10)),(0,t.expect)(c.current.cookieBanner.title).toBe("Custom Cookie Settings"),(0,t.expect)(c.current.cookieBanner.description).toBe("Custom Description"),(0,t.expect)(c.current.consentManagerDialog.title).toBe("Privacy Settings"),(0,t.expect)(c.current.common.acceptAll).toBe("Accept All"),(0,t.expect)(c.current.common.rejectAll).toBe("Reject All"),(0,t.expect)(c.current.common.customize).toBe("Customize"),(0,t.expect)(c.current.common.save).toBe("Save Settings")}),(0,t.test)("falls back to English when selected language is not available",async()=>{let{result:s}=(0,n.renderHook)(()=>(0,r.useTranslations)(),{wrapper:({children:t})=>(0,e.jsx)(o.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1},translations:{defaultLanguage:"fr"}},children:t})});await new Promise(e=>setTimeout(e,10)),(0,t.expect)(s.current.cookieBanner.title).toBe("We value your privacy"),(0,t.expect)(s.current.cookieBanner.description).toBe("This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content."),(0,t.expect)(s.current.consentManagerDialog.title).toBe("Privacy Settings"),(0,t.expect)(s.current.common.acceptAll).toBe("Accept All"),(0,t.expect)(s.current.common.rejectAll).toBe("Reject All"),(0,t.expect)(s.current.common.customize).toBe("Customize"),(0,t.expect)(s.current.common.save).toBe("Save Settings")}),(0,t.test)("Custom English instead of English when German is selected",async()=>{let{result:s}=(0,n.renderHook)(()=>(0,r.useTranslations)(),{wrapper:({children:t})=>(0,e.jsx)(o.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:t})});await new Promise(e=>setTimeout(e,20)),(0,t.expect)(s.current.common.acceptAll).toBe("Custom English Accept All"),(0,t.expect)(s.current.common.rejectAll).toBe("Custom English Reject All"),(0,t.expect)(s.current.common.customize).toBe("Custom English Customize"),(0,t.expect)(s.current.common.save).toBe("Custom English Save"),(0,t.expect)(s.current.cookieBanner.title).toBe("Custom English Title"),(0,t.expect)(s.current.cookieBanner.description).toBe("Custom English Description"),(0,t.expect)(s.current.consentManagerDialog.title).toBe("Custom English Dialog Title"),(0,t.expect)(s.current.consentTypes?.necessary?.title).toBe("Custom English Necessary")})});
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as t from"vitest";import*as n from"vitest-browser-react";import*as o from"../../providers/consent-manager-provider.js";import*as r from"../use-translations.js";(0,t.describe)("useTranslations",()=>{(0,t.beforeEach)(()=>{(0,o.clearConsentManagerCache)()}),(0,t.test)("returns English translations by default",async()=>{let{result:s}=(0,n.renderHook)(()=>(0,r.useTranslations)(),{wrapper:({children:t})=>(0,e.jsx)(o.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1}},children:t})});await new Promise(e=>setTimeout(e,10)),(0,t.expect)(s.current.cookieBanner.title).toBe("We value your privacy"),(0,t.expect)(s.current.cookieBanner.description).toBe("This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content."),(0,t.expect)(s.current.consentManagerDialog.title).toBe("Privacy Settings"),(0,t.expect)(s.current.common.acceptAll).toBe("Accept All"),(0,t.expect)(s.current.common.rejectAll).toBe("Reject All"),(0,t.expect)(s.current.common.customize).toBe("Customize"),(0,t.expect)(s.current.common.save).toBe("Save Settings"),(0,t.expect)(s.current.consentTypes?.necessary?.title).toBe("Strictly Necessary")}),(0,t.test)("returns German translations instead of English when German is selected",async()=>{let{result:s}=(0,n.renderHook)(()=>(0,r.useTranslations)(),{wrapper:({children:t})=>(0,e.jsx)(o.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:t})});await new Promise(e=>setTimeout(e,10)),(0,t.expect)(s.current.cookieBanner.title).toBe("German Title"),(0,t.expect)(s.current.cookieBanner.description).toBe("German Description"),(0,t.expect)(s.current.consentManagerDialog.title).toBe("German Dialog Title"),(0,t.expect)(s.current.common.acceptAll).toBe("German Accept All"),(0,t.expect)(s.current.common.rejectAll).toBe("German Reject All"),(0,t.expect)(s.current.common.customize).toBe("German Customize"),(0,t.expect)(s.current.common.save).toBe("German Save"),(0,t.expect)(s.current.consentTypes?.necessary?.title).toBe("German Necessary")}),(0,t.test)("merges custom translations with defaults",async()=>{let s={translations:{en:{cookieBanner:{title:"Custom Cookie Settings",description:"Custom Description"}}}},{result:c}=(0,n.renderHook)(()=>(0,r.useTranslations)(),{wrapper:({children:t})=>(0,e.jsx)(o.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1},translations:s},children:t})});await new Promise(e=>setTimeout(e,10)),(0,t.expect)(c.current.cookieBanner.title).toBe("Custom Cookie Settings"),(0,t.expect)(c.current.cookieBanner.description).toBe("Custom Description"),(0,t.expect)(c.current.consentManagerDialog.title).toBe("Privacy Settings"),(0,t.expect)(c.current.common.acceptAll).toBe("Accept All"),(0,t.expect)(c.current.common.rejectAll).toBe("Reject All"),(0,t.expect)(c.current.common.customize).toBe("Customize"),(0,t.expect)(c.current.common.save).toBe("Save Settings")}),(0,t.test)("falls back to English when selected language is not available",async()=>{let{result:s}=(0,n.renderHook)(()=>(0,r.useTranslations)(),{wrapper:({children:t})=>(0,e.jsx)(o.ConsentManagerProvider,{options:{mode:"offline",react:{noStyle:!1},translations:{defaultLanguage:"fr"}},children:t})});await new Promise(e=>setTimeout(e,10)),(0,t.expect)(s.current.cookieBanner.title).toBe("We value your privacy"),(0,t.expect)(s.current.cookieBanner.description).toBe("This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content."),(0,t.expect)(s.current.consentManagerDialog.title).toBe("Privacy Settings"),(0,t.expect)(s.current.common.acceptAll).toBe("Accept All"),(0,t.expect)(s.current.common.rejectAll).toBe("Reject All"),(0,t.expect)(s.current.common.customize).toBe("Customize"),(0,t.expect)(s.current.common.save).toBe("Save Settings")}),(0,t.test)("Custom English instead of English when German is selected",async()=>{let{result:s}=(0,n.renderHook)(()=>(0,r.useTranslations)(),{wrapper:({children:t})=>(0,e.jsx)(o.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:t})});await new Promise(e=>setTimeout(e,20)),(0,t.expect)(s.current.common.acceptAll).toBe("Custom English Accept All"),(0,t.expect)(s.current.common.rejectAll).toBe("Custom English Reject All"),(0,t.expect)(s.current.common.customize).toBe("Custom English Customize"),(0,t.expect)(s.current.common.save).toBe("Custom English Save"),(0,t.expect)(s.current.cookieBanner.title).toBe("Custom English Title"),(0,t.expect)(s.current.cookieBanner.description).toBe("Custom English Description"),(0,t.expect)(s.current.consentManagerDialog.title).toBe("Custom English Dialog Title"),(0,t.expect)(s.current.consentTypes?.necessary?.title).toBe("Custom English Necessary")})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";let __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__={};let 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 __webpack_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,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[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";let __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__={};let 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 __webpack_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[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react/jsx-runtime";import*as n from"c15t";import*as t from"vitest";import*as i from"vitest-browser-react";import*as a from"../../index.js";let r=t.vi.fn();window.fetch=r,(0,t.describe)("ConsentManagerProvider Basic Request Behavior",()=>{(0,t.beforeEach)(()=>{t.vi.resetAllMocks(),t.vi.useFakeTimers(),r.mockResolvedValue(new Response(JSON.stringify({showConsentBanner:!0,translations:{language:"en",translations:n.defaultTranslationConfig.translations.en}}),{status:200,headers:{"Content-Type":"application/json"}}))}),(0,t.afterEach)(()=>{t.vi.clearAllMocks(),t.vi.useRealTimers()}),(0,t.it)("should only make one initial request for consent banner status",async()=>{(0,i.render)((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"c15t",backendURL:"/api/c15t"},children:(0,e.jsx)("div",{children:"Test Component"})})),await t.vi.runAllTimersAsync(),(0,t.expect)(r).toHaveBeenCalledTimes(1),(0,t.expect)(r).toHaveBeenCalledWith(t.expect.stringContaining("/api/c15t/show-consent-banner"),t.expect.any(Object))}),(0,t.it)("should not make additional requests when props change but core options remain same",async()=>{r.mockClear();let{rerender:n}=(0,i.render)((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"offline",react:{theme:{"banner.root":"light"}}},children:(0,e.jsx)("div",{children:"Light theme"})}));await t.vi.runAllTimersAsync(),(0,t.expect)(r).not.toHaveBeenCalled(),n((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"offline",react:{theme:{"banner.root":"dark"}}},children:(0,e.jsx)("div",{children:"Dark theme"})})),await t.vi.runAllTimersAsync(),(0,t.expect)(r).not.toHaveBeenCalled()}),(0,t.it)("should make a new request when core options change",async()=>{let{rerender:n}=(0,i.render)((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"c15t",backendURL:"/api/c15t-1"},children:(0,e.jsx)("div",{children:"First URL"})}));await t.vi.runAllTimersAsync(),(0,t.expect)(r).toHaveBeenCalledTimes(1),(0,t.expect)(r).toHaveBeenCalledWith(t.expect.stringContaining("/api/c15t-1/show-consent-banner"),t.expect.any(Object)),r.mockClear(),n((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"c15t",backendURL:"/api/c15t-2"},children:(0,e.jsx)("div",{children:"Second URL"})})),await t.vi.runAllTimersAsync(),(0,t.expect)(r).toHaveBeenCalledWith(t.expect.stringContaining("/api/c15t-2/show-consent-banner"),t.expect.any(Object))}),(0,t.it)("should handle rapid re-renders without making duplicate requests",async()=>{r.mockClear();let{rerender:n}=(0,i.render)((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"offline"},children:(0,e.jsx)("div",{children:"Counter: 0"})}));await t.vi.runAllTimersAsync(),(0,t.expect)(r).not.toHaveBeenCalled();for(let i=1;i<=5;i++)n((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"offline"},children:(0,e.jsxs)("div",{children:["Counter: ",i]})})),await t.vi.runAllTimersAsync();(0,t.expect)(r).not.toHaveBeenCalled()})});
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as n from"c15t";import*as t from"vitest";import*as i from"vitest-browser-react";import*as a from"../../index.js";let r=t.vi.fn();window.fetch=r,(0,t.describe)("ConsentManagerProvider Basic Request Behavior",()=>{(0,t.beforeEach)(()=>{t.vi.resetAllMocks(),t.vi.useFakeTimers(),r.mockResolvedValue(new Response(JSON.stringify({showConsentBanner:!0,jurisdiction:{code:"GDPR"},translations:{language:"en",translations:n.defaultTranslationConfig.translations.en}}),{status:200,headers:{"Content-Type":"application/json"}}))}),(0,t.afterEach)(()=>{t.vi.clearAllMocks(),t.vi.useRealTimers()}),(0,t.it)("should only make one initial request for consent banner status",async()=>{(0,i.render)((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"c15t",backendURL:"/api/c15t"},children:(0,e.jsx)("div",{children:"Test Component"})})),await t.vi.runAllTimersAsync(),(0,t.expect)(r).toHaveBeenCalledTimes(1),(0,t.expect)(r).toHaveBeenCalledWith(t.expect.stringContaining("/api/c15t/show-consent-banner"),t.expect.any(Object))}),(0,t.it)("should not make additional requests when props change but core options remain same",async()=>{r.mockClear();let{rerender:n}=(0,i.render)((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"offline",react:{theme:{"banner.root":"light"}}},children:(0,e.jsx)("div",{children:"Light theme"})}));await t.vi.runAllTimersAsync(),(0,t.expect)(r).not.toHaveBeenCalled(),n((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"offline",react:{theme:{"banner.root":"dark"}}},children:(0,e.jsx)("div",{children:"Dark theme"})})),await t.vi.runAllTimersAsync(),(0,t.expect)(r).not.toHaveBeenCalled()}),(0,t.it)("should make a new request when core options change",async()=>{let{rerender:n}=(0,i.render)((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"c15t",backendURL:"/api/c15t-1"},children:(0,e.jsx)("div",{children:"First URL"})}));await t.vi.runAllTimersAsync(),(0,t.expect)(r).toHaveBeenCalledTimes(1),(0,t.expect)(r).toHaveBeenCalledWith(t.expect.stringContaining("/api/c15t-1/show-consent-banner"),t.expect.any(Object)),r.mockClear(),n((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"c15t",backendURL:"/api/c15t-2"},children:(0,e.jsx)("div",{children:"Second URL"})})),await t.vi.runAllTimersAsync(),(0,t.expect)(r).toHaveBeenCalledWith(t.expect.stringContaining("/api/c15t-2/show-consent-banner"),t.expect.any(Object))}),(0,t.it)("should handle rapid re-renders without making duplicate requests",async()=>{r.mockClear();let{rerender:n}=(0,i.render)((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"offline"},children:(0,e.jsx)("div",{children:"Counter: 0"})}));await t.vi.runAllTimersAsync(),(0,t.expect)(r).not.toHaveBeenCalled();for(let i=1;i<=5;i++)n((0,e.jsx)(a.ConsentManagerProvider,{options:{mode:"offline"},children:(0,e.jsxs)("div",{children:["Counter: ",i]})})),await t.vi.runAllTimersAsync();(0,t.expect)(r).not.toHaveBeenCalled()})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";let __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__={};let 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),{getCallbacks:()=>t.callbacks||{},showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0,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})})}));let modifyContextShowPopup=external_vitest_namespaceObject.vi.fn();for(var __webpack_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_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})}),(0,external_vitest_namespaceObject.it)("should execute callbacks when provided",async()=>{let t=external_vitest_namespaceObject.vi.fn();(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",callbacks:{onConsentSet:t}},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"Test"})})),await external_vitest_namespaceObject.vi.runAllTimersAsync(),await external_vitest_namespaceObject.vi.waitFor(()=>{(0,external_vitest_namespaceObject.expect)(e).toHaveBeenCalled()},{timeout:3e3});let a=e.mock.calls[0];if((0,external_vitest_namespaceObject.expect)(a).toBeDefined(),a){let e=a[0];(0,external_vitest_namespaceObject.expect)(e).toHaveProperty("callbacks"),(0,external_vitest_namespaceObject.expect)(e.callbacks).toHaveProperty("onConsentSet",t)}})}),__webpack_exports__)exports[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";let __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__={};let 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),{getCallbacks:()=>t.callbacks||{},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})})}));let modifyContextShowPopup=external_vitest_namespaceObject.vi.fn();for(var __webpack_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})}),(0,external_vitest_namespaceObject.it)("should execute callbacks when provided",async()=>{let t=external_vitest_namespaceObject.vi.fn();(0,external_vitest_browser_react_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(external_consent_manager_provider_cjs_namespaceObject.ConsentManagerProvider,{options:{mode:"offline",callbacks:{onConsentSet:t}},children:(0,jsx_runtime_namespaceObject.jsx)("div",{children:"Test"})})),await external_vitest_namespaceObject.vi.runAllTimersAsync(),await external_vitest_namespaceObject.vi.waitFor(()=>{(0,external_vitest_namespaceObject.expect)(e).toHaveBeenCalled()},{timeout:3e3});let a=e.mock.calls[0];if((0,external_vitest_namespaceObject.expect)(a).toBeDefined(),a){let e=a[0];(0,external_vitest_namespaceObject.expect)(e).toHaveProperty("callbacks"),(0,external_vitest_namespaceObject.expect)(e.callbacks).toHaveProperty("onConsentSet",t)}})}),__webpack_exports__)exports[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react/jsx-runtime";import*as t from"c15t";import*as a from"vitest";import*as n from"vitest-browser-react";import*as s from"../../hooks/use-consent-manager.js";import*as o from"../consent-manager-provider.js";import*as r from"./test-helpers.js";let{mockConfigureConsentManager:i}=(0,r.setupMocks)();a.vi.mock("c15t",async()=>({...await a.vi.importActual("c15t"),configureConsentManager:e=>(i(e),{getCallbacks:()=>e.callbacks||{},showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0,translations:{language:"en",translations:t.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})})}));let l=a.vi.fn();a.vi.mock("../../hooks/use-consent-manager",async()=>{let e=await a.vi.importActual("../../hooks/use-consent-manager");return{...e,useConsentManager:()=>{let t=e.useConsentManager();return t.showPopup=!0,l(),t}}}),(0,a.describe)("ConsentManagerProvider Context Values",()=>{(0,a.beforeEach)(()=>{a.vi.resetAllMocks(),a.vi.useFakeTimers()}),(0,a.afterEach)(()=>{a.vi.clearAllMocks(),a.vi.useRealTimers()}),(0,a.it)("should provide correct context values to children",async()=>{let{getByTestId:t}=(0,n.render)((0,e.jsx)(o.ConsentManagerProvider,{options:{mode:"offline",react:{theme:{"banner.root":"dark"}}},children:(0,e.jsx)(()=>{let t=(0,s.useConsentManager)();return(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{"data-testid":"has-manager",children:(!!t.manager).toString()}),(0,e.jsx)("div",{"data-testid":"show-popup",children:t.showPopup?"true":"false"}),(0,e.jsx)("div",{"data-testid":"debug-state",children:JSON.stringify({showPopup:t.showPopup})})]})},{})}));await a.vi.runAllTimersAsync(),(0,a.expect)(l).toHaveBeenCalled(),await a.vi.waitFor(()=>{(0,a.expect)(t("has-manager")).toHaveTextContent("true"),(0,a.expect)(t("show-popup")).toHaveTextContent("true")},{timeout:3e3})}),(0,a.it)("should execute callbacks when provided",async()=>{let t=a.vi.fn();(0,n.render)((0,e.jsx)(o.ConsentManagerProvider,{options:{mode:"offline",callbacks:{onConsentSet:t}},children:(0,e.jsx)("div",{children:"Test"})})),await a.vi.runAllTimersAsync(),await a.vi.waitFor(()=>{(0,a.expect)(i).toHaveBeenCalled()},{timeout:3e3});let s=i.mock.calls[0];if((0,a.expect)(s).toBeDefined(),s){let e=s[0];(0,a.expect)(e).toHaveProperty("callbacks"),(0,a.expect)(e.callbacks).toHaveProperty("onConsentSet",t)}})});
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as t from"c15t";import*as a from"vitest";import*as n from"vitest-browser-react";import*as s from"../../hooks/use-consent-manager.js";import*as o from"../consent-manager-provider.js";import*as r from"./test-helpers.js";let{mockConfigureConsentManager:i}=(0,r.setupMocks)();a.vi.mock("c15t",async()=>({...await a.vi.importActual("c15t"),configureConsentManager:e=>(i(e),{getCallbacks:()=>e.callbacks||{},showConsentBanner:async()=>({ok:!0,data:{showConsentBanner:!0,jurisdiction:{code:"GDPR"},translations:{language:"en",translations:t.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})})}));let l=a.vi.fn();a.vi.mock("../../hooks/use-consent-manager",async()=>{let e=await a.vi.importActual("../../hooks/use-consent-manager");return{...e,useConsentManager:()=>{let t=e.useConsentManager();return t.showPopup=!0,l(),t}}}),(0,a.describe)("ConsentManagerProvider Context Values",()=>{(0,a.beforeEach)(()=>{a.vi.resetAllMocks(),a.vi.useFakeTimers(),(0,o.clearConsentManagerCache)()}),(0,a.afterEach)(()=>{a.vi.clearAllMocks(),a.vi.useRealTimers()}),(0,a.it)("should provide correct context values to children",async()=>{let{getByTestId:t}=(0,n.render)((0,e.jsx)(o.ConsentManagerProvider,{options:{mode:"offline",react:{theme:{"banner.root":"dark"}}},children:(0,e.jsx)(()=>{let t=(0,s.useConsentManager)();return(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{"data-testid":"has-manager",children:(!!t.manager).toString()}),(0,e.jsx)("div",{"data-testid":"show-popup",children:t.showPopup?"true":"false"}),(0,e.jsx)("div",{"data-testid":"debug-state",children:JSON.stringify({showPopup:t.showPopup})})]})},{})}));await a.vi.runAllTimersAsync(),(0,a.expect)(l).toHaveBeenCalled(),await a.vi.waitFor(()=>{(0,a.expect)(t("has-manager")).toHaveTextContent("true"),(0,a.expect)(t("show-popup")).toHaveTextContent("true")},{timeout:3e3})}),(0,a.it)("should execute callbacks when provided",async()=>{let t=a.vi.fn();(0,n.render)((0,e.jsx)(o.ConsentManagerProvider,{options:{mode:"offline",callbacks:{onConsentSet:t}},children:(0,e.jsx)("div",{children:"Test"})})),await a.vi.runAllTimersAsync(),await a.vi.waitFor(()=>{(0,a.expect)(i).toHaveBeenCalled()},{timeout:3e3});let s=i.mock.calls[0];if((0,a.expect)(s).toBeDefined(),s){let e=s[0];(0,a.expect)(e).toHaveProperty("callbacks"),(0,a.expect)(e.callbacks).toHaveProperty("onConsentSet",t)}})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";let __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__.n=e=>{var
|
|
2
|
+
"use strict";let __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__.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(a,{a:a}),a},__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});let jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_c15t_namespaceObject=require("c15t"),external_react_namespaceObject=require("react"),external_package_json_namespaceObject=require("../../package.json");var external_package_json_default=__webpack_require__.n(external_package_json_namespaceObject);let 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"),storeCache=new Map,managerCache=new Map;function clearConsentManagerCache(){storeCache.clear(),managerCache.clear()}function generateCacheKey(e,a,n){return`${e}:${a??"default"}:${n?"custom":"none"}`}function ConsentManagerProvider({children:e,options:a}){let{mode:n,backendURL:t,callbacks:r,store:c={},translations:_,react:o={}}=a,{initialGdprTypes:s,initialComplianceSettings:i}=c,{theme:l,disableAnimation:u=!1,scrollLock:p=!1,trapFocus:m=!0,colorScheme:b,noStyle:g=!1}=o,d=(0,external_react_namespaceObject.useMemo)(()=>"undefined"!=typeof window&&!!(("c15t"===n||"offline"===n)&&(t?.includes("c15t.dev")||t?.includes("c15t.cloud")||window.location.hostname.includes("c15t.dev")||window.location.hostname.includes("c15t.cloud"))),[n,t]),j=generateCacheKey(n||"c15t",t||"/api/c15t","endpointHandlers"in a?a.endpointHandlers:void 0),x=(0,external_react_namespaceObject.useMemo)(()=>{let e,_=managerCache.get(j);return _||(e="offline"===n?(0,external_c15t_namespaceObject.configureConsentManager)({mode:"offline",callbacks:r,store:c}):"custom"===n&&"endpointHandlers"in a?(0,external_c15t_namespaceObject.configureConsentManager)({mode:"custom",endpointHandlers:a.endpointHandlers,callbacks:r,store:c}):(0,external_c15t_namespaceObject.configureConsentManager)({mode:"c15t",backendURL:t||"/api/c15t",callbacks:r,store:c}),managerCache.set(j,e),e)},[j,n,t,r,c,a]),f=(0,external_react_namespaceObject.useMemo)(()=>{let e=storeCache.get(j);if(e)return e;let t=(0,external_c15t_namespaceObject.createConsentManagerStore)(x,{unstable_googleTagManager:a.unstable_googleTagManager,config:{pkg:"@c15t/react",version:external_package_json_default().version,mode:n||"Unknown"},ignoreGeoLocation:a.ignoreGeoLocation,initialGdprTypes:a.consentCategories,...c,isConsentDomain:d,initialTranslationConfig:_});return storeCache.set(j,t),t},[j,x,n,a.unstable_googleTagManager,a.ignoreGeoLocation,a.consentCategories,c,d,_]),[C,w]=(0,external_react_namespaceObject.useState)(()=>f?f.getState():{});(0,external_react_namespaceObject.useEffect)(()=>{if(!f)return;let{setGdprTypes:e,setComplianceSetting:n}=f.getState();if((s||a.consentCategories)&&e(s||a.consentCategories||[]),i)for(let[e,a]of Object.entries(i))n(e,a);return f.subscribe(w)},[f,s,i,a.consentCategories]);let h=(0,external_react_namespaceObject.useMemo)(()=>({theme:l,noStyle:g,disableAnimation:u,scrollLock:p,trapFocus:m,colorScheme:b}),[l,g,u,p,m,b]);(0,use_color_scheme_cjs_namespaceObject.useColorScheme)(b);let O=(0,external_react_namespaceObject.useMemo)(()=>{if(!f)throw Error("Consent store must be initialized before creating context value");return{state:C,store:f,manager:x}},[C,f,x]);return(0,jsx_runtime_namespaceObject.jsx)(consent_manager_context_cjs_namespaceObject.ConsentStateContext.Provider,{value:O,children:(0,jsx_runtime_namespaceObject.jsx)(theme_context_cjs_namespaceObject.GlobalThemeContext.Provider,{value:h,children:e})})}for(var __webpack_i__ in exports.ConsentManagerProvider=__webpack_exports__.ConsentManagerProvider,exports.clearConsentManagerCache=__webpack_exports__.clearConsentManagerCache,__webpack_exports__)-1===["ConsentManagerProvider","clearConsentManagerCache"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import type { ConsentManagerProviderProps } from '../types/consent-manager';
|
|
2
|
+
/**
|
|
3
|
+
* Clears all cached consent managers and stores.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This utility function is primarily intended for use in tests to ensure
|
|
7
|
+
* clean state between test cases. The module-level caches persist across
|
|
8
|
+
* component unmounts/remounts, which can cause test interference.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function clearConsentManagerCache(): void;
|
|
2
13
|
/**
|
|
3
14
|
* Provider component for consent management functionality.
|
|
4
15
|
*
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAY5E;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,sBAAsB,CAAC,EACtC,QAAQ,EACR,OAAO,GACP,EAAE,2BAA2B,2CAgM7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import*as e from"react/jsx-runtime";import*as
|
|
2
|
+
import*as e from"react/jsx-runtime";import*as n from"c15t";import*as t from"react";import*as o from"../../package.json";import*as r from"../context/consent-manager-context.js";import*as a from"../context/theme-context.js";import*as i from"../hooks/use-color-scheme.js";let s=new Map,c=new Map;function l(){s.clear(),c.clear()}function u({children:l,options:u}){var g,d,m;let{mode:f,backendURL:p,callbacks:C,store:M={},translations:v,react:h={}}=u,{initialGdprTypes:x,initialComplianceSettings:b}=M,{theme:w,disableAnimation:j=!1,scrollLock:S=!1,trapFocus:T=!0,colorScheme:k,noStyle:G=!1}=h,H=(0,t.useMemo)(()=>"undefined"!=typeof window&&!!(("c15t"===f||"offline"===f)&&(p?.includes("c15t.dev")||p?.includes("c15t.cloud")||window.location.hostname.includes("c15t.dev")||window.location.hostname.includes("c15t.cloud"))),[f,p]),L=(g=f||"c15t",d=p||"/api/c15t",m="endpointHandlers"in u?u.endpointHandlers:void 0,`${g}:${d??"default"}:${m?"custom":"none"}`),P=(0,t.useMemo)(()=>{let e,t=c.get(L);return t||(e="offline"===f?(0,n.configureConsentManager)({mode:"offline",callbacks:C,store:M}):"custom"===f&&"endpointHandlers"in u?(0,n.configureConsentManager)({mode:"custom",endpointHandlers:u.endpointHandlers,callbacks:C,store:M}):(0,n.configureConsentManager)({mode:"c15t",backendURL:p||"/api/c15t",callbacks:C,store:M}),c.set(L,e),e)},[L,f,p,C,M,u]),$=(0,t.useMemo)(()=>{let e=s.get(L);if(e)return e;let t=(0,n.createConsentManagerStore)(P,{unstable_googleTagManager:u.unstable_googleTagManager,config:{pkg:"@c15t/react",version:o.default.version,mode:f||"Unknown"},ignoreGeoLocation:u.ignoreGeoLocation,initialGdprTypes:u.consentCategories,...M,isConsentDomain:H,initialTranslationConfig:v});return s.set(L,t),t},[L,P,f,u.unstable_googleTagManager,u.ignoreGeoLocation,u.consentCategories,M,H,v]),[_,y]=(0,t.useState)(()=>$?$.getState():{});(0,t.useEffect)(()=>{if(!$)return;let{setGdprTypes:e,setComplianceSetting:n}=$.getState();if((x||u.consentCategories)&&e(x||u.consentCategories||[]),b)for(let[e,t]of Object.entries(b))n(e,t);return $.subscribe(y)},[$,x,b,u.consentCategories]);let E=(0,t.useMemo)(()=>({theme:w,noStyle:G,disableAnimation:j,scrollLock:S,trapFocus:T,colorScheme:k}),[w,G,j,S,T,k]);(0,i.useColorScheme)(k);let U=(0,t.useMemo)(()=>{if(!$)throw Error("Consent store must be initialized before creating context value");return{state:_,store:$,manager:P}},[_,$,P]);return(0,e.jsx)(r.ConsentStateContext.Provider,{value:U,children:(0,e.jsx)(a.GlobalThemeContext.Provider,{value:E,children:l})})}export{u as ConsentManagerProvider,l as clearConsentManagerCache};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c15t/react",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"license": "GPL-3.0-only",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"@radix-ui/react-switch": "1.1.4",
|
|
69
69
|
"clsx": "2.1.1",
|
|
70
70
|
"zustand": "^5.0.3",
|
|
71
|
-
"c15t": "1.4.
|
|
72
|
-
"@c15t/node-sdk": "1.4.
|
|
71
|
+
"c15t": "1.4.2",
|
|
72
|
+
"@c15t/node-sdk": "1.4.2"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@c15t/backend": "1.4.
|
|
75
|
+
"@c15t/backend": "1.4.2",
|
|
76
76
|
"@c15t/typescript-config": "0.0.1-beta.1",
|
|
77
77
|
"@c15t/vitest-config": "1.0.0"
|
|
78
78
|
},
|