From 4c7b0d23723d988444b08701d8fb90ba89f05ec8 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Mon, 3 Feb 2025 20:05:57 +0100 Subject: [PATCH] refactor: remove some imports from to e2e (#58556) --- client/src/utils/superblock-map-titles.ts | 2 +- e2e/failed-updates.spec.ts | 5 +- e2e/map.spec.ts | 95 ++++++++++++++++------- e2e/seo.spec.ts | 18 ++++- 4 files changed, 89 insertions(+), 31 deletions(-) diff --git a/client/src/utils/superblock-map-titles.ts b/client/src/utils/superblock-map-titles.ts index 7aae1629a5a..a5efa527d1b 100644 --- a/client/src/utils/superblock-map-titles.ts +++ b/client/src/utils/superblock-map-titles.ts @@ -9,7 +9,7 @@ enum SuperBlockI18nKeys { // the key above is used to create the last word for superBlock titles used on // the map and window. e.g. 'Certification' in Responsive Web Design // Certification -export const superBlocksWithoutLastWord = [ +const superBlocksWithoutLastWord = [ SuperBlocks.RespWebDesign, SuperBlocks.CodingInterviewPrep, SuperBlocks.TheOdinProject, diff --git a/e2e/failed-updates.spec.ts b/e2e/failed-updates.spec.ts index ae189198734..d9ffa82b3f2 100644 --- a/e2e/failed-updates.spec.ts +++ b/e2e/failed-updates.spec.ts @@ -1,6 +1,5 @@ import { execSync } from 'child_process'; import { test, expect } from '@playwright/test'; -import { ChallengeData } from '../tools/challenge-editor/api/interfaces/challenge-data'; const failedUpdates = [ { @@ -16,8 +15,8 @@ const failedUpdates = [ ]; const storeKey = 'fcc-failed-updates'; -function getCompletedIds(completedChallenges: ChallengeData[]): string[] { - return completedChallenges.map((challenge: ChallengeData) => challenge.id); +function getCompletedIds(completedChallenges: { id: string }[]): string[] { + return completedChallenges.map(challenge => challenge.id); } test.use({ storageState: 'playwright/.auth/development-user.json' }); diff --git a/e2e/map.spec.ts b/e2e/map.spec.ts index a7188659fba..00c19dcf748 100644 --- a/e2e/map.spec.ts +++ b/e2e/map.spec.ts @@ -1,22 +1,76 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; -import intro from '../client/i18n/locales/english/intro.json'; - -import { SuperBlockStage, superBlockStages } from '../shared/config/curriculum'; -import { superBlocksWithoutLastWord } from '../client/src/utils/superblock-map-titles'; test.beforeEach(async ({ page }) => { await page.goto('/learn'); }); -const superBlocksWithLinks = [ - ...superBlockStages[SuperBlockStage.Core], - ...superBlockStages[SuperBlockStage.Next], - ...superBlockStages[SuperBlockStage.English], - ...superBlockStages[SuperBlockStage.NextEnglish], - ...superBlockStages[SuperBlockStage.Professional], - ...superBlockStages[SuperBlockStage.Extra], - ...superBlockStages[SuperBlockStage.Legacy] +const LANDING_PAGE_LINKS = [ + { + slug: '2022/responsive-web-design', + name: 'Responsive Web Design Certification' + }, + { + slug: 'javascript-algorithms-and-data-structures-v8', + name: 'JavaScript Algorithms and Data Structures Certification' + }, + { + slug: 'front-end-development-libraries', + name: 'Front End Development Libraries Certification' + }, + { slug: 'data-visualization', name: 'Data Visualization Certification' }, + { slug: 'relational-database', name: 'Relational Database Certification' }, + { + slug: 'back-end-development-and-apis', + name: 'Back End Development and APIs Certification' + }, + { slug: 'quality-assurance', name: 'Quality Assurance Certification' }, + { + slug: 'scientific-computing-with-python', + name: 'Scientific Computing with Python Certification' + }, + { + slug: 'data-analysis-with-python', + name: 'Data Analysis with Python Certification' + }, + { slug: 'information-security', name: 'Information Security Certification' }, + { + slug: 'machine-learning-with-python', + name: 'Machine Learning with Python Certification' + }, + { + slug: 'college-algebra-with-python', + name: 'College Algebra with Python Certification' + }, + { + slug: 'full-stack-developer', + name: 'Certified Full Stack Developer Curriculum' + }, + { + slug: 'a2-english-for-developers', + name: 'A2 English for Developers (Beta) Certification' + }, + { + slug: 'b1-english-for-developers', + name: 'B1 English for Developers (Beta) Certification' + }, + { + slug: 'foundational-c-sharp-with-microsoft', + name: '(New) Foundational C# with Microsoft Certification' + }, + { slug: 'the-odin-project', name: 'The Odin Project - freeCodeCamp Remix' }, + { slug: 'coding-interview-prep', name: 'Coding Interview Prep' }, + { slug: 'project-euler', name: 'Project Euler' }, + { slug: 'rosetta-code', name: 'Rosetta Code' }, + { + slug: 'responsive-web-design', + name: 'Legacy Responsive Web Design Challenges' + }, + { + slug: 'javascript-algorithms-and-data-structures', + name: 'Legacy JavaScript Algorithms and Data Structures Certification' + }, + { slug: 'python-for-everybody', name: 'Legacy Python for Everybody' } ]; test.describe('Map Component', () => { @@ -31,27 +85,16 @@ test.describe('Map Component', () => { page.getByText(translations.landing['interview-prep-heading']) ).toBeVisible(); const curriculumBtns = page.getByTestId('curriculum-map-button'); - await expect(curriculumBtns).toHaveCount(superBlocksWithLinks.length); - - for (let i = 0; i < superBlocksWithLinks.length; i++) { - const addLastWord = !Object.values(superBlocksWithoutLastWord).includes( - superBlocksWithLinks[i] - ); - - const name = addLastWord - ? `${intro[superBlocksWithLinks[i]].title} Certification` - : intro[superBlocksWithLinks[i]].title; + await expect(curriculumBtns).toHaveCount(23); + for (const { name, slug } of LANDING_PAGE_LINKS) { const superblockLink = page.getByRole('link', { exact: true, name }); await expect(superblockLink).toBeVisible(); - await expect(superblockLink).toHaveAttribute( - 'href', - `/learn/${superBlocksWithLinks[i]}/` - ); + await expect(superblockLink).toHaveAttribute('href', `/learn/${slug}/`); } }); }); diff --git a/e2e/seo.spec.ts b/e2e/seo.spec.ts index ddc13fe4e35..1393bcc48f9 100644 --- a/e2e/seo.spec.ts +++ b/e2e/seo.spec.ts @@ -1,6 +1,5 @@ import { test, expect } from '@playwright/test'; import { SuperBlocks } from '../shared/config/curriculum'; -import type { ListItem } from '../client/src/components/seo/'; import metaTags from '../client/i18n/locales/english/meta-tags.json'; interface StructuredData { @@ -9,6 +8,23 @@ interface StructuredData { itemListElement: ListItem[]; } +interface ListItem { + '@type': string; + position: number; + item: { + '@type': string; + url: string; + name: string; + description: string; + provider: { + '@type': string; + name: string; + sameAs: string; + nonprofitStatus: string; + }; + }; +} + test.beforeEach(async ({ page }) => { await page.goto('/'); });