Skip to content

Commit 125b3ec

Browse files
committed
Tests: Fix issue where consent pops up after click event
1 parent d19b2a5 commit 125b3ec

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ list help::
1616
@echo "<PRE-COMMIT>"
1717
@echo " setup-pre-commit: Sets up pre-commit (assuming it is installed)"
1818
@echo "<PLAYWRIGHT TESTS>"
19-
@echo " tests: Runs playwright against the old theme."
20-
@echo " tests-update-screenshots: Runs playwright against the old theme."
19+
@echo " tests: Runs playwright against the new theme."
20+
@echo " tests-update-screenshots: Runs playwright against the new theme."
2121

2222
.PHONY: biome-format biome-lint biome-all setup-pre-commit tests build-example-site
2323
FLAG :=

layouts/partials/header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
{{ partial "lucide" (dict "context" . "icon" "chevron-down") }}
4444
</span>
4545
</button>
46-
<div class="dropdown-content" id="dropdown-content" data-testid="header__f5sites_content">
46+
<div class="dropdown-content" id="dropdown-content" data-testid="header__f5sites__content">
4747
<ul>
4848
{{ range $f5Sites }}
4949
<li>

tests/playwright.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export default defineConfig({
1414
screenshots: 'only-on-failure',
1515
video: 'retain-on-failure',
1616
trace: 'on-first-retry',
17-
timezoneId: 'America/Los_Angeles',
17+
geolocation: { longitude: -8.486316, latitude: 51.896893 },
18+
permissions: ['geolocation'],
1819
},
1920
projects: [
2021
{

tests/src/header.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ test.describe('Smoke test for header', () => {
4646
test('F5 Sites button works', async ({ page }) => {
4747
const f5SitesButton = await page.getByTestId('header__f5sites__button');
4848
await f5SitesButton.click();
49-
const f5SitesContent = await page.getByTestId('header__f5sites_content');
49+
const f5SitesContent = await page.getByTestId('header__f5sites__content');
5050
await expect(f5SitesContent.count()).toBeTruthy();
5151
});
5252
});

tests/src/sidebar.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ async function openPage(page, sidebarPage) {
4040
}
4141

4242
test.describe('Smoke test for sidebar', () => {
43+
44+
// Slow test
45+
test.setTimeout(100_000);
46+
4347
test.beforeEach(async ({ page }) => {
4448
await page.goto('/test-product/');
4549
});

tests/src/util.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ export async function runSmokeTestOnPage(page) {
1212

1313
// THE GDPR Consent button appears when test is run from EU locations. This handles that popup.
1414
export async function handleConsentPopup(page) {
15-
const consentContent = page.locator('#truste-consent-content');
16-
const isConsentContentVisibile = await consentContent.isVisible();
17-
if (isConsentContentVisibile) {
18-
const consentButton = page.locator('#truste-consent-required');
19-
expect(consentButton).toBeVisible();
20-
await consentButton.click();
21-
}
15+
await page.addLocatorHandler(
16+
page.locator('#truste-consent-content'),
17+
async () => {
18+
const consentButton = page.locator('#truste-consent-required');
19+
expect(consentButton).toBeVisible();
20+
await consentButton.click();
21+
}
22+
);
2223
}
2324

2425
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

0 commit comments

Comments
 (0)