From 574a0ea26f73a2610a381620ac5d6b120329315f Mon Sep 17 00:00:00 2001 From: Krzysztof G <60067306+gikf@users.noreply.github.com> Date: Mon, 5 Feb 2024 08:32:58 +0100 Subject: [PATCH] fix(playwright): remove localhost from expected url (#53532) --- e2e/bread-crumb.spec.ts | 30 ++++++++++++++---------------- e2e/completion-modal.spec.ts | 11 +++++------ 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/e2e/bread-crumb.spec.ts b/e2e/bread-crumb.spec.ts index 19712e87c75..6515bc75a1c 100644 --- a/e2e/bread-crumb.spec.ts +++ b/e2e/bread-crumb.spec.ts @@ -1,8 +1,14 @@ import { test, expect } from '@playwright/test'; const breadcrumbNavs = { - leftBreadcrumb: '(New) Foundational C# with Microsoft', - rightBreadcrumb: 'Write Your First Code Using C#' + left: { + text: '(New) Foundational C# with Microsoft', + url: '/learn/foundational-c-sharp-with-microsoft' + }, + right: { + text: 'Write Your First Code Using C#', + url: '/learn/foundational-c-sharp-with-microsoft/#write-your-first-code-using-c-sharp' + } }; test.beforeEach(async ({ page }) => { @@ -18,25 +24,19 @@ test.afterEach(async ({ page }) => { test.describe('Challenge Breadcrumb Component Tests', () => { test('breadcrumb nav links should be visible', async ({ page }) => { await expect( - page - .getByRole('listitem') - .filter({ hasText: breadcrumbNavs.leftBreadcrumb }) + page.getByRole('listitem').filter({ hasText: breadcrumbNavs.left.text }) ).toBeVisible(); await expect( - page - .getByRole('listitem') - .filter({ hasText: breadcrumbNavs.rightBreadcrumb }) + page.getByRole('listitem').filter({ hasText: breadcrumbNavs.right.text }) ).toBeVisible(); }); test('left breadcrumb nav link should have correct URL', async ({ page }) => { await page .getByRole('listitem') - .filter({ hasText: breadcrumbNavs.leftBreadcrumb }) + .filter({ hasText: breadcrumbNavs.left.text }) .click(); - await expect(page).toHaveURL( - 'http://localhost:8000/learn/foundational-c-sharp-with-microsoft' - ); + await expect(page).toHaveURL(breadcrumbNavs.left.url); }); test('right breadcrumb nav link should have correct URL', async ({ @@ -44,10 +44,8 @@ test.describe('Challenge Breadcrumb Component Tests', () => { }) => { await page .getByRole('listitem') - .filter({ hasText: breadcrumbNavs.rightBreadcrumb }) + .filter({ hasText: breadcrumbNavs.right.text }) .click(); - await expect(page).toHaveURL( - 'http://localhost:8000/learn/foundational-c-sharp-with-microsoft/#write-your-first-code-using-c-sharp' - ); + await expect(page).toHaveURL(breadcrumbNavs.right.url); }); }); diff --git a/e2e/completion-modal.spec.ts b/e2e/completion-modal.spec.ts index be6e9e63bb9..e6c87cf810c 100644 --- a/e2e/completion-modal.spec.ts +++ b/e2e/completion-modal.spec.ts @@ -1,6 +1,9 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; +const timeCalculatorUrl = + '/learn/scientific-computing-with-python/scientific-computing-with-python-projects/time-calculator'; + test.beforeEach(async ({ page }) => { await page.goto( '/learn/scientific-computing-with-python/scientific-computing-with-python-projects/arithmetic-formatter' @@ -41,9 +44,7 @@ test.describe('Challenge Completion Modal Tests (Signed Out)', () => { await page .getByRole('button', { name: translations.buttons['go-to-next'] }) .click(); - await expect(page).toHaveURL( - 'http://localhost:8000/learn/scientific-computing-with-python/scientific-computing-with-python-projects/time-calculator' - ); + await expect(page).toHaveURL(timeCalculatorUrl); }); }); @@ -72,8 +73,6 @@ test.describe('Challenge Completion Modal Tests (Signed In)', () => { await page .getByRole('button', { name: translations.buttons['submit-and-go'] }) .click(); - await expect(page).toHaveURL( - 'http://localhost:8000/learn/scientific-computing-with-python/scientific-computing-with-python-projects/time-calculator' - ); + await expect(page).toHaveURL(timeCalculatorUrl); }); });