fix(editor): submit a live formula's computed value, not its raw text #310

Merged
allan merged 30 commits from process-formula into version7-13 2026-08-30 22:00:07 +00:00
Owner

Summary

Formula cells (typed, pasted, autofilled, or applied via "Apply as formula") were submitting their raw =... text to the backend instead of the value HyperFormula actually displays — affecting character columns, numeric columns, and primary key columns, each with its own failure mode.

Intent

Formulas are enabled on every column, but the grid's underlying dataSource never mutates when HyperFormula recalculates a cell's displayed value — it only updates the render layer. saveTable() originally resolved computed values only for HARDFORMULA/SOFTFORMULA columns, so any other live formula reached the backend as literal text, which a SAS field (especially a numeric one) can't parse.

A primary key needed different treatment again: PK values drive row identity throughout the edit session (dataModified/classifyRow match a row by comparing its PK). Resolving a PK's formula only at submit time meant its value could differ from whatever dataModified snapshotted earlier, silently dropping the row from submission. This applies whether the formula was user-entered or seeded by a HARDFORMULA/SOFTFORMULA rule assigned directly to a PK column — nothing prevents that assignment, and a rule-seeded PK formula is present from the very first render, not just after an edit.

Changes

  • saveTable() now resolves any live =-led cell to its computed value before submission, for every column (not just HARDFORMULA/SOFTFORMULA ones).
  • coerceNumericRow (beforePaste/beforeAutofill) no longer lets a numeric column's raw formula text bypass resolution.
  • A new afterChange hook resolves a primary key's formula to its computed value immediately, the moment the edit completes (typed, pasted, autofilled, or "Apply as formula"'d) — a PK is never left holding a live, still-recalculating formula.
  • A new resolvePkFormulaSeedValues() freezes a HARDFORMULA/SOFTFORMULA-driven PK to its computed value once, right after the initial table load, mirroring the same value onto dataSourceUnchanged so row-identity matching stays consistent.
  • Mock server: added MPE_X_FORMULA_PK_TEST, a dedicated table with a composite PK made of a HARDFORMULA numeric column and a SOFTFORMULA character column, for exercising the rule-seeded PK case end-to-end.
  • Karma: added integration coverage (real Handsontable + HyperFormula instances) for character, numeric, and PK columns, both user-entered and rule-seeded formulas.
  • Cypress: added tests 49–52 covering formula submission in a character column, a numeric column, a user-entered PK formula, and a HARDFORMULA/SOFTFORMULA composite PK.
## Summary Formula cells (typed, pasted, autofilled, or applied via "Apply as formula") were submitting their raw `=...` text to the backend instead of the value HyperFormula actually displays — affecting character columns, numeric columns, and primary key columns, each with its own failure mode. ## Intent Formulas are enabled on every column, but the grid's underlying `dataSource` never mutates when HyperFormula recalculates a cell's displayed value — it only updates the render layer. `saveTable()` originally resolved computed values only for HARDFORMULA/SOFTFORMULA columns, so any other live formula reached the backend as literal text, which a SAS field (especially a numeric one) can't parse. A primary key needed different treatment again: PK values drive row identity throughout the edit session (`dataModified`/`classifyRow` match a row by comparing its PK). Resolving a PK's formula only at submit time meant its value could differ from whatever `dataModified` snapshotted earlier, silently dropping the row from submission. This applies whether the formula was user-entered or seeded by a HARDFORMULA/SOFTFORMULA rule assigned directly to a PK column — nothing prevents that assignment, and a rule-seeded PK formula is present from the very first render, not just after an edit. ## Changes - `saveTable()` now resolves any live `=`-led cell to its computed value before submission, for every column (not just HARDFORMULA/SOFTFORMULA ones). - `coerceNumericRow` (`beforePaste`/`beforeAutofill`) no longer lets a numeric column's raw formula text bypass resolution. - A new `afterChange` hook resolves a primary key's formula to its computed value immediately, the moment the edit completes (typed, pasted, autofilled, or "Apply as formula"'d) — a PK is never left holding a live, still-recalculating formula. - A new `resolvePkFormulaSeedValues()` freezes a HARDFORMULA/SOFTFORMULA-driven PK to its computed value once, right after the initial table load, mirroring the same value onto `dataSourceUnchanged` so row-identity matching stays consistent. - Mock server: added `MPE_X_FORMULA_PK_TEST`, a dedicated table with a composite PK made of a HARDFORMULA numeric column and a SOFTFORMULA character column, for exercising the rule-seeded PK case end-to-end. - Karma: added integration coverage (real Handsontable + HyperFormula instances) for character, numeric, and PK columns, both user-entered and rule-seeded formulas. - Cypress: added tests 49–52 covering formula submission in a character column, a numeric column, a user-entered PK formula, and a HARDFORMULA/SOFTFORMULA composite PK.
Yury added 1 commit 2026-08-25 15:21:06 +00:00
fix(editor): submit a live formula's computed value, not its raw text
Build / Build-and-ng-test (pull_request) Successful in 5m47s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m27s
Build / Build-and-test-development (pull_request) Successful in 27m6s
b7d31066ae
saveTable() only resolved computed values for HARDFORMULA/SOFTFORMULA
columns - a formula typed, pasted, or "Apply as formula"'d into any
other character column still had its raw `=...` text submitted,
since HyperFormula recomputes the display without ever mutating the
underlying dataSource string.
hermes left a comment
Collaborator

