Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
26fb722
Added test case file: consent-tools-vanilla-opt-in.test.ts
neelkanth-kaushik Apr 21, 2025
e48f302
Replaced One Test Case from WebDriver.IO to Playwright: consent-tools…
neelkanth-kaushik Apr 21, 2025
86ffd28
Replaced One Test Case from WebDriver.IO to Playwright: consent-tools…
neelkanth-kaushik Apr 21, 2025
64136f7
Removed wdio.conf.local.ts
neelkanth-kaushik Apr 21, 2025
5a31945
Updated the code after Seth's feedback on the PR
neelkanth-kaushik Apr 23, 2025
127f683
Added Opt out test case
neelkanth-kaushik Apr 23, 2025
3528d93
Updated code after Seth's review
neelkanth-kaushik Apr 24, 2025
f2b70d4
Updated code after Seth's review
neelkanth-kaushik Apr 24, 2025
c82ee1d
Update the code of mockCDNSettingsAPI() to use CDNSettings
neelkanth-kaushik Apr 24, 2025
9a5cfa9
Update the code of mockCDNSettingsAPI() to use CDNSettings
neelkanth-kaushik Apr 24, 2025
eb27030
Replaced any[] with SegmentEvent[]
neelkanth-kaushik Apr 24, 2025
355a289
Removed any[] and replaced it with proper interfaces
neelkanth-kaushik Apr 24, 2025
68fd11a
WIP: One Trust Test Case
neelkanth-kaushik Apr 29, 2025
6cac5f9
WIP: One Trust Test Case
neelkanth-kaushik Apr 29, 2025
0f52a33
WIP: One Trust Test Case
neelkanth-kaushik Apr 29, 2025
cc45627
Skipped One Trust Case
neelkanth-kaushik May 5, 2025
bce7c7c
update README
silesky May 9, 2025
7afa571
finish migration
silesky May 9, 2025
dc4e34d
update CI
silesky May 9, 2025
d773b6b
remove unneeded globals
silesky May 9, 2025
6aec6ea
add gitignore to eslint rules
silesky May 9, 2025
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
14 changes: 14 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,21 @@ steps:
plugins:
- ssh://[email protected]/segmentio/cache-buildkite-plugin#v2.0.0:
key: "v1.1-cache-dev-{{ checksum 'yarn.lock' }}"

- label: '[Consent] Integration Tests'
agents:
queue: v1
commands:
- npm config set "//registry.npmjs.org/:_authToken" $${NPM_TOKEN}
- echo "--- Install dependencies"
- HUSKY=0 yarn install --immutable
- echo "--- Build + Test"
- yarn turbo run --filter='./packages/consent/consent-tools-integration-tests' test:int

plugins:
- ssh://[email protected]/segmentio/cache-buildkite-plugin#v2.0.0:
key: "v1.1-cache-dev-{{ checksum 'yarn.lock' }}"

