Skip to content

Commit

Permalink
Adds back E2E tests at project root and ripple-test-tools package (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylankelly authored Jul 1, 2019
1 parent d71d85a commit 7b0a6c6
Show file tree
Hide file tree
Showing 45 changed files with 3,742 additions and 144 deletions.
10 changes: 10 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"baseUrl": "http://localhost:3000",
"fixturesFolder": "test/e2e/fixtures",
"integrationFolder": "test/e2e/integration",
"pluginsFile": "test/e2e/plugins/index.js",
"screenshotsFolder": "test/e2e/screenshots",
"supportFile": "test/e2e/support/index.js",
"videosFolder": "test/e2e/videos",
"ignoreTestFiles": "*.js"
}
1 change: 1 addition & 0 deletions examples/vic-gov-au/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const tideFilters = require('./tide/tide.mapping-filters')

// .env variables.
require('dotenv').config()
process.env.DEBUG = 'nuxt:*' // display nuxt.js logs

export default {
/*
Expand Down
7 changes: 3 additions & 4 deletions examples/vic-gov-au/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
"dependencies": {
"@dpc-sdp/ripple-nuxt-tide": "1.0.0-beta.5",
"@dpc-sdp/ripple-nuxt-ui": "1.0.0-beta.5",
"@nuxtjs/axios": "^5.3.1",
"@nuxtjs/proxy": "^1.2.4",
"@nuxtjs/robots": "^2.0.0",
"@nuxtjs/style-resources": "^0.1.2",
"basic-auth": "^2.0.0",
"cookieparser": "^0.1.0",
"csvtojson": "^2.0.8",
"dotenv": "^5.0.1",
"nuxt": "2.6.3",
Expand All @@ -31,9 +30,9 @@
"svgo-loader": "^2.1.0"
},
"devDependencies": {
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@vue/test-utils": "1.0.0-beta.29",
"@vue/test-utils": "^1.0.0-beta.29",
"babel-eslint": "^10.0.1",
"babel-plugin-dynamic-import-node": "^2.2.0",
"cross-env": "^5.2.0",
"eslint": "^4.15.0",
"eslint-config-standard": "^10.2.1",
Expand Down
17 changes: 15 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,28 @@
"packages/ripple-nuxt-tide",
"packages/ripple-nuxt-ui",
"packages/ripple-create-app",
"packages/ripple-test-tools",
"examples/**/*"
],
"scripts": {
"publish": "lerna publish",
"start:storybook": "cd packages/ripple-ui-components/ && yarn run storybook",
"start:example": "cd examples/vic-gov-au/ && yarn run dev"
"start:example": "cd examples/vic-gov-au/ && yarn run dev",
"test:dev": "NODE_ENV=dev start-server-and-test start:example http://localhost:3000 cy:open",
"test:storybook": "cd packages/ripple-ui-components/ && yarn run test",
"cy:open": "cypress open"

},
"devDependencies": {
"lerna": "^3.0.0"
"lerna": "^3.0.0",
"cypress": "^3.1.5",
"cypress-axe": "^0.4.0",
"cypress-cucumber-preprocessor": "^1.11.0",
"axe-core": "^3.2.2",
"start-server-and-test": "^1.7.11"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
},
"browserslist": [
"> 1%",
Expand Down
1 change: 0 additions & 1 deletion packages/ripple-nuxt-tide/lib/core/tide.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export const tide = (axios, site, config) => ({
if (!_.isEmpty(headers)) {
_.merge(config, {headers: headers})
}

return axios.$get(url, config)
},

Expand Down
3 changes: 2 additions & 1 deletion packages/ripple-nuxt-tide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"@dpc-sdp/ripple-timeline": "1.0.0-beta.5",
"@dpc-sdp/ripple-updated-date": "1.0.0-beta.5",
"@dpc-sdp/ripple-whats-next": "1.0.0-beta.5",
"@nuxtjs/proxy": "^1.2.4",
"@nuxtjs/axios": "^5.3.1",
"cheerio": "^1.0.0-rc.2",
"cookies": "^0.7.3",
"elastic-builder": "^2.0.2",
Expand All @@ -65,7 +67,6 @@
},
"peerDependencies": {
"@nuxtjs/axios": "^5.3.1",
"@nuxtjs/proxy": "^1.2.4",
"nuxt": "^2.4.3"
}
}
38 changes: 38 additions & 0 deletions packages/ripple-test-tools/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint-disable no-undef */
const csv = require('csvtojson')
const faker = require('faker')