Code Review

Verdict: Approve — no changes needed.


Reviewed by Hermes Agent

## Code Review **Verdict: Approve** — no changes needed. --- *Reviewed by Hermes Agent*
Collaborator

Test Coverage

Services: 22/60 (37%) | Macros: 12/42 (29%) | Overall: 34/102 (33%) — 2026-08-25T15:38:18Z on b7d31066ae

PR diff


Generated by Hermes Agent

## Test Coverage **Services: 22/60 (37%) | Macros: 12/42 (29%) | Overall: 34/102 (33%)** — `2026-08-25T15:38:18Z` on `b7d31066ae` [PR diff](https://git.datacontroller.io/dc/dc/pulls/310/files) --- *Generated by Hermes Agent*
allan added 1 commit 2026-08-25 15:43:41 +00:00
Merge branch 'version7-13' into process-formula
Build / Build-and-ng-test (pull_request) Successful in 6m0s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m29s
Build / Build-and-test-development (pull_request) Successful in 27m4s
1b1937bad8
Yury added 1 commit 2026-08-26 07:53:49 +00:00
fix(editor): resolve computed value for a live formula in numeric columns too
Build / Build-and-ng-test (pull_request) Successful in 5m46s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m55s
Build / Build-and-test-development (pull_request) Successful in 26m47s
2cc8489892
saveTable() only resolved a live formula's computed value for character columns - coerceNumericRow (beforePaste/beforeAutofill) deliberately leaves a non-numeric, formula-looking value alone rather than forcing it to NaN, so a numeric column can hold a live formula too. Its raw `=...` text was reaching the backend, which a numeric SAS field can't parse.
Yury added 1 commit 2026-08-26 16:13:13 +00:00
fix(editor): resolve a primary key's live formula to its computed value, not the raw formula text
Build / Build-and-ng-test (pull_request) Successful in 5m12s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m40s
Build / Build-and-test-development (pull_request) Successful in 27m13s
d72e19a308
hermes added 1 commit 2026-08-27 11:42:20 +00:00
chore: lint fix
Build / Build-and-ng-test (pull_request) Successful in 5m53s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m3s
Build / Build-and-test-development (pull_request) Failing after 33m36s
18a16fcb06
hermes added 1 commit 2026-08-27 16:21:13 +00:00
feat: functional JS mocks
Build / Build-and-ng-test (pull_request) Successful in 5m28s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m25s
Build / Build-and-test-development (pull_request) Failing after 33m34s
ee52bb8967
hermes added 1 commit 2026-08-27 16:53:52 +00:00
fix: using utility macro for webout
Build / Build-and-ng-test (pull_request) Successful in 5m52s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m26s
Build / Build-and-test-development (pull_request) Failing after 33m42s
3595bb9499
hermes added 1 commit 2026-08-27 21:41:56 +00:00
fix: history mock
Build / Build-and-ng-test (pull_request) Successful in 5m16s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m32s
Build / Build-and-test-development (pull_request) Failing after 33m38s
0082828543
hermes added 1 commit 2026-08-27 23:35:43 +00:00
fix: dynamic js mocks
Build / Build-and-ng-test (pull_request) Successful in 5m16s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m35s
Build / Build-and-test-development (pull_request) Failing after 33m28s
3b9344cb60
Yury added 1 commit 2026-08-28 09:42:15 +00:00
fix(editor): stop turning missing columns into undefined, and fix column lookup for sparse rows
Build / Build-and-ng-test (pull_request) Successful in 5m36s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m58s
Build / Build-and-test-development (pull_request) Failing after 33m41s
a104f78645
Writing back an unescaped cell's value unconditionally materialized a column the backend never populated as an explicit `undefined`, which the SASjs adapter rejects at submit time. dynamicCellValidation's column-name lookup (Object.keys(row)[column]) only worked by coincidence when every row had a full key set - fixed to use hot.colToProp instead.
hermes added 1 commit 2026-08-28 13:03:05 +00:00
fix: unnecessary getsubmits call removed
Build / Build-and-ng-test (pull_request) Successful in 5m19s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m40s
Build / Build-and-test-development (pull_request) Failing after 33m35s
cc2ff873fa
hermes added 1 commit 2026-08-28 15:25:44 +00:00
fix: more mock improvements
Build / Build-and-ng-test (pull_request) Successful in 5m19s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m34s
Build / Build-and-test-development (pull_request) Failing after 33m31s
a80927cbb6
hermes added 2 commits 2026-08-28 20:29:27 +00:00
- Accept a single pasted/uploaded combined licence key (base64+gzip of
  licence+activation key), auto-detected in either paste mode, alongside
  the legacy two-field format
