Skip to content

Commit

Permalink
Add census functional test and add cypress
Browse files Browse the repository at this point in the history
Add cypress to packages

Generate pages from census too

Correct spelling

Add in census cypress happy path

Update helpers so they include missing attributes

Add census selenium happy path test

Upadate against codacy comments

Update to use camelcased var names

Update to use camelcased var names

Update to use camelcased var names

Update against codacy comments

Add cy as global

Use browser within selenium tests

Correct broken selenium test

Add shortcuts for testing census via cypress

Call cypress without ui

Use string based keys over reading from file

Remove unused module

Use environment vars

Missing semicolons

Remove unneccessary debug/timeout

Remove unused plugin file

Remove prefix filters from generate pages

Add call to census tests in travis script

Add display result for census tests

Add minimal cypress open config and update readme

Add cypress yarn entry
  • Loading branch information
iwootten committed Feb 14, 2019
1 parent 88f3ac2 commit b1b5737
Show file tree
Hide file tree
Showing 15 changed files with 1,163 additions and 79 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"$": true,
"jQuery": true,
"browser": true,
"cy": true,
"ga": true
},
"rules": {
Expand Down
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# eQ Census Survey Runner v3
[![Build Status](https://travis-ci.org/ONSdigital/eq-survey-runner.svg?branch=v3)](https://travis-ci.org/ONSdigital/eq-survey-runner)
[![codecov](https://codecov.io/gh/ONSdigital/eq-survey-runner/branch/v3/graph/badge.svg)](https://codecov.io/gh/ONSdigital/eq-survey-runner/branch/v3)
[![Build Status](https://travis-ci.org/ONSdigital/eq-survey-runner.svg?branch=v3)](https://travis-ci.org/ONSdigital/eq-survey-runner)
[![codecov](https://codecov.io/gh/ONSdigital/eq-survey-runner/branch/v3/graph/badge.svg)](https://codecov.io/gh/ONSdigital/eq-survey-runner/branch/v3)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a2bc191a96e546b99a6d1c33b9b0ed62)](https://app.codacy.com/project/MebinAbraham/eq-survey-runner/dashboard?branchId=10869033)

This version of runner looks at optimising the service to accommodate the Census.
There are a number of major changes we need make to survey runner to develop the features required for the Census.
These changes are a combination of fixing technical debt we've built up and adding new features.
While these changes would be possible to implement in ***v2***, having to develop them in such a way to be compatible with existing data and rolling deploys will add an un-acceptable overhead.
This version of runner looks at optimising the service to accommodate the Census.
There are a number of major changes we need make to survey runner to develop the features required for the Census.
These changes are a combination of fixing technical debt we've built up and adding new features.
While these changes would be possible to implement in ***v2***, having to develop them in such a way to be compatible with existing data and rolling deploys will add an un-acceptable overhead.

The changes we're aware of now:

Expand All @@ -21,9 +21,9 @@ The changes we're aware of now:
- relationships
- hub and spoke navigation
- look up patterns (address, occupation etc)
*Existing ***v2*** schemas will be easily migrate-able to the new format when ***v3*** is stable.
This will be clearly documented and there is the possibility of scripts being provided to migrate schemas.

*Existing ***v2*** schemas will be easily migrate-able to the new format when ***v3*** is stable.
This will be clearly documented and there is the possibility of scripts being provided to migrate schemas.
Once we know more about the implementation a decision will be made whether answer store migrations will be written for compatibility with existing data.*

---
Expand Down Expand Up @@ -156,6 +156,7 @@ Command | Task
`yarn test` | Runs the unit tests through Karma and the functional tests through a local Selenium instance.
`yarn test_unit` | Watches the unit tests via Karma.
`yarn test_functional` | Runs the functional tests through ChimpJS (requires app running on localhost:5000 and generated pages).
`yarn test_census` | Runs the census functional tests through Cypress (requires app running on localhost:5000 and generated pages).
`yarn generate_pages` | Generates the functional test pages.
`yarn lint` | Lints the JS, reporting errors/warnings.
`yarn format` | Format the json schemas.
Expand Down Expand Up @@ -211,6 +212,10 @@ To run the tests against a remote deployment you will need to specify the enviro

`EQ_FUNCTIONAL_TEST_ENV=https://staging-new-surveys.dev.eq.ons.digital/ yarn test_functional`

To run the census functional tests within the cypress UI:

./node_modules/cypress/bin/cypress open

### Deployment with elastic beanstalk

You will need to install the EB CLI tools using PIP.
Expand Down
7 changes: 7 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fixturesFolder": false,
"pluginsFile": false,
"supportFile": false,
"integrationFolder": "tests/functional/cypress/spec/",
"baseUrl": "http://localhost:5000"
}
4 changes: 2 additions & 2 deletions data/en/census_household.json
Original file line number Diff line number Diff line change
Expand Up @@ -5946,7 +5946,7 @@
"type": "TextField"
},
{
"id": "employer-adress-answer-postcode",
"id": "employer-address-answer-postcode",
"label": "Postcode",
"mandatory": false,
"type": "TextField"
Expand Down Expand Up @@ -6002,7 +6002,7 @@
"type": "TextField"
},
{
"id": "no-business-name-employer-adress-answer-postcode",
"id": "no-business-name-employer-address-answer-postcode",
"label": "Postcode",
"mandatory": false,
"type": "TextField"
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"test_unit": "gulp test:scripts:unit:watch",
"test_unit_no_watch": "gulp test:scripts:unit",
"test_functional": "chimp tests/functional/chimp.js",
"generate_pages": "rm -rf ./tests/functional/generated_pages && cd tests/functional && pipenv run ./generate_pages.py ../../data/en/ ./generated_pages -r '../../base_pages' -p 'test_' && cd ../..",
"test_census": "node tests/functional/cypress.js",
"cypress": "cypress open",
"generate_pages": "rm -rf ./tests/functional/generated_pages && cd tests/functional && pipenv run ./generate_pages.py ../../data/en/ ./generated_pages -r '../../base_pages' && cd ../..",
"a11y": "gulp test:a11ym",
"format": "gulp format:json"
},
Expand All @@ -42,6 +44,7 @@
"chai-as-promised": "^7.1.1",
"chimp": "^0.50.0",
"cssnano": "^3.10.0",
"cypress": "^3.1.5",
"del": "^3.0.0",
"eslint": "^4.3.0",
"eslint-config-standard": "^10.2.1",
Expand Down
5 changes: 5 additions & 0 deletions scripts/run_tests_functional.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ echo "Running front end functional tests"
yarn test_functional

display_result $? 5 "Front end functional tests"

echo "Running census functional tests"
yarn test_census

display_result $? 6 "Front end census functional tests"
12 changes: 12 additions & 0 deletions tests/functional/cypress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const cypress = require('cypress');

cypress.run({
headed: process.env.EQ_RUN_FUNCTIONAL_TESTS_HEADLESS ? false : true,
config: {
baseUrl: process.env.EQ_FUNCTIONAL_TEST_ENV || "http://localhost:5000",
viewportWidth: 1280,
viewportHeight: 1080,
video: false,
integrationFolder: "tests/functional/cypress/spec/"
}
});
22 changes: 22 additions & 0 deletions tests/functional/cypress/helpers/census.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const _ = require('lodash');
const generateToken = require('../../jwt_helper');

const getUri = uri => cy.config.baseUrl + uri;

const getRandomString = length => _.sampleSize('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', length).join('');

const openCensusQuestionnaire = (schema, sexualIdentity = false, region = 'GB-ENG', language = 'en') => {
return cy
.then(() => {
return generateToken(schema, {userId: getRandomString(10), collectionId: getRandomString(10), periodId: '2011', periodStr: null, regionCode: region, languageCode: language, sexualIdentity: sexualIdentity, country: 'E', displayAddress: '68 Abingdon Road, Goathill'});
})
.then(function(token) {
return cy.visit('/session?token=' + token);
});
};

module.exports = {
getUri,
getRandomString,
openCensusQuestionnaire
};
Loading

0 comments on commit b1b5737

Please sign in to comment.