diff --git a/e2e/email-sign-up.spec.ts b/e2e/email-sign-up.spec.ts index 721c7da4818..83bbe5071a6 100644 --- a/e2e/email-sign-up.spec.ts +++ b/e2e/email-sign-up.spec.ts @@ -1,3 +1,5 @@ +import { execSync } from 'child_process'; + import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; @@ -26,12 +28,6 @@ test.describe('Email sign-up page when user is not signed in', () => { test.use({ storageState: { cookies: [], origins: [] } }); test.beforeEach(async ({ page }) => { - // Intercept the endpoint to prevent `acceptedPrivacyTerms` from being set - await page.route('*/**/update-privacy-terms', async route => { - const json = [{ message: 'flash.privacy-updated', type: 'success' }]; - await route.fulfill({ json }); - }); - await page.goto('/email-sign-up'); }); @@ -110,22 +106,12 @@ test.describe('Email sign-up page when user is signed in', () => { 'user appears to not signed in on Webkit' ); - await page.route('*/**/user/get-session-user', async route => { - const response = await route.fetch(); - const json = await response.json(); - - // /email-sign-up is only accessible if `acceptedPrivacyTerms` is `false`. - // We need to patch the response in order to access the page. - json.user.certifieduser.acceptedPrivacyTerms = false; - json.user.certifieduser.sendQuincyEmail = false; - await route.fulfill({ json }); - }); - - // Intercept the endpoint to prevent `acceptedPrivacyTerms` from being set - await page.route('*/**/update-privacy-terms', async route => { - const json = [{ message: 'flash.privacy-updated', type: 'success' }]; - await route.fulfill({ json }); - }); + // It's necessary to seed with a user that has not accepted the privacy + // terms, otherwise the user will be redirected away from the email sign-up + // page. + execSync( + 'node ./tools/scripts/seed/seed-demo-user certified-user --unset-privacy-terms' + ); await page.goto('/email-sign-up'); });