Skip to content

Commit

Permalink
Test Baikal initialisation with Cypress (#74)
Browse files Browse the repository at this point in the history
* Added Cypress test to verify initial Baikal setup
* Test all image variants
* Perform tests on on PRs

Co-authored-by: ckulka <ckulka@wlgore.com>
  • Loading branch information
ckulka and ckulka committed Jan 30, 2022
1 parent 1b7e6fa commit dc2f693
Show file tree
Hide file tree
Showing 8 changed files with 5,394 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# See https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md
root: true
extends:
- prettier
parser: "@typescript-eslint/parser"
parserOptions:
ecmaVersion: 2019
sourceType: module
plugins:
- "@typescript-eslint"
- prettier
rules:
prettier/prettier:
- error
45 changes: 45 additions & 0 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: test

on:
pull_request:
paths:
- .github/workflows/docker-test.yml
- "*.dockerfile"
- cypress/*
- cypress.json
- files/*
- package.json
- package-lock.json

jobs:
test:
name: Test Docker image
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
dockerfile: [apache, apache-php8.0, nginx, nginx-php8.0]

steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: "16"

- name: Install Cypress dependencies
run: npm ci

- name: Build and start Baikal
run: docker run --rm -dp 80:80 $(docker build -qf ${{ matrix.dockerfile }}.dockerfile .)

- name: Run Cypress tests
run: npm run test

- name: Archive test results
uses: actions/upload-artifact@v2
with:
name: cypress-results-${{ matrix.dockerfile }}
path: |
cypress/screenshots
cypress/videos
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
docker-compose.override.yml

# Apple
*.DS_Store
.DS_Store

# Cypress
cypress/screenshots
cypress/videos
cypress/logs
# Currently not needed
cypress/plugins/
cypress/support/

# Node (see https://github.com/github/gitignore/blob/master/Node.gitignore)
.npm/
build/
dist/
**/node_modules/
node_modules/
jspm_packages/

# Visual Studio Code (see https://github.com/github/gitignore/blob/master/Global/VisualStudioCode.gitignore)
.vscode/
*.code-workspace
.history/
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
33 changes: 33 additions & 0 deletions cypress/integration/create-baikal-instance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
describe("Create Baikal instance", () => {
it("Should initialise administrator password", () => {
cy.visit("localhost");

cy.get("#overview > h1").should(
"have.text",
"Baïkal initialization wizard"
);
cy.get("#admin_passwordhash").type("asdasd");
cy.get("#admin_passwordhash_confirm").type("asdasd");
cy.get("button[type='submit']").click();
});

it("Should initialise database", () => {
cy.get("#overview > h1").should("have.text", "Baïkal Database setup");
cy.get("button[type='submit']").click();
});

it("Should start Baikal", () => {
cy.get("a.btn.btn-success")
.should("have.text", "Start using Baïkal")
.click();
});

it("Should sign in as administrator", () => {
cy.get("input[name='password']").type("asdasd");
cy.get("button[type='submit']").should("have.text", "Authenticate").click();
});

it("Should show dashboard", () => {
cy.get("#overview > h1").should("have.text", "Dashboard");
});
});
8 changes: 8 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress"]
},
"include": ["**/*.ts"]
}
Loading

0 comments on commit dc2f693

Please sign in to comment.