diff --git a/api/tests/integration/test_heavy_get_json.py b/api/tests/integration/test_heavy_get_json.py index 612acaf..aa63a28 100644 --- a/api/tests/integration/test_heavy_get_json.py +++ b/api/tests/integration/test_heavy_get_json.py @@ -61,6 +61,19 @@ def _strip_nulls(value): return value +def test_pg_jsonb_strip_nulls_matches_strip_nulls(client, db_session): + literal = '{"a":{"b":null},"c":[null,{"d":null,"e":1},[{"f":null}]],"g":null,"h":{}}' + + async def _go(): + res = await db_session.execute(text("SELECT jsonb_strip_nulls(CAST(:v AS jsonb))"), {"v": literal}) + return res.scalar_one() + pg = client.portal.call(_go) + if isinstance(pg, str): + pg = json.loads(pg) + assert pg == _strip_nulls(json.loads(literal)) + assert pg == {"a": {}, "c": [None, {"e": 1}, [{}]], "h": {}} + + def _has_null_field(value) -> bool: if isinstance(value, dict): return any(v is None or _has_null_field(v) for v in value.values()) diff --git a/web/src/components/RealtimeTable/utils/cellUtils.test.js b/web/src/components/RealtimeTable/utils/cellUtils.test.js index a7f849e..92bc357 100644 --- a/web/src/components/RealtimeTable/utils/cellUtils.test.js +++ b/web/src/components/RealtimeTable/utils/cellUtils.test.js @@ -229,3 +229,19 @@ test('AURORA-1848: отсутствующий скалярный ключ вер const out = updateCells(data, [['INPUT', 3, 1, { line_id: 9 }]]); assert.equal(out[0].data.line_id, 9); }); + +test('AURORA-1848: блок отсутствует на двух уровнях вглубь — создаётся цепочка, вход не меняется', () => { + const data = deepFreeze([row({ line_id: 7 })]); + const out = updateCells(data, [['INPUT', 3, 1, { plan: { support: { q1: 5 } } }]]); + assert.equal(out[0].data.plan.support.q1, 5); + assert.deepEqual(data[0].data, { line_id: 7 }); +}); + +test('AURORA-1848: два обновления одной строки в одном батче складываются', () => { + const data = deepFreeze([row({ line_id: 7 })]); + const out = updateCells(data, [ + ['INPUT', 3, 1, { q1: { m1: 5 } }], + ['INPUT', 3, 1, { q1: { m2: 3 } }], + ]); + assert.deepEqual(out[0].data.q1, { m1: 5, m2: 3 }); +}); diff --git a/web/src/components/RealtimeTable/utils/rowUtils.js b/web/src/components/RealtimeTable/utils/rowUtils.js index af5efcb..cc3ce5d 100644 --- a/web/src/components/RealtimeTable/utils/rowUtils.js +++ b/web/src/components/RealtimeTable/utils/rowUtils.js @@ -30,7 +30,7 @@ export function buildRowHierarchy(items, mapItem = (item) => item) { } export function getDataRowId(data) { - return data?.id || data?.line_id; + return data?.id || data?.line_id || null; } export function getRowId(row) { diff --git a/web/src/components/RealtimeTable/utils/rowUtils.test.js b/web/src/components/RealtimeTable/utils/rowUtils.test.js index 0c40434..7d45956 100644 --- a/web/src/components/RealtimeTable/utils/rowUtils.test.js +++ b/web/src/components/RealtimeTable/utils/rowUtils.test.js @@ -1,6 +1,6 @@ import assert from 'node:assert/strict'; import test from 'node:test'; -import { buildRowHierarchy } from './rowUtils.js'; +import { buildRowHierarchy, getDataRowId } from './rowUtils.js'; test('row hierarchy uses row types when depth skips a level and keeps INPUT rows as siblings', () => { const rows = [ @@ -19,3 +19,10 @@ test('row hierarchy uses row types when depth skips a level and keeps INPUT rows assert.deepEqual(tree[0].subRows[0].subRows.map(({ id }) => id), ['input-1', 'input-2']); assert.deepEqual(tree[0].subRows[0].subRows[0].subRows, []); }); + +test('AURORA-1848: getDataRowId без id и line_id возвращает null и сериализуется в row_id:null', () => { + assert.equal(getDataRowId({ header: {} }), null); + assert.equal(getDataRowId({ id: 5 }), 5); + assert.equal(getDataRowId({ line_id: 7 }), 7); + assert.ok(JSON.stringify({ row_id: getDataRowId({ header: {} }) }).includes('"row_id":null')); +});