@jsb188/mday 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +142 -0
- package/src/constants/agentMemory.ts +166 -0
- package/src/constants/agentNote.ts +212 -0
- package/src/constants/aiChat.ts +10 -0
- package/src/constants/billing.ts +126 -0
- package/src/constants/campaign.ts +236 -0
- package/src/constants/contact.ts +72 -0
- package/src/constants/csvExport.ts +133 -0
- package/src/constants/dataTable.ts +22 -0
- package/src/constants/dataTableFieldTypes.generated.ts +59 -0
- package/src/constants/docAccess.ts +33 -0
- package/src/constants/dt.ts +234 -0
- package/src/constants/email.ts +146 -0
- package/src/constants/fieldDoc.ts +104 -0
- package/src/constants/graphqlReactivity.ts +196 -0
- package/src/constants/inboundContact.ts +8 -0
- package/src/constants/integration.ts +13 -0
- package/src/constants/log.ts +21 -0
- package/src/constants/logDisplay/README.md +88 -0
- package/src/constants/logDisplay/defaults.ts +39 -0
- package/src/constants/logDisplay/index.ts +27 -0
- package/src/constants/logDisplay/operations/arable.ts +16 -0
- package/src/constants/logDisplay/operations/farmersMarket.ts +10 -0
- package/src/constants/logDisplay/operations/foodManufacturing.ts +13 -0
- package/src/constants/logDisplay/shared/accounting.ts +13 -0
- package/src/constants/logDisplay/shared/interactions.ts +13 -0
- package/src/constants/logDisplay/shared/rackTemperatures.ts +42 -0
- package/src/constants/logTaxonomy.generated.ts +2199 -0
- package/src/constants/noteDoc.ts +77 -0
- package/src/constants/organization.ts +60 -0
- package/src/constants/pageRoute.ts +23 -0
- package/src/constants/qrCode.ts +30 -0
- package/src/constants/sheet.ts +132 -0
- package/src/constants/sms.ts +18 -0
- package/src/constants/square.ts +16 -0
- package/src/constants/storage.ts +85 -0
- package/src/constants/usage.ts +82 -0
- package/src/constants/workflowSteps.ts +60 -0
- package/src/schemas/editLogEntry.ts +879 -0
- package/src/schemas/inboundContact.ts +77 -0
- package/src/schemas/logsQuery.ts +93 -0
- package/src/types/account.d.ts +81 -0
- package/src/types/agentMemory.d.ts +100 -0
- package/src/types/agentNote.d.ts +441 -0
- package/src/types/billing.d.ts +537 -0
- package/src/types/campaign.d.ts +1533 -0
- package/src/types/contact.d.ts +15 -0
- package/src/types/csvExport.d.ts +213 -0
- package/src/types/dataAnalysis.d.ts +44 -0
- package/src/types/dataTable.d.ts +159 -0
- package/src/types/definitionElement.d.ts +35 -0
- package/src/types/docAccess.d.ts +96 -0
- package/src/types/dt.d.ts +257 -0
- package/src/types/email.d.ts +231 -0
- package/src/types/emailReplyReport.d.ts +76 -0
- package/src/types/fieldDoc.d.ts +702 -0
- package/src/types/fieldDocContract.d.ts +90 -0
- package/src/types/inboundContact.d.ts +65 -0
- package/src/types/integration.d.ts +42 -0
- package/src/types/log.d.ts +338 -0
- package/src/types/logDisplay.types.ts +85 -0
- package/src/types/organization.d.ts +350 -0
- package/src/types/pageRoute.d.ts +48 -0
- package/src/types/qrCode.d.ts +96 -0
- package/src/types/richText.d.ts +81 -0
- package/src/types/sheet.d.ts +847 -0
- package/src/types/sms.d.ts +38 -0
- package/src/types/storage.d.ts +481 -0
- package/src/types/usage.d.ts +106 -0
- package/src/types/workflow.d.ts +435 -0
- package/src/utils/agentMemory.ts +15 -0
- package/src/utils/agentNote.ts +850 -0
- package/src/utils/aiChat.ts +43 -0
- package/src/utils/aiChatWork.ts +64 -0
- package/src/utils/billing.ts +37 -0
- package/src/utils/campaign.ts +1173 -0
- package/src/utils/campaignAI.ts +72 -0
- package/src/utils/campaignAccess.ts +239 -0
- package/src/utils/campaignEmail.ts +601 -0
- package/src/utils/campaignEmailCompiler.ts +372 -0
- package/src/utils/campaignEmailImages.ts +60 -0
- package/src/utils/campaignEmailStyles.ts +544 -0
- package/src/utils/campaignLifecycle.ts +104 -0
- package/src/utils/campaignPreview.ts +285 -0
- package/src/utils/contact.ts +50 -0
- package/src/utils/csvExport.ts +19 -0
- package/src/utils/dataTable.ts +311 -0
- package/src/utils/dataTableFieldTypeRegistry.ts +106 -0
- package/src/utils/dataTableRelativeDate.ts +447 -0
- package/src/utils/definitionElement.ts +84 -0
- package/src/utils/docAccess.ts +383 -0
- package/src/utils/documentName.ts +53 -0
- package/src/utils/email.ts +379 -0
- package/src/utils/emailReplyReport.test.ts +187 -0
- package/src/utils/emailReplyReport.ts +143 -0
- package/src/utils/fieldDoc.ts +157 -0
- package/src/utils/fieldDocAnswers.ts +128 -0
- package/src/utils/fieldDocDefaults.ts +36 -0
- package/src/utils/fieldDocProgram.ts +36 -0
- package/src/utils/fieldDocSummary.ts +30 -0
- package/src/utils/log.ts +357 -0
- package/src/utils/logDisplay.helpers.ts +177 -0
- package/src/utils/logDisplay.ts +87 -0
- package/src/utils/logRegistryValue.ts +90 -0
- package/src/utils/logStoreRead.ts +262 -0
- package/src/utils/logTaxonomy.helpers.ts +17 -0
- package/src/utils/logTaxonomy.ts +76 -0
- package/src/utils/logTaxonomyDisplay.ts +395 -0
- package/src/utils/noteDoc.ts +609 -0
- package/src/utils/organization.ts +669 -0
- package/src/utils/pageRoute.ts +71 -0
- package/src/utils/qrCode.helpers.ts +189 -0
- package/src/utils/qrCode.test.ts +519 -0
- package/src/utils/qrCode.ts +273 -0
- package/src/utils/richTextHTML.ts +385 -0
- package/src/utils/sheet.ts +262 -0
- package/src/utils/sheetAxisMove.ts +616 -0
- package/src/utils/sheetBootstrap.ts +1402 -0
- package/src/utils/sheetCellLiteral.ts +101 -0
- package/src/utils/sheetCommand.ts +358 -0
- package/src/utils/sheetDesign.ts +705 -0
- package/src/utils/sheetExport.ts +186 -0
- package/src/utils/sheetFeatureReference.ts +183 -0
- package/src/utils/sheetFormulaArgs.ts +168 -0
- package/src/utils/sheetFormulaCompile.ts +475 -0
- package/src/utils/sheetFormulaConditionalAggregate.ts +254 -0
- package/src/utils/sheetFormulaCriteria.ts +656 -0
- package/src/utils/sheetFormulaDate.ts +444 -0
- package/src/utils/sheetFormulaEvaluation.ts +899 -0
- package/src/utils/sheetFormulaEvaluator.ts +997 -0
- package/src/utils/sheetFormulaFunctionHandlers.ts +403 -0
- package/src/utils/sheetFormulaLogical.ts +116 -0
- package/src/utils/sheetFormulaLookup.ts +488 -0
- package/src/utils/sheetFormulaMath.ts +48 -0
- package/src/utils/sheetFormulaParser.ts +729 -0
- package/src/utils/sheetFormulaRange.ts +330 -0
- package/src/utils/sheetFormulaReference.ts +703 -0
- package/src/utils/sheetFormulaReferenceAggregates.ts +313 -0
- package/src/utils/sheetFormulaReferenceDates.ts +237 -0
- package/src/utils/sheetFormulaReferenceLogical.ts +330 -0
- package/src/utils/sheetFormulaReferenceLookup.ts +341 -0
- package/src/utils/sheetFormulaReferenceMath.ts +95 -0
- package/src/utils/sheetFormulaReferenceRewrite.ts +220 -0
- package/src/utils/sheetFormulaReferenceText.ts +462 -0
- package/src/utils/sheetFormulaSyntax.ts +1027 -0
- package/src/utils/sheetFormulaText.ts +430 -0
- package/src/utils/sheetJournal.ts +200 -0
- package/src/utils/sheetNumberFormat.ts +1012 -0
- package/src/utils/sheetPreview.ts +68 -0
- package/src/utils/sheetSequence.ts +118 -0
- package/src/utils/sheetSnapshot.ts +739 -0
- package/src/utils/sheetStructureEdit.ts +914 -0
- package/src/utils/sheetStructureReferences.ts +389 -0
- package/src/utils/square.ts +32 -0
- package/src/utils/storage.ts +198 -0
- package/src/utils/table-route.ts +262 -0
- package/src/utils/time.ts +12 -0
- package/src/utils/workflow.ts +506 -0
- package/src/utils/workflowLogFingerprint.ts +302 -0
- package/src/utils/workflowLogRevisionSnapshot.ts +424 -0
- package/src/utils/workflowProgress.ts +280 -0
- package/src/utils/workflowTriggers.ts +61 -0
- package/tests/agentNote.test.ts +395 -0
- package/tests/campaignAI.test.ts +119 -0
- package/tests/campaignAccess.test.ts +239 -0
- package/tests/campaignEmail.test.ts +441 -0
- package/tests/campaignLifecycle.test.ts +134 -0
- package/tests/campaignPublication.test.ts +309 -0
- package/tests/dataTableFieldTypeRegistry.test.ts +111 -0
- package/tests/dataTableRelativeDate.test.ts +412 -0
- package/tests/docAccess.test.ts +525 -0
- package/tests/editLogEntry.test.ts +112 -0
- package/tests/email.test.ts +39 -0
- package/tests/fieldDocProgram.test.ts +114 -0
- package/tests/logDisplay.fixtures.ts +67 -0
- package/tests/logDisplay.test.ts +227 -0
- package/tests/noteDoc.test.ts +514 -0
- package/tests/richTextHTML.test.ts +185 -0
- package/tests/sheetAxisMove.test.ts +352 -0
- package/tests/sheetBootstrap.test.ts +1967 -0
- package/tests/sheetFeatureReference.test.ts +22 -0
- package/tests/sheetFormulaCriteria.test.ts +269 -0
- package/tests/sheetFormulaEvaluator.test.ts +468 -0
- package/tests/sheetFormulaFunctions.test.ts +538 -0
- package/tests/sheetFormulaLanguage.test.ts +361 -0
- package/tests/sheetFormulaParity.fixtures.ts +872 -0
- package/tests/sheetFormulaParity.test.ts +188 -0
- package/tests/sheetFormulaRange.test.ts +167 -0
- package/tests/sheetFormulaReference.test.ts +78 -0
- package/tests/sheetFormulaReferenceRewrite.test.ts +117 -0
- package/tests/sheetFormulaTextDate.test.ts +512 -0
- package/tests/sheetSequence.test.ts +22 -0
- package/tests/sheetSnapshot.test.ts +134 -0
- package/tests/sheetStructureEdit.test.ts +537 -0
- package/tests/sheetStructureReferences.test.ts +589 -0
- package/tests/workflowLifecycleStatus.test.ts +60 -0
- package/tests/workflowLogFingerprint.test.ts +203 -0
- package/tests/workflowLogRevisionSnapshot.test.ts +96 -0
- package/tests/workflowProgress.test.ts +180 -0
- package/tests/workflowTriggers.test.ts +29 -0
- package/tsconfig.json +12 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { SHEET_MAX_ROW_COUNT } from '../src/constants/sheet.ts';
|
|
3
|
+
import {
|
|
4
|
+
parseSheetFormulaExpression,
|
|
5
|
+
parseSheetFormulaRangeReference,
|
|
6
|
+
tokenizeSheetFormulaReferences,
|
|
7
|
+
} from '../src/utils/sheetFormulaParser.ts';
|
|
8
|
+
import { parseSheetFormulaCellReference } from '../src/utils/sheetFormulaSyntax.ts';
|
|
9
|
+
import {
|
|
10
|
+
getInverseSheetAxisMoveInput,
|
|
11
|
+
getMovedSheetAxisDesign,
|
|
12
|
+
getSheetAxisMoveDestinationIndex,
|
|
13
|
+
normalizeSheetAxisMoveInput,
|
|
14
|
+
rewriteSheetFormulaForAxisMove,
|
|
15
|
+
type SheetAxisMoveIndexes,
|
|
16
|
+
} from '../src/utils/sheetAxisMove.ts';
|
|
17
|
+
|
|
18
|
+
const FILE_CONSTANTS = {
|
|
19
|
+
currentSheetTabId: 'tab-current',
|
|
20
|
+
otherSheetTabId: 'tab-other',
|
|
21
|
+
sheetTabIdByNameKey: new Map([
|
|
22
|
+
['current', 'tab-current'],
|
|
23
|
+
['other', 'tab-other'],
|
|
24
|
+
['other tab', 'tab-other'],
|
|
25
|
+
['a1', 'tab-other'],
|
|
26
|
+
]),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* Rewrite one formula through a column permutation in the shared server/client
|
|
31
|
+
* implementation while resolving qualifiers against the test workbook.
|
|
32
|
+
*/
|
|
33
|
+
function rewriteColumnFormula(value: string, indexes: SheetAxisMoveIndexes, movedSheetTabId = FILE_CONSTANTS.currentSheetTabId) {
|
|
34
|
+
return rewriteSheetFormulaForAxisMove(value, {
|
|
35
|
+
axis: 'COLUMN',
|
|
36
|
+
formulaSheetTabId: FILE_CONSTANTS.currentSheetTabId,
|
|
37
|
+
indexes,
|
|
38
|
+
movedSheetTabId,
|
|
39
|
+
sheetTabIdByNameKey: FILE_CONSTANTS.sheetTabIdByNameKey,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe('Sheet axis move inversion', () => {
|
|
44
|
+
it.each([
|
|
45
|
+
{
|
|
46
|
+
axis: 'COLUMN' as const,
|
|
47
|
+
sourceEndIndex: 3,
|
|
48
|
+
sourceStartIndex: 2,
|
|
49
|
+
targetStartIndex: 6,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
axis: 'ROW' as const,
|
|
53
|
+
sourceEndIndex: 7,
|
|
54
|
+
sourceStartIndex: 5,
|
|
55
|
+
targetStartIndex: 2,
|
|
56
|
+
},
|
|
57
|
+
])('restores every affected index for a $axis move', (move) => {
|
|
58
|
+
const inverse = getInverseSheetAxisMoveInput(move);
|
|
59
|
+
const forwardIndexes = normalizeSheetAxisMoveInput(move, 10);
|
|
60
|
+
const inverseIndexes = normalizeSheetAxisMoveInput(inverse, 10);
|
|
61
|
+
|
|
62
|
+
expect(inverse).toEqual({
|
|
63
|
+
axis: move.axis,
|
|
64
|
+
sourceEndIndex: move.targetStartIndex + (move.sourceEndIndex - move.sourceStartIndex),
|
|
65
|
+
sourceStartIndex: move.targetStartIndex,
|
|
66
|
+
targetStartIndex: move.sourceStartIndex,
|
|
67
|
+
});
|
|
68
|
+
for (let index = 1; index <= 10; index += 1) {
|
|
69
|
+
const movedIndex = getSheetAxisMoveDestinationIndex(index, forwardIndexes);
|
|
70
|
+
expect(getSheetAxisMoveDestinationIndex(movedIndex, inverseIndexes)).toBe(index);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('Sheet sparse axis design movement', () => {
|
|
76
|
+
it('moves sparse design across a million-column span without materializing holes', () => {
|
|
77
|
+
const moved = getMovedSheetAxisDesign({
|
|
78
|
+
axisDesign: {
|
|
79
|
+
'1': { width: 80 },
|
|
80
|
+
'2': { width: 120 },
|
|
81
|
+
'1000000': { hidden: true },
|
|
82
|
+
},
|
|
83
|
+
sourceEndIndex: 2,
|
|
84
|
+
sourceStartIndex: 2,
|
|
85
|
+
targetEndIndex: 1_000_000,
|
|
86
|
+
targetStartIndex: 1_000_000,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
expect(moved).toEqual({
|
|
90
|
+
'1': { width: 80 },
|
|
91
|
+
'999999': { hidden: true },
|
|
92
|
+
'1000000': { width: 120 },
|
|
93
|
+
});
|
|
94
|
+
expect(Object.keys(moved)).toHaveLength(3);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('Sheet axis move formulas', () => {
|
|
99
|
+
it('rejects fractional client-authored axis bounds instead of rounding them', () => {
|
|
100
|
+
expect(() =>
|
|
101
|
+
normalizeSheetAxisMoveInput(
|
|
102
|
+
{
|
|
103
|
+
axis: 'COLUMN',
|
|
104
|
+
sourceEndIndex: 2,
|
|
105
|
+
sourceStartIndex: 1.5,
|
|
106
|
+
targetStartIndex: 3,
|
|
107
|
+
},
|
|
108
|
+
10,
|
|
109
|
+
),
|
|
110
|
+
).toThrowError('INVALID_SHEET_AXIS_MOVE');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('parses relative and mixed absolute cell references', () => {
|
|
114
|
+
expect(parseSheetFormulaCellReference('C3')).toEqual({
|
|
115
|
+
columnIndex: 3,
|
|
116
|
+
columnLabel: 'C',
|
|
117
|
+
rowIndex: 3,
|
|
118
|
+
});
|
|
119
|
+
expect(parseSheetFormulaCellReference('$C3')).toEqual({
|
|
120
|
+
columnAbsolute: true,
|
|
121
|
+
columnIndex: 3,
|
|
122
|
+
columnLabel: 'C',
|
|
123
|
+
rowIndex: 3,
|
|
124
|
+
});
|
|
125
|
+
expect(parseSheetFormulaCellReference('C$3')).toEqual({
|
|
126
|
+
columnIndex: 3,
|
|
127
|
+
columnLabel: 'C',
|
|
128
|
+
rowAbsolute: true,
|
|
129
|
+
rowIndex: 3,
|
|
130
|
+
});
|
|
131
|
+
expect(parseSheetFormulaCellReference("'Other Tab'!$C$3")).toEqual({
|
|
132
|
+
columnAbsolute: true,
|
|
133
|
+
columnIndex: 3,
|
|
134
|
+
columnLabel: 'C',
|
|
135
|
+
rowAbsolute: true,
|
|
136
|
+
rowIndex: 3,
|
|
137
|
+
sheetName: 'Other Tab',
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('parses quoted and unquoted sheet qualifiers as complete references', () => {
|
|
142
|
+
const quotedNode = parseSheetFormulaExpression("'Other Tab'!$A$1");
|
|
143
|
+
const unquotedNode = parseSheetFormulaExpression('Other!B2');
|
|
144
|
+
|
|
145
|
+
expect(quotedNode).toMatchObject({
|
|
146
|
+
kind: 'CELL_REFERENCE',
|
|
147
|
+
reference: {
|
|
148
|
+
columnAbsolute: true,
|
|
149
|
+
columnIndex: 1,
|
|
150
|
+
rowAbsolute: true,
|
|
151
|
+
rowIndex: 1,
|
|
152
|
+
sheetName: 'Other Tab',
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
expect(unquotedNode).toMatchObject({
|
|
156
|
+
kind: 'CELL_REFERENCE',
|
|
157
|
+
reference: {
|
|
158
|
+
columnIndex: 2,
|
|
159
|
+
rowIndex: 2,
|
|
160
|
+
sheetName: 'Other',
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
expect(tokenizeSheetFormulaReferences("='Other Tab'!$A$1 + Other!B2")).toEqual([
|
|
164
|
+
expect.objectContaining({
|
|
165
|
+
columnAbsolute: true,
|
|
166
|
+
kind: 'SHEET_CELL',
|
|
167
|
+
rowAbsolute: true,
|
|
168
|
+
sheetName: 'Other Tab',
|
|
169
|
+
text: "'Other Tab'!$A$1",
|
|
170
|
+
}),
|
|
171
|
+
expect.objectContaining({
|
|
172
|
+
kind: 'SHEET_CELL',
|
|
173
|
+
sheetName: 'Other',
|
|
174
|
+
text: 'Other!B2',
|
|
175
|
+
}),
|
|
176
|
+
]);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('parses an open-row range through the shared maximum row constant', () => {
|
|
180
|
+
expect(parseSheetFormulaRangeReference("'Other Tab'!C3:C")).toEqual({
|
|
181
|
+
endColumnIndex: 3,
|
|
182
|
+
endColumnLabel: 'C',
|
|
183
|
+
endRowIndex: SHEET_MAX_ROW_COUNT,
|
|
184
|
+
endRowOpen: true,
|
|
185
|
+
sheetName: 'Other Tab',
|
|
186
|
+
startColumnIndex: 3,
|
|
187
|
+
startColumnLabel: 'C',
|
|
188
|
+
startRowIndex: 3,
|
|
189
|
+
});
|
|
190
|
+
expect(tokenizeSheetFormulaReferences("=SUM('Other Tab'!C3:C)")).toEqual([
|
|
191
|
+
expect.objectContaining({
|
|
192
|
+
endRowIndex: SHEET_MAX_ROW_COUNT,
|
|
193
|
+
endRowOpen: true,
|
|
194
|
+
kind: 'SHEET_RANGE',
|
|
195
|
+
sheetName: 'Other Tab',
|
|
196
|
+
text: "'Other Tab'!C3:C",
|
|
197
|
+
}),
|
|
198
|
+
]);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('preserves absolute markers when structural column moves rewrite references', () => {
|
|
202
|
+
expect(
|
|
203
|
+
rewriteColumnFormula(
|
|
204
|
+
"='Other Tab'!$A1 + 'Other Tab'!A$1 + 'Other Tab'!$A$1",
|
|
205
|
+
{
|
|
206
|
+
sourceEndIndex: 1,
|
|
207
|
+
sourceStartIndex: 1,
|
|
208
|
+
targetEndIndex: 3,
|
|
209
|
+
targetStartIndex: 3,
|
|
210
|
+
},
|
|
211
|
+
FILE_CONSTANTS.otherSheetTabId,
|
|
212
|
+
),
|
|
213
|
+
).toEqual({
|
|
214
|
+
changed: true,
|
|
215
|
+
status: 'CHANGED',
|
|
216
|
+
text: "='Other Tab'!$C1 + 'Other Tab'!C$1 + 'Other Tab'!$C$1",
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('treats a cell-like tab name as a qualifier instead of a local cell', () => {
|
|
221
|
+
expect(parseSheetFormulaExpression('A1!B2')).toMatchObject({
|
|
222
|
+
kind: 'CELL_REFERENCE',
|
|
223
|
+
reference: {
|
|
224
|
+
columnIndex: 2,
|
|
225
|
+
rowIndex: 2,
|
|
226
|
+
sheetName: 'A1',
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
expect(
|
|
230
|
+
rewriteColumnFormula(
|
|
231
|
+
'=A1!B2',
|
|
232
|
+
{
|
|
233
|
+
sourceEndIndex: 2,
|
|
234
|
+
sourceStartIndex: 2,
|
|
235
|
+
targetEndIndex: 3,
|
|
236
|
+
targetStartIndex: 3,
|
|
237
|
+
},
|
|
238
|
+
FILE_CONSTANTS.otherSheetTabId,
|
|
239
|
+
),
|
|
240
|
+
).toEqual({
|
|
241
|
+
changed: true,
|
|
242
|
+
status: 'CHANGED',
|
|
243
|
+
text: '=A1!C2',
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('does not mistake the inequality operator for a sheet qualifier', () => {
|
|
248
|
+
expect(parseSheetFormulaExpression('A1 != 0')).toMatchObject({
|
|
249
|
+
kind: 'BINARY_EXPRESSION',
|
|
250
|
+
operator: '!=',
|
|
251
|
+
});
|
|
252
|
+
expect(
|
|
253
|
+
rewriteColumnFormula('=A1 != 0', {
|
|
254
|
+
sourceEndIndex: 1,
|
|
255
|
+
sourceStartIndex: 1,
|
|
256
|
+
targetEndIndex: 2,
|
|
257
|
+
targetStartIndex: 2,
|
|
258
|
+
}),
|
|
259
|
+
).toEqual({
|
|
260
|
+
changed: true,
|
|
261
|
+
status: 'CHANGED',
|
|
262
|
+
text: '=B1 != 0',
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('preserves leading and end qualifier spelling while moving range coordinates', () => {
|
|
267
|
+
const indexes = {
|
|
268
|
+
sourceEndIndex: 1,
|
|
269
|
+
sourceStartIndex: 1,
|
|
270
|
+
targetEndIndex: 3,
|
|
271
|
+
targetStartIndex: 3,
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
expect(rewriteColumnFormula('=Other!A1:A2', indexes, FILE_CONSTANTS.otherSheetTabId)).toMatchObject({
|
|
275
|
+
changed: true,
|
|
276
|
+
text: '=Other!C1:C2',
|
|
277
|
+
});
|
|
278
|
+
expect(rewriteColumnFormula('=A1:Other!A2', indexes, FILE_CONSTANTS.otherSheetTabId)).toMatchObject({
|
|
279
|
+
changed: true,
|
|
280
|
+
text: '=C1:Other!C2',
|
|
281
|
+
});
|
|
282
|
+
expect(rewriteColumnFormula("=A1:'Other Tab'!A2", indexes, FILE_CONSTANTS.otherSheetTabId)).toMatchObject({
|
|
283
|
+
changed: true,
|
|
284
|
+
text: "=C1:'Other Tab'!C2",
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it('preserves an open-row endpoint while moving its column', () => {
|
|
289
|
+
expect(
|
|
290
|
+
rewriteColumnFormula('=SUM(C3:C)', {
|
|
291
|
+
sourceEndIndex: 3,
|
|
292
|
+
sourceStartIndex: 3,
|
|
293
|
+
targetEndIndex: 4,
|
|
294
|
+
targetStartIndex: 4,
|
|
295
|
+
}),
|
|
296
|
+
).toEqual({
|
|
297
|
+
changed: true,
|
|
298
|
+
status: 'CHANGED',
|
|
299
|
+
text: '=SUM(D3:D)',
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it('keeps reversed range endpoint orientation after a contiguous move', () => {
|
|
304
|
+
expect(
|
|
305
|
+
rewriteColumnFormula(
|
|
306
|
+
'=Other!B2:A1',
|
|
307
|
+
{
|
|
308
|
+
sourceEndIndex: 2,
|
|
309
|
+
sourceStartIndex: 1,
|
|
310
|
+
targetEndIndex: 4,
|
|
311
|
+
targetStartIndex: 3,
|
|
312
|
+
},
|
|
313
|
+
FILE_CONSTANTS.otherSheetTabId,
|
|
314
|
+
),
|
|
315
|
+
).toEqual({
|
|
316
|
+
changed: true,
|
|
317
|
+
status: 'CHANGED',
|
|
318
|
+
text: '=Other!D2:C1',
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it('leaves ranges unchanged when their referenced rectangle is invariant', () => {
|
|
323
|
+
expect(
|
|
324
|
+
rewriteColumnFormula('=SUM(A1:B1)', {
|
|
325
|
+
sourceEndIndex: 1,
|
|
326
|
+
sourceStartIndex: 1,
|
|
327
|
+
targetEndIndex: 2,
|
|
328
|
+
targetStartIndex: 2,
|
|
329
|
+
}),
|
|
330
|
+
).toEqual({
|
|
331
|
+
changed: false,
|
|
332
|
+
status: 'UNCHANGED',
|
|
333
|
+
text: '=SUM(A1:B1)',
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('rejects a range whose cells become discontiguous', () => {
|
|
338
|
+
expect(
|
|
339
|
+
rewriteColumnFormula('=SUM(B1:C1)', {
|
|
340
|
+
sourceEndIndex: 2,
|
|
341
|
+
sourceStartIndex: 1,
|
|
342
|
+
targetEndIndex: 4,
|
|
343
|
+
targetStartIndex: 3,
|
|
344
|
+
}),
|
|
345
|
+
).toEqual({
|
|
346
|
+
changed: false,
|
|
347
|
+
reason: 'DISCONTIGUOUS_RANGE',
|
|
348
|
+
status: 'UNSAFE',
|
|
349
|
+
text: '=SUM(B1:C1)',
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
});
|