Skip to content

Commit 01da7d3

Browse files
author
Juarez Mota
committed
test: check if auxia api is being called in sign-in gate
1 parent 15f93d2 commit 01da7d3

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

dotcom-rendering/playwright/tests/banner.e2e.spec.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { isUndefined } from '@guardian/libs';
22
import type { BrowserContext, Request } from '@playwright/test';
3-
import { test } from '@playwright/test';
3+
import { expect, test } from '@playwright/test';
44
import { cmpAcceptAll } from '../lib/cmp';
55
import { addCookie } from '../lib/cookies';
66
import { loadPage } from '../lib/load-page';
@@ -49,3 +49,41 @@ test.describe('The banner', function () {
4949
await rrBannerRequestPromise;
5050
});
5151
});
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

Comments
 (0)