diff --git a/e2e/link-ms-user.spec.ts b/e2e/link-ms-user.spec.ts index 022982715fa..10c7c385354 100644 --- a/e2e/link-ms-user.spec.ts +++ b/e2e/link-ms-user.spec.ts @@ -1,3 +1,5 @@ +import { execSync } from 'child_process'; + import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; @@ -38,6 +40,9 @@ test.describe('Link MS user component (signed-out user)', () => { }); test.describe('Link MS user component (signed-in user)', () => { + test.afterEach(() => { + execSync('node ./tools/scripts/seed/seed-ms-username'); + }); test.use({ storageState: 'playwright/.auth/certified-user.json' }); test("should recognize the user's MS account", async ({ page }) => { @@ -48,23 +53,14 @@ test.describe('Link MS user component (signed-in user)', () => { }) ).toBeVisible(); - await expect( - page.getByText( - 'The Microsoft account with username "certifieduser" is currently linked to your freeCodeCamp account. If this is not your Microsoft username, remove the link.' - ) - ).toBeVisible(); + await expect(page.locator('main')).toHaveText( + /The Microsoft account with username "certifieduser" is currently linked to your freeCodeCamp account\. If this is not your Microsoft username, remove the link\./ + ); }); test('should allow the user to unlink their MS account and display a form for re-link', async ({ page }) => { - // Intercept the endpoint to prevent `msUsername` from being deleted - // as the deletion will cause subsequent tests to fail - await page.route('*/**/user/ms-username', async route => { - const json = { msUsername: null }; - await route.fulfill({ json }); - }); - const unlinkButton = page.getByRole('button', { name: translations.buttons['unlink-account'] });