Skip to content

Commit

Permalink
Merge 4bab2d4 into 76b1a73
Browse files Browse the repository at this point in the history
  • Loading branch information
emma-imber authored Nov 19, 2024
2 parents 76b1a73 + 4bab2d4 commit 7b633ee
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 91 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-games-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@guardian/commercial': minor
---

Use region specific bundles for Prebid
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@
"webpack-merge": "^6.0.1"
},
"dependencies": {
"@guardian/prebid.js": "8.52.0-8",
"@octokit/core": "^6.1.2",
"fastdom": "^1.0.11",
"lodash-es": "^4.17.21",
"prebid.js": "guardian/prebid.js#4d50ccf7d3f74561ef9d11a091fde5dd434d9810",
"process": "^0.11.10",
"tslib": "^2.6.2",
"web-vitals": "^4.2.1"
Expand Down
171 changes: 87 additions & 84 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 23 additions & 2 deletions src/init/consented/prepare-prebid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import type {
import { getConsentFor, log, onConsent } from '@guardian/libs';
import { commercialFeatures } from '../../lib/commercial-features';
import { prebid } from '../../lib/header-bidding/prebid/prebid';
import { isInCanada } from '../../utils/geo-utils';
import { isInCanada, isInUk } from '../../utils/geo-utils';
import { _ } from './prepare-prebid';

const { setupPrebid } = _;

jest.mock('utils/geo-utils', () => ({
isInCanada: jest.fn(() => false),
isInUk: jest.fn(),
}));

jest.mock('experiments/ab', () => ({
Expand Down Expand Up @@ -158,6 +159,7 @@ describe('init', () => {
commercialFeatures.adFree = false;
mockOnConsent(tcfv2WithConsent);
mockGetConsentFor(true);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(prebid.initialise).toBeCalled();
Expand All @@ -173,6 +175,7 @@ describe('init', () => {
fakeUserAgent('Google Web Preview');
mockOnConsent(tcfv2WithConsent);
mockGetConsentFor(true);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(prebid.initialise).not.toBeCalled();
Expand All @@ -188,6 +191,7 @@ describe('init', () => {
};
mockOnConsent(tcfv2WithConsent);
mockGetConsentFor(true);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(prebid.initialise).not.toBeCalled();
Expand All @@ -203,7 +207,7 @@ describe('init', () => {
commercialFeatures.adFree = false;
mockOnConsent(tcfv2WithConsent);
mockGetConsentFor(true);
(isInCanada as jest.Mock).mockReturnValueOnce(false);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(prebid.initialise).toBeCalled();
Expand Down Expand Up @@ -235,6 +239,7 @@ describe('init', () => {
commercialFeatures.adFree = false;
mockOnConsent(tcfv2WithConsent);
mockGetConsentFor(true);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(prebid.initialise).not.toBeCalled();
Expand All @@ -250,6 +255,7 @@ describe('init', () => {
commercialFeatures.adFree = true;
mockOnConsent(tcfv2WithConsent);
mockGetConsentFor(true);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(prebid.initialise).not.toBeCalled();
Expand All @@ -266,6 +272,7 @@ describe('init', () => {
window.guardian.config.page.hasPageSkin = true;
mockOnConsent(tcfv2WithConsent);
mockGetConsentFor(true);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(prebid.initialise).not.toBeCalled();
Expand All @@ -280,6 +287,7 @@ describe('init', () => {
window.guardian.config.page.hasPageSkin = false;
mockOnConsent(tcfv2WithConsent);
mockGetConsentFor(true);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(prebid.initialise).toBeCalled();
Expand All @@ -295,6 +303,8 @@ describe('init', () => {
commercialFeatures.adFree = false;
mockOnConsent(tcfv2WithConsent);
mockGetConsentFor(true);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(prebid.initialise).toBeCalled();
});
Expand All @@ -309,6 +319,7 @@ describe('init', () => {
commercialFeatures.adFree = false;
mockOnConsent(tcfv2WithoutConsent);
mockGetConsentFor(false);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(log).toHaveBeenCalledWith(
Expand All @@ -330,6 +341,8 @@ describe('init', () => {
commercialFeatures.adFree = false;
mockOnConsent(usnatWithConsent);
mockGetConsentFor(true);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(prebid.initialise).toBeCalled();
});
Expand All @@ -344,6 +357,7 @@ describe('init', () => {
commercialFeatures.adFree = false;
mockOnConsent(usnatWithoutConsent);
mockGetConsentFor(false);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(log).toHaveBeenCalledWith(
Expand All @@ -365,6 +379,8 @@ describe('init', () => {
commercialFeatures.adFree = false;
mockOnConsent(ausWithConsent);
mockGetConsentFor(true);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(prebid.initialise).toBeCalled();
});
Expand All @@ -379,6 +395,7 @@ describe('init', () => {
commercialFeatures.adFree = false;
mockOnConsent(ausWithoutConsent);
mockGetConsentFor(false);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(log).toHaveBeenCalledWith(
Expand All @@ -400,6 +417,7 @@ describe('init', () => {
commercialFeatures.adFree = false;
mockOnConsent(invalidWithoutConsent);
mockGetConsentFor(true);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(log).toHaveBeenCalledWith(
Expand All @@ -421,6 +439,7 @@ describe('init', () => {
commercialFeatures.adFree = false;
mockOnConsent(tcfv2WithConsent);
mockGetConsentForWithCustom(true, false);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(prebid.initialise).toBeCalled();
Expand All @@ -436,6 +455,7 @@ describe('init', () => {
commercialFeatures.adFree = false;
mockOnConsent(tcfv2WithConsent);
mockGetConsentForWithCustom(false, true);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(prebid.initialise).toBeCalled();
Expand All @@ -451,6 +471,7 @@ describe('init', () => {
commercialFeatures.adFree = false;
mockOnConsent(tcfv2WithConsent);
mockGetConsentForWithCustom(false, false);
(isInUk as jest.Mock).mockReturnValueOnce(true);

await setupPrebid();
expect(log).toHaveBeenCalledWith(
Expand Down
Loading

0 comments on commit 7b633ee

Please sign in to comment.