function rippleCommands () {
Cypress.Commands.add('csvFixture', fixturePath => {
const csvToJson = async data => {
faker.locale = 'en_AU'
const csvData = await csv().fromString(data)
if (csvData) {
return csvData.reduce((o, val) => {
let value = val.value
if (value.length === 0 && val.Random && val.Random.length > 0) {
if (val.Random.charAt(0) === '{') {
value = faker.fake(val.Random)
} else if (val.Random.charAt(0) === '[') {
const randomValues = val.Random.substr(
1,
val.Random.length - 2
).split(',')
value =
randomValues[Math.floor(Math.random() * randomValues.length)]
}
}
o[Cypress._.camelCase(val.key)] = value
return o
}, {})
}
}

cy.fixture(fixturePath).then(async data => {
const fixtureData = await csvToJson(data)
return fixtureData
})
})
}

module.exports = rippleCommands
27 changes: 27 additions & 0 deletions packages/ripple-test-tools/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

const TideAdmin = require('./tide-admin')

module.exports = (on, config) => {
on('task', {
createLandingPage (data) {
return new TideAdmin().createLandingPage(data)
},
deleteUser (userId) {
return new TideAdmin().deleteUser(userId)
},
createGrantPage (data) {
return new TideAdmin().createGrantPage(data)
},
createUser (user) {
return new TideAdmin().createUser(user)
},
configureProtectedContent (options) {
return new TideAdmin().configureProtectedContent(options)
},
deleteNode (userId) {
return new TideAdmin().deleteNode(userId)
}
})

return config
}
17 changes: 17 additions & 0 deletions packages/ripple-test-tools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@dpc-sdp/ripple-test-tools",
"version": "1.0.0-beta.5",
"description": "Cypress.io helper library for testing a ripple nuxt site and tide backend",
"license": "Apache-2.0",
"contributors": [
{
"name": "Dylan Kelly <dylan.kelly@dpc.vic.gov.au>"
}
],
"main": "index.js",
"dependencies": {
"csvtojson": "^2.0.8",
"faker": "^4.1.0",
"puppeteer": "^1.13.0"
}
}
157 changes: 157 additions & 0 deletions packages/ripple-test-tools/page-models.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
const { dataSel, hrefSel } = require('./util')

