Skip to content

Commit 85a2af8

Browse files
committed
e2e/acceptance/email-confirmation: Migrate from mirage to @crates-io/msw
1 parent 1eb3d76 commit 85a2af8

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

e2e/acceptance/email-confirmation.spec.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
1-
import { test, expect } from '@/e2e/helper';
1+
import { expect, test } from '@/e2e/helper';
22

33
test.describe('Acceptance | Email Confirmation', { tag: '@acceptance' }, () => {
4-
test('unauthenticated happy path', async ({ page, mirage }) => {
5-
await mirage.addHook(server => {
6-
let user = server.create('user', { emailVerificationToken: 'badc0ffee' });
7-
globalThis.user = user;
8-
});
4+
test('unauthenticated happy path', async ({ page, msw }) => {
5+
let user = msw.db.user.create({ emailVerificationToken: 'badc0ffee' });
96

107
await page.goto('/confirm/badc0ffee');
11-
await page.waitForFunction(expect => globalThis.user.emailVerified === expect, false);
8+
await expect(user.emailVerified).toBe(false);
129
await expect(page).toHaveURL('/');
1310
await expect(page.locator('[data-test-notification-message="success"]')).toBeVisible();
1411

15-
await page.evaluate(() => globalThis.user.reload());
16-
await page.waitForFunction(expect => globalThis.user.emailVerified === expect, true);
12+
user = msw.db.user.findFirst({ where: { id: { equals: user.id } } });
13+
await expect(user.emailVerified).toBe(true);
1714
});
1815

19-
test('authenticated happy path', async ({ page, mirage, ember }) => {
20-
await mirage.addHook(server => {
21-
let user = server.create('user', { emailVerificationToken: 'badc0ffee' });
16+
test('authenticated happy path', async ({ page, msw, ember }) => {
17+
let user = msw.db.user.create({ emailVerificationToken: 'badc0ffee' });
2218

23-
authenticateAs(user);
24-
globalThis.user = user;
25-
});
19+
await msw.authenticateAs(user);
2620

2721
await page.goto('/confirm/badc0ffee');
28-
await page.waitForFunction(expect => globalThis.user.emailVerified === expect, false);
22+
await expect(user.emailVerified).toBe(false);
2923
await expect(page).toHaveURL('/');
3024
await expect(page.locator('[data-test-notification-message="success"]')).toBeVisible();
3125

@@ -35,8 +29,8 @@ test.describe('Acceptance | Email Confirmation', { tag: '@acceptance' }, () => {
3529
});
3630
expect(emailVerified).toBe(true);
3731

38-
await page.evaluate(() => globalThis.user.reload());
39-
await page.waitForFunction(expect => globalThis.user.emailVerified === expect, true);
32+
user = msw.db.user.findFirst({ where: { id: { equals: user.id } } });
33+
await expect(user.emailVerified).toBe(true);
4034
});
4135

4236
test('error case', async ({ page }) => {

0 commit comments

Comments
 (0)