Skip to content

Commit 22bd2ac

Browse files
authored
Support headline AB tests on card sublinks (#16709)
* Support headline AB tests on card sublinks * Regenerate schemas * Add a couple of test cases for the supporting content type
1 parent 9262ef1 commit 22bd2ac

5 files changed

Lines changed: 261 additions & 3 deletions

File tree

dotcom-rendering/src/frontend/feFront.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ export type FESupportingContent = {
434434
properties: {
435435
href?: string;
436436
webUrl?: string;
437+
tests?: EditorialTest[];
437438
};
438439
header: {
439440
kicker?: {

dotcom-rendering/src/frontend/schemas/feFront.json

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,57 @@
950950
},
951951
"webUrl": {
952952
"type": "string"
953+
},
954+
"tests": {
955+
"type": "array",
956+
"items": {
957+
"type": "object",
958+
"properties": {
959+
"testUuid": {
960+
"type": "string"
961+
},
962+
"variantMeta": {
963+
"type": "array",
964+
"items": {
965+
"type": "object",
966+
"properties": {
967+
"id": {
968+
"$ref": "#/definitions/VariantId"
969+
},
970+
"meta": {
971+
"type": "object",
972+
"additionalProperties": {}
973+
}
974+
},
975+
"required": [
976+
"id",
977+
"meta"
978+
]
979+
}
980+
},
981+
"startDate": {
982+
"type": "number"
983+
},
984+
"expiryDate": {
985+
"type": "number"
986+
},
987+
"frontsThisTestCanRunOn": {
988+
"type": "array",
989+
"items": {
990+
"type": "string"
991+
}
992+
},
993+
"hasManuallyEndedOnThisTrail": {
994+
"type": "boolean"
995+
}
996+
},
997+
"required": [
998+
"frontsThisTestCanRunOn",
999+
"hasManuallyEndedOnThisTrail",
1000+
"testUuid",
1001+
"variantMeta"
1002+
]
1003+
}
9531004
}
9541005
}
9551006
},
@@ -1836,6 +1887,57 @@
18361887
},
18371888
"webUrl": {
18381889
"type": "string"
1890+
},
1891+
"tests": {
1892+
"type": "array",
1893+
"items": {
1894+
"type": "object",
1895+
"properties": {
1896+
"testUuid": {
1897+
"type": "string"
1898+
},
1899+
"variantMeta": {
1900+
"type": "array",
1901+
"items": {
1902+
"type": "object",
1903+
"properties": {
1904+
"id": {
1905+
"$ref": "#/definitions/VariantId"
1906+
},
1907+
"meta": {
1908+
"type": "object",
1909+
"additionalProperties": {}
1910+
}
1911+
},
1912+
"required": [
1913+
"id",
1914+
"meta"
1915+
]
1916+
}
1917+
},
1918+
"startDate": {
1919+
"type": "number"
1920+
},
1921+
"expiryDate": {
1922+
"type": "number"
1923+
},
1924+
"frontsThisTestCanRunOn": {
1925+
"type": "array",
1926+
"items": {
1927+
"type": "string"
1928+
}
1929+
},
1930+
"hasManuallyEndedOnThisTrail": {
1931+
"type": "boolean"
1932+
}
1933+
},
1934+
"required": [
1935+
"frontsThisTestCanRunOn",
1936+
"hasManuallyEndedOnThisTrail",
1937+
"testUuid",
1938+
"variantMeta"
1939+
]
1940+
}
18391941
}
18401942
}
18411943
},
@@ -2722,6 +2824,57 @@
27222824
},
27232825
"webUrl": {
27242826
"type": "string"
2827+
},
2828+
"tests": {
2829+
"type": "array",
2830+
"items": {
2831+
"type": "object",
2832+
"properties": {
2833+
"testUuid": {
2834+
"type": "string"
2835+
},
2836+
"variantMeta": {
2837+
"type": "array",
2838+
"items": {
2839+
"type": "object",
2840+
"properties": {
2841+
"id": {
2842+
"$ref": "#/definitions/VariantId"
2843+
},
2844+
"meta": {
2845+
"type": "object",
2846+
"additionalProperties": {}
2847+
}
2848+
},
2849+
"required": [
2850+
"id",
2851+
"meta"
2852+
]
2853+
}
2854+
},
2855+
"startDate": {
2856+
"type": "number"
2857+
},
2858+
"expiryDate": {
2859+
"type": "number"
2860+
},
2861+
"frontsThisTestCanRunOn": {
2862+
"type": "array",
2863+
"items": {
2864+
"type": "string"
2865+
}
2866+
},
2867+
"hasManuallyEndedOnThisTrail": {
2868+
"type": "boolean"
2869+
}
2870+
},
2871+
"required": [
2872+
"frontsThisTestCanRunOn",
2873+
"hasManuallyEndedOnThisTrail",
2874+
"testUuid",
2875+
"variantMeta"
2876+
]
2877+
}
27252878
}
27262879
}
27272880
},

