Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
silesky committed Sep 6, 2023
1 parent 77dbfba commit 89c2929
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"hoistingLimits": "workspaces"
},
"devDependencies": {
"@internal/test-helpers": "workspace:^",
"@segment/analytics-consent-tools": "workspace:^",
"@segment/analytics-consent-wrapper-onetrust": "workspace:^",
"@segment/analytics-next": "workspace:^",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
n.parentNode.insertBefore(t, n)
analytics._loadOptions = e
}
analytics._writeKey = '9lSrez3BlfLAJ7NOChrqWtILiATiycoc'
analytics._writeKey = 'foo'
analytics.SNIPPET_VERSION = '4.15.3'

withOneTrust(analytics).load('9lSrez3BlfLAJ7NOChrqWtILiATiycoc') // modified
withOneTrust(analytics).load('foo') // modified
analytics.page()
}
})()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ export const analytics = new AnalyticsBrowser()
wrap(analytics)

analytics.load({
writeKey: '9lSrez3BlfLAJ7NOChrqWtILiATiycoc',
writeKey: 'foo',
})
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CDNSettingsBuilder } from '@internal/test-helpers'
import assert from 'assert'

const waitUntilReady = () =>
Expand All @@ -16,13 +17,48 @@ export abstract class BasePage {
assert(baseURL)
await waitUntilReady()
await browser.url(baseURL + '/' + this.page)
await this.mockCDNSettingsEndpoint()
}

async clearStorage() {
await browser.deleteAllCookies()
await browser.execute(() => localStorage.clear())
}

/**
* Mock the CDN Settings endpoint so that this can run offline
*/
private mockCDNSettingsEndpoint() {
const createConsentSettings = (categories: string[] = []) => ({
consentSettings: {
categories,
},
})
browser
.mock('https://cdn.segment.com/v1/projects/**/settings')
.then((mock) =>
mock.respond(
new CDNSettingsBuilder({ writeKey: 'something' })
.addActionDestinationSettings({
creationName: 'FullStory',
...createConsentSettings(['Analytics']),
})
.addActionDestinationSettings({
creationName: 'Actions Amplitude',
...createConsentSettings(['Advertising']),
})
.build(),
{
statusCode: 200,
headers: {
'Content-Type': 'application/json',
},
}
)
)
.catch(console.error)
}

/**
* Hard reload the page
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { expect } from 'expect'
import { Context } from '@segment/analytics-next'

// Verify that the consent tools wrapper is working as expected (no OneTrust)

it('should stamp each event', async () => {
await page.load()

const commands = [
`analytics.track("hello world")`,
`analytics.alias("foo", "bar")`,
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2359,6 +2359,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@internal/consent-tools-integration-tests@workspace:packages/consent/consent-tools-integration-tests"
dependencies:
"@internal/test-helpers": "workspace:^"
"@segment/analytics-consent-tools": "workspace:^"
"@segment/analytics-consent-wrapper-onetrust": "workspace:^"
"@segment/analytics-next": "workspace:^"
Expand Down

0 comments on commit 89c2929

Please sign in to comment.