From d1cb739924a1a5959d50e4b691b6c392bec46f6d Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:40:06 -0500 Subject: [PATCH] update --- .../src/page-objects/base-page.ts | 35 ++++++++++--------- .../src/analytics/cdn-settings-builder.ts | 10 ++++-- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts b/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts index 705e0f161..36b02af40 100644 --- a/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts +++ b/packages/consent/consent-tools-integration-tests/src/page-objects/base-page.ts @@ -15,9 +15,9 @@ export abstract class BasePage { async load(): Promise { const baseURL = browser.options.baseUrl assert(baseURL) + await this.mockCDNSettingsEndpoint() await waitUntilReady() await browser.url(baseURL + '/' + this.page) - await this.mockCDNSettingsEndpoint() } async clearStorage() { @@ -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, diff --git a/packages/test-helpers/src/analytics/cdn-settings-builder.ts b/packages/test-helpers/src/analytics/cdn-settings-builder.ts index 0309e2d20..1c69486f6 100644 --- a/packages/test-helpers/src/analytics/cdn-settings-builder.ts +++ b/packages/test-helpers/src/analytics/cdn-settings-builder.ts @@ -44,10 +44,10 @@ export class CDNSettingsBuilder { this.settings = settings } - addActionDestinationSettings( - ...remotePluginSettingsAndMore: I[] + addActionDestinationSettings( + ...destinations: DestinationSettingsBuilderConfig[] ) { - remotePluginSettingsAndMore.forEach((p) => { + destinations.forEach((p) => { const remotePlugin: RemotePlugin = { creationName: p.creationName ?? 'mockCreationName', libraryName: p.libraryName ?? 'mockLibraryName', @@ -72,4 +72,8 @@ export class CDNSettingsBuilder { build() { return this.settings } + + toJSON() { + return this.settings + } }