Skip to content

Commit e1968a3

Browse files
Merge branch 'main' into al-1710-popstate
2 parents c54126d + e1eef0e commit e1968a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+700
-905
lines changed

ab-testing/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ To add a test where there is not enough space in the default audience space (`A`
6363

6464
For example if there are already 3 25% tests in space `A` totalling 75%, and you want to run a 50% test, you can set the `audienceSpace` to `B` to allow this test to overlap with the existing tests.
6565

66+
### Test Status
67+
68+
Tests can be set to `ON` or `OFF` using the `status` field. Only tests with status `ON` will be validated and deployed.
69+
6670
## How it works
6771

6872
The AB testing framework uses Deno to run scripts that validate and deploy the tests. The `deno.json` file contains the tasks that can be run, such as `validate`, `deploy`, and `build`.

ab-testing/abTest.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ import type { ABTest } from './types';
1919
* - 100% Test variant MVT 500-999
2020
*/
2121

22-
export const ABTests: ABTest[] = [];
22+
const ABTests: ABTest[] = [];
23+
24+
const activeABtests = ABTests.filter((test) => test.status === 'ON');
25+
26+
export { ABTests as allABTests, activeABtests };

ab-testing/frontend/src/routes/+page.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { ABTests } from '../../../abTest';
2+
import { allABTests, activeABtests } from '../../../abTest';
33
import Table from '$lib/components/TableFixed.svelte';
44
import AudienceBreakdown from '$lib/components/AudienceBreakdown.svelte';
55
</script>
@@ -31,8 +31,8 @@
3131
</p>
3232
</section>
3333
<section>
34-
<AudienceBreakdown tests={ABTests} />
35-
<Table tests={ABTests} />
34+
<AudienceBreakdown tests={activeABtests} />
35+
<Table tests={allABTests} />
3636
</section>
3737

3838
<style>

ab-testing/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @ts-ignore - extension is required to import this as a package in DCR
2-
import { ABTests } from './abTest.ts';
1+
import { allABTests, activeABtests } from './abTest';
32

4-
export { ABTests };
3+
export { allABTests, activeABtests };

ab-testing/scripts/build/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ABTests } from '../../abTest.ts';
21
import { getMVTGroupsFromDictionary } from '../lib/fastly-api.ts';
32
import { buildABTestGroupKeyValues } from './build-ab-tests-dict.ts';
43
import { parseArgs } from 'jsr:@std/cli/parse-args';
54
import { calculateAllSpaceUpdates } from './calculate-mvt-updates.ts';
65
import { parseMVTValue, stringifyMVTValue } from '../lib/fastly-subfield.ts';
76
import { dirname } from 'jsr:@std/path';
7+
import { activeABtests } from '../../abTest.ts';
88

99
const flags = parseArgs(Deno.args, {
1010
string: ['mvts', 'ab-tests'],
@@ -26,9 +26,9 @@ const mvtGroups = new Map(
2626
}),
2727
);
2828

29-
const abTestGroupKeyValues = buildABTestGroupKeyValues(ABTests);
29+
const abTestGroupKeyValues = buildABTestGroupKeyValues(activeABtests);
3030

31-
const mvtIdKeyValues = calculateAllSpaceUpdates(mvtGroups, ABTests);
31+
const mvtIdKeyValues = calculateAllSpaceUpdates(mvtGroups, activeABtests);
3232

3333
const mvtDictArray = Array.from(
3434
mvtIdKeyValues.entries().map(([key, value]) => ({

ab-testing/scripts/validation/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ABTests } from '../../abTest.ts';
21
import { ABTest } from '../../types.ts';
2+
import { activeABtests } from '../../abTest.ts';
33
import { enoughSpace } from './enoughSpace.ts';
44
import { limitServerSideTests } from './limitServerSide.ts';
55
import { uniqueName } from './uniqueName.ts';
@@ -19,7 +19,7 @@ function validateTests(testList: ABTest[]) {
1919
}
2020

2121
try {
22-
validateTests(ABTests);
22+
validateTests(activeABtests);
2323
console.log('AB test validations passed');
2424
} catch (err) {
2525
const error = err as Error;

ab-testing/scripts/validation/validExpiration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function allExpirationsValid(tests: ABTest[]): boolean {
1212
throw new Error(
1313
`${
1414
test.name
15-
} has an expiration date in the past: ${expires.toISOString()}, has it expired?`,
15+
} has an expiration date in the past: ${expires.toISOString()}, has it expired? If it doesn't belong to you or your team, you can set the status to OFF for now.`,
1616
);
1717
});
1818
}

dotcom-rendering/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@
5959
"@storybook/test": "8.6.14",
6060
"@storybook/theming": "8.6.14",
6161
"@svgr/webpack": "8.1.0",
62-
"@swc/cli": "0.7.7",
63-
"@swc/core": "1.11.31",
64-
"@swc/jest": "0.2.38",
65-
"@testing-library/dom": "10.4.0",
66-
"@testing-library/jest-dom": "6.6.3",
62+
"@swc/cli": "0.7.8",
63+
"@swc/core": "1.13.5",
64+
"@swc/jest": "0.2.39",
65+
"@testing-library/dom": "10.4.1",
66+
"@testing-library/jest-dom": "6.9.1",
6767
"@testing-library/react": "16.3.0",
6868
"@testing-library/user-event": "14.6.1",
6969
"@types/body-parser": "1.19.2",

dotcom-rendering/src/client/userFeatures/user-features.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const refresh = async (): Promise<void> => {
3030
const requestNewData = async () => {
3131
const authStatus = await getAuthStatus();
3232
if (authStatus.kind !== 'SignedIn') {
33+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
3334
return Promise.reject('The user is not signed in');
3435
}
3536
return syncDataFromUserBenefitsApi(authStatus).then(persistResponse);

dotcom-rendering/src/components/Avatar.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,17 @@ type Props = {
5757
alt: string;
5858
shape?: AvatarShape;
5959
imageSize?: MediaSizeType;
60-
isInAllBoostsTest?: boolean;
6160
};
6261

6362
const decideImageWidths = (
6463
imageSize: MediaSizeType,
65-
isInAllBoostsTest = false,
6664
): [ImageWidthType, ...ImageWidthType[]] => {
6765
switch (imageSize) {
6866
case 'small':
6967
return [
7068
{
7169
breakpoint: breakpoints.mobile,
72-
width: isInAllBoostsTest ? 150 : 80,
70+
width: 80,
7371
aspectRatio: '1:1',
7472
},
7573
];
@@ -144,15 +142,9 @@ const defaultImageSizes: [ImageWidthType, ...ImageWidthType[]] = [
144142
{ breakpoint: breakpoints.tablet, width: 140 },
145143
];
146144

147-
export const Avatar = ({
148-
src,
149-
alt,
150-
shape = 'round',
151-
imageSize,
152-
isInAllBoostsTest,
153-
}: Props) => {
145+
export const Avatar = ({ src, alt, shape = 'round', imageSize }: Props) => {
154146
const imageWidths = imageSize
155-
? decideImageWidths(imageSize, isInAllBoostsTest)
147+
? decideImageWidths(imageSize)
156148
: defaultImageSizes;
157149

158150
const sources = generateSources(getSourceImageUrl(src), imageWidths);

0 commit comments

Comments
 (0)