Skip to content

Commit 5bd4585

Browse files
committed
e2e/acceptance/categories: Migrate from mirage to @crates-io/msw
1 parent 6739413 commit 5bd4585

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

e2e/acceptance/categories.spec.ts

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

33
test.describe('Acceptance | categories', { tag: '@acceptance' }, () => {
4-
test('listing categories', async ({ page, mirage, percy, a11y }) => {
5-
await mirage.addHook(server => {
6-
server.create('category', { category: 'API bindings' });
7-
server.create('category', { category: 'Algorithms' });
8-
server.createList('crate', 1, { categoryIds: ['algorithms'] });
9-
server.create('category', { category: 'Asynchronous' });
10-
server.createList('crate', 15, { categoryIds: ['asynchronous'] });
11-
server.create('category', { category: 'Everything', crates_cnt: 1234 });
12-
});
4+
test('listing categories', async ({ page, msw, percy, a11y }) => {
5+
msw.db.category.create({ category: 'API bindings' });
6+
let algos = msw.db.category.create({ category: 'Algorithms' });
7+
msw.db.crate.create({ categories: [algos] });
8+
let async = msw.db.category.create({ category: 'Asynchronous' });
9+
Array.from({ length: 15 }).forEach(() => msw.db.crate.create({ categories: [async] }));
10+
msw.db.category.create({ category: 'Everything', crates_cnt: 1234 });
1311

1412
await page.goto('/categories');
1513

@@ -22,10 +20,8 @@ test.describe('Acceptance | categories', { tag: '@acceptance' }, () => {
2220
await a11y.audit();
2321
});
2422

25-
test('category/:category_id index default sort is recent-downloads', async ({ page, mirage, percy, a11y }) => {
26-
await mirage.addHook(server => {
27-
server.create('category', { category: 'Algorithms' });
28-
});
23+
test('category/:category_id index default sort is recent-downloads', async ({ page, msw, percy, a11y }) => {
24+
msw.db.category.create({ category: 'Algorithms' });
2925
await page.goto('/categories/algorithms');
3026

3127
await expect(page.locator('[data-test-category-sort] [data-test-current-order]')).toHaveText('Recent Downloads');
@@ -34,11 +30,9 @@ test.describe('Acceptance | categories', { tag: '@acceptance' }, () => {
3430
await a11y.audit();
3531
});
3632

37-
test('listing category slugs', async ({ page, mirage }) => {
38-
await mirage.addHook(server => {
39-
server.create('category', { category: 'Algorithms', description: 'Crates for algorithms' });
40-
server.create('category', { category: 'Asynchronous', description: 'Async crates' });
41-
});
33+
test('listing category slugs', async ({ page, msw }) => {
34+
msw.db.category.create({ category: 'Algorithms', description: 'Crates for algorithms' });
35+
msw.db.category.create({ category: 'Asynchronous', description: 'Async crates' });
4236
await page.goto('/category_slugs');
4337

4438
await expect(page.locator('[data-test-category-slug="algorithms"]')).toHaveText('algorithms');
@@ -50,10 +44,8 @@ test.describe('Acceptance | categories', { tag: '@acceptance' }, () => {
5044

5145
test.describe('Acceptance | categories (locale: de)', { tag: '@acceptance' }, () => {
5246
test.use({ locale: 'de' });
53-
test('listing categories', async ({ page, mirage }) => {
54-
await mirage.addHook(server => {
55-
server.create('category', { category: 'Everything', crates_cnt: 1234 });
56-
});
47+
test('listing categories', async ({ page, msw }) => {
48+
msw.db.category.create({ category: 'Everything', crates_cnt: 1234 });
5749
await page.goto('categories');
5850

5951
await expect(page.locator('[data-test-category="everything"] [data-test-crate-count]')).toHaveText('1.234 crates');

0 commit comments

Comments
 (0)