- RealtimeContext: стор карты формул (formulaStore), загрузка при открытии листа и
переподключении (формы и отчёты проектов), обновление на каждом cell_updated,
защита от устаревших ответов при смене листа; useCellFormula; updateCell(..., { formula })
- Cell: маркер fx только при актуальной формуле, подсказка с единицей при displayFactor != 1
- EditCell: начальный текст «=выражение», выражение уходит в data.formula, без localStorage;
ввод «100+50» без «=» не отправляется (тост «Формула начинается с =»)
- удалены resolveEditorState и clearLegacyFormulaKeys; T6.1/T6.2 в cellFormulaUtils
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2.1 KiB
JavaScript
55 lines
2.1 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { isSameCellValue } from './formulaUtils.js';
|
|
|
|
// AURORA-1891: handleSave (EditCell.jsx) не должен слать cell_updated, если
|
|
// значение фактически не изменилось — иначе лишняя запись в БД/аудите при
|
|
// открытии и закрытии ячейки без правки.
|
|
|
|
test('a numeric string equals the same number', () => {
|
|
assert.equal(isSameCellValue('1500', 1500), true);
|
|
});
|
|
|
|
test('a thousands-separated, comma-decimal value equals the plain number', () => {
|
|
assert.equal(isSameCellValue('1 500,0', 1500), true);
|
|
});
|
|
|
|
test('empty string and null both mean "no value"', () => {
|
|
assert.equal(isSameCellValue('', null), true);
|
|
assert.equal(isSameCellValue(null, ''), true);
|
|
assert.equal(isSameCellValue(undefined, ''), true);
|
|
assert.equal(isSameCellValue(undefined, null), true);
|
|
});
|
|
|
|
test('a formula is never treated as unchanged, even against identical formula text', () => {
|
|
assert.equal(isSameCellValue('=1+2', '=1+2'), false);
|
|
assert.equal(isSameCellValue('=1+1', 2), false);
|
|
assert.equal(isSameCellValue(2, '=1+1'), false);
|
|
});
|
|
|
|
test('different values (numeric or text) are not the same', () => {
|
|
assert.equal(isSameCellValue('1500', 1501), false);
|
|
assert.equal(isSameCellValue('abc', 'abd'), false);
|
|
assert.equal(isSameCellValue('1500', ''), false);
|
|
});
|
|
|
|
test('non-numeric text compares as-is after trimming surrounding whitespace', () => {
|
|
assert.equal(isSameCellValue(' текст ', 'текст'), true);
|
|
});
|
|
|
|
test('isSameCellValue treats a numeric string and a number as equal', () => {
|
|
assert.equal(isSameCellValue('150', 150), true);
|
|
});
|
|
|
|
test('isSameCellValue treats an empty string and null as equal', () => {
|
|
assert.equal(isSameCellValue('', null), true);
|
|
});
|
|
|
|
test('isSameCellValue treats a numeric string with a trailing .0 as equal to the plain number', () => {
|
|
assert.equal(isSameCellValue('150.0', 150), true);
|
|
});
|
|
|
|
test('isSameCellValue treats different numbers as not equal', () => {
|
|
assert.equal(isSameCellValue('151', 150), false);
|
|
});
|