Skip to content

Commit f7f5366

Browse files
committed
tests/acceptance/read-only-mode: Migrate from mirage to @crates-io/msw
1 parent cefdf75 commit f7f5366

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/acceptance/read-only-mode-test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
11
import { visit } from '@ember/test-helpers';
22
import { module, test } from 'qunit';
33

4+
import { http, HttpResponse } from 'msw';
5+
46
import { setupApplicationTest } from 'crates-io/tests/helpers';
57

68
import { AjaxError } from '../../utils/ajax';
79

810
module('Acceptance | Read-only Mode', function (hooks) {
9-
setupApplicationTest(hooks);
11+
setupApplicationTest(hooks, { msw: true });
1012

1113
test('notification is not shown for read-write mode', async function (assert) {
1214
await visit('/');
1315
assert.dom('[data-test-notification-message="info"]').doesNotExist();
1416
});
1517

1618
test('notification is shown for read-only mode', async function (assert) {
17-
this.server.get('/api/v1/site_metadata', { read_only: true });
19+
this.worker.use(http.get('/api/v1/site_metadata', () => HttpResponse.json({ read_only: true })));
1820

1921
await visit('/');
2022
assert.dom('[data-test-notification-message="info"]').includesText('read-only mode');
2123
});
2224

2325
test('server errors are handled gracefully', async function (assert) {
24-
this.server.get('/api/v1/site_metadata', {}, 500);
26+
this.worker.use(http.get('/api/v1/site_metadata', () => HttpResponse.json({}, { status: 500 })));
2527

2628
await visit('/');
2729
assert.dom('[data-test-notification-message="info"]').doesNotExist();
2830
assert.deepEqual(this.owner.lookup('service:sentry').events.length, 0);
2931
});
3032

3133
test('client errors are reported on sentry', async function (assert) {
32-
this.server.get('/api/v1/site_metadata', {}, 404);
34+
this.worker.use(http.get('/api/v1/site_metadata', () => HttpResponse.json({}, { status: 404 })));
3335

3436
await visit('/');
3537
assert.dom('[data-test-notification-message="info"]').doesNotExist();

0 commit comments

Comments
 (0)