Skip to content

Commit 2cd6e21

Browse files
committed
temp async auth
1 parent 7e02074 commit 2cd6e21

14 files changed

+42
-42
lines changed

e2e/acceptance/api-token.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test.describe('Acceptance | api-tokens', { tag: '@acceptance' }, () => {
3131
lastUsedAt: '2017-11-02T01:45:14',
3232
});
3333

34-
msw.authenticateAs(user);
34+
await msw.authenticateAs(user);
3535
});
3636

3737
test('/me is showing the list of active API tokens', async ({ page }) => {

e2e/acceptance/crate-deletion.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from '@/e2e/helper';
33
test.describe('Acceptance | crate deletion', { tag: '@acceptance' }, () => {
44
test('happy path', async ({ page, msw }) => {
55
let user = msw.db.user.create();
6-
msw.authenticateAs(user);
6+
await msw.authenticateAs(user);
77

88
let crate = msw.db.crate.create({ name: 'foo' });
99
msw.db.version.create({ crate });

e2e/acceptance/crate-following.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@ import { expect, test } from '@/e2e/helper';
33
import { http, HttpResponse } from 'msw';
44

55
test.describe('Acceptance | Crate following', { tag: '@acceptance' }, () => {
6-
function prepare(msw, { skipLogin = false, following = false } = {}) {
6+
async function prepare(msw, { skipLogin = false, following = false } = {}) {
77
let crate = msw.db.crate.create({ name: 'nanomsg' });
88
msw.db.version.create({ crate, num: '0.6.0' });
99

1010
let loggedIn = !skipLogin;
1111
if (loggedIn) {
1212
let followedCrates = following ? [crate] : [];
1313
let user = msw.db.user.create({ followedCrates });
14-
msw.authenticateAs(user);
14+
await msw.authenticateAs(user);
1515
}
1616
}
1717

1818
test("unauthenticated users don't see the follow button", async ({ page, msw }) => {
19-
prepare(msw, { skipLogin: true });
19+
await prepare(msw, { skipLogin: true });
2020

2121
await page.goto('/crates/nanomsg');
2222
await expect(page.locator('[data-test-follow-button]')).toHaveCount(0);
2323
});
2424

2525
test('authenticated users see a loading spinner and can follow/unfollow crates', async ({ page, msw }) => {
26-
prepare(msw);
26+
await prepare(msw);
2727

2828
let followingDeferred = defer();
2929
await msw.worker.use(http.get('/api/v1/crates/:crate_id/following', () => followingDeferred.promise));
@@ -67,7 +67,7 @@ test.describe('Acceptance | Crate following', { tag: '@acceptance' }, () => {
6767
});
6868

6969
test('error handling when loading following state fails', async ({ msw, page }) => {
70-
prepare(msw);
70+
await prepare(msw);
7171

7272
let error = HttpResponse.json({}, { status: 500 });
7373
await msw.worker.use(http.get('/api/v1/crates/:crate_id/following', () => error));
@@ -82,7 +82,7 @@ test.describe('Acceptance | Crate following', { tag: '@acceptance' }, () => {
8282
});
8383

8484
test('error handling when follow fails', async ({ msw, page }) => {
85-
prepare(msw);
85+
await prepare(msw);
8686

8787
let error = HttpResponse.json({}, { status: 500 });
8888
await msw.worker.use(http.put('/api/v1/crates/:crate_id/follow', () => error));
@@ -95,7 +95,7 @@ test.describe('Acceptance | Crate following', { tag: '@acceptance' }, () => {
9595
});
9696

9797
test('error handling when unfollow fails', async ({ msw, page }) => {
98-
prepare(msw, { following: true });
98+
await prepare(msw, { following: true });
9999

100100
let error = HttpResponse.json({}, { status: 500 });
101101
await msw.worker.use(http.delete('/api/v1/crates/:crate_id/follow', () => error));

e2e/acceptance/crate.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ test.describe('Acceptance | crate page', { tag: '@acceptance' }, () => {
229229
loadFixtures(msw.db);
230230

231231
let user = msw.db.user.findFirst({ where: { login: { equals: 'thehydroimpulse' } } });
232-
msw.authenticateAs(user);
232+
await msw.authenticateAs(user);
233233

234234
await page.goto('/crates/nanomsg/0.5.0');
235235
const yankButton = page.locator('[data-test-version-yank-button="0.5.0"]');
@@ -257,7 +257,7 @@ test.describe('Acceptance | crate page', { tag: '@acceptance' }, () => {
257257
loadFixtures(msw.db);
258258

259259
let user = msw.db.user.findFirst({ where: { login: { equals: 'iain8' } } });
260-
msw.authenticateAs(user);
260+
await msw.authenticateAs(user);
261261

262262
await page.goto('/crates/nanomsg');
263263

@@ -268,7 +268,7 @@ test.describe('Acceptance | crate page', { tag: '@acceptance' }, () => {
268268
loadFixtures(msw.db);
269269

270270
let user = msw.db.user.findFirst({ where: { login: { equals: 'thehydroimpulse' } } });
271-
msw.authenticateAs(user);
271+
await msw.authenticateAs(user);
272272

273273
await page.goto('/crates/nanomsg');
274274
await page.click('[data-test-settings-tab] a');

e2e/acceptance/dashboard.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test.describe('Acceptance | Dashboard', { tag: '@acceptance' }, () => {
1717
avatar: 'https://avatars2.githubusercontent.com/u/1234567?v=4',
1818
});
1919

20-
msw.authenticateAs(user);
20+
await msw.authenticateAs(user);
2121

2222
{
2323
let crate = msw.db.crate.create({ name: 'rand' });

e2e/acceptance/email-change.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { http, HttpResponse } from 'msw';
44
test.describe('Acceptance | Email Change', { tag: '@acceptance' }, () => {
55
test('happy path', async ({ page, msw }) => {
66
let user = msw.db.user.create({ email: '[email protected]' });
7-
msw.authenticateAs(user);
7+
await msw.authenticateAs(user);
88

99
await page.goto('/settings/profile');
1010
await expect(page).toHaveURL('/settings/profile');
@@ -45,7 +45,7 @@ test.describe('Acceptance | Email Change', { tag: '@acceptance' }, () => {
4545

4646
test('happy path with `email: null`', async ({ page, msw }) => {
4747
let user = msw.db.user.create({ email: undefined });
48-
msw.authenticateAs(user);
48+
await msw.authenticateAs(user);
4949

5050
await page.goto('/settings/profile');
5151
await expect(page).toHaveURL('/settings/profile');
@@ -82,7 +82,7 @@ test.describe('Acceptance | Email Change', { tag: '@acceptance' }, () => {
8282

8383
test('cancel button', async ({ page, msw }) => {
8484
let user = msw.db.user.create({ email: '[email protected]' });
85-
msw.authenticateAs(user);
85+
await msw.authenticateAs(user);
8686

8787
await page.goto('/settings/profile');
8888
const emailInput = page.locator('[data-test-email-input]');
@@ -104,7 +104,7 @@ test.describe('Acceptance | Email Change', { tag: '@acceptance' }, () => {
104104

105105
test('server error', async ({ page, msw }) => {
106106
let user = msw.db.user.create({ email: '[email protected]' });
107-
msw.authenticateAs(user);
107+
await msw.authenticateAs(user);
108108

109109
let error = HttpResponse.json({}, { status: 500 });
110110
await msw.worker.use(http.put('/api/v1/users/:user_id', () => error));
@@ -130,7 +130,7 @@ test.describe('Acceptance | Email Change', { tag: '@acceptance' }, () => {
130130
test.describe('Resend button', function () {
131131
test('happy path', async ({ page, msw }) => {
132132
let user = msw.db.user.create({ email: '[email protected]', emailVerificationToken: 'secret123' });
133-
msw.authenticateAs(user);
133+
await msw.authenticateAs(user);
134134

135135
await page.goto('/settings/profile');
136136
await expect(page).toHaveURL('/settings/profile');
@@ -151,7 +151,7 @@ test.describe('Acceptance | Email Change', { tag: '@acceptance' }, () => {
151151

152152
test('server error', async ({ page, msw }) => {
153153
let user = msw.db.user.create({ email: '[email protected]', emailVerificationToken: 'secret123' });
154-
msw.authenticateAs(user);
154+
await msw.authenticateAs(user);
155155

156156
let error = HttpResponse.json({}, { status: 500 });
157157
await msw.worker.use(http.put('/api/v1/users/:user_id/resend', () => error));

e2e/acceptance/email-confirmation.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test.describe('Acceptance | Email Confirmation', { tag: '@acceptance' }, () => {
1616
test('authenticated happy path', async ({ page, msw, ember }) => {
1717
let user = msw.db.user.create({ emailVerificationToken: 'badc0ffee' });
1818

19-
msw.authenticateAs(user);
19+
await msw.authenticateAs(user);
2020

2121
await page.goto('/confirm/badc0ffee');
2222
await expect(user.emailVerified).toBe(false);

e2e/acceptance/invites.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test.describe('Acceptance | /me/pending-invites', { tag: '@acceptance' }, () =>
1111
});
1212

1313
test.describe('Acceptance | /me/pending-invites', { tag: '@acceptance' }, () => {
14-
function prepare(msw) {
14+
async function prepare(msw) {
1515
let inviter = msw.db.user.create({ name: 'janed' });
1616
let inviter2 = msw.db.user.create({ name: 'wycats' });
1717

@@ -35,13 +35,13 @@ test.describe('Acceptance | /me/pending-invites', { tag: '@acceptance' }, () =>
3535
inviter: inviter2,
3636
});
3737

38-
msw.authenticateAs(user);
38+
await msw.authenticateAs(user);
3939

4040
return { nanomsg, user };
4141
}
4242

4343
test('list all pending crate owner invites', async ({ page, msw }) => {
44-
prepare(msw);
44+
await prepare(msw);
4545

4646
await page.goto('/me/pending-invites');
4747
await expect(page).toHaveURL('/me/pending-invites');
@@ -69,7 +69,7 @@ test.describe('Acceptance | /me/pending-invites', { tag: '@acceptance' }, () =>
6969
});
7070

7171
test('shows empty list message', async ({ page, msw }) => {
72-
prepare(msw);
72+
await prepare(msw);
7373
msw.db.crateOwnerInvitation.deleteMany({});
7474

7575
await page.goto('/me/pending-invites');
@@ -79,7 +79,7 @@ test.describe('Acceptance | /me/pending-invites', { tag: '@acceptance' }, () =>
7979
});
8080

8181
test('invites can be declined', async ({ page, msw }) => {
82-
let { nanomsg, user } = prepare(msw);
82+
let { nanomsg, user } = await prepare(msw);
8383

8484
let invites = msw.db.crateOwnerInvitation.findMany({
8585
where: {
@@ -129,7 +129,7 @@ test.describe('Acceptance | /me/pending-invites', { tag: '@acceptance' }, () =>
129129
});
130130

131131
test('error message is shown if decline request fails', async ({ page, msw }) => {
132-
prepare(msw);
132+
await prepare(msw);
133133

134134
await page.goto('/me/pending-invites');
135135
await expect(page).toHaveURL('/me/pending-invites');
@@ -144,7 +144,7 @@ test.describe('Acceptance | /me/pending-invites', { tag: '@acceptance' }, () =>
144144
});
145145

146146
test('invites can be accepted', async ({ page, percy, msw }) => {
147-
let { nanomsg, user } = prepare(msw);
147+
let { nanomsg, user } = await prepare(msw);
148148

149149
let invites = msw.db.crateOwnerInvitation.findMany({
150150
where: {
@@ -194,7 +194,7 @@ test.describe('Acceptance | /me/pending-invites', { tag: '@acceptance' }, () =>
194194
});
195195

196196
test('error message is shown if accept request fails', async ({ page, msw }) => {
197-
prepare(msw);
197+
await prepare(msw);
198198

199199
await page.goto('/me/pending-invites');
200200
await expect(page).toHaveURL('/me/pending-invites');
@@ -209,7 +209,7 @@ test.describe('Acceptance | /me/pending-invites', { tag: '@acceptance' }, () =>
209209
});
210210

211211
test('specific error message is shown if accept request fails', async ({ page, msw }) => {
212-
prepare(msw);
212+
await prepare(msw);
213213

214214
let errorMessage =
215215
'The invitation to become an owner of the demo_crate crate expired. Please reach out to an owner of the crate to request a new invitation.';

e2e/acceptance/logout.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from '@/e2e/helper';
33
test.describe('Acceptance | Logout', { tag: '@acceptance' }, () => {
44
test('successful logout', async ({ page, msw }) => {
55
let user = msw.db.user.create({ name: 'John Doe' });
6-
msw.authenticateAs(user);
6+
await msw.authenticateAs(user);
77

88
await page.goto('/crates');
99
await expect(page).toHaveURL('/crates');

e2e/acceptance/publish-notifications.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { http, HttpResponse } from 'msw';
55
test.describe('Acceptance | publish notifications', { tag: '@acceptance' }, () => {
66
test('unsubscribe and resubscribe', async ({ page, msw }) => {
77
let user = msw.db.user.create();
8-
msw.authenticateAs(user);
8+
await msw.authenticateAs(user);
99

1010
await page.goto('/settings/profile');
1111
await expect(page).toHaveURL('/settings/profile');
@@ -28,7 +28,7 @@ test.describe('Acceptance | publish notifications', { tag: '@acceptance' }, () =
2828

2929
test('loading state', async ({ page, msw }) => {
3030
let user = msw.db.user.create();
31-
msw.authenticateAs(user);
31+
await msw.authenticateAs(user);
3232

3333
let deferred = defer();
3434
msw.worker.use(http.put('/api/v1/users/:user_id', () => deferred.promise));
@@ -49,7 +49,7 @@ test.describe('Acceptance | publish notifications', { tag: '@acceptance' }, () =
4949

5050
test('error state', async ({ page, msw }) => {
5151
let user = msw.db.user.create();
52-
msw.authenticateAs(user);
52+
await msw.authenticateAs(user);
5353

5454
msw.worker.use(http.put('/api/v1/users/:user_id', () => HttpResponse.text('', { status: 500 })));
5555

0 commit comments

Comments
 (0)