Skip to content

Commit

Permalink
Merge pull request #714 from liimaorg/feature/e2e-tests
Browse files Browse the repository at this point in the history
End-to-end tests for Liima
  • Loading branch information
mburri authored Nov 14, 2023
2 parents cd7a72a + b34bf7f commit 7b9fb95
Show file tree
Hide file tree
Showing 16 changed files with 4,159 additions and 95 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,10 @@ jobs:
run: mvn --batch-mode clean install

- name: Build Docker image
run: AMW_docker/build.sh
run: AMW_docker/build.sh

- name: Run e2e tests
run: |
cd AMW_e2e
npm install
npm run test:ci
2 changes: 1 addition & 1 deletion AMW_angular/io/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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/).
See AMW_e2e

## Further help

Expand Down
12 changes: 0 additions & 12 deletions AMW_angular/io/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,6 @@
"src/styles.scss"
]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "liima:serve"
},
"configurations": {
"production": {
"devServerTarget": "liima:serve:production"
}
}
}
}
}
Expand Down
32 changes: 0 additions & 32 deletions AMW_angular/io/e2e/protractor.conf.js

This file was deleted.

34 changes: 0 additions & 34 deletions AMW_angular/io/e2e/src/app/app.e2e.ts

This file was deleted.

13 changes: 0 additions & 13 deletions AMW_angular/io/e2e/tsconfig.json

This file was deleted.

2 changes: 0 additions & 2 deletions AMW_angular/io/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"test": "ng test",
"test-headless": "ng test --browsers=ChromeHeadless",
"lint": "ng lint",
"e2e": "ng e2e",
"mavenbuild": "ng test --watch=false --browsers=ChromeHeadless && ng build --configuration production"
},
"private": true,
Expand Down Expand Up @@ -54,7 +53,6 @@
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "^2.1.0",
"prettier": "3.0.3",
"protractor": "~7.0.0",
"ts-node": "~10.9.1",
"tslint": "~6.1.3",
"typescript": "~5.1.5"
Expand Down
1 change: 1 addition & 0 deletions AMW_e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
67 changes: 67 additions & 0 deletions AMW_e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Liima End to End Tests

This module contains end-to-end tests using [cypress](https://www.cypress.io/)

## Getting started

Install all dependencies:

```bash
npm install
```


## Run the application

To run the e2e test, you need a running application on http://localhost:8080/AMW_web

You can use the docker image to get an application with a fresh h2 database:

```bash
npm run docker:build
```

Start and stop the application manually:

```bash
npm start
npm stop
```

Note: there are other ways to start the application. Using docker is the most convenient way if you want to focus on writen end-to-end tests.

## Using the cypress ui

You can run the cypress ui with the following command:

```bash
npm run test:ui
```

This will start the cypress ui that let's you run individual tests and inspect the runs. You have to choose the test type and environment first.
Note: onyle e2e tests are setup up for this project, no component testing.

See https://docs.cypress.io/guides/getting-started/opening-the-app for more information.


## Run tests in headless mode

To just run all tests, without the ui use:

```bash
npm run test
```

## Run tests on CI

Start the docker container, wait for the application startup and execute all tests with:

```bash
npm run test:ci
```

Notes:
* the container will not shut down when the tests are finished.
* you may need to build a new docker image if changes to your application where made.


9 changes: 9 additions & 0 deletions AMW_e2e/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
5 changes: 5 additions & 0 deletions AMW_e2e/cypress/e2e/login.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe("login", () => {
it("should login with basic auth", () => {
cy.visit("http://admin:admin@localhost:8080/AMW_web");
});
})
5 changes: 5 additions & 0 deletions AMW_e2e/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]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
25 changes: 25 additions & 0 deletions AMW_e2e/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -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 AMW_e2e/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.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')
Loading

0 comments on commit 7b9fb95

Please sign in to comment.