Skip to content

Commit

Permalink
add cypress docker compose file
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscao633 committed Feb 28, 2024
1 parent 59f4d9a commit 44d8606
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 11 deletions.
4 changes: 4 additions & 0 deletions cypress.config.ts → cypress/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
},
env: {
umami_user: 'admin',
umami_password: 'pennydoodoo',
},
});
47 changes: 47 additions & 0 deletions cypress/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
26 changes: 16 additions & 10 deletions cypress/e2e/login.cy.ts
Original file line number Diff line number Diff line change
@@ -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');
},
);
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}": [
Expand Down

0 comments on commit 44d8606

Please sign in to comment.