Skip to content

Commit a7b1ea4

Browse files
jennydamanPintoGideon
authored andcommitted
Test PACS Q/R
1 parent b53e15c commit a7b1ea4

File tree

11 files changed

+139
-57
lines changed

11 files changed

+139
-57
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "miniChRIS"]
22
path = testing/miniChRIS
33
url = https://github.com/FNNDSC/miniChRIS-docker.git
4+
[submodule "testing/sample_dicoms"]
5+
path = testing/sample_dicoms
6+
url = https://github.com/FNNDSC/sample_dicom_downloader.git

README.md

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,11 @@ npm run dev:public
2222

2323
## Development
2424

25-
We support development on **Linux** only.
26-
27-
#### 0. Have the [_ChRIS_ backend](https://github.com/FNNDSC/ChRIS_ultron_backEnd) running (Optional)
28-
29-
For local development, use [Docker Compose](https://docs.docker.com/compose/) and [miniChRIS-docker](https://github.com/FNNDSC/miniChRIS-docker). Open a terminal and run
30-
31-
```shell
32-
git clone https://github.com/FNNDSC/miniChRIS-docker.git
33-
cd miniChRIS-docker
34-
./minichris.sh
35-
```
25+
There are two modes of development:
3626

27+
- "local": runs the _ChRIS_ backend locally. Requires Docker, and uses more disk space + slower startup time.
28+
- "public": use the global, public testing server. This is the easier option, especially for non-Linux OS.
29+
3730
<details>
3831
<summary>
3932
<strong>
@@ -64,51 +57,28 @@ $ ./unmake.sh
6457
If your backend is accessible from a host other than localhost, e.g. you are using a cloud or remote development
6558
server, run `cp .env .env.development.local` then edit `.env.development.local` with your backend API URL.
6659

67-
#### 1. Install Dependencies
60+
### 1. Dependencies
6861

6962
You need Node version 20 or 21.
7063

7164
```shell
7265
git clone https://github.com/FNNDSC/ChRIS_ui.git
7366
cd ChRIS_ui
74-
npm i
75-
```
76-
77-
<details>
78-
<summary>
79-
<strong>
80-
Alternatively, using Docker (click to expand)
81-
</strong>
82-
</summary>
83-
84-
These instructions are no longer supported.
85-
86-
Open a new terminal on your system and follow these steps:
87-
88-
```bash
89-
git clone https://github.com/FNNDSC/ChRIS_ui.git
90-
cd ChRIS_ui
91-
docker build -t localhost/fnndsc/chris_ui:dev -f Dockerfile_dev .
92-
docker run --rm -it -v $PWD:/home/localuser -p 3000:3000 -u $(id -u):$(id -g) --userns=host --name chris_ui localhost/fnndsc/chris_ui:dev
67+
npm ci
9368
```
9469

95-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
96-
97-
</details>
98-
99-
100-
#### 2. Run the development server
70+
### 2. Run the development server
10171

102-
If you are running and have configured a backend in step 0, run
72+
Either using the "public" server:
10373

10474
```shell
105-
npm run dev
75+
npm run dev:public
10676
```
10777

108-
Otherwise, you can use our public testing backend instance. Run
78+
Or, start a local backend and run the "local" server:
10979

11080
```shell
111-
npm run dev:public
81+
npm run dev:local
11282
```
11383

11484
## Build for production
@@ -142,16 +112,15 @@ npm test
142112

143113
### End-to-End Tests
144114

145-
> [!IMPORTANT]
146-
> End-to-end (E2E) tests are configured to run against our public testing backend instance, which is prepopulated with data.
147-
148-
E2E tests are located under `tests/`.
115+
End-to-end tests are located under `tests/`.
149116

150-
Playwright requires some system dependencies. On first run, you will be prompted to install these dependencies.
151-
With Playwright installed, run
117+
The end-to-end testing framework, Playwright, requires some system dependencies.
118+
On first run, you will be prompted to install these dependencies.
152119

153120
```shell
154-
npm run test:e2e
121+
npm run test:e2e # run tests using "public" backend
122+
123+
npm run test:e2e:local # run tests using "local" backend
155124
```
156125

157126
For more information, consult the wiki:

package.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,35 @@
55
"scripts": {
66
"start": "sirv dist --host --port ${PORT:=8080} --single --etag --quiet",
77
"__start": "# npm start command is used by s2i in OpenShift as the deployment command",
8-
"dev": "npm run minichris:up && vite",
8+
"dev": "npm run dev:local",
9+
"dev:local": "npm run test:prepare && vite",
910
"dev:public": "vite -c testing/publicCUBE/vite.config.ts",
1011
"build": "vite build",
1112
"test": "vitest",
13+
"__test:prepare:comment": "# test:prepare runs CUBE locally and loads sample DICOM data into the PACS.",
14+
"test:prepare": "npm run minichris:up && npm run get-dicoms && npm run minichris:wipe",
1215
"test:e2e": "playwright test -c playwright.config.ts",
16+
"test:e2e:local": "npm run test:prepare && env TEST_LOCAL=yes npm run test:e2e",
1317
"test:report": "nyc report --reporter=text",
1418
"test:lcov": "nyc report --reporter=lcov",
1519
"test:ui": "playwright test -c playwright.config.ts --ui",
16-
"test:codegen": "playwright codegen http://localhost:25173",
17-
"test:codegen:mobile": "playwright codegen --device 'Pixel 5' http://localhost:25173",
18-
"minichris:__comment": "The minichris:* commands are for running a ChRIS backend locally",
20+
"test:ui:local": "npm run test:prepare && env TEST_LOCAL=yes npm run test:ui",
21+
"test:codegen": "playwright codegen $(npm run -s get-running-url)",
22+
"test:codegen:mobile": "playwright codegen --device 'Pixel 5' $(npm run -s get-running-url)",
23+
"__minichris:comment": "# The minichris:* commands are for running a ChRIS backend locally",
1924
"minichris:up": "cd testing/miniChRIS && docker compose --profile pacs up -d && cd - && npm run chrisomatic",
2025
"minichris:down": "cd testing/miniChRIS && ./unmake.sh",
2126
"minichris:wipe": "./testing/miniChRIS/scripts/clear_pacsfiles.sh",
2227
"chrisomatic": "testing/chrisomatic.sh",
28+
"get-dicoms": "./testing/get_dicoms.sh",
29+
"list-mrns": "./testing/miniChRIS/scripts/list_mrns.sh",
2330
"lint": "biome lint .",
2431
"fix": "biome check --apply .",
2532
"fix:unsafe": "biome check --apply-unsafe .",
2633
"fmt": "biome format --write .",
2734
"preview": "vite preview",
35+
"__helper_functions": "",
36+
"get-running-url": "./testing/get_running_url.sh",
2837
"print-version": "./print_version.sh"
2938
},
3039
"dependencies": {

playwright.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// See https://github.com/FNNDSC/ChRIS_ui/wiki/E2E-Testing-with-Playwright#local-tests
2+
13
import { defineConfig, devices, PlaywrightTestConfig } from "@playwright/test";
24

35
const SAFARI_BROWSERS: PlaywrightTestConfig["projects"] = [];

testing/get_dicoms.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
HERE="$(dirname -- "$0")"
4+
5+
set -ex
6+
7+
cd "$HERE/sample_dicoms"
8+
make neuro
9+
cd -
10+
11+
exec "$HERE/miniChRIS/scripts/upload2orthanc.sh" "$HERE/sample_dicoms/data"

testing/get_running_url.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
URLS=(http://localhost:5173 http://localhost:25173)
4+
5+
for url in "${URLS[@]}"; do
6+
curl -o /dev/null "$url" > /dev/null 2>&1
7+
if [ "$?" = "0" ]; then
8+
echo "$url"
9+
exit 0
10+
fi
11+
done
12+
13+
echo "UI is not running. Please run `npm run dev`"
14+
exit 1

testing/miniChRIS

testing/sample_dicoms

Submodule sample_dicoms added at 29cb5b7

tests/NiivueDatasetViewer/firstPageLoads.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async function gotoVolumeView({
2727
}) {
2828
test.skip(isFirefoxInGitHubActions(browserName), "GitHub Actions bug.");
2929
test.skip(
30-
baseURL?.includes("localhost") || false,
30+
baseURL?.includes("localhost:5173") || false,
3131
"Depends on global test server data.",
3232
);
3333
await page.goto("/");

tests/createAccount.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import createAccountHelper from "./helpers/createAccount.ts";
33
import { faker } from "@faker-js/faker";
44

55
test("Can create new user accounts", async ({ page, baseURL }) => {
6-
if (!baseURL?.includes("localhost")) {
7-
test.slow();
8-
}
6+
test.slow();
97

108
const username = faker.internet.userName();
119
const email = faker.internet.email();

0 commit comments

Comments
 (0)