From ea2b9435e0b8c7181acdf853932dc590ecd9f323 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Thu, 6 Sep 2018 16:37:27 +0200 Subject: [PATCH] Add circle CI check on our partner integration (pole-emploi) --- circle.yml | 79 +++++++++++++------ cypress.json | 3 +- cypress/{integration => }/.eslintrc.yaml | 0 .../embauche/{landing.js => embauche.js} | 11 +++ .../embauche/external-integrations.js | 11 +++ cypress/integration/embauche/iframe.js | 14 ---- cypress/support/commands.js | 5 ++ 7 files changed, 85 insertions(+), 38 deletions(-) rename cypress/{integration => }/.eslintrc.yaml (100%) rename cypress/integration/embauche/{landing.js => embauche.js} (71%) create mode 100644 cypress/integration/embauche/external-integrations.js delete mode 100644 cypress/integration/embauche/iframe.js diff --git a/circle.yml b/circle.yml index dffaee4f6..ca69018a3 100644 --- a/circle.yml +++ b/circle.yml @@ -1,42 +1,75 @@ version: 2 jobs: - build: + unit-test: + docker: + - image: cypress/base:8 + steps: + - checkout + - restore_cache: + keys: + - v1-deps-{{ .Branch }}-{{ checksum "package.json" }} + - v1-deps-{{ .Branch }} + - v1-deps + - run: yarn install --frozen-lockfile + - save_cache: + key: v1-deps-{{ .Branch }}-{{ checksum "package.json" }} + paths: + - ~/.cache + - run: | + yarn run flow-typed install + git config --global core.quotepath false + yarn test + + end-to-end-test: docker: - image: cypress/base:8 environment: ## this enables colors in the output TERM: xterm CYPRESS_baseUrl: http://localhost:5000 - working_directory: ~/app steps: - checkout - restore_cache: - name: Restore Yarn and Cypress Cache keys: - v1-deps-{{ .Branch }}-{{ checksum "package.json" }} - v1-deps-{{ .Branch }} - v1-deps - - run: - name: Install Dependencies - command: | - yarn install --frozen-lockfile + - run: yarn install --frozen-lockfile - save_cache: - name: Save Yarn and Cypress Cache key: v1-deps-{{ .Branch }}-{{ checksum "package.json" }} paths: - ~/.cache - - run: - name: Install flow-typed - command: yarn run flow-typed install - - run: - name: Change git config to support UTF8 filename - command: git config --global core.quotepath false - - run: - name: Linting and unit test - command: yarn test - - run: - name: End to end test - command: | - yarn run compile - yarn run serve:embauche & - yarn run cypress run --record --key 21660df5-36a5-4c49-b23d-801799b0c759 + - run: | + yarn run compile + yarn run serve:embauche & + yarn run cypress run --record --key 21660df5-36a5-4c49-b23d-801799b0c759 --spec 'cypress/integration/**/!(external-integrations.js)' + +production-test: + docker: + - image: cypress/base:8 + environment: + ## this enables colors in the output + TERM: xterm + CYPRESS_baseUrl: http://embauche.beta.gouv.fr + steps: + - run: npm install --save-dev cypress + # We wait an arbitrary 4 min for the deploy (TODO: use netlify hook for triggering a this job) + - run: sleep 4 * 60 * 60 + - run: yarn run cypress run --record --key 21660df5-36a5-4c49-b23d-801799b0c759 + +workflows: + version: 2 + test: + jobs: + - unit-test + - end-to-end-test + - test-prod: + filters: + branches: + only: master + +experimental: + notify: + branches: + only: + - master diff --git a/cypress.json b/cypress.json index 7dabb88a0..98f25613b 100644 --- a/cypress.json +++ b/cypress.json @@ -1,4 +1,5 @@ { "projectId": "jxcngh", - "baseUrl": "http://localhost:8080/embauche" + "baseUrl": "http://localhost:8080/embauche", + "chromeWebSecurity": false } diff --git a/cypress/integration/.eslintrc.yaml b/cypress/.eslintrc.yaml similarity index 100% rename from cypress/integration/.eslintrc.yaml rename to cypress/.eslintrc.yaml diff --git a/cypress/integration/embauche/landing.js b/cypress/integration/embauche/embauche.js similarity index 71% rename from cypress/integration/embauche/landing.js rename to cypress/integration/embauche/embauche.js index c7f81ef38..011077d11 100644 --- a/cypress/integration/embauche/landing.js +++ b/cypress/integration/embauche/embauche.js @@ -6,6 +6,7 @@ const salaryInput = inputTitle => { inputContainer.click() return inputContainer.find('input') } + describe('Landing basic test', function() { it('should not crash', function() { cy.visit('/') @@ -20,3 +21,13 @@ describe('Landing basic test', function() { cy.get('.distribution-chart__container') }) }) + +describe('Iframe integration test', function() { + it('should display an iframe of the simulateur', function() { + cy.visit('/integration-test') + cy.get('#simulateurEmbauche') + .iframe() + .contains('Entrez un salaire mensuel') + cy.debug() + }) +}) diff --git a/cypress/integration/embauche/external-integrations.js b/cypress/integration/embauche/external-integrations.js new file mode 100644 index 000000000..219f32845 --- /dev/null +++ b/cypress/integration/embauche/external-integrations.js @@ -0,0 +1,11 @@ +describe('Pole emploi test', function() { + it('should display an iframe of the simulateur', function() { + cy.on('uncaught:exception', err => { + return !err.message.contains('Unexpected token <') + }) + cy.visit('https://entreprise.pole-emploi.fr/cout-salarie/') + cy.get('#simulateurEmbauche') + .iframe() + .contains('Entrez un salaire mensuel') + }) +}) diff --git a/cypress/integration/embauche/iframe.js b/cypress/integration/embauche/iframe.js deleted file mode 100644 index a39e6c5d6..000000000 --- a/cypress/integration/embauche/iframe.js +++ /dev/null @@ -1,14 +0,0 @@ -Cypress.Commands.add('iframe', { prevSubject: 'element' }, $iframe => { - return new Cypress.Promise(resolve => { - setTimeout(() => resolve($iframe.contents().find('body')), 5000) - }) -}) - -describe('Iframe integration test', function() { - it('should display an iframe of the simulateur', function() { - cy.visit('/integration-test') - cy.get('iframe') - .iframe() - .contains('Entrez un salaire mensuel') - }) -}) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index c1f5a772e..7636dcaf0 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -23,3 +23,8 @@ // // -- This is will overwrite an existing command -- // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) +Cypress.Commands.add('iframe', { prevSubject: 'element' }, $iframe => { + return new Cypress.Promise(resolve => { + setTimeout(() => resolve($iframe.contents().find('body')), 5000) + }) +})