Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 8 additions & 12 deletions e2e/link-ms-user.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { execSync } from 'child_process';

import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';

Expand Down Expand Up @@ -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 }) => {
Expand All @@ -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']
});
Expand Down