- Warn and block applying a key generated for the wrong protocol before
  it ever reaches the backend
- Decode both the legacy positional features string and a new named
  features object, so already-issued keys keep working unchanged
- Show a live "Key Details" preview (validity, users, site IDs, enabled
  features) as a key is typed, pasted, or uploaded
- Fix cypress test setup broken by the paste-format default change, and
  an unreliable FileReader-based base64 conversion in the test helpers
fix: failing test
Build / Build-and-ng-test (pull_request) Successful in 5m24s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m25s
Build / Build-and-test-development (pull_request) Failing after 33m33s
f213d24f09
hermes added 1 commit 2026-08-28 22:40:53 +00:00
fix: dynamic getdynamiccolvals.js
Build / Build-and-ng-test (pull_request) Successful in 5m22s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m27s
Build / Build-and-test-development (pull_request) Failing after 33m37s
d59ef44226
hermes added 1 commit 2026-08-28 23:17:23 +00:00
fix(tests): new libref
Build / Build-and-ng-test (pull_request) Successful in 5m27s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m39s
Build / Build-and-test-development (pull_request) Failing after 33m47s
c0bc87d331
hermes added 1 commit 2026-08-29 12:14:30 +00:00
fix: tests and realistic getcolvals.js
Build / Build-and-ng-test (pull_request) Successful in 5m49s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m56s
Build / Build-and-test-development (pull_request) Failing after 33m48s
5d03164b6a
hermes added 1 commit 2026-08-29 14:22:23 +00:00
fix(cypress): make licensing combined-key tests order-independent
Build / Build-and-ng-test (pull_request) Successful in 5m16s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m48s
Build / Build-and-test-development (pull_request) Failing after 33m43s
4db8d62dca
- Tests 7-10 only acted when already on the licensing page, silently
  no-oping otherwise; now they navigate to licensing/update explicitly
  when needed, chained via .then() to avoid Cypress conflating a raw
  async function's promise with the preceding cy.visit()/cy.wait()
- Replace Response(readable).arrayBuffer() with a direct
  ReadableStream reader loop in generateCombinedKey - the Response-based
  read never settled under Cypress, likely due to its fetch/Response
  patching for network interception
hermes added 1 commit 2026-08-29 19:14:37 +00:00
fix(licensing): bridge async proceed() through cy.then and replace Response.arrayBuffer with manual stream reader
Build / Build-and-ng-test (pull_request) Successful in 5m9s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m31s
Build / Build-and-test-development (pull_request) Failing after 33m53s
8e51fde524
- licensing.cy.ts: call proceed() unconditionally via cy.then() instead of conditionally chaining .then() after cy.wait(), so the command queue stays open across the async gap and enqueued commands always run
- combinedLicenceKey.ts: replace new Response(stream).arrayBuffer() with an explicit streamToArrayBuffer helper for broader browser support
- remove debug-license.cy.ts, an untracked throwaway repro for the promise-handling question
hermes added 1 commit 2026-08-29 22:53:28 +00:00
fix(cypress): correct mock data, test expectations, and abort modal
Build / Build-and-ng-test (pull_request) Successful in 5m20s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m39s
Build / Build-and-test-development (pull_request) Failing after 34m1s
13c10be30f
- editor.cy.ts: assert DC.USER_NAME is non-empty instead of hardcoded
  'sasdemo' (CI runs as a different OS user)
