Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests and upgrade dependencies #28

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"devDependencies": {
"@porscheofficial/prettier-config-porschedigital": "4.0.0",
"@types/node": "20.6.0",
"@types/node": "20.11.16",
"typescript": "5.2.2"
},
"packageManager": "[email protected]"
Expand Down
6 changes: 3 additions & 3 deletions packages/cookie-consent-banner-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
"@porscheofficial/eslint-config-porschedigital-react": "4.0.0",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
"eslint": "8.49.0",
"prettier": "3.0.3",
"eslint": "8.56.0",
"prettier": "3.2.5",
"react": "18.2.0",
"react-dom": "18.2.0",
"rimraf": "5.0.1",
"rimraf": "5.0.5",
"standard-version": "9.5.0",
"typescript": "5.2.2"
}
Expand Down
12 changes: 6 additions & 6 deletions packages/cookie-consent-banner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@
}
},
"dependencies": {
"@stencil/core": "4.2.1"
"@stencil/core": "4.12.0"
},
"devDependencies": {
"@porscheofficial/eslint-config-porschedigital-react": "4.0.0",
"@stencil/react-output-target": "0.5.3",
"@types/jest": "27.0.3",
"eslint": "8.49.0",
"@types/jest": "29.5.12",
"eslint": "8.56.0",
"eslint-plugin-html": "7.1.0",
"jest": "27.0.3",
"jest-cli": "27.4.5",
"prettier": "3.0.3",
"jest": "29.7.0",
"jest-cli": "29.7.0",
"prettier": "3.2.5",
"puppeteer": "21.2.1",
"standard-version": "9.5.0",
"typescript": "5.2.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,35 +213,44 @@ describe("Cookie Consent Banner", () => {
await page.setContent(cookieBannerFullyConfigured);
await page.waitForChanges();

// eslint-disable-next-line @typescript-eslint/no-explicit-any
await page.$eval("cookie-consent-banner", (elm: any) => {
/* eslint-disable @typescript-eslint/no-unsafe-member-access, no-param-reassign */
// within the browser's context
// let's set new property values on the component
elm.availableCategories = [
{
description:
"Enable you to navigate and use the basic functions and to store preferences.",
key: "technically_required",
label: "Technically necessary cookies",
isMandatory: true,
},
];
elm.cookieAttributes = {
expires: new Date("2024-01-01"),
secure: true,
sameSite: "lax",
};
/* eslint-enable @typescript-eslint/no-unsafe-member-access, no-param-reassign */
});
const inAWeek = new Date();
// eslint-disable-next-line no-magic-numbers, @typescript-eslint/no-magic-numbers
inAWeek.setDate(inAWeek.getDate() + 7);

await page.$eval(
"cookie-consent-banner",
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(elm: any, _inAWeekTimestamp) => {
/* eslint-disable @typescript-eslint/no-unsafe-member-access, no-param-reassign */
// within the browser's context
// let's set new property values on the component
elm.availableCategories = [
{
description:
"Enable you to navigate and use the basic functions and to store preferences.",
key: "technically_required",
label: "Technically necessary cookies",
isMandatory: true,
},
];
elm.cookieAttributes = {
expires: new Date(_inAWeekTimestamp),
secure: true,
sameSite: "lax",
};
},
inAWeek.getTime(),
);
await page.waitForChanges();
await clickInCookieBanner(".btn_accept_all");
await page.waitForChanges();

const cookieAcceptedCategories = await getConsentCookie();

// eslint-disable-next-line @typescript-eslint/no-magic-numbers
expect(cookieAcceptedCategories?.expires).toBe(1704067200);
expect(cookieAcceptedCategories?.expires).toBe(
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
Math.floor(inAWeek.getTime() / 1000), // Puppeteer returns seconds, JS uses milliseconds
);
expect(cookieAcceptedCategories?.secure).toBe(true);
expect(cookieAcceptedCategories?.sameSite).toBe("Lax");

Expand Down
6 changes: 5 additions & 1 deletion packages/cookie-consent-banner/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@
},
];

const inAWeek = new Date();
// eslint-disable-next-line no-magic-numbers
inAWeek.setDate(inAWeek.getDate() + 7);

cookieConsentBannerElement.cookieAttributes = {
expires: new Date("2024-01-01"),
expires: inAWeek,
path: "/",
domain: "localhost",
secure: true,
Expand Down
3 changes: 3 additions & 0 deletions packages/cookie-consent-banner/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ export const config: Config = {
serviceWorker: null, // disable service workers
},
],
testing: {
browserHeadless: "new",
},
};
Loading
Loading