diff --git a/__tests__/integration/mirador/basic.test.js b/__tests__/integration/mirador/basic.test.js index 94d8700e1437ad6d98d1a093c46f7bf98444b1e9..7ee22343a465036380bc0cbe12c06bd968fb4301 100644 --- a/__tests__/integration/mirador/basic.test.js +++ b/__tests__/integration/mirador/basic.test.js @@ -9,10 +9,10 @@ describe('Basic end to end Mirador', () => { it('loads a manifest and displays it', async () => { await expect(page).toClick('#addBtn'); await expect(page).toClick('.mirador-add-resource-button'); - await expect(page).toFill('#manifestURL', 'http://localhost:5000/api/sn904cj3429'); + await expect(page).toFill('#manifestURL', 'http://localhost:4488/__tests__/fixtures/version-2/sn904cj3429.json'); await expect(page).toClick('#fetchBtn'); - await expect(page).toMatchElement('[data-manifestid="http://localhost:5000/api/sn904cj3429"] button'); - await expect(page).toClick('[data-manifestid="http://localhost:5000/api/sn904cj3429"] button'); + await expect(page).toMatchElement('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-2/sn904cj3429.json"] button'); + await expect(page).toClick('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-2/sn904cj3429.json"] button'); await expect(page).toMatchElement( 'h2', { text: /Peter's San Francisco Locator/ }, diff --git a/__tests__/integration/mirador/invalid-api-response.test.js b/__tests__/integration/mirador/invalid-api-response.test.js index edecfe97f8a3e1353cb62dd32a517bba7f32cbd2..54ba148ef2914aae54766571886a2d3f4beaa45c 100644 --- a/__tests__/integration/mirador/invalid-api-response.test.js +++ b/__tests__/integration/mirador/invalid-api-response.test.js @@ -15,22 +15,22 @@ describe('Mirador Invalid API Response Handler Test', () => { await page.goto('http://127.0.0.1:4488/__tests__/integration/mirador/'); }); it('breaks Mirador', async () => { - fetchManifest('http://localhost:5000/invalid'); - await expect(page).toMatchElement('li', { text: 'http://localhost:5000/invalid', timeout: 2000 }); + fetchManifest('http://localhost:4488/invalid'); + await expect(page).toMatchElement('li', { text: 'http://localhost:4488/invalid', timeout: 2000 }); }, 10000); it('renders an error message when a manifest cannot be loaded (and allows it to be dismissed)', async () => { - fetchManifest('http://localhost:5000/api/broken'); + fetchManifest('http://localhost:4488/__tests__/fixtures/version-2/broken'); await expect(page).toMatchElement( 'p', { text: 'The resource cannot be added:', timeout: 2000 }, ); await expect(page).toMatchElement( - 'p', { text: 'http://localhost:5000/api/broken' }, + 'p', { text: 'http://localhost:4488/__tests__/fixtures/version-2/broken' }, ); await expect(page).toClick('button', { text: 'Dismiss' }); - await page.waitFor(() => !document.querySelector('li[data-manifestid="http://localhost:5000/api/broken"]')); + await page.waitFor(() => !document.querySelector('li[data-manifestid="http://localhost:4488/__tests__/fixtures/version-2/broken"]')); await expect(page).not.toMatchElement( 'p', diff --git a/__tests__/integration/mirador/negotiated-api-response.test.js b/__tests__/integration/mirador/negotiated-api-response.test.js deleted file mode 100644 index d86a6d63b7bff870f77185382ba6f1aa3fd24bc6..0000000000000000000000000000000000000000 --- a/__tests__/integration/mirador/negotiated-api-response.test.js +++ /dev/null @@ -1,21 +0,0 @@ -const supertest = require('supertest'); - -describe('GET Negotiated API Response', () => { - let request; - beforeAll(() => { - request = supertest('http://localhost:5000'); - }); - it('responds with API v3 json', () => request - .get('/api/001') - .set('Accept', 'application/ld+json;profile="http://iiif.io/api/presentation/3/context.json"') - .expect(200) - .then((res) => { - expect(res.text).toMatch(/http:\/\/iiif\.io\/api\/presentation\/3\/context\.json/); - })); - it('responds with API v2 json', () => request - .get('/api/001') - .expect(200) - .then((res) => { - expect(res.text).toMatch(/http:\/\/iiif\.io\/api\/presentation\/2\/context\.json/); - })); -}); diff --git a/__tests__/integration/mirador/window_actions.test.js b/__tests__/integration/mirador/window_actions.test.js index 0f62f257a26037413a97be643bb6395a71a88372..8e70da6a015e95218989adfac0d4879e6e043b38 100644 --- a/__tests__/integration/mirador/window_actions.test.js +++ b/__tests__/integration/mirador/window_actions.test.js @@ -5,11 +5,11 @@ describe('Window actions', () => { it('opens a window and closes it', async () => { await expect(page).toClick('#addBtn'); await expect(page).toClick('.mirador-add-resource-button'); - await expect(page).toFill('#manifestURL', 'http://localhost:5000/api/sn904cj3429'); + await expect(page).toFill('#manifestURL', 'http://localhost:4488/__tests__/fixtures/version-2/sn904cj3429.json'); await expect(page).toClick('#fetchBtn'); - await expect(page).toMatchElement('[data-manifestid="http://localhost:5000/api/sn904cj3429"] button'); - await expect(page).toClick('[data-manifestid="http://localhost:5000/api/sn904cj3429"] button'); + await expect(page).toMatchElement('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-2/sn904cj3429.json"] button'); + await expect(page).toClick('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-2/sn904cj3429.json"] button'); await expect(page).toMatchElement('.mirador-window'); await page.waitFor(1000); diff --git a/__tests__/integration/mirador/window_sidebar.test.js b/__tests__/integration/mirador/window_sidebar.test.js index b73cc92131245ffa516c3efe27280fb6a2411803..7460fa561f144e07ca372595f50730a2ebd75f96 100644 --- a/__tests__/integration/mirador/window_sidebar.test.js +++ b/__tests__/integration/mirador/window_sidebar.test.js @@ -6,11 +6,11 @@ describe('Window Sidebars', () => { await expect(page).toClick('#addBtn'); await expect(page).toClick('.mirador-add-resource-button'); - await expect(page).toFill('#manifestURL', 'http://localhost:5000/api/001'); + await expect(page).toFill('#manifestURL', 'http://localhost:4488/__tests__/fixtures/version-2/001.json'); await expect(page).toClick('#fetchBtn'); - await expect(page).toMatchElement('[data-manifestid="http://localhost:5000/api/001"] button'); - await expect(page).toClick('[data-manifestid="http://localhost:5000/api/001"] button'); + await expect(page).toMatchElement('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-2/001.json"] button'); + await expect(page).toClick('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-2/001.json"] button'); }); it('renders and updates canvas level metadata', async () => { @@ -24,7 +24,7 @@ describe('Window Sidebars', () => { )); const windowId = Object.values(windows) - .find(window => window.manifestId === 'http://localhost:5000/api/001') + .find(window => window.manifestId === 'http://localhost:4488/__tests__/fixtures/version-2/001.json') .id; await expect(page).toMatchElement(`#${windowId} button[aria-label="Toggle sidebar"]`); @@ -39,7 +39,7 @@ describe('Window Sidebars', () => { )); const windowId = Object.values(windows) - .find(window => window.manifestId === 'http://localhost:5000/api/001') + .find(window => window.manifestId === 'http://localhost:4488/__tests__/fixtures/version-2/001.json') .id; await expect(page).toMatchElement(`#${windowId} button[aria-label="Toggle sidebar"]`); diff --git a/jest-puppeteer.config.js b/jest-puppeteer.config.js index bdb1bca5ffe753a6c731d8f927da3f3d3284d980..f2324320bc4f2d94696575f495b44753639c7e94 100644 --- a/jest-puppeteer.config.js +++ b/jest-puppeteer.config.js @@ -5,8 +5,5 @@ module.exports = { server: [{ command: 'npm run server -- -p 4488', port: 4488, - }, - { - command: 'npm run server:json', }], }; diff --git a/package.json b/package.json index 9477ee2f3946b94123ed88d9bffe12cd255c51ec..2a646bfae3f2b0af0a08dbda973991a360269988 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "clean": "rm -rf ./dist", "lint": "node_modules/.bin/eslint ./ && npm run lint:translations", "lint:translations": "node ./scripts/i18n-lint.js", - "server": "node_modules/.bin/http-server", + "server": "node_modules/.bin/http-server --cors", "test": "npm run build && npm run lint && npm run size && jest -c jest.json", "test:watch": "jest -c jest.json --watch", "build": "webpack --mode=production", @@ -22,8 +22,7 @@ "build:watch": "webpack --watch --mode=development", "prepublishOnly": "npm run clean && npm run build:es && npm run build:cjs && npm run build", "size": "bundlewatch --config bundlewatch.config.json", - "start": "npm run build:dev && concurrently \"npm run build:watch\" \"npm run server -- -p 4444\"", - "server:json": "node ./scripts/json-server/server.js >> ./scripts/json-server/json-server.log" + "start": "npm run build:dev && concurrently \"npm run build:watch\" \"npm run server -- -p 4444\"" }, "license": "Apache-2.0", "contributors": [ @@ -110,7 +109,6 @@ "jest-fetch-mock": "^2.1.2", "jest-puppeteer": "^4.1.1", "jsdom": "15.1.1", - "json-server": "^0.15.0", "puppeteer": "^1.18.1", "react": "^16.8.6", "react-dev-utils": "^9.0.1", diff --git a/scripts/json-server/routes.json b/scripts/json-server/routes.json deleted file mode 100644 index 0d07c778aa2f7b1c92b7fa926d21876490fe2094..0000000000000000000000000000000000000000 --- a/scripts/json-server/routes.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "invalid": { "invalid-key": "invalid-value" } -} diff --git a/scripts/json-server/server.js b/scripts/json-server/server.js deleted file mode 100644 index cbf9c77e32cabc4e1b5015a031bb762ecf8cb7ed..0000000000000000000000000000000000000000 --- a/scripts/json-server/server.js +++ /dev/null @@ -1,26 +0,0 @@ -const jsonServer = require('json-server'); // eslint-disable-line import/no-extraneous-dependencies - -const server = jsonServer.create(); -const router = jsonServer.router('./scripts/json-server/routes.json'); -const defaults = { - static: './__tests__/fixtures', -}; -const middlewares = jsonServer.defaults(defaults); -server.use(middlewares); - -const options = { - root: './__tests__/fixtures/', -}; -server.get('/api/:id?', (req, res) => { - let apiVersion; - if (req.get('Accept') === 'application/ld+json;profile="http://iiif.io/api/presentation/3/context.json"') { - apiVersion = '3'; - } else { - apiVersion = '2'; - } - const fileId = req.params.id; - res.sendFile(`/version-${apiVersion}/${fileId}.json`, options); -}); - -server.use(router); -server.listen(5000, () => {});