- editor.cy.ts: use =SOME_BESTNUM * 0 + 1936 for a deterministic formula
  result regardless of the column's actual value
- excel.cy.ts: expect computed value '2' instead of formula text '=1+1'
  (no XL_RULE=FORMULA configured on that column)
- excel-multi-load.cy.ts: use DC996664 libref to match the actual fixture
  sheet names
- makedata.js: add labels to DC_JSLIB.MPE_X_TEST schema (SOME_CHAR,
  SOME_DATE, SOME_DATETIME, SOME_TIME) for the viewer-labels tests
- makedata.js: register DC996664 libref with MPE_X_TEST/MPE_TABLES/
  MPE_VALIDATIONS/MPE_ALERTS and copy table files for multi-load fixtures
- makedata.js: change SOME_SHORTNUM HARDREGEX from [1-5] to [0-2]
- loadfile.js: exclude VAR_TXFROM/VAR_TXTO/VAR_PROCESSED columns from the
  missing-cols check for TXTEMPORAL tables (computed at load time)
- InfoModal.ts: add _PROGRAM to AbortDetails
- info-modal.component.html: display _PROGRAM in the abort modal
- 4 call sites: pass abortRes._PROGRAM when building AbortDetails
hermes added 1 commit 2026-08-30 00:18:21 +00:00
fix(mocks): remove MPE_VALIDATIONS and MPE_ALERTS from DC996664 libref
Build / Build-and-ng-test (pull_request) Successful in 5m20s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m59s
Build / Build-and-test-development (pull_request) Failing after 8h28m57s
4f7b845390
The multi-load fixture sheets for DC996664.MPE_VALIDATIONS had data
misaligned with the schema, corrupting the shared submit state. The
tests only need MPE_X_TEST and MPE_TABLES, so only register those two.
hermes added 3 commits 2026-08-30 09:30:46 +00:00
rejection.js defined its own local saveTableData(tableName, tableData)
with 2 args, but dcMockUtils.js (loaded via eval) also defines
saveTableData(dataDir, tableName, tableData) with 3 args. The
dcMockUtils version was shadowing the local one, causing
saveTableData('MPE_SUBMIT', submitData) to pass the table name as
dataDir and the data object as tableName, crashing with
'TypeError: tableName.toLowerCase is not a function'.

Removed the local saveTableData and updated calls to use the
dcMockUtils 3-arg signature: saveTableData(dataDir, tableName, data).
Same shadowing issue as rejection.js: postdata.js defined its own
saveTableData(tableName, tableData, tableLibref) which was shadowed
by dcMockUtils.saveTableData(dataDir, tableName, tableData) from the
eval. Renamed to saveTableToLib to eliminate the collision.
fix(mocks): remove SOME_SHORTNUM HARDREGEX from MPE_VALIDATIONS
Build / Build-and-ng-test (pull_request) Successful in 5m51s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m6s
Build / Build-and-test-development (pull_request) Failing after 31m25s
34bd6607c5
The Excel fixture files (7th_tab, extra_column, duplicate_column,
duplicate_row, regular_xls, regular_with_delete, password, leading
whitespace) contain SOME_SHORTNUM values of 0, 1, and 2. The
HARDREGEX /^(?![0-2](\.\d+)?$).*/ blocks those values, aborting
the upload before it reaches the submit/approve flow. Removing the
rule allows all 23 excel.cy.ts tests and both liveness.cy.ts tests
to pass.
hermes added 1 commit 2026-08-30 17:53:09 +00:00
fix(mocks): add LIBRARYNAME to startupservice, fix viewbox column order
Build / Build-and-ng-test (pull_request) Successful in 5m19s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m27s
Build / Build-and-test-development (pull_request) Failing after 27m3s
c0af86ef29
startupservice.js only returned LIBREF in saslibs, but the dc-tree
component renders LIBRARYNAME — without it the nav tree node text was
empty, so libraryToOpenIncludes could not match. Added LIBRARYNAME,
LIBRARYID, and ENGINE to match the viewlibs service format.

