test: remove api mocks from link ms user spec (#54482)

Co-authored-by: Naomi <nhcarrigan@gmail.com>
This commit is contained in:
Oliver Eyton-Williams
2024-05-03 11:12:34 +02:00
committed by GitHub
parent 5ad1bfcc2b
commit 7214c2eb0c
+8 -12
View File
@@ -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']
});