|
1 | 1 | import { isUndefined } from '@guardian/libs'; |
2 | 2 | import type { BrowserContext, Request } from '@playwright/test'; |
3 | | -import { test } from '@playwright/test'; |
| 3 | +import { expect, test } from '@playwright/test'; |
4 | 4 | import { cmpAcceptAll } from '../lib/cmp'; |
5 | 5 | import { addCookie } from '../lib/cookies'; |
6 | 6 | import { loadPage } from '../lib/load-page'; |
@@ -49,3 +49,41 @@ test.describe('The banner', function () { |
49 | 49 | await rrBannerRequestPromise; |
50 | 50 | }); |
51 | 51 | }); |
| 52 | + |
| 53 | +test.describe('Sign-in gate portal', function () { |
| 54 | + test('makes a request to the auxia', async ({ page, context }) => { |
| 55 | + await optOutOfArticleCountConsent(context); |
| 56 | + |
| 57 | + const auxiaUrl = |
| 58 | + 'https://contributions.guardianapis.com/auxia/get-treatments'; |
| 59 | + const auxiaRequestPromise = page.waitForRequest((request) => |
| 60 | + requestBodyHasProperties(request, auxiaUrl, ['isSupporter']), |
| 61 | + ); |
| 62 | + |
| 63 | + await loadPage({ |
| 64 | + page, |
| 65 | + path: `/Article/https://www.theguardian.com/politics/2019/nov/20/jeremy-corbyn-boris-johnson-tv-debate-watched-by-67-million-people`, |
| 66 | + waitUntil: 'domcontentloaded', |
| 67 | + region: 'GB', |
| 68 | + preventSupportBanner: false, |
| 69 | + queryParamsOn: true, |
| 70 | + queryParams: { showgate: 'true' }, |
| 71 | + }); |
| 72 | + |
| 73 | + await cmpAcceptAll(page); |
| 74 | + |
| 75 | + await page.evaluate(() => { |
| 76 | + // Set geolocation to IE to force the sign-in gate to appear |
| 77 | + window.localStorage.setItem('gu.geo.override', 'IE'); |
| 78 | + }); |
| 79 | + |
| 80 | + await page.reload({ waitUntil: 'domcontentloaded' }); |
| 81 | + |
| 82 | + const signInGateIsland = page.locator('#sign-in-gate'); |
| 83 | + await expect(signInGateIsland).toHaveCount(1, { timeout: 1_000 }); |
| 84 | + // Scroll to the sign-in gate to trigger auxia api call |
| 85 | + await signInGateIsland.scrollIntoViewIfNeeded(); |
| 86 | + |
| 87 | + await auxiaRequestPromise; |
| 88 | + }); |
| 89 | +}); |
0 commit comments