- label: '[Signals] Lint + Test'
agents:
queue: v1
Expand Down
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/** @type { import('eslint').Linter.Config } */
module.exports = {
root: true,
ignorePatterns: ['node_modules', 'dist'],
ignorePatterns: require('eslint-gitignore').readGitignoreFiles({
cwd: __dirname,
}),
parserOptions: {
ecmaVersion: 2020,
},
Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,3 @@ jobs:
restore-keys: |
${{ runner.os }}-turbo-
- run: yarn turbo run --filter='./packages/node-integration-tests' test:cloudflare-workers
consent-intg-tests:
name: Consent Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: browser-actions/setup-chrome@v1
- uses: actions/setup-node@v3
with:
node-version: 16 # UPDATE TO NODE 20!!!
cache: 'yarn'
- run: yarn install --immutable
- name: Turbo cache
uses: actions/cache@v3
with:
path: node_modules/.cache/turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- run: yarn turbo run --filter='./packages/consent/consent-tools-integration-tests' test:int
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"concurrently": "^7.6.0",
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-gitignore": "^0.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.2",
"eslint-plugin-prettier": "^4.0.0",
Expand Down
15 changes: 1 addition & 14 deletions packages/consent/consent-tools-integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
Why is this using wd.io instead of playwright?

- Webdriver.io is committed to the Webdriver Protocol, which is a community-driven spec (as opposed to Chrome Webdriver Protocol.). Playwright uses the Chrome Webdriver protocol for chrome and it's own [custom protocol](https://github.com/microsoft/playwright/issues/4862) for safari / edge.
- Webdriver.io protocol allows for much better device support-- such as ie11.
- Webdriver.io has native support for lighthouse and lots of other cool stuff!
# @internal/consent-tools-integration-tests"

## Project structure
- `/public` - Test server root
Expand All @@ -18,12 +14,3 @@ Why is this using wd.io instead of playwright?
```
yarn . test:int
```

### Debugging Tips:
- Webdriver.io has the handy `browser.debug()` command.

- You can serve the static pages by themselves (without webdriver.io) with the following:
```
yarn webpack -w &
npx live-server .
```
17 changes: 6 additions & 11 deletions packages/consent/consent-tools-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,28 @@
"private": true,
"scripts": {
".": "yarn run -T turbo run --filter=@internal/consent-tools-integration-tests...",
"test:int": "yarn wdio:local",
"test:int": "playwright test",
"test:int-debug": "playwright test --debug",
"build": "webpack",
"watch": "yarn build --watch",
"wdio:local": "wdio wdio.conf.local.ts",
"lint": "yarn concurrently 'yarn:eslint .' 'yarn:tsc --noEmit'",
"eslint": "yarn run -T eslint",
"tsc": "tsc",
"concurrently": "yarn run -T concurrently --raw"
"concurrently": "yarn run -T concurrently --raw",
"serve": "http-server --port 5432"
},
"installConfig": {
"hoistingLimits": "workspaces"
},
"devDependencies": {
"@internal/test-helpers": "workspace:^",
"@playwright/test": "^1.28.1",
"@segment/analytics-consent-tools": "workspace:^",
"@segment/analytics-consent-wrapper-onetrust": "workspace:^",
"@segment/analytics-next": "workspace:^",
"@wdio/cli": "^8.10.6",
"@wdio/devtools-service": "^8.10.6",
"@wdio/local-runner": "^8.10.6",
"@wdio/mocha-framework": "^8.10.6",
"@wdio/spec-reporter": "^8.10.6",
"@wdio/static-server-service": "^8.10.6",
"@wdio/types": "8",
"expect": "^29.4.1",
"globby": "^11.0.2",
"wdio-intercept-service": "^4.4.0",
"http-server": "14.1.1",
"webpack": "^5.94.0",
"webpack-cli": "^4.8.0"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import type { PlaywrightTestConfig } from '@playwright/test'
import { devices } from '@playwright/test'
import path from 'path'

/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
webServer: {
command: 'yarn serve',
url: 'http://127.0.0.1:5432',
reuseExistingServer: !process.env.CI,
},
testDir: './src/tests',
globalSetup: path.resolve(__dirname, 'playwright.global-setup.ts'),
/* Maximum time one test can run for. */
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
},
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [['html', { open: 'never' }]],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
baseURL: `http://127.0.0.1:5432`,
trace: 'on',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
},
},
],
}

export default config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { FullConfig } from '@playwright/test'
import { execSync } from 'child_process'

export default function globalSetup(_cfg: FullConfig) {
console.log('Executing global setup...')
execSync('yarn build', { stdio: 'inherit' })
console.log('Finished global setup.')
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<script src="https://cdn.cookielaw.org/scripttemplates/otSDKStub.js" type="text/javascript" charset="UTF-8"
data-domain-script="80ca7b5c-e72f-4bd0-972a-b74d052a0820-test"></script>

<script src="/node_modules/@segment/analytics-consent-wrapper-onetrust/dist/umd/analytics-onetrust.umd.js"></script>

<script>
<!-- <script src="/node_modules/@segment/analytics-consent-wrapper-onetrust/dist/umd/analytics-onetrust.umd.js"></script> -->
<script src="dist/onetrust.bundle.js"></script>
<!-- <script>
!(function () {
var analytics = (window.analytics = window.analytics || [])
if (!analytics.initialize)
Expand Down Expand Up @@ -67,7 +67,7 @@
analytics.page()
}
})()
</script>
</script> -->
</head>

<body>
Expand All @@ -76,4 +76,4 @@ <h2>Please Check Network tab</h2>
<p>This page can used as playground or run by webdriver.io</p>
</body>

</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<body>
<h1>Hello World - Serving Analytics</h1>
<h2>Please Check Network tab</h2>
<p>This page can used as playground or run by webdriver.io</p>
<script src="/public/dist/consent-tools-vanilla-opt-in.bundle.js"></script>
<p>This page can used as playground or run by Playwright</p>
<script src="dist/consent-tools-vanilla-opt-in.bundle.js"></script>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<body>
<h1>Hello World - Serving Analytics (Consent Tools Vanilla Opt Out)</h1>
<h2>Please Check Network tab</h2>
<p>This page can used as playground or run by webdriver.io</p>
<script src="/public/dist/consent-tools-vanilla-opt-out.bundle.js"></script>
<p>This page can used as playground or run by Playwright</p>
<script src="dist/consent-tools-vanilla-opt-out.bundle.js"></script>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const analytics = new AnalyticsBrowser()

withMockCMP(analytics).load(
{
writeKey: '9lSrez3BlfLAJ7NOChrqWtILiATiycoc',
writeKey: 'foo',
},
{ initialPageview: true }
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { AnalyticsBrowser } from '@segment/analytics-next'
import { withOneTrust } from '@segment/analytics-consent-wrapper-onetrust'

const analytics = new AnalyticsBrowser()

withOneTrust(analytics).load(
{
writeKey: 'foo',
},
{ initialPageview: true }
)
;(window as any).analytics = analytics
Loading