Skip to content

Commit

Permalink
adds cypress record to travis
Browse files Browse the repository at this point in the history
adds unit test shell for unconnected App
  • Loading branch information
christopher-johnson committed Dec 8, 2018
1 parent 6d0e0d1 commit 0b313c5
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package-lock.json

# testing
coverage
*.mp4
e2e-results.xml

# production
lib
Expand Down
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
language: node_js
node_js:
- "node"
cache:
npm: true
directories:
- ~/.cache
before_script:
- npm install
- cd packages/mirador3-core
Expand All @@ -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
2 changes: 1 addition & 1 deletion packages/mirador3-app-base/jest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js",
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}"
"<rootDir>/src/**/?(*.)(spec|test|unit).{js,jsx,ts,tsx}"
],
"testEnvironment": "jsdom",
"testURL": "http://localhost",
Expand Down
3 changes: 3 additions & 0 deletions packages/mirador3-app-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
14 changes: 6 additions & 8 deletions packages/mirador3-app-base/src/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,22 @@ class App extends Component {
return 'Nothing Selected Yet';
}

buildManifestList() {
return Object.keys(this.props.manifests).map(manifest => (
<ManifestListItem key={manifest} manifest={manifest}/>));
}

/**
* render
* @return {String} - HTML markup for the component
*/
render() {
const manifestList = Object.keys(this.props.manifests).map(manifest => (
<ManifestListItem
key={manifest}
manifest={manifest}
/>
));
return (
<div className={ns('app')}>
<Workspace />
<div className={ns('control-panel')}>
<ManifestForm setLastRequested={this.setLastRequested} />
<ul>{manifestList}</ul>

<ul>{this.buildManifestList}</ul>
<Display
manifest={this.props.manifests[this.state.lastRequested]}
/>
Expand Down
10 changes: 10 additions & 0 deletions packages/mirador3-app-base/src/components/App.unit.jsx
Original file line number Diff line number Diff line change
@@ -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
})
})
3 changes: 0 additions & 3 deletions packages/mirador3-app-base/src/setupTests.js
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion packages/mirador3-e2e-tests/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"reporterOptions": {
"mochaFile": "e2e-results.xml",
"toConsole": true
}
},
"projectId": "epruij"
}
Original file line number Diff line number Diff line change
@@ -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();
});
});
5 changes: 3 additions & 2 deletions packages/mirador3-e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/mirador3-e2e-tests/src/start.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const server = require('./server');

process.title = server;
process.title = 'serverjs';
server.start(Number(process.env.PORT || 4000));

0 comments on commit 0b313c5

Please sign in to comment.