Skip to content

Commit a588dd9

Browse files
committed
fix(greenhouse): reproduce imported raw input loss
1 parent c45179a commit a588dd9

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

‎apps/sim/lib/workflows/migrations/subblock-migrations.test.ts‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,71 @@ describe('migration targets', () => {
126126
})
127127

128128
describe('migrateSubblockIds', () => {
129+
it.each([
130+
{ operation: { id: 'operation', type: 'dropdown', value: 'convert_prospect' }, value: '42' },
131+
{ operation: { id: 'operation', type: 'dropdown', value: 'convert_prospect' }, value: '' },
132+
{ operation: { id: 'operation', type: 'dropdown', value: 'convert_prospect' }, value: null },
133+
{ operation: { id: 'operation', type: 'dropdown', value: 'convert_prospect' }, value: false },
134+
{ operation: { id: 'operation', type: 'dropdown', value: 'convert_prospect' }, value: 0 },
135+
{ operation: 'convert_prospect', value: '42' },
136+
])(
137+
'preserves bare Greenhouse input $value during import normalization',
138+
({ operation, value }) => {
139+
const block = makeBlock({
140+
type: 'greenhouse_v2',
141+
subBlocks: {
142+
operation,
143+
id: { id: 'id', type: 'short-input', value: 'unrelated-candidate' },
144+
update_application_id: value,
145+
convert_prospect_job_id: '<lookup.job.id>',
146+
} as BlockState['subBlocks'],
147+
})
148+
const result = migrateSubblockIds({ 'block-1': block })
149+
const saved = result.blocks['block-1'].subBlocks
150+
expect(saved.id.value).toBe(value)
151+
expect(saved.job_id.value).toBe('<lookup.job.id>')
152+
expect(saved).not.toHaveProperty('update_application_id')
153+
expect(migrateSubblockIds(result.blocks).migrated).toBe(false)
154+
}
155+
)
156+
157+
it('retains wrapped Greenhouse source metadata while replacing the canonical target', () => {
158+
const source = {
159+
id: 'update_application_id',
160+
type: 'short-input' as const,
161+
value: '42',
162+
metadata: { source: { reference: 'candidate-lookup' } },
163+
}
164+
const block = makeBlock({
165+
type: 'greenhouse_v2',
166+
subBlocks: {
167+
operation: { id: 'operation', type: 'dropdown', value: 'update_application' },
168+
id: { id: 'id', type: 'short-input', value: 'unrelated-candidate' },
169+
update_application_id: source,
170+
},
171+
})
172+
const result = migrateSubblockIds({ 'block-1': block })
173+
expect(result.blocks['block-1'].subBlocks.id).toMatchObject({
174+
value: '42',
175+
metadata: source.metadata,
176+
})
177+
expect(block.subBlocks.update_application_id).toBe(source)
178+
})
179+
180+
it('preserves a bare Greenhouse array over a stale list filter during import', () => {
181+
const block = makeBlock({
182+
type: 'greenhouse_v2',
183+
subBlocks: {
184+
operation: { id: 'operation', type: 'dropdown', value: 'create_application' },
185+
job_ids: { id: 'job_ids', type: 'short-input', value: '99' },
186+
create_application_job_ids: [42, 81],
187+
} as BlockState['subBlocks'],
188+
})
189+
const result = migrateSubblockIds({ 'block-1': block })
190+
expect(result.blocks['block-1'].subBlocks.job_ids.value).toEqual([42, 81])
191+
expect(result.blocks['block-1'].subBlocks).not.toHaveProperty('create_application_job_ids')
192+
})
193+
129194
it.each(['42', ''])(
130195
'preserves the active Greenhouse alias %j over an unrelated stored target',
131196
(value) => {

0 commit comments

Comments
 (0)