Skip to content

Commit

Permalink
refactor and use @guardian/ab-core in commrcial (#1457)
Browse files Browse the repository at this point in the history
* initial refactor of ab tests and related code

* remove ab-ophan modue

* fix jest test fail for setTargetting

* remove redundant modules

* add changeset

* Update src/experiments/ab.ts

Co-authored-by: Jake <[email protected]>

* update pnpm-lock

* update pnpm lock

* update logs to commercial

---------

Co-authored-by: Jake <[email protected]>
  • Loading branch information
dskamiotis and Jakeii authored Jul 19, 2024
1 parent ba4b7d9 commit 25031be
Show file tree
Hide file tree
Showing 20 changed files with 151 additions and 764 deletions.
5 changes: 5 additions & 0 deletions .changeset/rotten-vans-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@guardian/commercial': patch
---

replaces current ab test library with @guardian/ab-core
1 change: 1 addition & 0 deletions jest.setupTestFrameworkScriptFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ window.guardian = {
},
ophan: {
pageViewId: 'dummy_pvid_123456790',
record: jest.fn(),
},
css: {},
adBlockers: {
Expand Down
97 changes: 0 additions & 97 deletions src/experiments/ab-core.ts

This file was deleted.

31 changes: 0 additions & 31 deletions src/experiments/ab-local-storage.ts

This file was deleted.

119 changes: 0 additions & 119 deletions src/experiments/ab-ophan.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/experiments/ab-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { mpuWhenNoEpic } from './tests/mpu-when-no-epic';
* the commercial code. Any test here also needs to be in both DCR and Frontend,
* but any tests in DCR and Frontend do not need to necessarily be added here.
*/
export const concurrentTests: readonly ABTest[] = [
export const concurrentTests: ABTest[] = [
// one test per line
mpuWhenNoEpic,
];
13 changes: 1 addition & 12 deletions src/experiments/ab-url.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { ABTest, Participations, Variant } from '@guardian/ab-core';
import { testAndParticipationsToVariant } from './ab-utils';
import type { Participations } from '@guardian/ab-core';

export const getForcedParticipationsFromUrl = (): Participations => {
if (window.location.hash.startsWith('#ab')) {
Expand All @@ -21,13 +20,3 @@ export const getForcedParticipationsFromUrl = (): Participations => {

return {};
};

// If the given test has a variant which is forced by the URL, return it
export const getVariantFromUrl = (test: ABTest): Variant | null | undefined =>
testAndParticipationsToVariant(test, getForcedParticipationsFromUrl());

// Useful if you want to force a test even when it normally wouldn't run
// (for example, to display a specific epic variant to verify it renders
// okay).
export const getIgnoreCanRunFromUrl = (): boolean =>
window.location.hash.includes('ignoreCanRun=true');
75 changes: 0 additions & 75 deletions src/experiments/ab-utils.ts

This file was deleted.

Loading

0 comments on commit 25031be

Please sign in to comment.