Skip to content

Commit

Permalink
adds cypress testing
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-johnson committed Dec 14, 2018
1 parent 4484f22 commit 6994b77
Show file tree
Hide file tree
Showing 20 changed files with 120 additions and 91 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
node_modules/
.idea
1 change: 1 addition & 0 deletions minimal_redux_poc/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
config/
coverage/

3 changes: 2 additions & 1 deletion minimal_redux_poc/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
coverage/

videos/
screenshots/
21 changes: 0 additions & 21 deletions minimal_redux_poc/__tests__/integration/mirador/basic.test.js

This file was deleted.

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions minimal_redux_poc/__tests__/integration/vanilla-js.test.js

This file was deleted.

8 changes: 0 additions & 8 deletions minimal_redux_poc/__tests__/integration/vanilla-js/README.md

This file was deleted.

1 change: 1 addition & 0 deletions minimal_redux_poc/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions minimal_redux_poc/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
15 changes: 15 additions & 0 deletions minimal_redux_poc/cypress/integration/mirador-base.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* global cy */
describe('Mirador Base', () => {
it('Visits Mirador Base', () => {
cy.visit('http://localhost:4444/cypress/public/mirador/');
cy.get('title').should('contain', 'Mirador');
cy.get('#manifestURL').type('https://purl.stanford.edu/sn904cj3429/iiif/manifest');
cy.get('#fetchBtn').click();
cy.get('li').should('contain', 'https://purl.stanford.edu/sn904cj3429/iiif/manifest');
cy.get('h3').should('contain', 'Peter\'s San Francisco Locator. The Birds-Eye-View Map of the Exposition City. Published by Locator Publishing Co');
cy.get('li>button').click();
cy.get('.mirador-window>img').should('have.attr', 'src', 'https://stacks.stanford.edu/image/iiif/sn904cj3429%2F12027000/full/!400,400/0/default.jpg');
cy.get('.mirador-window-close').click();
cy.get('mirador-window').should('not.exist');
});
});
12 changes: 12 additions & 0 deletions minimal_redux_poc/cypress/integration/mirador-config.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* global cy */
describe('Config updating from instance', () => {
it('can modify the config via api', () => {
cy.visit('http://localhost:4444/cypress/public/mirador/');
cy.window().then((win) => {
const a = win.miradorInstance.actions.updateConfig({ foo: 'bat' });
win.miradorInstance.store.dispatch(a);
const configFromState = win.miradorInstance.store.getState().config;
expect(configFromState.foo).to.equal('bat');
});
});
});
13 changes: 13 additions & 0 deletions minimal_redux_poc/cypress/integration/vanilla.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* global cy */
describe('Plain JavaScript example', () => {
it('has the correct page title', () => {
cy.visit('http://localhost:4444/cypress/public/vanilla/');
cy.get('title').should('contain', 'Examples');
});
it('loads a manifest and displays it', () => {
cy.visit('http://localhost:4444/cypress/public/vanilla/');
cy.get('#manifestURL').type('https://purl.stanford.edu/sn904cj3429/iiif/manifest');
cy.get('#fetchBtn').click();
cy.get('#exampleManifest').should('contain', 'http://iiif.io/api/presentation/2/context.json');
});
});
17 changes: 17 additions & 0 deletions minimal_redux_poc/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
};
25 changes: 25 additions & 0 deletions minimal_redux_poc/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions minimal_redux_poc/cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands';

// Alternatively you can use CommonJS syntax:
// require('./commands')
9 changes: 0 additions & 9 deletions minimal_redux_poc/jest-puppeteer.config.js

This file was deleted.

11 changes: 8 additions & 3 deletions minimal_redux_poc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
"description": "",
"main": "index.js",
"scripts": {
"cypress:open": "npm run pretest & cypress open && npm run posttest",
"cypress:run": "cypress run cypress.json",
"lint": "node_modules/.bin/eslint ./",
"pretest": "npm run server:e2e",
"posttest": "kill $(lsof -t -i:4444)",
"server": "node_modules/.bin/http-server",
"test": "npm run build && npm run lint && jest -c jest.json",
"server:e2e": "http-server -p 4444 &",
"test": "npm run build && npm run lint && jest -c jest.json && npm run cypress:run",
"test:coverage": "jest -c jest.json --coverage",
"test:watch": "jest -c jest.json --watch",
"build": "webpack --mode=production",
Expand Down Expand Up @@ -47,6 +52,7 @@
"babel-plugin-named-asset-import": "^0.2.3",
"concurrently": "^4.0.1",
"css-loader": "^1.0.0",
"cypress": "^3.1.2",
"enzyme": "^3.4.4",
"enzyme-adapter-react-16": "^1.2.0",
"eslint": "^5.10.0",
Expand All @@ -61,8 +67,7 @@
"http-server": "^0.11.1",
"jest": "^22.4.4",
"jest-fetch-mock": "^1.5.0",
"jest-puppeteer": "^3.0.1",
"puppeteer": "^1.4.0",
"jest-puppeteer": "^3.7.0",
"react-dev-utils": "^6.1.1",
"redux-mock-store": "^1.5.1",
"style-loader": "^0.22.1",
Expand Down

0 comments on commit 6994b77

Please sign in to comment.