Repository navigation
Conversation
Contributor
|
thanks |
vharseko
approved these changes
Aug 7, 2025
vharseko
added a commit
to OpenIdentityPlatform/OpenIG
that referenced
this pull request
Oct 22, 2026
…ven test phase (#179) Fixes #175. The `qunit` task had been commented out of the `build` task since 2019 (`f270c42a`), and `grunt qunit` itself timed out: grunt-contrib-qunit 1.3 / PhantomJS cannot load the ES2015 app any more. The four suites in `src/test/js/tests` (39 tests) gave no signal. ### Runner - `grunt-contrib-qunit` 1.3.0 → 10.2.0 (headless Chrome via Puppeteer; Chrome is downloaded during `npm install`), QUnit 2.26 from npm instead of the `qunit:1.15.0` Maven artifact (`copy-dependencies-qunit` execution, the two dependencies and the root pom's two `qunit` download items removed). Puppeteer is pinned to 24.43.1 so that every fresh install tests against the same Chrome (openig-ui has no lockfile; the plugin itself asks for `^24.0.0`). - Chrome runs with `--allow-file-access-from-files`: the test page is opened from `file://` and the app fetches translations and templates through XHR, which Chrome blocks for local files by default (PhantomJS did not). `puppeteer.args` replaces the arguments the plugin would build itself, so they are rebuilt next to it: `CHROMIUM_FLAGS` if set, else `--no-sandbox` when `CI` is set. Building as root (e.g. in a container) therefore needs `CI=true` or `CHROMIUM_FLAGS=--no-sandbox`, as with the plugin alone. - New `grunt test` task (`copy:qunit` + `qunit`), bound to the Maven **`test`** phase as a separate execution rather than put back into `build`: `mvn verify` fails on a failing JS test, and `-DskipTests` skips the suite through frontend-maven-plugin's built-in `skipTests` parameter (same layout as OpenAM's `npm-test` execution, OpenIdentityPlatform/OpenAM#902). The plugin never reads `maven.test.skip`, so a `maven-test-skip` profile, active on `-Dmaven.test.skip=true`, skips that execution as well; `<skip>` on the execution itself would have replaced `${skip.grunt}` for it. ### Harness (`config.js` / `run.js`) Two problems only showed up once Chrome actually ran the page: 1. `config.js` required `main` and `../test/run` together. The paths the test suites' dependencies resolve through (`i18next`, `backbone`, …) are set by the `require.config` inside `main.js`; after `grunt build` that is the uglified bundle, which loads slower than the tiny `run.js`, so the dependencies were resolved before the config existed (`Script error for "i18next"`). Historically `qunit` ran in `build-dev` *before* `requirejs`, so the race was won by luck. Now `run.js` registers the `EVENT_APP_INITIALIZED` listener before `main` is required and loads the suites inside that listener. 2. The optimised bundle carries its own copy of jQuery, lodash, bootstrap, …; the test page has already loaded jQuery as a module (needed by `MockServer`/`EventManager`), so executing the bundle created a second jQuery instance — `bootstrap` (shim) attached `$.fn.modal` to the new global while the AMD `bootstrap-dialog` got the old one (`Cannot read properties of undefined (reading 'Constructor')`). The test config therefore starts the app from the unbundled `target/compose/main.js` (`paths.main`); everything else is still served from `target/www`. ### Tests - Migrated to the QUnit 2 API: `module()` → `QUnit.module()`, `QUnit.asyncTest` + `QUnit.start()` → `QUnit.test` (all callbacks under test are synchronous). PhantomJS `Function.prototype.bind` polyfill removed. - `assert.throws(…, transformService.TransformServiceException("invalidModel"), …)` called the constructor without `new`, so `expected` was `undefined` and the assertions only checked that *something* was thrown. They now use a validator that checks `name` and `errorType`; this exposed that the "unknown filter type" test expected `invalidModel` while `transformFilter` throws `unknownFilterType`. - The "no 'name'" and "no 'baseURI'" fixtures each left *both* attributes empty, and `RouteModel.validate()` stops at the first missing one, so neither test could fail if the check it names was removed. Each fixture now leaves out only the attribute under test. - New `StylesheetTests`: every `@import` of the built `css/structure.css` must load. Less keeps a CSS `@import` as it is and a stylesheet that fails to load does not fail the page, which is how the CodeMirror path below stayed broken unnoticed. ### Also - `structure.less` still imported `../libs/CodeMirror-4.10.0/lib/codemirror.css`; #36 moved the CodeMirror location to `libs/codemirror5-4.10.0` in `main.js` only, so the stylesheet has been a 404 in the built UI since then (CodeMirror is used for the route JSON view). Path fixed; `StylesheetTests` now covers it. ### Verification - `mvn -pl openig-ui -am verify`: `grunt-test` → `40 tests completed, 0 failed`, BUILD SUCCESS. - `-DskipTests` and `-Dmaven.test.skip=true`: `grunt-test` → `Skipping execution.`; `-Dskip.grunt=true` still skips both `grunt` and `grunt-test`. - Negative checks against the built copies (each → `1 failed`, grunt exit 6): - a flipped expectation in `DataFilterTests`; - `transformError("invalidModel")` in the unknown filter type test (`Actual: TransformServiceException: UnknownTypeOfFilter`); - the `name` branch, then the `baseURI` branch, removed from `RouteModel.validate()` → the matching "no 'name'" / "no 'baseURI'" test fails; - the old `CodeMirror-4.10.0` path in `structure.css` → `css/../libs/CodeMirror-4.10.0/lib/codemirror.css is loaded` fails. - Chrome arguments: none → `--allow-file-access-from-files`; `CI=true` → `+ --no-sandbox`; `CHROMIUM_FLAGS="--no-sandbox --disable-gpu"` → `+ --no-sandbox --disable-gpu` (suite green); `CHROMIUM_FLAGS` wins over `CI`, as in the plugin. - `grunt eslint`: 0 errors; the 5 warnings are pre-existing in `src/main/js`. - Remaining console noise in the test run is expected: `file:///api/info` (`Footer` → `ServerInfoService.getInfo()` with no backend, handled by its `.fail`) and the resulting "Unknown error" message from the commons REST error handler.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.