|
| 1 | +## Test Cases |
| 2 | + |
| 3 | +The characterisation specs from `combobox-selector-safety-net` stay the net, adapted at their construction only: `createSelector(props)` resolves the selector from the container and runs the setup host, `setProps(next)` stands for the next render. Every behavioural expectation that is not listed under Behaviour changes below holds unchanged. |
| 4 | + |
| 5 | +### Regression Tests |
| 6 | + |
| 7 | +- Views render the same DOM (unit) - `src/__tests__/*.spec.tsx` |
| 8 | + - **Given**: the views over the derived selectors |
| 9 | + - **When**: the 29 component cases run |
| 10 | + - **Then**: all pass, the 5 snapshots are unchanged |
| 11 | +- Selector seam (unit) - `src/helpers/**/__tests__/*.spec.ts*` |
| 12 | + - **Given**: every family through the harness, `enforceActions: "always"` |
| 13 | + - **When**: status, value, captions, filtering, limit, lazy loading, writes |
| 14 | + - **Then**: the pinned expectations hold, no `[MobX]` warning |
| 15 | + |
| 16 | +### New cases |
| 17 | + |
| 18 | +- Association: no items requested while a datasource without lazy loading is loading; the page limit kept and nothing requested from an unpaged datasource while a lazy one is loading; client-side filtering with an expression caption even when lazy loading is on. |
| 19 | +- Database single: the datasource selection is the value when no attribute is bound; an unchanged attribute value leaves the selection alone across a props push; loading status while the datasource loads. |
| 20 | +- Container: a props push reaches the selector through the gate; the selector's side effects start with the setup host and not before. |
| 21 | +- `useComboboxCore`: a props push during render is reflected in the ViewModel of that render. |
| 22 | + |
| 23 | +### E2E |
| 24 | + |
| 25 | +- `pnpm run e2e` locally against the test project after an app restart, then on the PR through CI. Snapshots must be identical; this change changes no DOM. |
| 26 | + |
| 27 | +## Decisions |
| 28 | + |
| 29 | +- **Derive, do not copy.** A selector is a set of computeds over `gate.props` and the frozen config, the pattern of `rows.model.ts` and `items.model.ts` in the data grid and gallery. The only state left is the search term and the "page requested" marker of lazy loading. |
| 30 | +- **Mendix values behind plain getters.** A computed that returns a Mendix value object would compare it by identity and hide a change made in place, which the test builders do and which the design doc's rule 5 warns about. `attr`, `ds`, `selection` and the like are plain getters, so every computed that uses them reads `gate.props` itself. |
| 31 | +- **Side effects as setup reactions.** The datasource limit is an autorun over the wanted limit; the filter is a reaction on the search term; the database single selector syncs the datasource selection in a reaction keyed on the attribute value and the page ids (structural comparison, so a props push without a change fires nothing). They run on mount for the first props and synchronously inside each props push afterwards. Before, the same writes ran during the first render too. |
| 32 | +- **Family-neutral providers through `MappedGate`.** The association and database selectors map their props into `DatasourceSource` and `CaptionSource`, so one options provider and one captions provider serve both families. The mapped props object is new on every gate change, which is what the providers want. |
| 33 | +- **The loaded page is latched.** A datasource mid-reload may report no items; the provider keeps the previous page until the next one arrives, which is what the database selector's "skip while loading" guard protected, without freezing the rest of the selector. |
| 34 | +- **The static config grows by what the selectors read once.** `clearable`, the caption type, the editability rule and the chip sorting are simple-type properties, so they are read once like the rest. |
| 35 | +- **The specs go through the container.** A harness that resolves the selector from `createComboboxContainer` tests the wiring as well as the class: a selector that forgets to register with the setup host, or a token that is bound wrong, fails here first. |
| 36 | +- **Preview selectors are plain objects.** They take the preview props once and never change, so they need neither MobX nor a gate. |
| 37 | + |
| 38 | +## Behaviour changes |
| 39 | + |
| 40 | +Deliberate, each one a candidate the safety-net change had rated. Flipped expectations are marked in the specs. |
| 41 | + |
| 42 | +1. **Static: an external clear clears the selection.** The old selector kept a stale `currentId` when the attribute was emptied by a microflow (safety-net quirk 1, rated medium). A derivation cannot keep stale state; the CHANGELOG records the fix. |
| 43 | +2. **Database single: `status` is `"loading"` while the datasource loads.** It was `"unavailable"` on the first load and frozen at the previous value on later reloads. The views treat `"loading"` like `"available"`, so the widget renders with the previous page instead of a placeholder on the first load. |
| 44 | +3. **Database single without a bound attribute takes the datasource selection as its value.** Before, the value only existed after `setValue` in the same page visit, so a reload showed nothing selected. |
| 45 | +4. **Enumeration: `clearable` while unavailable is the configured value**, not `true` (a pinned quirk with no effect, since nothing renders in that status). Likewise `readOnly` and `validation` read the attribute in every status. |
| 46 | +5. **The lazy-loading limit never-shrink rule is gone.** `LazyLoadProvider` remembered a limit that was overwritten with the current one on every update, so the rule never applied. |
| 47 | + |
| 48 | +Not changed on purpose: chip sorting without a datasource sort order is still descending (quirk 2); the forced boxes style was already resolved in the config by step 2 (quirk 3); a missing `emptyOptionText` still makes a selector unavailable; a read-only control still limits its datasource to zero items. |
| 49 | + |
| 50 | +## Notes |
| 51 | + |
| 52 | +- The Core bound its commands before `makeObservable`, so the first `ComboboxCore` instance in a process carried the unwrapped prototype methods and `highlight` from a downshift effect tripped strict mode. The full suite passed by ordering; `pnpm run test -t "sets option to selected item"` failed on the step 3 tip. Binding after `makeObservable` fixes it; with it, the component specs pass in any order. |
| 53 | +- brandi rejects a class whose instance has a protected member named `valueOf`, since `Object.valueOf` is public; the database helper is `optionValue`. |
| 54 | +- Test count: 227 on the step 3 tip, minus the 9 `LazyLoadProvider` cases and 6 cases on fields that moved to the config, plus 6 new cases, equals 218. |
0 commit comments