Changed libraryToOpenIncludes_SASJS from 'dc' to 'dc_jslib' to avoid
matching multiple libraries (DC_JSLIB and DC996664 both contain 'dc').

viewdata.js: removed alphabetical .sort() on cols (SAS preserves
physical column order via mp_getcols); added empty row with correct
SAS missing values ('.' for numeric, '' for character) when a table
has no data, so the viewbox grid can derive column headers.
hermes added 1 commit 2026-08-30 18:18:49 +00:00
fix(mocks): look up PK_FIELDS from MPE_TABLES in viewdata, fallback for MPE_AUDIT
Build / Build-and-ng-test (pull_request) Successful in 5m52s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m54s
Build / Build-and-test-development (pull_request) Failing after 25m39s
94d2a7970e
viewdata.js hardcoded PK_FIELDS as empty, so the viewbox grid treated
all columns as non-PK. removeAllColumns() could delete every column
including the ones the tests expect to be protected.

Now reads MPE_TABLES buskey (mirrors mp_getpk) and falls back to
LOAD_REF LIBREF DSN KEY_HASH TGTVAR_NM for MPE_AUDIT (which has a
known index-based PK in real SAS but isn't registered in MPE_TABLES).

All 12 viewbox.cy.ts tests now pass.
hermes added 1 commit 2026-08-30 18:25:56 +00:00
fix(mocks): add fixture staged data and MPE_SUBMIT row for stage.cy.ts
Build / Build-and-ng-test (pull_request) Successful in 5m44s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m25s
Build / Build-and-test-development (pull_request) Failing after 25m9s
6e2548d78c
stage.cy.ts navigates directly to /stage/DC20221007T122326121_612316_7259
and expects a hot table with MPE_X_TEST data. The mock had no fixture
staged.json or MPE_SUBMIT row for this table ID, so getstagetable
returned 0 rows and getchangeinfo returned empty jsparams.

Added a fixture staged.json with MPE_X_TEST rows (SOME_DATE=42) and
a matching MPE_SUBMIT row (SUBMITTED status) in makedata.js.
hermes added 2 commits 2026-08-30 19:20:31 +00:00
getchangeinfo.js: use SAS datetime19. format (DDMMMYYYY:HH:MM:SS)
for SUBMITTED_ON_DTTM and REVIEWED_ON_DTTM, matching the real SAS
output. Use SUBMIT_STATUS_CD field name (not REVIEW_STATUS_ID)
to match the MPE_SUBMIT column name and getchangeinfo.sas output.

stage.cy.ts: add login step in beforeEach (the beforeAll logs out
after uploading the license, so each test needs to re-login).
Use loginAndUpdateValidKey(true) to force license upload.
fix(mocks): limit stage fixture to 1 row, fix column order
Build / Build-and-ng-test (pull_request) Successful in 5m12s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m49s
Build / Build-and-test-development (pull_request) Successful in 24m6s
f25ecd8828
The stage.cy.ts fixture had 7 rows of MPE_X_TEST data with wide string
values, causing Handsontable to auto-size columns wider so only 4 of
10 fit in the 1280px viewport. The test checks .ht_clone_top headers
which only render visible columns.

Limited to 1 row (matching the original sas9 mock) and moved
_____DELETE__THIS__RECORD_____ to the end of the column order.
hermes added 1 commit 2026-08-30 21:29:52 +00:00
fix(stage): submit data via editor flow, use dynamic date assertion
Build / Build-and-ng-test (pull_request) Successful in 5m14s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m30s
Build / Build-and-test-development (pull_request) Successful in 24m11s
490d0137b9
Rewrite stage.cy.ts to follow the same pattern as excel.cy.ts:
open MPE_X_TEST, attach regular_excel.xlsx, submit to create staged
data, then test the formatted/unformatted toggle on the stage page.

The date assertion is now dynamic: reads the raw SOME_DATE value
from the unformatted view and computes the expected SAS date9.
formatted value, rather than hardcoding 12FEB1960.

Remove the fixture stageSubmission code from makedata.js — staged
data is created at runtime by stagedata.js, not by makedata.
allan merged commit 25434b35b9 into version7-13 2026-08-30 22:00:07 +00:00
allan deleted branch process-formula 2026-08-30 22:00:07 +00:00
Sign in to join this conversation.
No Reviewers
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/dc#310