Skip to content

Commit 23b30ac

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(serializer): preserve singleton canonical values
1 parent 6df18b0 commit 23b30ac

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

apps/sim/serializer/field-analysis.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,38 @@ describe('extractBlockParams', () => {
213213
expect(params.credential).toBeUndefined()
214214
expect(params.manualCredential).toBeUndefined()
215215
})
216+
217+
it('preserves a singleton canonical credential when additional fields are open', () => {
218+
svcConfig.value = config([
219+
{
220+
id: 'credential',
221+
title: 'QuickBooks Account',
222+
type: 'oauth-input',
223+
canonicalParamId: 'oauthCredential',
224+
required: true,
225+
},
226+
{
227+
id: 'privateNote',
228+
title: 'Private Note',
229+
type: 'long-input',
230+
mode: 'advanced',
231+
},
232+
])
233+
234+
const state = block({
235+
type: 'svc',
236+
advancedMode: true,
237+
subBlocks: {
238+
credential: { value: 'credential-id' },
239+
privateNote: { value: 'Updated through Sim' },
240+
},
241+
})
242+
const params = extractBlockParams(state)
243+
const issues = collectBlockFieldIssues(state, svcConfig.value, params)
244+
245+
expect(params.oauthCredential).toBe('credential-id')
246+
expect(params.credential).toBeUndefined()
247+
expect(params.privateNote).toBe('Updated through Sim')
248+
expect(issues.missingRequiredFields).toEqual([])
249+
})
216250
})

apps/sim/serializer/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ export function extractBlockParams(block: BlockState): Record<string, any> {
569569
const { basicValue, advancedValue } = getCanonicalValues(group, params)
570570
const hasExplicitOverride = canonicalModeOverrides?.[group.canonicalId] != null
571571
const pairMode =
572-
hasExplicitOverride || !legacyAdvancedMode
572+
!isCanonicalPair(group) || hasExplicitOverride || !legacyAdvancedMode
573573
? resolveCanonicalMode(group, allValues, canonicalModeOverrides)
574574
: 'advanced'
575575
const chosen = pairMode === 'advanced' ? advancedValue : basicValue

0 commit comments

Comments
 (0)