Skip to content

Commit

Permalink
Implement core metadata schema in the eCR viewer (#2756)
Browse files Browse the repository at this point in the history
* Starting small tweaks for implementing core schema

* WIP

* implement core schema

* error tweak

* add script to update data.sql for cypress testing

* [pre-commit.ci] auto fixes from pre-commit hooks

* Bring in data.sql gen script and update for new schema to fix cypress tests

* test fixture for db cleanup update, maybe this'll do it

* change database.one to .none for error, update sql script references

* oops I broke cypress again, fixing

* rollback test fixture changes

* remove borked data.sql path and make new cypress docker compose

* remove borked data.sql path and make new cypress docker compose

* fix cypress #876234

* cypress fix please

* increase cypress timeout

* remove duplicate cypress timeout increase

* fix borked cypress tests again

* fix unit tests

* tweak cypress settings, update gitignore

* attempt to satisfy fickle cypress gods by changing localhost to 127.0.0.1 in baseUrl

* reenable cypress video

* Save docker logs

* set working directory for logs

* set working directory for logs

* add space

* Remove working directory from push logs

* Rename db to postgres

* Add a stop docker container step in e2e before getting logs

* Change docker compose down to stop to retain logs

* get rid of docker compose stop

* set base url to localhost again ?

* change local cypress script from db to postgres

---------

Co-authored-by: Austin Hall <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Boban Ljuljdjurovic <[email protected]>
Co-authored-by: Boban <[email protected]>
  • Loading branch information
5 people authored Oct 23, 2024
1 parent b7b0728 commit 4225f1d
Show file tree
Hide file tree
Showing 23 changed files with 3,085 additions and 1,109 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/container-ecr-viewer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,9 @@ jobs:
working-directory: ./containers/${{env.CONTAINER}} # Navigate to your Node.js app directory
run: npm install

- name: Copy seed data
working-directory: ./containers/${{env.CONTAINER}}
run: cp ./cypress/assets/data.sql ./seed-scripts/sql

- name: Start ${{env.CONTAINER}}
working-directory: ./containers/${{env.CONTAINER}}
run: docker compose --env-file .env.test up -d
working-directory: ./containers/${{env.CONTAINER}}/cypress
run: docker compose --env-file ../.env.test up -d

- name: Wait for server to be ready
run: |
Expand All @@ -93,6 +89,21 @@ jobs:
containers/ecr-viewer/cypress/screenshots/*
containers/ecr-viewer/cypress/videos/*
- name: Get docker logs
if: always()
working-directory: ./containers/${{env.CONTAINER}}/cypress
shell: bash
run: |
echo "Saving $container logs"
docker compose logs --timestamps >& cypress-run.log
- name: Archive docker logs
if: always()
uses: actions/upload-artifact@v4
with:
name: logs
path: ./containers/${{env.CONTAINER}}/cypress/cypress-run.log

lighthouse:
runs-on: ubuntu-latest
timeout-minutes: 20
Expand Down
5 changes: 4 additions & 1 deletion containers/ecr-viewer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ node_modules
.env.local

# localstack data
volume/
volume/

cypress/screenshots
cypress/videos
2 changes: 1 addition & 1 deletion containers/ecr-viewer/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineConfig({
env: {
BASE_PATH: `${isDev ? "/" : "/ecr-viewer"}`,
},
defaultCommandTimeout: 120000,
},
video: true,
defaultCommandTimeout: 120000,
});
23 changes: 17 additions & 6 deletions containers/ecr-viewer/cypress/assets/data.sql

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions containers/ecr-viewer/cypress/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
services:
# PostgreSQL database
postgres:
image: "postgres:alpine"
ports:
- "5432:5432"
volumes:
- ../sql/core.sql:/docker-entrypoint-initdb.d/core.sql
- ../seed-scripts/sql/01-init.sql:/docker-entrypoint-initdb.d/01-init.sql
- ./assets/data.sql:/docker-entrypoint-initdb.d/data.sql
- ../seed-scripts/sql/.pgpass/:/usr/local/lib/.pgpass
environment:
- POSTGRES_USER=postgres
- PGUSER=postgres
- POSTGRES_PASSWORD=pw
- POSTGRES_DB=ecr_viewer_db
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 2s
timeout: 5s
retries: 20

# Next.js app
ecr-viewer:
build:
context: ../../..
dockerfile: ./containers/ecr-viewer/Dockerfile
ports:
- "3000:3000"
environment:
- DATABASE_URL=${DATABASE_URL:-postgres://postgres:pw@db:5432/ecr_viewer_db}
- APP_ENV=${APP_ENV:-prod}
6 changes: 4 additions & 2 deletions containers/ecr-viewer/cypress/e2e/app.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ describe("Happy Path", () => {
it("Should load the eCR Viewer for a known ID", () => {
// Visit a valid URL
const basePath = Cypress.env("BASE_PATH") || "";
cy.visit(`${basePath}/view-data?id=6100896d-b520-497c-b2fe-1c111c679274`);
cy.visit(
`${basePath}/view-data?id=1.2.840.114350.1.13.478.3.7.8.688883.230886`,
);

// Gets the expected content
cy.get("#patient-summary").contains("Patient Summary");
cy.contains("VICTORIA HUNTER");
cy.contains("APPLE ZTEST");
});
});

Expand Down
3 changes: 2 additions & 1 deletion containers/ecr-viewer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ services:
ports:
- "5432:5432"
volumes:
- ./seed-scripts/sql/:/docker-entrypoint-initdb.d/
- ./sql/core.sql:/docker-entrypoint-initdb.d/core.sql
- ./seed-scripts/sql/01-init.sql:/docker-entrypoint-initdb.d/01-init.sql
- ./seed-scripts/sql/.pgpass/:/usr/local/lib/.pgpass
environment:
- POSTGRES_USER=postgres
Expand Down
2 changes: 1 addition & 1 deletion containers/ecr-viewer/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
2 changes: 1 addition & 1 deletion containers/ecr-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"update-cypress-data": "docker compose -f ./seed-scripts/docker-compose-create-sql.yml up --build --abort-on-container-exit",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"cypress:run-local": "cp ./cypress/assets/data.sql ./seed-scripts/sql && docker compose --env-file .env.test up db -d && concurrently --kill-others 'npm run dev' 'npx wait-on http://localhost:3000 && NODE_ENV=dev cypress run ; docker compose down && rm ./seed-scripts/sql/data.sql'",
"cypress:run-local": "docker compose -f cypress/docker-compose.yml --env-file .env.test up postgres -d && concurrently --kill-others 'npm run dev' 'npx wait-on http://localhost:3000 && NODE_ENV=dev cypress run ; docker compose down'",
"cypress:run-prod": "NODE_ENV=production cypress run"
},
"dependencies": {
Expand Down

This file was deleted.

Loading

0 comments on commit 4225f1d

Please sign in to comment.