Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boban/2602 e2e tests #2822

Draft
wants to merge 48 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0a86d25
Add search component
BobanL Oct 16, 2024
0cc7ed6
update next-env.d.ts
BobanL Oct 16, 2024
85a20ed
Add search to page
BobanL Oct 16, 2024
3df744f
fix height and scroll bar on mage page
BobanL Oct 16, 2024
ce33d35
Use search field value to set search param in url
BobanL Oct 17, 2024
20295de
Merge branch 'main' into boban/2602-patient-name-search-ecr-library
BobanL Oct 24, 2024
ea0473d
mock search
BobanL Oct 24, 2024
f6ac22b
Add search term to listEcrData postgres
BobanL Oct 25, 2024
b47c251
Rename search component to librarysearch
BobanL Oct 25, 2024
4cff460
fix bug where refresh would remove all text from search box
BobanL Oct 25, 2024
20f4c72
pass search term through page and ecr table
BobanL Oct 25, 2024
d1cd0c2
add optional search term to getTotalEcrCount
BobanL Oct 25, 2024
eba79b9
Clarify test
BobanL Oct 25, 2024
3b38eff
add search term in get total ecr count
BobanL Oct 25, 2024
e4777b7
fix query
BobanL Oct 25, 2024
ae37ff6
remove extra db
BobanL Oct 25, 2024
4b65ee7
Handle setting the page to 1 if new search is made
BobanL Oct 25, 2024
f9d4062
mock console.error to cleanup test
BobanL Oct 25, 2024
e38943a
Merge branch 'main' into boban/2602-patient-name-search-ecr-library
BobanL Oct 25, 2024
20cc11d
add cypress tests
BobanL Oct 25, 2024
367c20e
add setup-local-env
BobanL Oct 25, 2024
e8d0e58
remove unused vars
BobanL Oct 25, 2024
1d6b520
Merge branch 'boban/2602-patient-name-search-ecr-library' into boban/…
BobanL Oct 25, 2024
f052c2f
skip e2e tests in jest
BobanL Oct 25, 2024
53e3401
increase timeout temporarily to 45 minutes
BobanL Oct 25, 2024
391a1b8
set checkpoint timeout to 30mins to avoid it running
BobanL Oct 28, 2024
eb3ab25
Merge branch 'main' into boban/2602-e2e-tests
BobanL Oct 30, 2024
eaffe05
Merge branch 'main' into boban/2602-e2e-tests
BobanL Oct 30, 2024
f26c152
Revert "set checkpoint timeout to 30mins to avoid it running"
BobanL Oct 28, 2024
76364a0
Merge branch 'main' into boban/2602-e2e-tests
BobanL Nov 2, 2024
7052de2
Merge branch 'main' into boban/2602-e2e-tests
BobanL Nov 13, 2024
567e128
update package-lock
BobanL Nov 13, 2024
9372448
Separate seed data into three steps
BobanL Nov 14, 2024
53b8c6e
Merge branch 'main' into boban/2602-e2e-tests
BobanL Nov 15, 2024
3c1a5d0
Merge branch 'main' into boban/2602-e2e-tests
BobanL Nov 29, 2024
1c377c4
update github workflow
BobanL Nov 29, 2024
1368702
update package to update snapshots and record e2e
BobanL Nov 29, 2024
a1200f6
update webserver command
BobanL Nov 29, 2024
ca9938a
update tests to match main changes
BobanL Nov 29, 2024
0c2c445
update command to run playwright tests
BobanL Nov 29, 2024
209846b
update playwright
BobanL Dec 2, 2024
96e9a7a
chage webserver url
BobanL Dec 2, 2024
57f452c
add snapshots
BobanL Dec 2, 2024
91cd0c0
fix header to use Link rather than a tag
BobanL Dec 2, 2024
e513904
delete unused files
BobanL Dec 2, 2024
a41eb48
add docker ignore
BobanL Dec 2, 2024
a93f3a0
add docker compose
BobanL Dec 2, 2024
02b594d
update start up commands
BobanL Dec 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 21 additions & 30 deletions .github/workflows/container-ecr-viewer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,52 +50,43 @@ jobs:
- name: Run tests
working-directory: ./containers/${{env.CONTAINER}} # Navigate to your Node.js app directory
run: npm test
cypress-e2e-tests:
if: false
e2e-test:
runs-on: ubuntu-latest
timeout-minutes: 20
timeout-minutes: 45
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{env.NODE_VERSION}}

- name: Install dependencies
working-directory: ./containers/${{env.CONTAINER}} # Navigate to your Node.js app directory
run: npm install
run: npm ci

- name: Start ${{env.CONTAINER}}
working-directory: ./containers/${{env.CONTAINER}}/cypress
run: docker compose --env-file ../.env.test up -d
- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run cypress tests
- name: Set up env vars
run: npm run setup-local-env
working-directory: ./containers/${{env.CONTAINER}}
run: npm run cypress:run

- name: Archive cypress failures
if: always()
uses: actions/upload-artifact@v4
with:
name: cypress-results
path: |
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: Run seed data conversion
run: npm run convert-seed-data:build
working-directory: ./containers/${{env.CONTAINER}}

- name: Run Playwright tests
working-directory: ./containers/${{env.CONTAINER}}
run: npx @dotenvx/dotenvx run -f .env.local -- sh -c 'docker compose -f ./e2e/docker-compose.yml --profile ${SOURCE} --profile ${METADATA_DATABASE_TYPE} --profile ecr-viewer up'

- name: Archive docker logs
if: always()
uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: logs
path: ./containers/${{env.CONTAINER}}/cypress/cypress-run.log
name: playwright-report
path: containers/${{env.CONTAINER}}/playwright-report/
retention-days: 30

