From f43d44451ba1e1fcffe873495b92e76b1cd006c2 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Wed, 25 Dec 2024 01:30:50 +0100 Subject: [PATCH] test: enable quiz and super-block-page spec (#57552) Co-authored-by: Naomi Carrigan Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com> --- .../components/super-block-accordion.tsx | 5 +- e2e/quiz-challenge.spec.ts | 19 ++---- e2e/super-block-page.spec.ts | 62 ++++--------------- 3 files changed, 21 insertions(+), 65 deletions(-) diff --git a/client/src/templates/Introduction/components/super-block-accordion.tsx b/client/src/templates/Introduction/components/super-block-accordion.tsx index e897e08e8b7..e4eca7ba173 100644 --- a/client/src/templates/Introduction/components/super-block-accordion.tsx +++ b/client/src/templates/Introduction/components/super-block-accordion.tsx @@ -106,7 +106,10 @@ const Chapter = ({ return ( - +
{ - test.skip( - () => process.env.SHOW_UPCOMING_CHANGES !== 'true', - 'The FSD superblock is not available if SHOW_UPCOMING_CHANGES is false' - ); - test.beforeEach(async ({ page }) => { await page.goto( '/learn/full-stack-developer/quiz-basic-html/quiz-basic-html' @@ -71,7 +66,7 @@ test.describe('Quiz challenge', () => { // The navigation should be blocked, the user should stay on the same page await expect(page).toHaveURL( - '/learn/front-end-development/quiz-basic-html/quiz-basic-html' + '/learn/full-stack-developer/quiz-basic-html/quiz-basic-html' ); await expect(page.getByRole('dialog')).toBeVisible(); @@ -88,7 +83,7 @@ test.describe('Quiz challenge', () => { .getByRole('button', { name: 'Yes, I want to leave the quiz' }) .click(); - await page.waitForURL('/learn/front-end-development/#quiz-basic-html'); + await page.waitForURL('/learn/full-stack-developer/#quiz-basic-html'); await expect( page.getByRole('heading', { level: 3, name: 'Basic HTML Quiz' }) ).toBeVisible(); @@ -107,21 +102,15 @@ test.describe('Quiz challenge', () => { .getByRole('button', { name: 'Yes, I want to leave the quiz' }) .click(); - await page.waitForURL('/learn/front-end-development/#quiz-basic-html'); + await page.waitForURL('/learn/full-stack-developer/#quiz-basic-html'); await expect( page.getByRole('heading', { level: 3, name: 'Basic HTML Quiz' }) ).toBeVisible(); }); test('should show a confirm exit modal when user closes the page', async ({ - page, - browserName + page }) => { - test.skip( - browserName === 'webkit' || browserName === 'chromium', - 'This test is flaky on Chromium and WebKit' - ); - // Wait for the page content to render await expect(page.getByRole('radiogroup')).toHaveCount(20); diff --git a/e2e/super-block-page.spec.ts b/e2e/super-block-page.spec.ts index cfcd2e96c4d..09d6cc564bb 100644 --- a/e2e/super-block-page.spec.ts +++ b/e2e/super-block-page.spec.ts @@ -103,11 +103,6 @@ test.describe('Super Block Page - Authenticated User', () => { }); test.describe('Super Block in Accordion View', () => { - test.skip( - () => process.env.SHOW_UPCOMING_CHANGES !== 'true', - 'The FSD superblock is not available if SHOW_UPCOMING_CHANGES is false' - ); - test('should expand the correct block when user goes to the page from breadcrumb click', async ({ page }) => { @@ -123,23 +118,18 @@ test.describe('Super Block Page - Authenticated User', () => { // Chapter await expect( - page.getByRole('button', { - name: 'CSS', - exact: true - }) + page.getByTestId('chapter-button').filter({ hasText: /CSS/ }) ).toHaveAttribute('aria-expanded', 'true'); // Module await expect( - page.getByRole('button', { - name: 'Basic CSS' - }) + page.getByRole('button', { name: /Basic CSS/ }) ).toHaveAttribute('aria-expanded', 'true'); // Block await expect( page.getByRole('button', { - name: 'Workshop Design a Cafe Menu' + name: /Workshop Design a Cafe Menu/ }) ).toHaveAttribute('aria-expanded', 'true'); }); @@ -158,24 +148,18 @@ test.describe('Super Block Page - Authenticated User', () => { // HTML chapter await expect( - page.getByRole('button', { - name: 'HTML', - exact: true - }) + page.getByTestId('chapter-button').filter({ hasText: /HTML/ }) ).toHaveAttribute('aria-expanded', 'true'); // Basic HTML module await expect( - page.getByRole('button', { - name: 'Basic HTML', - exact: true - }) + page.getByRole('button', { name: /Basic HTML/ }) ).toHaveAttribute('aria-expanded', 'true'); // What is HTML block await expect( page.getByRole('button', { - name: 'Lecture What is HTML?' + name: /Lecture What is HTML/ }) ).toHaveAttribute('aria-expanded', 'true'); }); @@ -189,23 +173,20 @@ test.describe('Super Block Page - Authenticated User', () => { // First chapter await expect( - page.getByRole('button', { - name: 'Welcome', - exact: true - }) + page.getByTestId('chapter-button').filter({ hasText: /Welcome/ }) ).toHaveAttribute('aria-expanded', 'true'); // First module await expect( page.getByRole('button', { - name: 'Getting Started with freeCodeCamp' + name: /Getting Started with freeCodeCamp/ }) ).toHaveAttribute('aria-expanded', 'true'); // First block await expect( page.getByRole('button', { - name: 'Lecture Welcome to freeCodeCamp' + name: /Lecture Welcome to freeCodeCamp/ }) ).toHaveAttribute('aria-expanded', 'true'); @@ -221,26 +202,17 @@ test.describe('Super Block Page - Authenticated User', () => { // The entire first chapter is collapsed await expect( - page.getByRole('button', { - name: 'Welcome', - exact: true - }) + page.getByTestId('chapter-button').filter({ hasText: /Welcome/ }) ).toHaveAttribute('aria-expanded', 'false'); // HTML chapter await expect( - page.getByRole('button', { - name: 'HTML', - exact: true - }) + page.getByTestId('chapter-button').filter({ hasText: /HTML/ }) ).toHaveAttribute('aria-expanded', 'true'); // Semantic HTML module await expect( - page.getByRole('button', { - name: 'Semantic HTML', - exact: true - }) + page.getByRole('button', { name: /^Semantic HTML/ }) ).toHaveAttribute('aria-expanded', 'true'); // Cat Blog Page block @@ -279,11 +251,6 @@ test.describe('Super Block Page - Unauthenticated User', () => { }); test.describe('Super Block in Accordion View', () => { - test.skip( - () => process.env.SHOW_UPCOMING_CHANGES !== 'true', - 'The FSD superblock is not available if SHOW_UPCOMING_CHANGES is false' - ); - test('should expand the first block of the super block', async ({ page }) => { @@ -291,10 +258,7 @@ test.describe('Super Block Page - Unauthenticated User', () => { // First chapter await expect( - page.getByRole('button', { - name: 'Welcome', - exact: true - }) + page.getByTestId('chapter-button').filter({ hasText: /Welcome/ }) ).toHaveAttribute('aria-expanded', 'true'); // First module