dotcom-rendering/src/frontend/schemas/feTagPage.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,57 @@
793793
},
794794
"webUrl": {
795795
"type": "string"
796+
},
797+
"tests": {
798+
"type": "array",
799+
"items": {
800+
"type": "object",
801+
"properties": {
802+
"testUuid": {
803+
"type": "string"
804+
},
805+
"variantMeta": {
806+
"type": "array",
807+
"items": {
808+
"type": "object",
809+
"properties": {
810+
"id": {
811+
"$ref": "#/definitions/VariantId"
812+
},
813+
"meta": {
814+
"type": "object",
815+
"additionalProperties": {}
816+
}
817+
},
818+
"required": [
819+
"id",
820+
"meta"
821+
]
822+
}
823+
},
824+
"startDate": {
825+
"type": "number"
826+
},
827+
"expiryDate": {
828+
"type": "number"
829+
},
830+
"frontsThisTestCanRunOn": {
831+
"type": "array",
832+
"items": {
833+
"type": "string"
834+
}
835+
},
836+
"hasManuallyEndedOnThisTrail": {
837+
"type": "boolean"
838+
}
839+
},
840+
"required": [
841+
"frontsThisTestCanRunOn",
842+
"hasManuallyEndedOnThisTrail",
843+
"testUuid",
844+
"variantMeta"
845+
]
846+
}
796847
}
797848
}
798849
},

dotcom-rendering/src/model/enhanceCards.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {
22
FEFrontCardStyle,
33
FEMediaAsset,
44
FEMediaAtom,
5+
FESupportingContent,
56
} from '../frontend/feFront';
67
import { ArticleDesign, ArticleDisplay, Pillar } from '../lib/articleFormat';
78
import type { EditorialTest, VariantMeta } from '../types/front';
@@ -656,6 +657,16 @@ describe('Enhance Cards', () => {
656657
},
657658
};
658659

660+
const cardWithSublinkWithEditorialTest = {
661+
...cardWithNoEditorialTest,
662+
supportingContent: [cardWithEditorialTest],
663+
};
664+
665+
const cardWithSublinkWithExpiredEditorialTest = {
666+
...cardWithNoEditorialTest,
667+
supportingContent: [cardWithExpiredEditorialTest],
668+
};
669+
659670
it('returns the default headline if no editorial test exists on the card, page is not in allowed fronts list, and user is not in a test bucket', () => {
660671
expect(
661672
decideHeadline(
@@ -789,5 +800,33 @@ describe('Enhance Cards', () => {
789800
),
790801
).toEqual('Headline');
791802
});
803+
804+
it('returns the variant headline if an editorial test is present on a sublink', () => {
805+
expect(
806+
decideHeadline(
807+
cardWithSublinkWithEditorialTest
808+
.supportingContent[0] as FESupportingContent,
809+
{
810+
'fronts-and-curation-editorial-test': 'a',
811+
},
812+
true,
813+
'test-front',
814+
),
815+
).toEqual('Headline A');
816+
});
817+
818+
it('returns the default headline for a sublink if an editorial test is expired on a sublink', () => {
819+
expect(
820+
decideHeadline(
821+
cardWithSublinkWithExpiredEditorialTest
822+
.supportingContent[0] as FESupportingContent,
823+
{
824+
'fronts-and-curation-editorial-test': 'a',
825+
},
826+
true,
827+
'test-front',
828+
),
829+
).toEqual('Headline');
830+
});
792831
});
793832
});

0 commit comments

Comments
 (0)