Repository: freeCodeCamp/freeCodeCamp
File: e2e/unsubscribed.spec.ts (TypeScript)

Code before:
import { test, expect, type Page } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
import metaTags from '../client/i18n/locales/english/meta-tags.json';

let page: Page;

test.afterAll(async () => {
  await page.close();
});

test.describe('The unsubscribed page without unsubscribeId', () => {
  test.beforeAll(async ({ browser }) => {
    page = await browser.newPage();
    await page.goto('/unsubscribed');
  });

  test('The page renders with correct title', async () => {
    await expect(page).toHaveTitle(
      `${metaTags['youre-unsubscribed']} | freeCodeCamp.org`
    );
  });

  test('The page has correct main heading', async () => {
    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 () => {
    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 () => {
    const resubscribeButton = page.getByRole('link', {
      name: translations.buttons['resubscribe']
    });

    await expect(resubscribeButton).not.toBeVisible();
  });
});

test.describe('The unsubscribed page with unsubscribeId', () => {

Review comment (suggestion):
```suggestion
  test('The page has correct main heading', async ({ page }) => {
```

Code after:
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.afterEach(async ({ page }) => {
  await page.close();
});

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