|
| 1 | +export const mockAuxiaResponseDismissible = { |
| 2 | + status: true, |
| 3 | + data: { |
| 4 | + userTreatment: { |
| 5 | + treatmentId: 'auxia-treatment-001', |
| 6 | + treatmentTrackingId: 'tracking-001', |
| 7 | + surface: 'signin-gate', |
| 8 | + treatmentContent: JSON.stringify({ |
| 9 | + title: 'Register for free and continue reading', |
| 10 | + subtitle: "It's still free to read – this is not a paywall", |
| 11 | + body: "We're committed to keeping our quality reporting open. By registering and providing us with insight into your preferences, you're helping us to engage with you more deeply.", |
| 12 | + first_cta_name: 'Register for free', |
| 13 | + first_cta_link: 'https://profile.theguardian.com/register', |
| 14 | + second_cta_name: "I'll do it later", |
| 15 | + }), |
| 16 | + }, |
| 17 | + }, |
| 18 | +}; |
| 19 | + |
| 20 | +export const mockAuxiaResponseNonDismissible = { |
| 21 | + status: true, |
| 22 | + data: { |
| 23 | + userTreatment: { |
| 24 | + treatmentId: 'auxia-treatment-002', |
| 25 | + treatmentTrackingId: 'tracking-002', |
| 26 | + surface: 'signin-gate', |
| 27 | + treatmentContent: JSON.stringify({ |
| 28 | + title: 'Complete registration to continue reading', |
| 29 | + subtitle: 'Registration is required to access this content', |
| 30 | + body: 'To continue reading this article and access our quality journalism, please complete your registration.', |
| 31 | + first_cta_name: 'Complete registration', |
| 32 | + first_cta_link: 'https://profile.theguardian.com/register', |
| 33 | + second_cta_name: '', // Empty makes it non-dismissible |
| 34 | + }), |
| 35 | + }, |
| 36 | + }, |
| 37 | +}; |
| 38 | + |
| 39 | +export const mockAuxiaResponseLegacy = { |
| 40 | + status: true, |
| 41 | + data: { |
| 42 | + userTreatment: { |
| 43 | + treatmentId: 'default-treatment-id', // This triggers legacy gate |
| 44 | + treatmentTrackingId: 'legacy-tracking', |
| 45 | + surface: 'signin-gate', |
| 46 | + treatmentContent: JSON.stringify({ |
| 47 | + title: 'Register to continue reading', |
| 48 | + subtitle: '', |
| 49 | + body: '', |
| 50 | + first_cta_name: 'Register', |
| 51 | + first_cta_link: 'https://profile.theguardian.com/register', |
| 52 | + second_cta_name: 'Not now', |
| 53 | + }), |
| 54 | + }, |
| 55 | + }, |
| 56 | +}; |
| 57 | + |
| 58 | +export const mockAuxiaResponseNoTreatment = { |
| 59 | + status: false, |
| 60 | + data: undefined, |
| 61 | +}; |
| 62 | + |
| 63 | +export const getAuxiaMock = (payload: string): unknown => { |
| 64 | + const body = JSON.parse(payload) as Record<string, unknown>; |
| 65 | + |
| 66 | + const mocks = { |
| 67 | + dismissable: mockAuxiaResponseDismissible, |
| 68 | + 'non-dismissable': mockAuxiaResponseNonDismissible, |
| 69 | + legacy: mockAuxiaResponseLegacy, |
| 70 | + 'no-treatment': mockAuxiaResponseNoTreatment, |
| 71 | + }; |
| 72 | + |
| 73 | + const key = body.sectionId as keyof typeof mocks; |
| 74 | + const mock: unknown = mocks[key]; |
| 75 | + |
| 76 | + return mock ?? mockAuxiaResponseNoTreatment; |
| 77 | +}; |
0 commit comments