diff --git a/.gitignore b/.gitignore index 2ad5c93..37d71d6 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ package-lock.json # testing coverage +*.mp4 +e2e-results.xml # production lib diff --git a/.travis.yml b/.travis.yml index d3e7c28..ae01a74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ language: node_js node_js: - "node" +cache: + npm: true + directories: + - ~/.cache before_script: - npm install - cd packages/mirador3-core @@ -13,4 +17,7 @@ before_script: - npm install - cd ../.. - lerna run build -script: lerna run test --stream +script: + - lerna run test --stream + - cd packages/mirador3-e2e-tests + - npm run cypress:record diff --git a/packages/mirador3-app-base/jest.json b/packages/mirador3-app-base/jest.json index 1ee4de1..a1ff051 100644 --- a/packages/mirador3-app-base/jest.json +++ b/packages/mirador3-app-base/jest.json @@ -12,7 +12,7 @@ "setupTestFrameworkScriptFile": "/src/setupTests.js", "testMatch": [ "/src/**/__tests__/**/*.{js,jsx,ts,tsx}", - "/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}" + "/src/**/?(*.)(spec|test|unit).{js,jsx,ts,tsx}" ], "testEnvironment": "jsdom", "testURL": "http://localhost", diff --git a/packages/mirador3-app-base/package.json b/packages/mirador3-app-base/package.json index 3575027..b22e5b3 100644 --- a/packages/mirador3-app-base/package.json +++ b/packages/mirador3-app-base/package.json @@ -26,6 +26,7 @@ "css-loader": "1.0.0", "dotenv": "6.0.0", "dotenv-expand": "4.2.0", + "enzyme": "^3.7.0", "enzyme-adapter-react-16": "^1.7.0", "eslint": "5.6.0", "eslint-config-airbnb": "^17.1.0", @@ -41,9 +42,11 @@ "fs-extra": "7.0.0", "html-webpack-plugin": "4.0.0-alpha.2", "identity-obj-proxy": "3.0.0", + "jest": "23.6.0", "jest-canvas-mock": "^1.1.0", "jest-pnp-resolver": "1.0.1", "jest-resolve": "23.6.0", + "jsdom": "^13.0.0", "mini-css-extract-plugin": "0.4.3", "node-sass": "^4.9.4", "optimize-css-assets-webpack-plugin": "5.0.1", diff --git a/packages/mirador3-app-base/src/components/App.jsx b/packages/mirador3-app-base/src/components/App.jsx index 5ff1e71..487b335 100644 --- a/packages/mirador3-app-base/src/components/App.jsx +++ b/packages/mirador3-app-base/src/components/App.jsx @@ -50,24 +50,22 @@ class App extends Component { return 'Nothing Selected Yet'; } + buildManifestList() { + return Object.keys(this.props.manifests).map(manifest => ( + )); + } + /** * render * @return {String} - HTML markup for the component */ render() { - const manifestList = Object.keys(this.props.manifests).map(manifest => ( - - )); return (
-
    {manifestList}
- +
    {this.buildManifestList}
diff --git a/packages/mirador3-app-base/src/components/App.unit.jsx b/packages/mirador3-app-base/src/components/App.unit.jsx new file mode 100644 index 0000000..f74b600 --- /dev/null +++ b/packages/mirador3-app-base/src/components/App.unit.jsx @@ -0,0 +1,10 @@ +import * as React from "react"; +import {mount} from "enzyme"; +import App from './App'; + +describe("App component", ()=> { + + it("should render correctly", ()=> { + // TODO + }) +}) diff --git a/packages/mirador3-app-base/src/setupTests.js b/packages/mirador3-app-base/src/setupTests.js index d67de9f..6847f55 100644 --- a/packages/mirador3-app-base/src/setupTests.js +++ b/packages/mirador3-app-base/src/setupTests.js @@ -1,5 +1,4 @@ import { JSDOM } from 'jsdom'; // eslint-disable-line import/no-extraneous-dependencies -import fetch from 'jest-fetch-mock'; // eslint-disable-line import/no-extraneous-dependencies import Enzyme from 'enzyme'; // eslint-disable-line import/no-extraneous-dependencies import Adapter from 'enzyme-adapter-react-16'; // eslint-disable-line import/no-extraneous-dependencies @@ -17,8 +16,6 @@ function copyProps(src, target) { } window.HTMLCanvasElement.prototype.getContext = () => {}; -jest.setMock('node-fetch', fetch); -global.fetch = require('jest-fetch-mock'); // eslint-disable-line import/no-extraneous-dependencies global.window = window; global.document = window.document; diff --git a/packages/mirador3-e2e-tests/cypress.json b/packages/mirador3-e2e-tests/cypress.json index 97d735f..2479eea 100644 --- a/packages/mirador3-e2e-tests/cypress.json +++ b/packages/mirador3-e2e-tests/cypress.json @@ -4,5 +4,6 @@ "reporterOptions": { "mochaFile": "e2e-results.xml", "toConsole": true - } + }, + "projectId": "epruij" } diff --git a/packages/mirador3-e2e-tests/cypress/integration/mirador-base.spec.js b/packages/mirador3-e2e-tests/cypress/integration/mirador-base.spec.js index 88e9c90..017765f 100644 --- a/packages/mirador3-e2e-tests/cypress/integration/mirador-base.spec.js +++ b/packages/mirador3-e2e-tests/cypress/integration/mirador-base.spec.js @@ -1,7 +1,12 @@ /* global cy */ describe('Mirador Base', () => { it('Visits Mirador Base', () => { - cy.visit('http://localhost:4000/mirador-base'); + cy.visit('http://localhost:4000/mirador3-base'); cy.get('title').contains('Mirador'); + cy.get('#manifestURL').type('https://purl.stanford.edu/sn904cj3429/iiif/manifest'); + cy.get('#fetchBtn').click(); + cy.get('li').contains('https://purl.stanford.edu/sn904cj3429/iiif/manifest'); + cy.get('h3').contains('Peter\'s San Francisco Locator. The Birds-Eye-View Map of the Exposition City. Published by Locator Publishing Co'); + cy.get('li').find('>button').click(); }); }); diff --git a/packages/mirador3-e2e-tests/package.json b/packages/mirador3-e2e-tests/package.json index ec093bc..8960c16 100644 --- a/packages/mirador3-e2e-tests/package.json +++ b/packages/mirador3-e2e-tests/package.json @@ -5,9 +5,10 @@ "scripts": { "build": "NODE_ENV=production webpack --config ./webpack.config.js", "start": "node src/start.js", - "stop": "pkill --signal SIGINT server", + "stop": "pkill --signal SIGINT serverjs", "test:ci": "npm run start:prod & cypress run cypress.json && kill $!", - "cypress:open": "npm run start & cypress open && kill $!" + "cypress:open": "npm run start & cypress open && kill $!", + "cypress:record": "npm run start & cypress run --record --key 1d0533b4-bffb-41c8-954b-dc6782b93058" }, "dependencies": { "ejs": "^2.6.1", diff --git a/packages/mirador3-e2e-tests/src/start.js b/packages/mirador3-e2e-tests/src/start.js index 8cbfe53..6290344 100644 --- a/packages/mirador3-e2e-tests/src/start.js +++ b/packages/mirador3-e2e-tests/src/start.js @@ -1,4 +1,4 @@ const server = require('./server'); -process.title = server; +process.title = 'serverjs'; server.start(Number(process.env.PORT || 4000));