lighthouse:
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions containers/ecr-viewer/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
Dockerfile
.dockerignore
e2e
.next
6 changes: 5 additions & 1 deletion containers/ecr-viewer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ seed-scripts/baseECR/KY
seed-scripts/baseECR/ME

cypress/screenshots
cypress/videos
cypress/videos
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
17 changes: 17 additions & 0 deletions containers/ecr-viewer/e2e/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: ecr-viewer

include:
- ../docker-compose.yml

services:
playwright:
image: mcr.microsoft.com/playwright:v1.49.0-noble
working_dir: /work/
command:
- /bin/sh
- -c
- |
npm i
npm run test:e2e
volumes:
- ../:/work/
22 changes: 22 additions & 0 deletions containers/ecr-viewer/e2e/ecrLibrary.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { test, expect } from "@playwright/test";

// http://host.docker.internal:3000/
// const E2E_URL = "http://localhost:3000/ecr-viewer";
const E2E_URL = "http://ecr-viewer:3000/ecr-viewer";

test("eCRs per page should persist on reload ", async ({ page }) => {
await page.goto(E2E_URL);
await page.getByTestId("Select").selectOption("75");
await page.reload();
await expect(page.getByTestId("Select")).toContainText("75");
});

test("eCR search filters results", async ({ page }) => {
await page.goto(E2E_URL);
await page.getByTestId("textInput").click();
await page.getByTestId("textInput").fill("test");
await page.getByTestId("form").getByTestId("button").click();
await expect(
page.getByRole("cell", { name: "Adam Test DOB: 01/01/" }).first(),
).toBeVisible();
});
24 changes: 24 additions & 0 deletions containers/ecr-viewer/e2e/ecrViewer.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { test, expect } from "@playwright/test";

// host.docker.internal
// const E2E_URL = "http://localhost:3000/ecr-viewer";
const E2E_URL = "http://ecr-viewer:3000/ecr-viewer";

test("eCR Viewer matches snapshot", async ({ page }) => {
await page.goto(
`${E2E_URL}/view-data?id=1.2.840.114350.1.13.297.3.7.8.688883.573942`,
);
await page.getByText("Patient Name").first().waitFor();
await expect(page).toHaveScreenshot({ fullPage: true });
});

test("eCR Viewer matches snapshot fully expanded", async ({ page }) => {
await page.goto(
`${E2E_URL}/view-data?id=1.2.840.114350.1.13.297.3.7.8.688883.573942`,
);
await page.getByTestId("accordionButton_Giardiasis").click();
await page.getByTestId("accordionButton_Cryptosporidiosis").click();
await page.getByTestId("accordionButton_Amebiasis").click();
await page.getByRole("button", { name: "Expand all labs" }).click();
await expect(page).toHaveScreenshot({ fullPage: true });
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions containers/ecr-viewer/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const createJestConfig = nextJest({
// Add any custom config to be passed to Jest
const customJestConfig = {
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
testPathIgnorePatterns: ["/e2e/"],
testEnvironment: "jest-environment-jsdom",
};

Expand Down
64 changes: 64 additions & 0 deletions containers/ecr-viewer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions containers/ecr-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"lint": "next lint",
"test": "TZ=America/New_York jest",
"test:watch": "TZ=America/New_York jest --watch",
"test:e2e": "playwright test",
"test:e2e:record": "playwright codegen localhost:3000/ecr-viewer",
"test:e2e:update-snapshots": "playwright test --update-snapshots",
"clear-local": "docker compose -f ./docker-compose.yml --profile \"*\" down -v",
"convert-seed-data": "npx @dotenvx/dotenvx run -f .env.local -- sh -c 'docker compose -f ./seed-scripts/docker-compose-seed.yml --profile ${SOURCE} --profile ${METADATA_DATABASE_TYPE} --profile ecr-viewer up --abort-on-container-exit'",
"convert-seed-data:build": "npx @dotenvx/dotenvx run -f .env.local -- sh -c 'docker compose -f ./seed-scripts/docker-compose-seed.yml --profile ${SOURCE} --profile ${METADATA_DATABASE_TYPE} --profile ecr-viewer up --abort-on-container-exit --build'",
Expand Down Expand Up @@ -67,6 +70,7 @@
"devDependencies": {
"@dotenvx/dotenvx": "^1.22.0",
"@next/eslint-plugin-next": "^14.2.5",
"@playwright/test": "^1.49.0",
"@smithy/util-stream": "^2.1.2",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/react": "^15.0.7",
Expand Down
84 changes: 84 additions & 0 deletions containers/ecr-viewer/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { defineConfig, devices } from "@playwright/test";

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

// http://host.docker.internal:3000/
// const E2E_URL = "http://localhost:3000/ecr-viewer";
const E2E_URL = "http://ecr-viewer:3000/ecr-viewer";

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: "./e2e",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
},

/* Configure projects for major browsers */
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},

{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},

{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
webServer: {
command: "npm run build && npm run start",
url: E2E_URL,
reuseExistingServer: true,
timeout: 120000,
},
});
5 changes: 2 additions & 3 deletions containers/ecr-viewer/src/app/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Link from "next/link";
import React from "react";

/**
Expand All @@ -13,9 +14,7 @@ const Header: React.FC = () => (
<div className="usa-navbar">
<div className="usa-logo">
<h1>
<a href="/" title="<Project title>">
DIBBs eCR Viewer
</a>
<Link href="/">DIBBs eCR Viewer</Link>
</h1>
</div>
</div>
Expand Down
Loading