Skip to content

Commit

Permalink
Merge pull request #1309 from thebiggive/develop
Browse files Browse the repository at this point in the history
develop to main
  • Loading branch information
NoelLH authored Sep 26, 2023
2 parents 5a33091 + e50374a commit 88ad51e
Show file tree
Hide file tree
Showing 31 changed files with 2,591 additions and 4,643 deletions.
27 changes: 16 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,30 @@ jobs:
wget http://archive.ubuntu.com/ubuntu/pool/main/libu/libu2f-host/libu2f-udev_1.1.4-1_all.deb;
sudo dpkg -i libu2f-udev_1.1.4-1_all.deb;
cd ~/donate
# We can't use Chrome 115+ without a hack until we retire Protractor e2e's (which is planned).
# See https://github.com/angular/webdriver-manager/issues/523
- browser-tools/install-chrome:
chrome-version: 114.0.5735.90 # https://github.com/puppeteer/puppeteer/blob/main/versions.js
chrome-version: 116.0.5845.96 # https://github.com/puppeteer/puppeteer/blob/main/versions.js
- browser-tools/install-chromedriver

- checkout

- restore_cache:
keys:
- v4-dependencies-with-chrome-{{ checksum "package-lock.json" }}
- v5-dependencies-with-chrome-{{ checksum "package-lock.json" }}

- run: npm install --quiet

- save_cache:
paths:
- node_modules
- /home/circleci/.cache/Cypress
- /home/circleci/.cache/puppeteer
key: v4-dependencies-with-chrome-{{ checksum "package-lock.json" }}
key: v5-dependencies-with-chrome-{{ checksum "package-lock.json" }}

- run: npm run ci

- store_artifacts:
path: cypress/screenshots

deploy-staging-static:
docker:
# This image's base Node version must match that used in `Dockerfile`, which is the basis for ECS app
Expand All @@ -66,14 +68,15 @@ jobs:

- restore_cache:
keys:
- v4-dependencies-{{ checksum "package-lock.json" }}
- v5-dependencies-{{ checksum "package-lock.json" }}
- run: npm config set puppeteer_skip_chromium_download true
- run: npm install --quiet
- save_cache:
paths:
- node_modules
- /home/circleci/.cache/Cypress
- /home/circleci/.cache/puppeteer
key: v4-dependencies-{{ checksum "package-lock.json" }}
key: v5-dependencies-{{ checksum "package-lock.json" }}

- run: npm run build:staging

Expand Down Expand Up @@ -109,14 +112,15 @@ jobs:

- restore_cache:
keys:
- v4-dependencies-{{ checksum "package-lock.json" }}
- v5-dependencies-{{ checksum "package-lock.json" }}
- run: npm config set puppeteer_skip_chromium_download true
- run: npm install --quiet
- save_cache:
paths:
- node_modules
- /home/circleci/.cache/Cypress
- /home/circleci/.cache/puppeteer
key: v4-dependencies-{{ checksum "package-lock.json" }}
key: v5-dependencies-{{ checksum "package-lock.json" }}

- run: npm run build:regression

Expand Down Expand Up @@ -152,14 +156,15 @@ jobs:

- restore_cache:
keys:
- v4-dependencies-{{ checksum "package-lock.json" }}
- v5-dependencies-{{ checksum "package-lock.json" }}
- run: npm config set puppeteer_skip_chromium_download true
- run: npm install --quiet
- save_cache:
paths:
- node_modules
- /home/circleci/.cache/Cypress
- /home/circleci/.cache/puppeteer
key: v4-dependencies-{{ checksum "package-lock.json" }}
key: v5-dependencies-{{ checksum "package-lock.json" }}

- run: npm run build:production

Expand Down
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
],
"parserOptions": {
"project": [
"tsconfig.json",
"e2e/tsconfig.json"
"tsconfig.json"
],
"createDefaultProgram": true
},
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ npm-debug.log
yarn-error.log
testem.log
/typings
/cypress/screenshots

# System Files
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.

### Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
Run `ng e2e` to execute the (minimal) end-to-end tests via Cypress.

### Further help

Expand Down
36 changes: 27 additions & 9 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,17 @@
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"builder": "@cypress/schematic:cypress",
"options": {
"protractorConfig": "e2e/protractor.conf.js"
"devServerTarget": "donate-frontend:serve",
"watch": false,
"headless": true
},
"configurations": {
"production": {
"devServerTarget": "donate-frontend:serve:production"
},
"development": {
"devServerTarget": "donate-frontend:serve:development"
}
},
"defaultConfiguration": "development"
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
Expand Down Expand Up @@ -321,13 +319,33 @@
"src/**/*.html"
]
}
},
"cypress-run": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "donate-frontend:serve"
},
"configurations": {
"production": {
"devServerTarget": "donate-frontend:serve:production"
}
}
},
"cypress-open": {
"builder": "@cypress/schematic:cypress",
"options": {
"watch": false,
"headless": true
}
}
}
}
},
"cli": {
"schematicCollections": [
"@angular-eslint/schematics"
"@cypress/schematic",
"@angular-eslint/schematics",
"@schematics/angular"
],
"analytics": false
},
Expand All @@ -339,4 +357,4 @@
"setParserOptionsProject": true
}
}
}
}
12 changes: 12 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from 'cypress'

export default defineConfig({
blockHosts: [
'sf-api-staging.thebiggivetest.org.uk',
'api.getAddress.io',
],
e2e: {
baseUrl: 'http://localhost:4200',
includeShadowDom: true,
},
})
20 changes: 20 additions & 0 deletions cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {CampaignStats} from "../../src/app/campaign-stats.model";

describe('App boot fundamentals', () => {
beforeEach(() => {
cy.intercept(
{url: "https://sf-api-staging.thebiggivetest.org.uk/campaigns/services/apexrest/v1.0/campaigns/stats"},
{
body: {totalRaised: 500_000, totalCampaignCount: 123_456} as CampaignStats
}
)
})

it('Shows our copy on the Donate home page', () => {
cy.visit('/');

cy.contains('Matching Donations.');
cy.contains('£500,000');
cy.contains('raised for over 123,456 charity projects since 2008');
})
})
5 changes: 5 additions & 0 deletions 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]"
}

43 changes: 43 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// ***********************************************
// This example namespace declaration will help
// with Intellisense and code completion in your
// IDE or Text Editor.
// ***********************************************
// declare namespace Cypress {
// interface Chainable<Subject = any> {
// customCommand(param: any): typeof customCommand;
// }
// }
//
// function customCommand(param: any): void {
// console.warn(param);
// }
//
// NOTE: You can use it like so:
// Cypress.Commands.add('customCommand', customCommand);
//
// ***********************************************
// 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 will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
21 changes: 21 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ***********************************************************
// This example support/e2e.ts 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
// ***********************************************************

// When a command from ./commands is ready to use, import with `import './commands'` syntax
// import './commands';

import {CampaignStats} from "../../src/app/campaign-stats.model";


8 changes: 8 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"include": ["**/*.ts"],
"compilerOptions": {
"sourceMap": false,
"types": ["cypress"]
}
}
14 changes: 0 additions & 14 deletions e2e/protractor-ci.conf.js

This file was deleted.

32 changes: 0 additions & 32 deletions e2e/protractor.conf.js

This file was deleted.

27 changes: 0 additions & 27 deletions e2e/src/app.e2e-spec.ts

This file was deleted.

10 changes: 0 additions & 10 deletions e2e/src/app.po.ts

This file was deleted.

Loading

0 comments on commit 88ad51e

Please sign in to comment.