@openmrs/esm-fast-data-entry-app 1.1.1-pre.208 → 1.1.1-pre.216
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/routes.json +1 -1
- package/e2e/core/global-setup.ts +32 -0
- package/e2e/core/index.ts +1 -0
- package/e2e/core/test.ts +20 -0
- package/e2e/fixtures/api.ts +26 -0
- package/e2e/fixtures/index.ts +1 -0
- package/e2e/pages/index.ts +1 -0
- package/e2e/pages/sample-test.ts +9 -0
- package/e2e/specs/sample-test.spec.ts +10 -0
- package/e2e/support/github/Dockerfile +34 -0
- package/e2e/support/github/docker-compose.yml +24 -0
- package/e2e/support/github/run-e2e-docker-env.sh +37 -0
- package/example.env +6 -0
- package/jest.config.json +17 -8
- package/package.json +6 -2
- package/playwright.config.ts +32 -0
package/README.md
CHANGED
|
@@ -56,3 +56,11 @@ yarn start --importmap "https://spa-modules.nyc3.digitaloceanspaces.com/import-m
|
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
To see more options run `npx openmrs --help`
|
|
59
|
+
|
|
60
|
+
## To run end-to-end tests, run:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
yarn test-e2e
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Read the [e2e testing guide](https://openmrs.atlassian.net/wiki/spaces/docs/pages/150962731/Testing+Frontend+Modules+O3) to learn more about End-to-End tests in this project.
|
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.2.0"},"pages":[{"component":"root","routeRegex":"forms","online":true,"offline":true}],"extensions":[{"name":"forms-app-link","slot":"app-menu-slot","component":"formsAppMenuLink","online":true,"offline":true}],"version":"1.1.1-pre.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.2.0"},"pages":[{"component":"root","routeRegex":"forms","online":true,"offline":true}],"extensions":[{"name":"forms-app-link","slot":"app-menu-slot","component":"formsAppMenuLink","online":true,"offline":true}],"version":"1.1.1-pre.216"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { request } from '@playwright/test';
|
|
2
|
+
import * as dotenv from 'dotenv';
|
|
3
|
+
|
|
4
|
+
dotenv.config();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This configuration is to reuse the signed-in state in the tests
|
|
8
|
+
* by log in only once using the API and then skip the log in step for all the tests.
|
|
9
|
+
*
|
|
10
|
+
* https://playwright.dev/docs/auth#reuse-signed-in-state
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
async function globalSetup() {
|
|
14
|
+
const requestContext = await request.newContext();
|
|
15
|
+
const token = Buffer.from(`${process.env.E2E_USER_ADMIN_USERNAME}:${process.env.E2E_USER_ADMIN_PASSWORD}`).toString(
|
|
16
|
+
'base64',
|
|
17
|
+
);
|
|
18
|
+
await requestContext.post(`${process.env.E2E_BASE_URL}/ws/rest/v1/session`, {
|
|
19
|
+
data: {
|
|
20
|
+
sessionLocation: process.env.E2E_LOGIN_DEFAULT_LOCATION_UUID,
|
|
21
|
+
locale: 'en',
|
|
22
|
+
},
|
|
23
|
+
headers: {
|
|
24
|
+
Accept: 'application/json',
|
|
25
|
+
Authorization: `Basic ${token}`,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
await requestContext.storageState({ path: 'e2e/storageState.json' });
|
|
29
|
+
await requestContext.dispose();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default globalSetup;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './test';
|
package/e2e/core/test.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { APIRequestContext, Page, test as base } from '@playwright/test';
|
|
2
|
+
import { api } from '../fixtures';
|
|
3
|
+
|
|
4
|
+
// This file sets up our custom test harness using the custom fixtures.
|
|
5
|
+
// See https://playwright.dev/docs/test-fixtures#creating-a-fixture for details.
|
|
6
|
+
// If a spec intends to use one of the custom fixtures, the special `test` function
|
|
7
|
+
// exported from this file must be used instead of the default `test` function
|
|
8
|
+
// provided by playwright.
|
|
9
|
+
|
|
10
|
+
export interface CustomTestFixtures {
|
|
11
|
+
loginAsAdmin: Page;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CustomWorkerFixtures {
|
|
15
|
+
api: APIRequestContext;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const test = base.extend<CustomTestFixtures, CustomWorkerFixtures>({
|
|
19
|
+
api: [api, { scope: 'worker' }],
|
|
20
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { APIRequestContext, PlaywrightWorkerArgs, WorkerFixture } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A fixture which initializes an [`APIRequestContext`](https://playwright.dev/docs/api/class-apirequestcontext)
|
|
5
|
+
* that is bound to the configured OpenMRS API server. The context is automatically authenticated
|
|
6
|
+
* using the configured admin account.
|
|
7
|
+
*
|
|
8
|
+
* Use the request context like this:
|
|
9
|
+
* ```ts
|
|
10
|
+
* test('your test', async ({ api }) => {
|
|
11
|
+
* const res = await api.get('patient/1234');
|
|
12
|
+
* await expect(res.ok()).toBeTruthy();
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export const api: WorkerFixture<APIRequestContext, PlaywrightWorkerArgs> = async ({ playwright }, use) => {
|
|
17
|
+
const ctx = await playwright.request.newContext({
|
|
18
|
+
baseURL: `${process.env.E2E_BASE_URL}/ws/rest/v1/`,
|
|
19
|
+
httpCredentials: {
|
|
20
|
+
username: process.env.E2E_USER_ADMIN_USERNAME,
|
|
21
|
+
password: process.env.E2E_USER_ADMIN_PASSWORD,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
await use(ctx);
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './api';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sample-test';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { test, expect } from '@playwright/test';
|
|
2
|
+
import { FastDataEntryPage } from '../pages';
|
|
3
|
+
|
|
4
|
+
// This test is a sample E2E test. You can delete it.
|
|
5
|
+
|
|
6
|
+
test('sample-test', async ({ page }) => {
|
|
7
|
+
const fastDataEntryPage = new FastDataEntryPage(page);
|
|
8
|
+
await fastDataEntryPage.goto();
|
|
9
|
+
await expect(page.getByText('Fast Data Entry')).toBeVisible();
|
|
10
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1.3
|
|
2
|
+
FROM --platform=$BUILDPLATFORM node:18-alpine as dev
|
|
3
|
+
|
|
4
|
+
ARG APP_SHELL_VERSION=next
|
|
5
|
+
|
|
6
|
+
RUN mkdir -p /app
|
|
7
|
+
WORKDIR /app
|
|
8
|
+
|
|
9
|
+
COPY . .
|
|
10
|
+
|
|
11
|
+
RUN npm_config_legacy_peer_deps=true npm install -g openmrs@${APP_SHELL_VERSION:-next}
|
|
12
|
+
ARG CACHE_BUST
|
|
13
|
+
RUN npm_config_legacy_peer_deps=true openmrs assemble --manifest --mode config --config spa-assemble-config.json --target ./spa
|
|
14
|
+
|
|
15
|
+
FROM --platform=$BUILDPLATFORM openmrs/openmrs-reference-application-3-frontend:nightly as frontend
|
|
16
|
+
FROM nginx:1.23-alpine
|
|
17
|
+
|
|
18
|
+
RUN apk update && \
|
|
19
|
+
apk upgrade && \
|
|
20
|
+
# add more utils for sponge to support our startup script
|
|
21
|
+
apk add --no-cache moreutils
|
|
22
|
+
|
|
23
|
+
# clear any default files installed by nginx
|
|
24
|
+
RUN rm -rf /usr/share/nginx/html/*
|
|
25
|
+
|
|
26
|
+
COPY --from=frontend /etc/nginx/nginx.conf /etc/nginx/nginx.conf
|
|
27
|
+
# this assumes that NOTHING in the framework is in a subdirectory
|
|
28
|
+
COPY --from=frontend /usr/share/nginx/html/* /usr/share/nginx/html/
|
|
29
|
+
COPY --from=frontend /usr/local/bin/startup.sh /usr/local/bin/startup.sh
|
|
30
|
+
RUN chmod +x /usr/local/bin/startup.sh
|
|
31
|
+
|
|
32
|
+
COPY --from=dev /app/spa/ /usr/share/nginx/html/
|
|
33
|
+
|
|
34
|
+
CMD ["/usr/local/bin/startup.sh"]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This docker compose file is used to create a backend environment for the e2e.yml workflow.
|
|
2
|
+
version: '3.7'
|
|
3
|
+
|
|
4
|
+
services:
|
|
5
|
+
gateway:
|
|
6
|
+
image: openmrs/openmrs-reference-application-3-gateway:${TAG:-nightly}
|
|
7
|
+
ports:
|
|
8
|
+
- '8080:80'
|
|
9
|
+
|
|
10
|
+
frontend:
|
|
11
|
+
build:
|
|
12
|
+
context: .
|
|
13
|
+
environment:
|
|
14
|
+
SPA_PATH: /openmrs/spa
|
|
15
|
+
API_URL: /openmrs
|
|
16
|
+
|
|
17
|
+
backend:
|
|
18
|
+
image: openmrs/openmrs-reference-application-3-backend:nightly-with-data
|
|
19
|
+
depends_on:
|
|
20
|
+
- db
|
|
21
|
+
|
|
22
|
+
# MariaDB
|
|
23
|
+
db:
|
|
24
|
+
image: openmrs/openmrs-reference-application-3-db:nightly-with-data
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env bash -eu
|
|
2
|
+
|
|
3
|
+
# get the dir containing the script
|
|
4
|
+
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|
5
|
+
# create a temporary working directory
|
|
6
|
+
working_dir=$(mktemp -d "${TMPDIR:-/tmp/}openmrs-e2e-frontends.XXXXXXXXXX")
|
|
7
|
+
# get the app name
|
|
8
|
+
app_name=$(jq -r '.name' "$script_dir/../../../package.json")
|
|
9
|
+
|
|
10
|
+
echo "Creating packed archive of the app..."
|
|
11
|
+
# @openmrs/esm-whatever -> _openmrs_esm_whatever
|
|
12
|
+
packed_app_name=$(echo "$app_name" | tr '[:punct:]' '_');
|
|
13
|
+
# run yarn pack for our app and add it to the working directory
|
|
14
|
+
yarn pack -o "$working_dir/$packed_app_name.tgz" >/dev/null;
|
|
15
|
+
echo "Created packed app archives"
|
|
16
|
+
|
|
17
|
+
echo "Creating dynamic spa-assemble-config.json..."
|
|
18
|
+
# dynamically assemble our list of frontend modules, prepending the login app and
|
|
19
|
+
# primary navigation apps; apps will all be in the /app directory of the Docker
|
|
20
|
+
# container
|
|
21
|
+
jq -n \
|
|
22
|
+
--arg app_name "$app_name" \
|
|
23
|
+
--arg app_file "/app/$packed_app_name.tgz" \
|
|
24
|
+
'{"@openmrs/esm-primary-navigation-app": "next"} + {
|
|
25
|
+
($app_name): $app_file
|
|
26
|
+
}' | jq '{"frontendModules": .}' > "$working_dir/spa-assemble-config.json"
|
|
27
|
+
echo "Created dynamic spa-assemble-config.json"
|
|
28
|
+
|
|
29
|
+
echo "Copying Docker configuration..."
|
|
30
|
+
cp "$script_dir/Dockerfile" "$working_dir/Dockerfile"
|
|
31
|
+
cp "$script_dir/docker-compose.yml" "$working_dir/docker-compose.yml"
|
|
32
|
+
|
|
33
|
+
cd $working_dir
|
|
34
|
+
echo "Starting Docker containers..."
|
|
35
|
+
# CACHE_BUST to ensure the assemble step is always run
|
|
36
|
+
docker compose build --build-arg CACHE_BUST=$(date +%s) frontend
|
|
37
|
+
docker compose up -d
|
package/example.env
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# This is an example environment file for configuring dynamic values.
|
|
2
|
+
E2E_BASE_URL=http://localhost:8080/openmrs
|
|
3
|
+
E2E_USER_ADMIN_USERNAME=admin
|
|
4
|
+
E2E_USER_ADMIN_PASSWORD=Admin123
|
|
5
|
+
E2E_LOGIN_DEFAULT_LOCATION_UUID=44c3efb0-2583-4c80-a79e-1f756a03c0a1
|
|
6
|
+
# The above location UUID is for the "Outpatient Clinic" location in the reference application
|
package/jest.config.json
CHANGED
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
|
|
2
2
|
{
|
|
3
|
+
"clearMocks": true,
|
|
4
|
+
"collectCoverageFrom": [
|
|
5
|
+
"**/src/**/*.component.tsx",
|
|
6
|
+
"!**/node_modules/**",
|
|
7
|
+
"!**/src/declarations.d.ts",
|
|
8
|
+
"!**/e2e/**"
|
|
9
|
+
],
|
|
3
10
|
"transform": {
|
|
4
|
-
"^.+\\.tsx?$": "@swc/jest"
|
|
11
|
+
"^.+\\.tsx?$": ["@swc/jest"]
|
|
5
12
|
},
|
|
6
13
|
"transformIgnorePatterns": ["/node_modules/(?!@openmrs)"],
|
|
7
14
|
"moduleNameMapper": {
|
|
8
|
-
"\\.(s?css)$": "identity-obj-proxy",
|
|
9
15
|
"@openmrs/esm-framework": "@openmrs/esm-framework/mock",
|
|
16
|
+
"\\.(s?css)$": "identity-obj-proxy",
|
|
10
17
|
"^lodash-es/(.*)$": "lodash/$1",
|
|
11
|
-
"^
|
|
18
|
+
"^lodash-es$": "lodash",
|
|
12
19
|
"^dexie$": "<rootDir>/node_modules/dexie",
|
|
13
|
-
"
|
|
20
|
+
"^react-i18next$": "<rootDir>/__mocks__/react-i18next.js"
|
|
14
21
|
},
|
|
15
|
-
"setupFilesAfterEnv": [
|
|
16
|
-
"<rootDir>/src/setup-tests.ts"
|
|
17
|
-
],
|
|
22
|
+
"setupFilesAfterEnv": ["<rootDir>/src/setup-tests.ts"],
|
|
18
23
|
"testEnvironment": "jsdom",
|
|
19
24
|
"testEnvironmentOptions": {
|
|
20
25
|
"url": "http://localhost/"
|
|
21
|
-
}
|
|
26
|
+
},
|
|
27
|
+
"testPathIgnorePatterns": [
|
|
28
|
+
"/node_modules/",
|
|
29
|
+
"/e2e/"
|
|
30
|
+
]
|
|
22
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-fast-data-entry-app",
|
|
3
|
-
"version": "1.1.1-pre.
|
|
3
|
+
"version": "1.1.1-pre.216",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "O3 frontend module for fast data entry using the OpenMRS Angular Form Engine",
|
|
6
6
|
"browser": "dist/openmrs-esm-fast-data-entry-app.js",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"verify": "turbo lint typescript test",
|
|
19
19
|
"coverage": "yarn test -- --coverage ",
|
|
20
20
|
"postinstall": "husky install",
|
|
21
|
-
"extract-translations": "i18next 'src/**/*.tsx' --config ./tools/i18next-parser.config.js"
|
|
21
|
+
"extract-translations": "i18next 'src/**/*.tsx' --config ./tools/i18next-parser.config.js",
|
|
22
|
+
"test-e2e": "playwright test"
|
|
22
23
|
},
|
|
23
24
|
"browserslist": [
|
|
24
25
|
"extends browserslist-config-openmrs"
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@carbon/react": "1.71.0",
|
|
53
54
|
"@openmrs/esm-framework": "next",
|
|
55
|
+
"@playwright/test": "^1.49.1",
|
|
54
56
|
"@swc-node/loader": "^1.3.7",
|
|
55
57
|
"@swc/core": "^1.3.84",
|
|
56
58
|
"@swc/jest": "^0.2.29",
|
|
@@ -93,8 +95,10 @@
|
|
|
93
95
|
"webpack-cli": "^5.1.4"
|
|
94
96
|
},
|
|
95
97
|
"dependencies": {
|
|
98
|
+
"dotenv": "^16.4.7",
|
|
96
99
|
"i18next": "^21.10.0",
|
|
97
100
|
"i18next-parser": "^6.6.0",
|
|
101
|
+
"playwright": "^1.49.1",
|
|
98
102
|
"react-hook-form": "^7.34.2",
|
|
99
103
|
"turbo": "^2.3.3",
|
|
100
104
|
"uuid": "^9.0.1"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { devices, PlaywrightTestConfig } from '@playwright/test';
|
|
2
|
+
import * as dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
// See https://playwright.dev/docs/test-configuration.
|
|
6
|
+
const config: PlaywrightTestConfig = {
|
|
7
|
+
testDir: './e2e/specs',
|
|
8
|
+
timeout: 3 * 60 * 1000,
|
|
9
|
+
expect: {
|
|
10
|
+
timeout: 40 * 1000,
|
|
11
|
+
},
|
|
12
|
+
fullyParallel: true,
|
|
13
|
+
forbidOnly: !!process.env.CI,
|
|
14
|
+
retries: 0,
|
|
15
|
+
reporter: process.env.CI ? [['junit', { outputFile: 'results.xml' }], ['html']] : [['html']],
|
|
16
|
+
globalSetup: require.resolve('./e2e/core/global-setup'),
|
|
17
|
+
use: {
|
|
18
|
+
baseURL: `${process.env.E2E_BASE_URL}/spa/`,
|
|
19
|
+
storageState: 'e2e/storageState.json',
|
|
20
|
+
video: 'retain-on-failure',
|
|
21
|
+
},
|
|
22
|
+
projects: [
|
|
23
|
+
{
|
|
24
|
+
name: 'chromium',
|
|
25
|
+
use: {
|
|
26
|
+
...devices['Desktop Chrome'],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default config;
|