const adminPageModels = {
login: {
name: '#edit-name',
pass: '#edit-pass',
form: '#user-login-form'
},
common: {
title: dataSel('edit-title-0-value'),
summary: dataSel('edit-field-landing-page-summary-0-value'),
topic: dataSel('edit-field-topic-0-target-id'),
siteCheckbox: (site) => dataSel(`edit-field-node-site-${site}`),
primarySite: (site) => dataSel(`edit-field-node-primary-site-${site}`),
moderationState: dataSel('edit-moderation-state-0-state')
},
landingPage: {
formId: dataSel('node-landing-page-form'),
componentSelect: dataSel('edit-field-landing-page-component-add-more-add-more-select'),
componentAddButton: dataSel('edit-field-landing-page-component-add-more-add-more-button'),
webFormTitle: dataSel('edit-field-landing-page-component-0-subform-field-paragraph-title-0-value'),
webFormType: dataSel('edit-field-landing-page-component-0-subform-field-paragraph-webform-0-target-id'),
authenticatedContent: dataSel('edit-field-authenticated-content'),
components: {
accordion: {
title: (idx) => dataSel(`edit-field-landing-page-component-${idx}-subform-field-paragraph-title-0-value`),
style: (idx) => dataSel(`edit-field-landing-page-component-${idx}-subform-field-paragraph-accordion-style`),
item: {
name: (cmpIdx, accIdx) => dataSel(`edit-field-landing-page-component-${cmpIdx}-subform-field-paragraph-accordion-${accIdx}-subform-field-paragraph-accordion-name-0-value`),
content: (cmpIdx, accIdx) => dataSel(`edit-field-landing-page-component-${cmpIdx}-subform-field-paragraph-accordion-${accIdx}-subform-field-paragraph-accordion-body-wrapper`),
addItemBtn: (cmpIdx) => `[name="field_landing_page_component_${cmpIdx}_subform_field_paragraph_accordion_accordion_content_add_more"]`
}
},
basic: {
wysiwyg: '.paragraph-type--basic-text:first-child .form-textarea-wrapper'
},
webform: {
title: (idx) => dataSel(`edit-field-landing-page-component-${idx}-subform-field-paragraph-title-0-value`),
type: (idx) => dataSel(`edit-field-landing-page-component-${idx}-subform-field-paragraph-webform-0-target-id`)
},
cardEventAuto: {
cta: (idx) => dataSel(`edit-field-landing-page-component-${idx}-subform-field-paragraph-cta-text-0-value`),
event: (idx) => dataSel(`edit-field-landing-page-component-${idx}-subform-field-paragraph-reference-0-target-id`)
},
userAuthBlock: {
nextPage: (idx) => dataSel(`edit-field-landing-page-component-${idx}-subform-field-next-page-0-uri`)
}
}
},
createUser: {
email: dataSel('edit-mail'),
username: dataSel('edit-name'),
password: dataSel('edit-pass-pass1'),
passwordConfirm: dataSel('edit-pass-pass2'),
statusBlocked: dataSel('edit-status-0'),
statusConfirmed: dataSel('edit-status-1'),
submitButton: dataSel('edit-submit'),
memberRole: dataSel('edit-roles-member')
},
deleteUser: {
deleteAccountAndContent: dataSel('edit-user-cancel-method-user-cancel-delete')
},
grantPage: {
tabs: {
grantDetails: hrefSel('#edit-group-body-content'),
grantAuthor: hrefSel('#edit-group-grant-author')
},
grantDetails: {
tabs: {
overview: hrefSel('#edit-group-grant-overview'),
timeline: hrefSel('#edit-group-grant-timeline'),
guidelines: hrefSel('#edit-group-guidelines'),
supportingDocs: hrefSel('#edit-group-supporting-documents')
},
overview: {
title: dataSel('edit-field-overview-title-0-value'),
funding: {
from: dataSel('edit-field-node-funding-level-0-from'),
to: dataSel('edit-field-node-funding-level-0-to')
},
audienceAddMore: dataSel('edit-field-audience-add-more'),
audience1: dataSel('edit-field-audience-0-target-id'),
audience2: dataSel('edit-field-audience-1-target-id'),
ongoingCheckbox: dataSel('edit-field-node-on-going-value'),
cta: {
uri: dataSel('edit-field-call-to-action-0-uri'),
title: dataSel('edit-field-call-to-action-0-title')
},
date: {
startdate: dataSel('edit-field-node-dates-0-value-date'),
starttime: dataSel('edit-field-node-dates-0-value-time'),
enddate: dataSel('edit-field-node-dates-0-end-value-date'),
endtime: dataSel('edit-field-node-dates-0-end-value-time')
},
description: dataSel('edit-field-description-wrapper'),
websiteUrl: dataSel('edit-field-node-link-0-uri')
},
timeline: {
title: dataSel('edit-field-node-timeline-0-subform-field-paragraph-title-0-value'),
item: {
title: dataSel('edit-field-node-timeline-0-subform-field-timeline-0-subform-field-paragraph-title-0-value'),
summary: dataSel('edit-field-node-timeline-0-subform-field-timeline-0-subform-field-paragraph-summary-0-value'),
startdate: dataSel('edit-field-node-timeline-0-subform-field-timeline-0-subform-field-paragraph-date-range-0-value-date'),
starttime: dataSel('edit-field-node-timeline-0-subform-field-timeline-0-subform-field-paragraph-date-range-0-value-time'),
enddate: dataSel('edit-field-node-timeline-0-subform-field-timeline-0-subform-field-paragraph-date-range-0-end-value-date'),
endtime: dataSel('edit-field-node-timeline-0-subform-field-timeline-0-subform-field-paragraph-date-range-0-end-value-time')
}
},
guidelines: {
eligibility: {
title: dataSel('edit-field-node-guidelines-0-subform-field-paragraph-accordion-0-subform-field-paragraph-accordion-name-0-value'),
text: dataSel('edit-field-node-guidelines-0-subform-field-paragraph-accordion-0-subform-field-paragraph-accordion-body-wrapper')
},
criteria: {
title: dataSel('edit-field-node-guidelines-0-subform-field-paragraph-accordion-1-subform-field-paragraph-accordion-name-0-value'),
text: dataSel('edit-field-node-guidelines-0-subform-field-paragraph-accordion-1-subform-field-paragraph-accordion-body-wrapper')
},
process: {
title: dataSel('edit-field-node-guidelines-0-subform-field-paragraph-accordion-2-subform-field-paragraph-accordion-name-0-value'),
text: dataSel('edit-field-node-guidelines-0-subform-field-paragraph-accordion-2-subform-field-paragraph-accordion-body-wrapper')
},
howToApply: {
title: dataSel('edit-field-node-guidelines-0-subform-field-paragraph-accordion-3-subform-field-paragraph-accordion-name-0-value'),
text: dataSel('edit-field-node-guidelines-0-subform-field-paragraph-accordion-3-subform-field-paragraph-accordion-body-wrapper')
}
}
},
grantAuthor: {
fullName: dataSel('edit-field-node-author-0-value'),
email: dataSel('edit-field-node-email-0-value'),
phone: dataSel('edit-field-node-phone-0-value'),
department: dataSel('edit-field-node-department')
}
},
jwt: {
expiry: dataSel('edit-jwt-exp'),
key: dataSel('edit-jwt-key')
},
accounts: {
adminApproval: dataSel('edit-user-register-visitors-admin-approval')
}

}

const frontEndPageModels = {
grant: {

},
landingPage: {

}
}

module.exports = {
adminPageModels,
frontEndPageModels
}
Loading

0 comments on commit 7b0a6c6

Please sign in to comment.