|
1 | 1 | import { visit } from '@ember/test-helpers'; |
2 | 2 | import { module, test } from 'qunit'; |
3 | 3 |
|
| 4 | +import { http, HttpResponse } from 'msw'; |
| 5 | + |
4 | 6 | import { setupApplicationTest } from 'crates-io/tests/helpers'; |
5 | 7 |
|
6 | 8 | import { AjaxError } from '../../utils/ajax'; |
7 | 9 |
|
8 | 10 | module('Acceptance | Read-only Mode', function (hooks) { |
9 | | - setupApplicationTest(hooks); |
| 11 | + setupApplicationTest(hooks, { msw: true }); |
10 | 12 |
|
11 | 13 | test('notification is not shown for read-write mode', async function (assert) { |
12 | 14 | await visit('/'); |
13 | 15 | assert.dom('[data-test-notification-message="info"]').doesNotExist(); |
14 | 16 | }); |
15 | 17 |
|
16 | 18 | 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 }))); |
18 | 20 |
|
19 | 21 | await visit('/'); |
20 | 22 | assert.dom('[data-test-notification-message="info"]').includesText('read-only mode'); |
21 | 23 | }); |
22 | 24 |
|
23 | 25 | 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 }))); |
25 | 27 |
|
26 | 28 | await visit('/'); |
27 | 29 | assert.dom('[data-test-notification-message="info"]').doesNotExist(); |
28 | 30 | assert.deepEqual(this.owner.lookup('service:sentry').events.length, 0); |
29 | 31 | }); |
30 | 32 |
|
31 | 33 | 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 }))); |
33 | 35 |
|
34 | 36 | await visit('/'); |
35 | 37 | assert.dom('[data-test-notification-message="info"]').doesNotExist(); |
|
0 commit comments