add cypress docker compose file

This commit is contained in:
Francis Cao 2024-02-28 15:01:13 -08:00
parent 59f4d9aff8
commit 44d8606d1a
4 changed files with 69 additions and 11 deletions

View File

@ -4,4 +4,8 @@ export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
},
env: {
umami_user: 'admin',
umami_password: 'pennydoodoo',
},
});

View File

@ -0,0 +1,47 @@
---
version: '3'
services:
umami:
image: ghcr.io/umami-software/umami:postgresql-latest
ports:
- '3000:3000'
environment:
DATABASE_URL: postgresql://umami:umami@db:5432/umami
DATABASE_TYPE: postgresql
APP_SECRET: replace-me-with-a-random-string
depends_on:
db:
condition: service_healthy
restart: always
healthcheck:
test: ['CMD-SHELL', 'curl http://localhost:3000/api/heartbeat']
interval: 5s
timeout: 5s
retries: 5
db:
image: postgres:15-alpine
environment:
POSTGRES_DB: umami
POSTGRES_USER: umami
POSTGRES_PASSWORD: umami
volumes:
- umami-db-data:/var/lib/postgresql/data
restart: always
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}']
interval: 5s
timeout: 5s
retries: 5
cypress:
image: 'cypress/included:13.6.0'
depends_on:
- umami
- db
environment:
- CYPRESS_baseUrl=http://localhost:3000
entrypoint: /bin/sh -c "yarn install"
working_dir: /cypress
volumes:
- ./:/cypress
volumes:
umami-db-data:

View File

@ -1,12 +1,18 @@
describe('Login test', () => {
it('logs user in with correct credentials and logs user out', () => {
cy.visit('/login');
cy.dataCy('input-username').type(Cypress.env('umami_user'));
cy.dataCy('input-password').type(Cypress.env('umami_password'));
cy.dataCy('button-submit').click();
cy.url().should('eq', Cypress.config().baseUrl + '/dashboard');
cy.dataCy('button-profile').click();
cy.dataCy('item-logout').click();
cy.url().should('eq', Cypress.config().baseUrl + '/login');
});
it(
'logs user in with correct credentials and logs user out',
{
defaultCommandTimeout: 10000,
},
() => {
cy.visit('/login');
cy.dataCy('input-username').type(Cypress.env('umami_user'));
cy.dataCy('input-password').type(Cypress.env('umami_password'));
cy.dataCy('button-submit').click();
cy.url().should('eq', Cypress.config().baseUrl + '/dashboard');
cy.dataCy('button-profile').click();
cy.dataCy('item-logout').click();
cy.url().should('eq', Cypress.config().baseUrl + '/login');
},
);
});

View File

@ -43,7 +43,8 @@
"lint": "next lint --quiet",
"prepare": "node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || husky install",
"postbuild": "node scripts/postbuild.js",
"cypress-open": "cypress open"
"cypress-open": "cypress open cypress run --config-file cypress/cypress.config.ts",
"cypress-run": "cypress run cypress run --config-file cypress/cypress.config.ts"
},
"lint-staged": {
"**/*.{js,jsx,ts,tsx}": [