Skip to content

feat(widget-harness): add live data-store harness with a Datagrid scenario - #2580

Draft
iobuhov wants to merge 1 commit into
mainfrom
widget-harness
Draft

iobuhov wants to merge 1 commit into
mainfrom
widget-harness

Conversation

@iobuhov

@iobuhov iobuhov commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Pull request type

Test related change (New E2E test, test automation, etc.)


Why

Running a widget in a real browser today means mxbuild, mxruntime and Docker (automation/run-e2e). This adds a lightweight harness that renders the real widget components with props backed by a live in-memory data store, so widgets can be exercised in Playwright in seconds. It fakes only the pluggable widget API props (mendix typings) and the data behind them. It is not a Mendix client, and it is built only from the public typings and the widgets' own code.

What changed

New private package packages/shared/widget-harness:

  • src/store (no React, no Jest): DataStore holds plain entity objects and stable ObjectItems. LiveList is a live ListValue that applies setFilter condition trees, sortOrder, offset/limit, requestTotalCount/totalCount, hasMoreItems and reload, and goes loading → available after a configurable delay. Each change publishes a new snapshot, like the client giving widgets new props.
  • src/filters/builders.ts: a mendix/filters/builders implementation; evaluateFilter runs its trees against rows.
  • src/props/Harness.ts: live props on top of the store, with a version that changes whenever a widget-visible value changes.
  • host/: Vite page that mounts a scenario and re-renders it with fresh props. First scenario: datagrid-basic, real Datagrid with the real text filter in a column header.
  • e2e/: 5 Playwright tests: first page renders, sort asc/desc, case-insensitive text filter, paging, and a store mutation re-rendering a row plus a row click recording onClick.

Live vs stubbed:

Live Stubbed / not yet
ListValue (filter, sort, paging, total count, reload, loading delay) Validation on object attributes
ListAttributeValue.get → EditableValue, setValue writes to the store setFormatter, setKeepSelection are no-ops
ListExpressionValue, ListWidgetValue isExecuting is always false
ActionValue, ListActionValue (record calls, can mutate the store) Associations stored but not exercised
Standalone EditableValue with validator Formatting is fixed en-US
SelectionSingleValue / SelectionMultiValue, DynamicValue

What Datagrid needed from the client: almost nothing. The mendix package throws at runtime and esbuild doesn't inline its const enums, so host/shims/mendix.ts provides ValueStatus/FormatterType. Datagrid's setup is not StrictMode-safe, so the host doesn't use StrictMode (neither does the client). window.mx is only used optionally in export.

How to run

cd packages/shared/widget-harness
pnpm run dev                              # http://localhost:5199/?scenario=datagrid-basic&delay=50
pnpm exec playwright install chromium     # once
pnpm run test:e2e

window.harness exposes the store and recorded action calls to tests.

Scope

Only the new package plus pnpm-lock.yaml. New devDeps: vite@7.3.7, sass@1.102.0, react/react-dom@18.3.1; deps big.js, mendix (typings). Left out: Jest entry for the store core, other widgets/filters, CI wiring.

Tradeoffs

  • Workspace libs are aliased to their src/ so no prior build is needed. The cost: host/ is excluded from tsc (typecheck covers src/ and e2e/), because widget sources only typecheck against built dist typings.
  • Script is test:e2e, not e2e, so the nightly pnpm -r run e2e doesn't pick it up until CI wiring is decided.
  • Semantics I chose (not confirmed against the runtime): case-insensitive string comparison, empty values sort first, any store change reloads every list.

Blast radius

None outside packages/shared/widget-harness. No widget code changed.

Verification

pnpm run lint, pnpm run typecheck and pnpm run test:e2e (5/5, stable over --repeat-each 3) in the package.

🤖 Generated with Claude Code

…nario

Renders real widgets in a Vite page with props backed by an in-memory store:
live ListValue (filter, sort, paging, total count, loading delay), a
mendix/filters/builders implementation, live props, and Playwright tests
for Datagrid rendering, sorting, text filtering, paging and actions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant