dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
import { execSync } from 'child_process';
|
|
import { test, expect } from '@playwright/test';
|
|
|
|
import translations from '../client/i18n/locales/english/translations.json';
|
|
import { alertToBeVisible } from './utils/alerts';
|
|
|
|
test.describe("Email sign-up alert when user has not selected Quincy's newsletter preference", () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
// 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');
|
|
await page.goto('/learn');
|
|
});
|
|
|
|
test('should disable weekly newsletter if the user clicks No', async ({
|
|
page
|
|
}) => {
|
|
await expect(
|
|
page.getByText(translations.misc['email-blast'])
|
|
).toBeVisible();
|
|
|
|
const noThanksButton = page.getByRole('button', {
|
|
name: translations.buttons['no-thanks']
|
|
});
|
|
await expect(noThanksButton).toBeVisible();
|
|
await noThanksButton.click();
|
|
await alertToBeVisible(
|
|
page,
|
|
translations.flash['subscribe-to-quincy-updated']
|
|
);
|
|
await expect(
|
|
page.getByText(translations.misc['email-blast'])
|
|
).not.toBeVisible();
|
|
await page.goto('/settings');
|
|
await expect(
|
|
page.getByRole('button', { name: translations.buttons['no-thanks'] })
|
|
).toHaveAttribute('aria-pressed', 'true');
|
|
await expect(
|
|
page.getByRole('button', { name: translations.buttons['yes-please'] })
|
|
).toHaveAttribute('aria-pressed', 'false');
|
|
});
|
|
|
|
test('should enable weekly newsletter if the user clicks Yes', async ({
|
|
page
|
|
}) => {
|
|
await expect(
|
|
page.getByText(translations.misc['email-blast'])
|
|
).toBeVisible();
|
|
|
|
const yesPleaseButton = page.getByRole('button', {
|
|
name: translations.buttons['yes-please']
|
|
});
|
|
|
|
await expect(yesPleaseButton).toBeVisible();
|
|
await yesPleaseButton.click();
|
|
await alertToBeVisible(
|
|
page,
|
|
translations.flash['subscribe-to-quincy-updated']
|
|
);
|
|
await page.goto('/settings');
|
|
await expect(
|
|
page.getByRole('group', { name: translations.settings.email.weekly })
|
|
).toBeVisible();
|
|
await expect(
|
|
page.getByRole('button', { name: translations.buttons['yes-please'] })
|
|
).toHaveAttribute('aria-pressed', 'true');
|
|
await expect(
|
|
page.getByRole('button', { name: translations.buttons['no-thanks'] })
|
|
).toHaveAttribute('aria-pressed', 'false');
|
|
});
|
|
});
|