Skip to content

fix(webapps): restore test harnesses and validate SDK calendar dates - #3820

Closed
hauptmedia wants to merge 1 commit into
mainfrom
fix/frontend-test-harness-and-date-validation
Closed

hauptmedia wants to merge 1 commit into
mainfrom
fix/frontend-test-harness-and-date-validation

Conversation

@hauptmedia

@hauptmedia hauptmedia commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Superseded by three focused PRs

This combined PR has been split by problem into:

All three target main. Merge #3900 before #3901 so the SDK date regression can use the restored Mocha/Chai test runner. Together they preserve all changes from this PR. The original description and validation record are retained below for reference.


Summary

This PR addresses three independent problems found when attempting to run the existing test suites during the investigation of #3814: a broken legacy test entry point, a real SDK date-validation defect, and a network-dependent Neo XML test. These problems already exist independently of the multi-instance input-mapping change. This PR is not a prerequisite for #3818. The separate engine regression repairs are in #3819.

1. The legacy frontend still contains tests, but its test setup is incomplete

On the unchanged base, webapps/frontend/package.json defines npm test as karma start karma.config.js, but that configuration file is missing. Running the advertised command therefore stops with Cannot find module .../karma.config.js before any browser assertion runs. Required framework/launcher/assertion dependencies are also missing from the current setup.

The SDK client tests have a separate problem: they reference ../superagent-mock-config, which was removed from the repository layout, and cannot start without that fixture and its test dependencies. Once the historical setup is restored, five helper usages are incompatible with the current libraries: three assertions inspect request.headers rather than Superagent's request.header, and two Sinon spies call the removed reset() method rather than resetHistory(). The expected header values and behavioral assertions are retained.

The consequence is a verification gap: keeping these test source files in the repository does not mean they actually run. The legacy Maven frontend build runs dependency installation, the license check and production bundling; it does not execute the legacy npm test command. The PR workflow's dedicated frontend unit-test job targets Webapps Neo, so a green build does not prove that these older UI/SDK suites work.

This PR adds the missing Karma configuration, pins the required development dependencies, restores the original SDK request-mock fixture with its attribution, and provides separate npm run test:sdk and npm run test:ui commands. npm test invokes both in sequence. The SDK Node suite now runs successfully. The 32 UI browser spec files bundle, but browser execution is still unverified because Chromium cannot create its required Unix socket in the current executor. The older SDK browser and Commons browser inventories are not restored or claimed as executed by this change.

2. SDK Date validation checks the string's shape, but not whether the date exists

The existing Date branch in operaton-bpm-sdk-js/lib/forms/type-util.js only applies a regular expression for YYYY-MM-DDTHH:mm:ss and optional fractional seconds. It accepts two digits for each calendar/time field without checking their ranges or calendar relationships.

For example, 2023-02-29T12:34:56, 2024-02-30T12:34:56, 2024-04-31T12:34:56 and 2024-01-01T25:00:00 pass that check. Consequently, SDK form type checking can accept nonexistent dates or invalid times; convertToType(..., 'Date') can return those invalid strings rather than rejecting them. This is a product-validation defect, not merely an environment or test-runner issue.

The fix validates the Gregorian calendar (including century leap-year rules), month/day ranges and time fields without using JavaScript Date parsing or timezone conversion. It deliberately retains the existing input grammar and compatibility forms: four-digit years, mandatory seconds, zero-to-four fractional digits, the legacy trailing decimal point, second 60, and end-of-day 24:00:00 only when all smaller fields are zero. Offset/Z strings remain unsupported.

The new regression file contains 48 cases. Against the unchanged validator, 17 invalid-calendar/range cases fail while 31 compatibility controls pass; with the fix, all 48 pass. The checks also cover host-timezone independence for UTC, New York and Kathmandu.

3. A Neo XML unit test unexpectedly requires external network access

QuerySessionFactoryTest parses the generated MyBatis configuration using a plain JAXP document builder. The XML references the MyBatis DTD, so the parser attempts external DTD resolution. The test can fail when that host cannot be resolved or reached, even when the generated mapping configuration is correct.

