From 35b4e77bcd0141cd1f49130f2b9f9f9b083a8b02 Mon Sep 17 00:00:00 2001 From: czlonkowski <56956555+czlonkowski@users.noreply.github.com> Date: Sat, 2 Aug 2025 09:35:15 +0200 Subject: [PATCH] fix: resolve TypeScript errors in fixed-collection-validator tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added type imports and isNodeConfig type guard helper - Fixed all 'autofix is possibly undefined' errors - Added proper type guards for accessing properties on union type - Maintained test logic integrity while ensuring type safety 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- data/nodes.db | Bin 26591232 -> 26591232 bytes .../utils/fixed-collection-validator.test.ts | 64 ++++++++++++++---- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/data/nodes.db b/data/nodes.db index 0a0ddf1dd165a6da909785bce944433308cde669..3f07a522a1f2ad9d982f8abb9742bac5585b7d38 100644 GIT binary patch delta 1403 zcmWmAXQK!N07l_^6$)9|gv^RcWMz|GD3uX9WM%IZagB5BO?znXy@#~-UfO%_opx^@ zo6waTzsd>v1#S4}og;GNHkUgcOl#8T-%l^_p8cHK+EKQ`T z93ThELDEc`%fWJp94am3Fli~RWTcFelO#W*WsICGV`ZF- zmkBaaPLWA6S*FNTnI_X^hRl>%GF#@zT$v}Q%6vIZPL~C;P|lD=vRH~_i7b_6vRss6 zSs^QBm8_OEvR2l~df6ZwWs_`{EwWX%$(eGNoGs_bxpJPIFBiy#a*=G8i{%ozR4$Xt z+*)YDR0T!@{YVK@5%e} zfqW<*$;a}Ed@7&G=kkSoDPPIg@{N2e-^us#gZwBz$0Grd&HhmGD=11*emvqGEp|l#XeC!Dn!Mo6qRG&s1jA9T2zl3Q8Q{q?Why` zMct?u^<)2N5DlYIG>#_GG!BRZ~B05CJ z=oFo!OLUEH(LH*^kOpH@vQcR91F*T;e^q3JdV^++LIWafp#i=nrPK(oH zK`e|jVo@xPqF543V_7T@qc~Q?%2*YvV@<4$b+JA+#KzbZn`29CE!@Gj!tFc%0}K!+ AwEzGB delta 1403 zcmWmA)q)TN00q(Am6j4DrBwu_L6AbZu?C$Qa>%;kh zQ(U~ed~s~4UBzJq1+_*M6jb}IprB|+LE*fqTbs2ha@b0wP>N&^DIq1Ll$4e-QdY{z zo>E>aNJXh6m1QrfB2{H?sV3E>hSZc=Qd{UDM%KzY zSuY!8qim8>WwUINt#X=dlkKuYPM0&}OgT%=mUHA>IZw`)3*GWCcn!c@~8YIf6G7e?>Y)M zQ5Z$BN0f+?Q7TGDnJ63OV$Uca6{2EPipsH9REeswcT|h&Q6p+bt*9OQM4hM`^`d?> zh=$Q9_Kp2w|7aWsM3ZP52gX6sESg7)Xc?`db+n1L(Jl^-_R%2@iH^}JI!Bl28r`CM z^oX9(D|$ztI5hgkVR3jI5l6;R(JzjU{xKj1#-JD+LtiLYx@$Vty=$g|R43ip8-cmd3JJ v9xI|aR>rD0IZg> { describe('Core Functionality', () => { @@ -58,8 +63,12 @@ describe('FixedCollectionValidator', () => { expect(conditionsValuesError).toBeDefined(); expect(conditionsValuesError!.message).toContain('propertyValues[itemName] is not iterable'); expect(result.autofix).toBeDefined(); - expect(result.autofix.rules.values).toBeDefined(); - expect(result.autofix.rules.values[0].outputKey).toBe('output1'); + expect(isNodeConfig(result.autofix)).toBe(true); + if (isNodeConfig(result.autofix)) { + expect(result.autofix.rules).toBeDefined(); + expect((result.autofix.rules as any).values).toBeDefined(); + expect((result.autofix.rules as any).values[0].outputKey).toBe('output1'); + } }); test('should provide correct autofix for switch node', () => { @@ -76,9 +85,12 @@ describe('FixedCollectionValidator', () => { const result = FixedCollectionValidator.validate('switch', invalidConfig); - expect(result.autofix.rules.values).toHaveLength(2); - expect(result.autofix.rules.values[0].outputKey).toBe('output1'); - expect(result.autofix.rules.values[1].outputKey).toBe('output2'); + expect(isNodeConfig(result.autofix)).toBe(true); + if (isNodeConfig(result.autofix)) { + expect((result.autofix.rules as any).values).toHaveLength(2); + expect((result.autofix.rules as any).values[0].outputKey).toBe('output1'); + expect((result.autofix.rules as any).values[1].outputKey).toBe('output2'); + } }); }); @@ -132,7 +144,10 @@ describe('FixedCollectionValidator', () => { expect(result.isValid).toBe(false); expect(result.errors[0].pattern).toBe('fieldsToSummarize.values.values'); expect(result.errors[0].fix).toContain('not nested values.values'); - expect(result.autofix.fieldsToSummarize.values).toHaveLength(2); + expect(isNodeConfig(result.autofix)).toBe(true); + if (isNodeConfig(result.autofix)) { + expect((result.autofix.fieldsToSummarize as any).values).toHaveLength(2); + } }); test('should validate Compare Datasets node', () => { @@ -150,7 +165,10 @@ describe('FixedCollectionValidator', () => { expect(result.isValid).toBe(false); expect(result.errors[0].pattern).toBe('mergeByFields.values.values'); - expect(result.autofix.mergeByFields.values).toHaveLength(1); + expect(isNodeConfig(result.autofix)).toBe(true); + if (isNodeConfig(result.autofix)) { + expect((result.autofix.mergeByFields as any).values).toHaveLength(1); + } }); test('should validate Sort node', () => { @@ -169,7 +187,10 @@ describe('FixedCollectionValidator', () => { expect(result.isValid).toBe(false); expect(result.errors[0].pattern).toBe('sortFieldsUi.sortField.values'); expect(result.errors[0].fix).toContain('not sortField.values'); - expect(result.autofix.sortFieldsUi.sortField).toHaveLength(1); + expect(isNodeConfig(result.autofix)).toBe(true); + if (isNodeConfig(result.autofix)) { + expect((result.autofix.sortFieldsUi as any).sortField).toHaveLength(1); + } }); test('should validate Aggregate node', () => { @@ -187,7 +208,10 @@ describe('FixedCollectionValidator', () => { expect(result.isValid).toBe(false); expect(result.errors[0].pattern).toBe('fieldsToAggregate.fieldToAggregate.values'); - expect(result.autofix.fieldsToAggregate.fieldToAggregate).toHaveLength(1); + expect(isNodeConfig(result.autofix)).toBe(true); + if (isNodeConfig(result.autofix)) { + expect((result.autofix.fieldsToAggregate as any).fieldToAggregate).toHaveLength(1); + } }); test('should validate Set node', () => { @@ -205,7 +229,10 @@ describe('FixedCollectionValidator', () => { expect(result.isValid).toBe(false); expect(result.errors[0].pattern).toBe('fields.values.values'); - expect(result.autofix.fields.values).toHaveLength(1); + expect(isNodeConfig(result.autofix)).toBe(true); + if (isNodeConfig(result.autofix)) { + expect((result.autofix.fields as any).values).toHaveLength(1); + } }); test('should validate HTML node', () => { @@ -223,7 +250,10 @@ describe('FixedCollectionValidator', () => { expect(result.isValid).toBe(false); expect(result.errors[0].pattern).toBe('extractionValues.values.values'); - expect(result.autofix.extractionValues.values).toHaveLength(1); + expect(isNodeConfig(result.autofix)).toBe(true); + if (isNodeConfig(result.autofix)) { + expect((result.autofix.extractionValues as any).values).toHaveLength(1); + } }); test('should validate HTTP Request node', () => { @@ -242,7 +272,10 @@ describe('FixedCollectionValidator', () => { expect(result.isValid).toBe(false); expect(result.errors[0].pattern).toBe('body.parameters.values'); expect(result.errors[0].fix).toContain('not parameters.values'); - expect(result.autofix.body.parameters).toHaveLength(1); + expect(isNodeConfig(result.autofix)).toBe(true); + if (isNodeConfig(result.autofix)) { + expect((result.autofix.body as any).parameters).toHaveLength(1); + } }); test('should validate Airtable node', () => { @@ -260,7 +293,10 @@ describe('FixedCollectionValidator', () => { expect(result.isValid).toBe(false); expect(result.errors[0].pattern).toBe('sort.sortField.values'); - expect(result.autofix.sort.sortField).toHaveLength(1); + expect(isNodeConfig(result.autofix)).toBe(true); + if (isNodeConfig(result.autofix)) { + expect((result.autofix.sort as any).sortField).toHaveLength(1); + } }); });