]> git.openstreetmap.org Git - nominatim-ui.git/blob - test/api_errors.js
replace httpbin with beeceptor for mocking HTTP error codes
[nominatim-ui.git] / test / api_errors.js
1 import assert from 'assert';
2
3 describe('Nominatim API errors', function () {
4   let page;
5
6   describe('HTTP 503 - service unavailable', function () {
7     before(async function () {
8       page = await browser.newPage();
9       await page.goto('http://localhost:9999/search.html?q=london&mock_http_status=503');
10     });
11
12     after(async function () {
13       await page.close();
14     });
15
16     it('should display an error', async function () {
17       await page.waitForSelector('#error');
18
19       let message = await page.$eval('#error', el => el.textContent);
20       assert.ok(message.includes('/status/503'));
21       assert.ok(message.includes('Error fetching data from'));
22     });
23   });
24
25   describe('HTTP 200 - JSON parsing fails', function () {
26     before(async function () {
27       page = await browser.newPage();
28       await page.goto('http://localhost:9999/search.html?q=london&mock_http_status=200');
29     });
30
31     after(async function () {
32       await page.close();
33     });
34
35     it('should display an error', async function () {
36       await page.waitForSelector('#error');
37
38       let message = await page.$eval('#error', el => el.textContent);
39       assert.ok(message.includes('/status/200'));
40       assert.ok(message.includes('Error parsing JSON data from'));
41     });
42   });
43 });