Repository: freeCodeCamp/freeCodeCamp
File: e2e/show-cert-from-superblock.spec.ts (TypeScript)

Code before:
  ]
};

test.describe('Front End Development Libraries Superblock', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/learn/front-end-development-libraries');
  });

  test('should navigate to "/settings#cert-front-end-development-libraries" when clicking the "Go to settings to claim your certification" anchor', async ({
    page
  }) => {
    await page
      .getByRole('link', { name: 'Go to settings to claim your certification' })
      .click();
    expect(page.url()).toContain(
      '/settings#cert-front-end-development-libraries'
    );
  });
});

test.describe('After submitting all 5 projects', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/settings');
  });

  test('should be possible to view certifications from the settings page', async ({
    page
  }) => {
    await submitFrontEndSolutions(page);
    await page.goto(`/learn/${projects.superBlock}/`);
    await page
      .getByRole('link', { name: 'Go to settings to claim your certification' })
      .click();
    expect(page.url()).toContain('/settings');

    await page.getByTestId('radioBisLocked').click();
    await page.getByTestId('radioBname').click();
    await page.getByTestId('radioBshowCerts').click();
    await page.getByTestId('radioBshowTimeLine').click();

    await page.getByRole('button', { name: 'Save' }).nth(2).click();

    await page
      .getByRole('button', {
        name: "I agree to freeCodeCamp's Academic Honesty Policy."
      })
      .click();
    await page.getByTestId('btn-for-front-end-development-libraries').click();
    await page.getByRole('link', { name: 'Show Certification' }).click();
    await page.waitForURL(
      `/certification/developmentuser/${projects.superBlock}`

Review comment (suggestion):
You might hate me for this, but I removed this test case in #54689 because the test is very similar to what the `projects.spec.ts` covers. And... this means we don't need to rewrite the test here.

Here is the commit: [`0f79f41` (#54689)](https://github.com/freeCodeCamp/freeCodeCamp/pull/54689/commits/0f79f41c195110bae6876560a5dcc6f9a4a27675).

I think with `show-cert-from-superblock`, we would need to confirm that:
- There is a "Go to settings..."  link on the curriculum page if the user has not claimed the cert.
- There is a "Show Certification" link on the curriculum page if the user has claimed the cert.

Code after:
import { execSync } from 'child_process';
import { expect, test } from '@playwright/test';

test.describe('When the user HAS NOT claimed their cert', () => {
  test.use({ storageState: 'playwright/.auth/development-user.json' });

  test.beforeAll(() => {
    execSync('node ./tools/scripts/seed/seed-demo-user');
  });

  test.beforeEach(async ({ page }) => {
    await page.goto('/learn/front-end-development-libraries');
  });

  test('should see a "Go to settings to claim your certification" pointing to "/settings#cert-front-end-development-libraries"', async ({
    page
  }) => {
    const link = page.getByRole('link', {
      name: 'Go to settings to claim your certification'
    });

    await expect(link).toBeVisible();
    await expect(link).toHaveAttribute(
      'href',
      '/settings#cert-front-end-development-libraries'
    );
  });

  test.afterAll(() => {
    execSync('node ./tools/scripts/seed/seed-demo-user certified-user');
  });
});

test.describe('When the user HAS claimed their cert', () => {
  test.use({ storageState: 'playwright/.auth/certified-user.json' });

  test.beforeEach(async ({ page }) => {
    await page.goto('/learn/front-end-development-libraries');
  });

  test('should see a "Show Certification" link pointing to "/certification/certifieduser/front-end-development-libraries"', async ({
    page
  }) => {
    const link = page.getByRole('link', {
      name: 'Show Certification'
    });

    await expect(link).toBeVisible();
    await expect(link).toHaveAttribute(
      'href',
      '/certification/certifieduser/front-end-development-libraries'
    );
  });
});