Skip to content

Commit 24293c9

Browse files
Add Playwright configuration and initial test for cookie consent functionality
1 parent 0693945 commit 24293c9

File tree

7 files changed

+368
-9
lines changed

7 files changed

+368
-9
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ Thumbs.db
4747
.runtimeconfig.json
4848
adminSdkConf.json
4949

50+
51+
# Playwright
52+
/test-results/
53+
/playwright-report/
54+
/playwright/.cache/

angular.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@
127127
],
128128
"scripts": []
129129
}
130+
},
131+
"e2e": {
132+
"builder": "playwright-ng-schematics:playwright",
133+
"options": {
134+
"devServerTarget": "angularblogapp:serve"
135+
},
136+
"configurations": {
137+
"production": {
138+
"devServerTarget": "angularblogapp:serve:production"
139+
},
140+
"local": {
141+
"devServerTarget": "angularblogapp:serve:local"
142+
}
143+
}
130144
}
131145
}
132146
}

e2e/example.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
test('has title and handles cookie consent', async ({ page }) => {
4+
await page.goto('/');
5+
await expect(page).toHaveTitle(/AngularBlogApp/);
6+
7+
const cookieConsentDialog = page
8+
.getByLabel('Cookie Consent')
9+
.locator('div')
10+
.filter({ hasText: 'Cookie Consent Consent' })
11+
.nth(1);
12+
13+
await expect(cookieConsentDialog).toBeVisible();
14+
15+
const allowAllButton = page.getByRole('button', { name: 'Allow All' });
16+
await allowAllButton.click();
17+
18+
await expect(cookieConsentDialog).not.toBeVisible();
19+
});

e2e/tsconfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"include": ["./**/*.ts"]
4+
}

0 commit comments

Comments
 (0)