Skip to content

Commit 3528d93

Browse files
Updated code after Seth's review
1 parent 127f683 commit 3528d93

File tree

4 files changed

+41
-17
lines changed

4 files changed

+41
-17
lines changed

packages/consent/consent-tools-integration-tests/package.json

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@
33
"private": true,
44
"scripts": {
55
".": "yarn run -T turbo run --filter=@internal/consent-tools-integration-tests...",
6-
"test:int": "yarn wdio:local",
6+
"test:int": "playwright test",
77
"build": "webpack",
88
"watch": "yarn build --watch",
9-
"wdio:local": "wdio wdio.conf.local.ts",
109
"lint": "yarn concurrently 'yarn:eslint .' 'yarn:tsc --noEmit'",
1110
"eslint": "yarn run -T eslint",
1211
"tsc": "tsc",
1312
"concurrently": "yarn run -T concurrently --raw",
14-
"playwright-test": "playwright test",
15-
"playwright-test:headed": "playwright test --headed",
16-
"playwright-test:debug": "playwright test --debug",
17-
"serve": "http-server public -p 4567",
18-
"server": "http-server --port 5432",
19-
"browser": "playwright test --debug"
13+
"serve": "http-server --port 5432"
2014
},
2115
"installConfig": {
2216
"hoistingLimits": "workspaces"
@@ -27,17 +21,9 @@
2721
"@segment/analytics-consent-tools": "workspace:^",
2822
"@segment/analytics-consent-wrapper-onetrust": "workspace:^",
2923
"@segment/analytics-next": "workspace:^",
30-
"@wdio/cli": "^8.10.6",
31-
"@wdio/devtools-service": "^8.10.6",
32-
"@wdio/local-runner": "^8.10.6",
33-
"@wdio/mocha-framework": "^8.10.6",
34-
"@wdio/spec-reporter": "^8.10.6",
35-
"@wdio/static-server-service": "^8.10.6",
36-
"@wdio/types": "8",
3724
"expect": "^29.4.1",
3825
"globby": "^11.0.2",
3926
"http-server": "14.1.1",
40-
"wdio-intercept-service": "^4.4.0",
4127
"webpack": "^5.94.0",
4228
"webpack-cli": "^4.8.0"
4329
}

packages/consent/consent-tools-integration-tests/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import path from 'path'
77
*/
88
const config: PlaywrightTestConfig = {
99
webServer: {
10-
command: 'yarn run server',
10+
command: 'yarn serve',
1111
url: 'http://127.0.0.1:5432',
1212
reuseExistingServer: !process.env.CI,
1313
},
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Playwright Test targeting @segment/analytics-consent-wrapper-onetrust
3+
*
4+
* This test verifies that a consent changed event is sent
5+
* when the user clicks "Accept" on the OneTrust popup.
6+
*/
7+
8+
import page from '../page-objects/onetrust'
9+
import { test, expect } from '@playwright/test'
10+
11+
test.afterEach(async () => {
12+
await page.cleanup()
13+
})
14+
15+
test('should send a consent changed event when user clicks accept on popup', async ({
16+
page: pwPage,
17+
}) => {
18+
await page.load()
19+
20+
// Optional pause (if needed for visual confirmation or stability)
21+
await pwPage.waitForTimeout(1000)
22+
23+
// Initially, no consent change events should be sent
24+
expect(page.getConsentChangedEvents().length).toBe(0)
25+
26+
// Simulate user accepting consent via OneTrust popup
27+
await page.clickAcceptButtonAndClosePopup()
28+
29+
// Wait for one consent change event to be sent
30+
await expect
31+
.poll(() => page.getConsentChangedEvents().length, {
32+
timeout: 30000,
33+
interval: 100,
34+
})
35+
.toBe(1)
36+
})

yarn.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3169,6 +3169,7 @@ __metadata:
31693169
resolution: "@internal/consent-tools-integration-tests@workspace:packages/consent/consent-tools-integration-tests"
31703170
dependencies:
31713171
"@internal/test-helpers": "workspace:^"
3172+
"@playwright/test": ^1.28.1
31723173
"@segment/analytics-consent-tools": "workspace:^"
31733174
"@segment/analytics-consent-wrapper-onetrust": "workspace:^"
31743175
"@segment/analytics-next": "workspace:^"
@@ -3181,6 +3182,7 @@ __metadata:
31813182
"@wdio/types": 8
31823183
expect: ^29.4.1
31833184
globby: ^11.0.2
3185+
http-server: 14.1.1
31843186
wdio-intercept-service: ^4.4.0
31853187
webpack: ^5.94.0
31863188
webpack-cli: ^4.8.0

0 commit comments

Comments
 (0)