diff --git a/AGENTS.md b/AGENTS.md index 75d9aa29..76871bd7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,7 +8,7 @@ MOSIP Admin Portal — an Angular 8 SPA used by privileged administrative person The repo has two independently buildable modules: - `admin-ui/` — the Angular frontend -- `uitest-admin/` — a Selenium + TestNG automation test suite (Java 21, Maven) +- `uitest-admin/` — a Playwright + Cucumber UI automation suite on the shared `uitest-commons` library (Java 21, Maven) --- @@ -31,19 +31,12 @@ ng e2e # end-to-end tests via Protractor ```bash cd uitest-admin -mvn clean install # build and package the fat JAR - -# Run tests against a deployed environment -java -Dpath=https://admin..mosip.net/ \ - -DKeyclockURL=https://iam..mosip.net \ - -Denv.user=api-internal. \ - -Denv.endpoint=https://api-internal..mosip.net \ - -jar target/uitest-admin-1.3.0-jar-with-dependencies.jar +mvn test # run every feature against the configured env +mvn test -DscenarioToRun="Center type CRUD" # by exact scenario name (comma-separated) +mvn test -Dcucumber.filter.tags="not @bulkUploadCRUD" # by tag ``` -Control test execution via `src/main/resources/TestData.json`: -- `setExcludedGroups`: comma-separated group tags to skip (e.g. `"BL,CT"`) -- `headless`: `"yes"` for headless Chrome +Configure the target environment in `src/test/resources/config/adminui.properties` (tracked with blank secrets — never commit real values) or via environment variables of the same names: `baseUrl`, `apiInternalEndPoint`, `keycloak-external-url`, `mosip_admin_client_secret`, `mosip_testrig_client_secret`. `mvn package` skips the live suite when `CI=true`. --- @@ -91,7 +84,7 @@ API paths are constructed in `app.constants.ts` as ` + ` to change). + +## Run a subset + +By exact scenario name (case-insensitive, comma-separated): +``` +mvn test -DscenarioToRun="Center type CRUD,Device CRUD" +``` +or set `scenarioToRun=` in `adminui.properties`; the `-D` flag wins if both are set. + +By tag — each feature carries the name of the TestNG test it replaces, so the old +`setExcludedGroups` codes map as follows: +``` +mvn test -Dcucumber.filter.tags="@centerCRUD or @deviceCRUD" +mvn test -Dcucumber.filter.tags="not @bulkUploadCRUD" +``` + +| Old code | Tag | Feature | +|---|---|---| +| BL | `@blocklistedwordsCRUD` | `blocklisted-words.feature` | +| BU | `@bulkUploadCRUD` | `bulk-upload.feature` | +| CTR | `@centerCRUD` | `center.feature` | +| CT | `@centerTypeCRUD` | `center-type.feature` | +| DS | `@deviceSpecCRUD` | `device-specification.feature` | +| D | `@deviceCRUD` | `device.feature` | +| DT | `@deviceTypesCRUD` | `device-type.feature` | +| DOC | `@documentCategoriesCRUD` | `document-category.feature` | +| DOCT | `@documentTypesCRUD` | `document-type.feature` | +| DF | `@dynamicFieldCRUD` | `dynamic-field.feature` | +| H | `@holidaysCRUD` | `holiday.feature` | +| MS | `@machineSpecCRUD` | `machine-specification.feature` | +| M | `@machineCRUD` | `machine.feature` | +| MT | `@machineTypesCRUD` | `machine-type.feature` | +| T | `@templateCRUD` | `template.feature` | + +Area tags `@masterdata`, `@resources` and `@bulkupload` select whole groups. + +## Run in Docker + +``` +docker build -t uitest-admin . +docker run -e ADMINUI_CONFIG_PATH=/home/mosip/config/adminui.properties \ + -v /path/to/local/adminui.properties:/home/mosip/config/adminui.properties \ + uitest-admin +``` + +The image (Microsoft's Playwright Java base image) compiles the test sources at build time and +runs `mvn -o test` at container start. `entrypoint.sh` copies the mounted config file over the +tracked `adminui.properties`; plain environment variables work too. The pre-Playwright +`adminPortalPath` variable is still accepted when `baseUrl` is not set. + +## Local portal (ng serve) + +When `baseUrl` points at `localhost`, the suite skips the Keycloak login (localhost is not an +allowed redirect, KER-ACP-009) and instead stores the admin token as an `Authorization` cookie on +`masterdatabaseurl` (e.g. a local kernel-masterdata-service on `http://localhost:8086`), launches +Chromium with web security off for the cross-origin calls, and answers the portal's audit-log +calls itself, since a local admin service does not serve them. + +## Configuration + +Property layers (lowest → highest), loaded by `AdminConfigManager.init()`: +1. `Kernel.properties` (apitest-commons JAR — MOSIP-wide defaults) +2. `uitest.properties` (uitest-commons JAR — browser defaults) +3. `adminui.properties` (this module) +4. Environment variables + +Notable keys in `adminui.properties`: `loginlang` (Keycloak login language and the +`BulkUploadFiles//` folder), `preappend` (prefix of the generated `${data}` value), +`bulkUploadStatusWaitSeconds`, and `cleanupMasterData` with `db-server`/`postgres-password` +(post-run deletion of the master data rows this run created; skipped while the password is blank). + +## Architecture + +1. `AdminTestRunner` (`runner/`) — JUnit5 `@Suite` entry point, no logic. +2. `AdminHooks` (`hooks/`) — suite lifecycle: loads config, creates the run's Keycloak admin user + (`_admin-ui-auto`) and maps it to a leaf zone, generates the run's test data + (`AdminTestData`), and after the run cleans up master data (`AdminDbCleanup`) and the user. +3. Feature files drive generic steps in `steps/` (`MasterDataSteps` for every CRUD page, + `CenterSteps`, `BulkUploadSteps`), which drive page objects in `pages/`. + +Feature files reference generated test data as `${name}` placeholders: `${data}`, +`${blocklistedWord}`, `${holidayDate}`, `${holidayDateCenter}`, `${validityDate}`, `${publicKey}`, +`${signPublicKey}`. + +Scenarios that create types/specs and scenarios whose forms pick the first type/spec from a +dropdown are kept from running at the same time via Cucumber exclusive resources in +`junit-platform.properties`. + +## Known issues + +Add `bugId------Scenario name` lines to `src/test/resources/config/Known_Issues.txt`; matching +scenarios are skipped and reported with a link to the bug. + +## Reports + +Each run writes an Extent HTML report to `reportOutputDir` (default `test-output/`), named +`admin-ui---