diff --git a/e2e/bread-crumb.spec.ts b/e2e/bread-crumb.spec.ts index 6515bc75a1c..f519ddcc435 100644 --- a/e2e/bread-crumb.spec.ts +++ b/e2e/bread-crumb.spec.ts @@ -1,51 +1,35 @@ import { test, expect } from '@playwright/test'; -const breadcrumbNavs = { - 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 }) => { await page.goto( '/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/trophy-write-your-first-code-using-c-sharp' ); }); -test.afterEach(async ({ page }) => { - await page.close(); -}); - test.describe('Challenge Breadcrumb Component Tests', () => { - test('breadcrumb nav links should be visible', async ({ page }) => { - await expect( - page.getByRole('listitem').filter({ hasText: breadcrumbNavs.left.text }) - ).toBeVisible(); - await expect( - page.getByRole('listitem').filter({ hasText: breadcrumbNavs.right.text }) - ).toBeVisible(); - }); + test('should display correctly', async ({ page }) => { + const superBlock = page.getByRole('listitem').first(); + await expect(superBlock).toBeVisible(); - test('left breadcrumb nav link should have correct URL', async ({ page }) => { - await page - .getByRole('listitem') - .filter({ hasText: breadcrumbNavs.left.text }) - .click(); - await expect(page).toHaveURL(breadcrumbNavs.left.url); - }); + const superBlockLink = superBlock.getByRole('link', { + name: '(New) Foundational C# with Microsoft' + }); + await expect(superBlockLink).toBeVisible(); + await expect(superBlockLink).toHaveAttribute( + 'href', + '/learn/foundational-c-sharp-with-microsoft' + ); - test('right breadcrumb nav link should have correct URL', async ({ - page - }) => { - await page - .getByRole('listitem') - .filter({ hasText: breadcrumbNavs.right.text }) - .click(); - await expect(page).toHaveURL(breadcrumbNavs.right.url); + const block = page.getByRole('listitem').last(); + await expect(superBlock).toBeVisible(); + + const blockLink = block.getByRole('link', { + name: 'Write Your First Code Using C#' + }); + await expect(blockLink).toBeVisible(); + await expect(blockLink).toHaveAttribute( + 'href', + '/learn/foundational-c-sharp-with-microsoft/#write-your-first-code-using-c-sharp' + ); }); });