MyBatis already bundles the required DTD and provides XMLMapperEntityResolver. Configuring that resolver in the test lets the parser use the bundled resource. The change is confined to test setup; it does not change runtime query generation or remove the test assertions.

Supporting cleanup and scope

The remaining edits are mechanical lint fixes in the legacy frontend build configuration and compatibility helper. Their normalized ASTs were compared to verify that the cleanup does not change behavior. This PR combines test-infrastructure repairs with the separately testable SDK validation fix; it introduces no multi-instance engine behavior changes and does not modify CI workflows.

Attribution

The SDK superagent-mock-config.js fixture is restored verbatim from repository history. Its original Camunda Apache-2.0 copyright/license header is retained. The source revision and path are also recorded in the commit.

Verified locally

  • SDK Node: 168 passed, zero failures, 9 existing pending, across 14 files.
  • Date regression red/green: unchanged code fails 17 invalid-calendar/range cases and passes 31 compatibility controls; repaired code passes all 48, including UTC/New York/Kathmandu host-zone checks.
  • Neo JavaScript: 638 tests in 66 files passed.
  • Legacy lint: zero errors and one existing nonfatal warning.
  • Frontend production build: exit 0, 54 warnings and zero errors, using bounded minifier concurrency.
  • All 32 UI browser spec files bundle. Browser execution remains deferred as detailed below.
  • Offline XML smoke: validates valid XML and rejects malformed/invalid XML without network access.

Verification scope

The three companion change sets were validated together on 79f9f874bcec4f3ff7423ac39270bfea2b66cfb1: 26,919 distinct Java cases, zero failures/errors and 142 existing skips; all 129 reactor modules completed successfully across verified recovery segments. This was not one uninterrupted build, and it is not a claim that each split branch independently passed the expanded full suite.

This branch is based on ce6e96e4139a006bb3ba6a3fce70f80eb3641f5c. The intervening main change only updates the REST documentation dependency lockfile. Every published changed file was checked byte-for-byte against the tested content.

Legacy browser test execution is explicitly deferred for this run: Chromium cannot create its required Unix socket in the test executor. The 32 UI, 7 SDK browser and 13 Commons browser spec inventories are not claimed as passed. No tests are permanently disabled. Optional external-database/runtime-container/E2E matrices were not run.

The cleanup script's isolated imports phase passed. Its code/test phases encountered existing recipe configuration errors, so the complete cleanup pipeline is not claimed as passed. git diff --check passed.

Restore legacy UI and SDK Node test tooling, repair date validation with 48 regression cases, and resolve the Neo XML test DTD offline. Include mechanical lint cleanup.

Restore superagent-mock-config.js verbatim from operaton/operaton commit ee7bbef at webapps/camunda-bpm-sdk-js/test/superagent-mock-config.js, retaining its original Camunda Apache-2.0 attribution.
Source: https://github.com/operaton/operaton/blob/ee7bbef8d02f85d0d6a7d4052b275d6b5b4cd18d/webapps/camunda-bpm-sdk-js/test/superagent-mock-config.js
@github-actions github-actions Bot added documentation Improvements or additions to documentation lang:java Pull requests that update Java code lang:javascript Pull requests that update Javascript code scope:webapp Changes affecting the legacy webapps. scope:tests Changes affecting only test code scope:webapp-neo Changes affecting the new webapps. labels Oct 9, 2026
@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

hauptmedia added a commit that referenced this pull request Oct 9, 2026
Reuse the verified offline XML test prerequisite from Operaton PR #3820. Preserve XML assertions while avoiding a live mybatis.org lookup during validation; runtime parsing is unchanged.
@hauptmedia hauptmedia closed this Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation lang:java Pull requests that update Java code lang:javascript Pull requests that update Javascript code scope:tests Changes affecting only test code scope:webapp Changes affecting the legacy webapps. scope:webapp-neo Changes affecting the new webapps.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant