From a670b244ac0c63226cd4b4df21a386dbe9980909 Mon Sep 17 00:00:00 2001 From: Paul Friederichsen Date: Wed, 24 Jun 2020 06:02:58 -0500 Subject: [PATCH 1/8] Create tests GH Actions workflow based on iteration template --- .github/workflows/tests.yml | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..0064850 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,47 @@ +name: Tests + +on: [push] + +jobs: + unit-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Cache node modules + uses: actions/cache@v1 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Use Node.js 12.x + uses: actions/setup-node@v1 + with: + node-version: 12.x + - name: Install dependencies (npm ci) + run: npm ci + working-directory: ./phone-store + - name: Run unit tests (npm run test) + run: npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI + working-directory: ./phone-store + e2e-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Cache node modules + uses: actions/cache@v1 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Use Node.js 12.x + uses: actions/setup-node@v1 + with: + node-version: 12.x + - name: Install dependencies (npm ci) + run: npm ci + working-directory: ./phone-store + - name: Run e2e tests + run: npm run e2eci + working-directory: ./phone-store From 085cb80e72f45678954de089fe7439bda48dcea6 Mon Sep 17 00:00:00 2001 From: Paul Friederichsen Date: Wed, 24 Jun 2020 06:05:04 -0500 Subject: [PATCH 2/8] Add ChromeHeadlessCI launcher to karma.conf.js --- phone-store/karma.conf.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phone-store/karma.conf.js b/phone-store/karma.conf.js index 1b1f7f8..25d98ff 100644 --- a/phone-store/karma.conf.js +++ b/phone-store/karma.conf.js @@ -26,6 +26,12 @@ module.exports = function (config) { logLevel: config.LOG_INFO, autoWatch: true, browsers: ['Chrome'], + customLaunchers: { + ChromeHeadlessCI: { + base: 'ChromeHeadless', + flags: ['--no-sandbox'] + } + }, singleRun: false, restartOnFileChange: true }); From 9876d04b76eb7fc550a6e791cb338adb34f1fe1c Mon Sep 17 00:00:00 2001 From: Paul Friederichsen Date: Wed, 24 Jun 2020 06:05:58 -0500 Subject: [PATCH 3/8] Create protractor-ci.conf.js --- phone-store/e2e/protractor-ci.conf.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 phone-store/e2e/protractor-ci.conf.js diff --git a/phone-store/e2e/protractor-ci.conf.js b/phone-store/e2e/protractor-ci.conf.js new file mode 100644 index 0000000..d36bc73 --- /dev/null +++ b/phone-store/e2e/protractor-ci.conf.js @@ -0,0 +1,15 @@ +const config = require('./protractor.conf').config; + +config.capabilities = { + browserName: 'chrome', + chromeOptions: { + args: ['--headless', '--no-sandbox'] + } +}; + +config.highlightDelay = undefined; + +config.seleniumServerJar = process.env.SELENIUM_JAR_PATH; +config.chromeDriver = process.env.CHROMEWEBDRIVER + '/chromedriver'; + +exports.config = config; From e4b0c0b49255e0b358aac93780b9936a527b33f1 Mon Sep 17 00:00:00 2001 From: Paul Friederichsen Date: Wed, 24 Jun 2020 06:08:13 -0500 Subject: [PATCH 4/8] Add e2e element highlighting from iteration template --- phone-store/e2e/protractor.conf.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phone-store/e2e/protractor.conf.js b/phone-store/e2e/protractor.conf.js index 7c798cf..5530bc7 100644 --- a/phone-store/e2e/protractor.conf.js +++ b/phone-store/e2e/protractor.conf.js @@ -28,5 +28,7 @@ exports.config = { project: require('path').join(__dirname, './tsconfig.json') }); jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); - } -}; \ No newline at end of file + }, + useBlockingProxy: true, + highlightDelay: 200 // How long it waits and highlights before interacting with an element +}; From 0df3aa3d966b4950f85b0c397d2aabbc58e89f14 Mon Sep 17 00:00:00 2001 From: Paul Friederichsen Date: Wed, 24 Jun 2020 06:08:38 -0500 Subject: [PATCH 5/8] Add custom E2E scripts from iteration template --- phone-store/package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phone-store/package.json b/phone-store/package.json index c0d5ac3..57b4650 100644 --- a/phone-store/package.json +++ b/phone-store/package.json @@ -7,7 +7,9 @@ "build": "ng build", "test": "ng test", "lint": "ng lint", - "e2e": "ng e2e" + "e2e": "ng e2e", + "pree2e": "node node_modules/protractor/bin/webdriver-manager -- update --gecko false", + "e2eci": "ng e2e --protractor-config=e2e/protractor-ci.conf.js" }, "private": true, "dependencies": { From 75e6140c684f1d45859d71d5d1b88d9d3594b95f Mon Sep 17 00:00:00 2001 From: Paul Friederichsen Date: Wed, 24 Jun 2020 06:11:35 -0500 Subject: [PATCH 6/8] Set directConnect: false in e2e test config to match iteration template --- phone-store/e2e/protractor.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phone-store/e2e/protractor.conf.js b/phone-store/e2e/protractor.conf.js index 5530bc7..d162761 100644 --- a/phone-store/e2e/protractor.conf.js +++ b/phone-store/e2e/protractor.conf.js @@ -15,7 +15,7 @@ exports.config = { capabilities: { browserName: 'chrome' }, - directConnect: true, + directConnect: false, baseUrl: 'http://localhost:4200/', framework: 'jasmine', jasmineNodeOpts: { From 48175dfa11990d14e18d6645ce378d5c288d98d6 Mon Sep 17 00:00:00 2001 From: Paul Friederichsen Date: Wed, 24 Jun 2020 15:47:45 -0500 Subject: [PATCH 7/8] Add "webdriverUpdate": false to e2e test config in angular.json From the iteration template --- phone-store/angular.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phone-store/angular.json b/phone-store/angular.json index 13b0637..7c9945f 100644 --- a/phone-store/angular.json +++ b/phone-store/angular.json @@ -114,7 +114,8 @@ "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "e2e/protractor.conf.js", - "devServerTarget": "phone-store:serve" + "devServerTarget": "phone-store:serve", + "webdriverUpdate": false }, "configurations": { "production": { From 023e3f2a45433659d7184b31055a38e97feaf252 Mon Sep 17 00:00:00 2001 From: Nic McPhee Date: Fri, 26 Jun 2020 10:30:41 -0500 Subject: [PATCH 8/8] Add GitHub actions to the README This very briefly mentions how the GitHub Actions were set up and the need to load the `webdriver-manager` binaries. --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index fcd5689..331b8df 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,23 @@ We will also not provide a complete tutorial on E2E tests with protractor or uni - :question: This creates a directory called `phone-store` in the project. Do we want to change the name to `client` to be more like our later structures? - At this point you can go into the `phone-store` directory and run `ng server` and see our little project! :smile: It of course doesn't actually _do_ anything interesting yet, but it does work. +### Setup GitHub Actions + +@floogulinc set up the GitHub Actions based on work done in S20. +These are all laid out in [this pull request](https://github.com/UMM-CSci-3601/revised-angular-tutorial/pull/3). + +For reasons we don't fully understand, this requires installing +some `webdriver-manager` binaries that didn't get installed on +their own. Without them, we can't run the `e2e` tests. + +Running: + +```bash +node_modules/protractor/bin/webdriver-manager update +``` + +installed the necessary binaries and all the tests ran and passed. + ## Start making components The tutorial starts you off with two components: