Skip to content

Commit

Permalink
Add cypress. Add test for App nav. (#8)
Browse files Browse the repository at this point in the history
* Add cypress. Add test for App nav.

* Amend readme.

* Amend readme.

* Add cypress gitignore

* Udpate yarn.lock

* Update yarn

* Set resolutions for cypress.

* Update global readme

* Amend bug report

* Amend feature request template.
  • Loading branch information
mzastue committed Mar 3, 2020
1 parent 3e277ad commit 7172753
Show file tree
Hide file tree
Showing 14 changed files with 1,083 additions and 456 deletions.
24 changes: 13 additions & 11 deletions .github/ISSUE_TEMPLATE/bug_report.md
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.md
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand Down
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -55,7 +55,10 @@ in the frontend or any of the services directories.

### E2E Tests

TBD
#### Cypress

- `yarn cy:run`
- `yarn cy:open`

## Deployment

Expand Down
4 changes: 4 additions & 0 deletions frontend/README.md
Expand Up @@ -22,6 +22,10 @@ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.

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

## Running Cypress Tests

Run `yarn cy:run`

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
2 changes: 2 additions & 0 deletions frontend/cypress.json
@@ -0,0 +1,2 @@
{
}
2 changes: 2 additions & 0 deletions frontend/cypress/.gitignore
@@ -0,0 +1,2 @@
videos/*
screenshots/*
19 changes: 19 additions & 0 deletions frontend/cypress/integration/src/app_spec.ts
@@ -0,0 +1,19 @@
describe('App spec', () => {
beforeEach(() => {
cy.visit('/');
});

it('shows App nav', () => {
cy.get('ul.app__links').should('have.length', 1);
});

it('shows items in App nav', () => {
const expectedNavLinks = ['home', 'hello'];

cy.get('ul.app__links li').should($items => {
const linkTextes = $items.toArray().forEach((item, index) => {
expect(item).to.contain(expectedNavLinks[index]);
});
});
});
});
24 changes: 24 additions & 0 deletions frontend/cypress/plugins/index.js
@@ -0,0 +1,24 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

/**
* @type {Cypress.PluginConfig}
*/
module.exports = (on, config) => {
on('task', {
protobufEncode: require('cypress-protobuf'),
});
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
};
25 changes: 25 additions & 0 deletions frontend/cypress/support/commands.js
@@ -0,0 +1,25 @@
// ***********************************************
// 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) => { ... })
20 changes: 20 additions & 0 deletions frontend/cypress/support/index.js
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js 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
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
13 changes: 13 additions & 0 deletions frontend/cypress/tsconfig.json
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"strict": true,
"baseUrl": "../node_modules",
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress"]
},
"include": [
"**/*.ts",
"../node_modules/cypress"
]
}
10 changes: 9 additions & 1 deletion frontend/package.json
Expand Up @@ -8,7 +8,9 @@
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"proto:generate": "protoc --plugin=protoc-gen-ng=./node_modules/.bin/protoc-gen-ng --ng_out=./src/app/proto -I ../services ../services/**/src/**/*.proto"
"proto:generate": "protoc --plugin=protoc-gen-ng=./node_modules/.bin/protoc-gen-ng --ng_out=./src/app/proto -I ../services ../services/**/src/**/*.proto",
"cy:open": "CYPRESS_BASE_URL=http://localhost:4200 cypress open",
"cy:run": "CYPRESS_BASE_URL=http://localhost:4200 cypress run"
},
"dependencies": {
"@angular/animations": "~9.0.0",
Expand All @@ -32,10 +34,13 @@
"@angular/compiler-cli": "~9.0.0",
"@angular/language-service": "~9.0.0",
"@ngx-grpc/protoc-gen-ng": "^0.4.3",
"@types/cypress": "^1.1.3",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"cypress": "^4.1.0",
"cypress-protobuf": "^1.0.5",
"husky": "^4.2.3",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
Expand All @@ -54,5 +59,8 @@
"hooks": {
"pre-commit": "pretty-quick --staged"
}
},
"resolutions": {
"cypress": "^4.1.0"
}
}
9 changes: 2 additions & 7 deletions frontend/tsconfig.json
Expand Up @@ -11,13 +11,8 @@
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "dom"]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
Expand Down

0 comments on commit 7172753

Please sign in to comment.