Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
silesky committed Sep 6, 2023
1 parent c33ff51 commit d1cb739
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export abstract class BasePage {
async load(): Promise<void> {
const baseURL = browser.options.baseUrl
assert(baseURL)
await this.mockCDNSettingsEndpoint()
await waitUntilReady()
await browser.url(baseURL + '/' + this.page)
await this.mockCDNSettingsEndpoint()
}

async clearStorage() {
Expand All @@ -29,24 +29,27 @@ export abstract class BasePage {
* Mock the CDN Settings endpoint so that this can run offline
*/
private mockCDNSettingsEndpoint() {
const createConsentSettings = (categories: string[] = []) => ({
consentSettings: {
categories,
},
const settings = new CDNSettingsBuilder({
writeKey: 'something',
})
const settings = new CDNSettingsBuilder({ writeKey: 'something' })
.addActionDestinationSettings({
creationName: 'FullStory',
...createConsentSettings(['Analytics']),
})
.addActionDestinationSettings({
creationName: 'Actions Amplitude',
...createConsentSettings(['Advertising']),
})
.addActionDestinationSettings(
{
creationName: 'FullStory',
consentSettings: {
categories: ['Analytics'],
},
},
{
creationName: 'Actions Amplitude',
consentSettings: {
categories: ['Advertising'],
},
}
)
.build()

browser
.mock('https://cdn.segment.com/v1/projects/**/settings')
return browser
.mock('**/settings')
.then((mock) =>
mock.respond(settings, {
statusCode: 200,
Expand Down
10 changes: 7 additions & 3 deletions packages/test-helpers/src/analytics/cdn-settings-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export class CDNSettingsBuilder {
this.settings = settings
}

addActionDestinationSettings<I extends DestinationSettingsBuilderConfig>(
...remotePluginSettingsAndMore: I[]
addActionDestinationSettings(
...destinations: DestinationSettingsBuilderConfig[]
) {
remotePluginSettingsAndMore.forEach((p) => {
destinations.forEach((p) => {
const remotePlugin: RemotePlugin = {
creationName: p.creationName ?? 'mockCreationName',
libraryName: p.libraryName ?? 'mockLibraryName',
Expand All @@ -72,4 +72,8 @@ export class CDNSettingsBuilder {
build() {
return this.settings
}

toJSON() {
return this.settings
}
}

0 comments on commit d1cb739

Please sign in to comment.