getdata padded every blank character cell to a space, including one the row holds as an explicit ''. That broke nine editor specs: the grid classifies a row by comparing what it holds against the payload it was given (classifyRow), so a payload whose empty strings had become spaces made every row read as modified on load - the row header showed +/- and DC.ROW_STATUS answered 'M' where 'U' is correct. The rule is now the one SAS expresses: a cell the row does not carry is missing and reaches the client as one space, and a value the row does carry is passed through. MPE_TABLES rows omit their blank columns, so the recorded golden still matches; the TESTDATA formula fixture stores '', and keeps it. getdata-blanks.test.js pins both sides.
45 lines
1.6 KiB
JavaScript
45 lines
1.6 KiB
JavaScript
/**
|
|
* How a blank character cell is expressed in getdata's sasdata.
|
|
*
|
|
* SAS pads a character variable, so a cell the row does not carry reaches the
|
|
* client as one space. A value the row *does* carry is passed through: the
|
|
* editor classifies a row by comparing what it holds against the payload it was
|
|
* given, so rewriting an explicit empty string to a space marks every row of a
|
|
* table like the TESTDATA formula fixture as modified on load.
|
|
*/
|
|
const test = require('node:test')
|
|
const assert = require('node:assert')
|
|
|
|
const { seededEstate, runService } = require('./harness')
|
|
|
|
function getdata(estate, libds) {
|
|
return JSON.parse(
|
|
runService(estate, 'editors/getdata', {
|
|
tableName: 'SASControlTable',
|
|
rows: [{ LIBDS: libds, FILTER_RK: -1 }]
|
|
})
|
|
)
|
|
}
|
|
|
|
test('a character cell the row does not carry is a space', () => {
|
|
const estate = seededEstate({ demo: false })
|
|
const body = getdata(estate, 'DC_JSLIB.MPE_TABLES')
|
|
|
|
assert.equal(body.sasjsAbort, undefined)
|
|
// MPE_TABLES rows omit every blank column (var_busfrom, the hooks, notes on
|
|
// most rows), so these arrive as SAS's missing
|
|
assert.equal(body.sasdata[0].VAR_BUSFROM, ' ')
|
|
assert.equal(body.sasdata[0].PRE_EDIT_HOOK, ' ')
|
|
})
|
|
|
|
test('an explicit empty string is left as the row holds it', () => {
|
|
const estate = seededEstate()
|
|
const body = getdata(estate, 'TESTDATA.MPE_X_FORMULA_TEST')
|
|
|
|
assert.equal(body.sasjsAbort, undefined)
|
|
// the fixture stores '', and the grid's formula and row-status machinery
|
|
// compares rows against this payload
|
|
assert.equal(body.sasdata[0].FORMULA_HARD_COL, '')
|
|
assert.equal(body.sasdata[0].ROW_STATUS_COL, '')
|
|
})
|