chore: import upstream snapshot with attribution
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
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
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import translations from '../client/i18n/locales/english/translations.json';
|
||||
import metaTags from '../client/i18n/locales/english/meta-tags.json';
|
||||
|
||||
test.describe('The unsubscribed page without unsubscribeId', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/unsubscribed');
|
||||
});
|
||||
|
||||
test('The page renders with correct title', async ({ page }) => {
|
||||
await expect(page).toHaveTitle(
|
||||
`${metaTags['youre-unsubscribed']} | freeCodeCamp.org`
|
||||
);
|
||||
});
|
||||
|
||||
test('The page has correct main heading', async ({ page }) => {
|
||||
const mainHeading = page.getByTestId('main-heading');
|
||||
|
||||
await expect(mainHeading).toBeVisible();
|
||||
await expect(mainHeading).toContainText(translations.misc['unsubscribed']);
|
||||
});
|
||||
|
||||
test('The page has correct motivation text', async ({ page }) => {
|
||||
const motivationText = page.getByTestId('motivation-text');
|
||||
|
||||
await expect(motivationText).toBeVisible();
|
||||
await expect(motivationText).toContainText(
|
||||
translations.misc['keep-coding']
|
||||
);
|
||||
});
|
||||
|
||||
test('The page has no button to resubscribe', async ({ page }) => {
|
||||
const resubscribeButton = page.getByRole('link', {
|
||||
name: translations.buttons['resubscribe']
|
||||
});
|
||||
|
||||
await expect(resubscribeButton).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('The unsubscribed page with unsubscribeId', () => {
|
||||
const encoded_url_text =
|
||||
'?messages=success%5B0%5D%3DWe%2527ve%2520successfully%2520updated%2520your%2520email%2520preferences.%2520Thank%2520you%2520for%2520resubscribing.';
|
||||
// This value is sourced from self/freeCodeCamp/tools/scripts/seed/certified-user-data.js
|
||||
// The file certified-user-data.js is used to seed the database before running the tests.
|
||||
const unsubscribeId = 'tBX8stC5jiustPBteF2mV';
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto(`/unsubscribed/${unsubscribeId}`);
|
||||
});
|
||||
|
||||
test('The page renders with correct title and other texts', async ({
|
||||
page
|
||||
}) => {
|
||||
await expect(page).toHaveTitle(
|
||||
`${metaTags['youre-unsubscribed']} | freeCodeCamp.org`
|
||||
);
|
||||
|
||||
const mainHeading = page.getByTestId('main-heading');
|
||||
|
||||
await expect(mainHeading).toBeVisible();
|
||||
await expect(mainHeading).toContainText(translations.misc['unsubscribed']);
|
||||
|
||||
const motivationText = page.getByTestId('motivation-text');
|
||||
|
||||
await expect(motivationText).toBeVisible();
|
||||
await expect(motivationText).toContainText(
|
||||
translations.misc['keep-coding']
|
||||
);
|
||||
});
|
||||
|
||||
test('Resubscribe and redirect to home with encoded text in the url', async ({
|
||||
page
|
||||
}) => {
|
||||
const resubscribeButton = page.getByRole('link', {
|
||||
name: translations.buttons['resubscribe']
|
||||
});
|
||||
|
||||
await expect(resubscribeButton).toBeVisible();
|
||||
const resubscribeButtonHref = await resubscribeButton.getAttribute('href');
|
||||
expect(resubscribeButtonHref).toContain(`/resubscribe/${unsubscribeId}`);
|
||||
await resubscribeButton.click();
|
||||
|
||||
await expect(page).toHaveURL(`${encoded_url_text}`);
|
||||
await expect(
|
||||
page.getByText(
|
||||
"We've successfully updated your email preferences. Thank you for resubscribing."
|
||||
)
|
||||
).toBeVisible();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user