Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

add cypress docker compose file

Francis Cao44d8606d1aa2
diff --git a/cypress.config.ts b/cypress/cypress.config.ts
similarity index 63%
rename from cypress.config.ts
rename to cypress/cypress.config.ts
index 5bed49b88..c52aeb497 100644
--- a/cypress.config.ts
+++ b/cypress/cypress.config.ts
@@ -4,4 +4,8 @@ export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
},
+ env: {
+ umami_user: 'admin',
+ umami_password: 'pennydoodoo',
+ },
});
diff --git a/cypress/docker-compose.yml b/cypress/docker-compose.yml
new file mode 100644
index 000000000..8ce1c9381
--- /dev/null
+++ b/cypress/docker-compose.yml
@@ -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:
diff --git a/cypress/e2e/login.cy.ts b/cypress/e2e/login.cy.ts
index f04905600..4bd6a6b78 100644
--- a/cypress/e2e/login.cy.ts
+++ b/cypress/e2e/login.cy.ts
@@ -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');
+ },
+ );
});
diff --git a/package.json b/package.json
index 24946e3f2..16658e2e4 100644
--- a/package.json
+++ b/package.json
@@ -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}": [