Skip to content

Commit f1a065c

Browse files
committed
fix(selectors): cover incomplete comparison catalogs
1 parent 6b545fd commit f1a065c

1 file changed

Lines changed: 40 additions & 4 deletions

File tree

apps/sim/lib/workflows/comparison/format-description.test.ts

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
*/
44
import { beforeEach, describe, expect, it, vi } from 'vitest'
55

6-
const { mockGetBlock } = vi.hoisted(() => ({
6+
const { mockGetBlock, mockLoadAllSelectorOptions } = vi.hoisted(() => ({
77
mockGetBlock: vi.fn(),
8+
mockLoadAllSelectorOptions: vi.fn(),
89
}))
910

1011
vi.mock('@/lib/workflows/subblocks/visibility', () => ({
@@ -17,7 +18,7 @@ vi.mock('@/triggers/constants', () => ({
1718
}))
1819

1920
vi.mock('@/blocks/types', () => ({
20-
SELECTOR_TYPES_HYDRATION_REQUIRED: [],
21+
SELECTOR_TYPES_HYDRATION_REQUIRED: ['channel-selector'],
2122
}))
2223

2324
vi.mock('@/executor/constants', () => ({
@@ -37,7 +38,7 @@ vi.mock('@/hooks/queries/oauth/oauth-credentials', () => ({
3738

3839
vi.mock('@/lib/selectors/client/execute-selector', () => ({
3940
executeSelectorRequest: vi.fn(() => ({ kind: 'detail', item: null })),
40-
loadAllSelectorOptions: vi.fn(() => []),
41+
loadAllSelectorOptions: mockLoadAllSelectorOptions,
4142
}))
4243

4344
import { WorkflowBuilder } from '@sim/testing'
@@ -47,7 +48,11 @@ import {
4748
formatDiffSummaryForDescription,
4849
formatDiffSummaryForDescriptionAsync,
4950
} from '@/lib/workflows/comparison/describe'
50-
import { formatValueForDisplay, resolveFieldLabel } from '@/lib/workflows/comparison/resolve-values'
51+
import {
52+
formatValueForDisplay,
53+
resolveFieldLabel,
54+
resolveValueForDisplay,
55+
} from '@/lib/workflows/comparison/resolve-values'
5156

5257
function emptyDiffSummary(overrides: Partial<WorkflowDiffSummary> = {}): WorkflowDiffSummary {
5358
return {
@@ -72,6 +77,7 @@ function emptyDiffSummary(overrides: Partial<WorkflowDiffSummary> = {}): Workflo
7277

7378
beforeEach(() => {
7479
vi.clearAllMocks()
80+
mockLoadAllSelectorOptions.mockResolvedValue({ items: [], truncated: false })
7581
})
7682

7783
describe('resolveFieldLabel', () => {
@@ -124,6 +130,36 @@ describe('formatValueForDisplay', () => {
124130
})
125131
})
126132

133+
describe('resolveValueForDisplay', () => {
134+
it('preserves a raw selector ID when the loaded catalog is incomplete', async () => {
135+
mockGetBlock.mockReturnValue({
136+
subBlocks: [
137+
{
138+
id: 'channel',
139+
title: 'Channel',
140+
type: 'channel-selector',
141+
selectorKey: 'slack.channels',
142+
},
143+
],
144+
})
145+
mockLoadAllSelectorOptions.mockResolvedValue({ items: [], truncated: true })
146+
147+
const channelId = 'C12345678'
148+
const result = await resolveValueForDisplay(channelId, {
149+
blockType: 'slack',
150+
subBlockId: 'channel',
151+
workflowId: 'wf-1',
152+
currentState: new WorkflowBuilder().build(),
153+
})
154+
155+
expect(result).toEqual({
156+
original: channelId,
157+
displayLabel: channelId,
158+
resolved: false,
159+
})
160+
})
161+
})
162+
127163
describe('formatDiffSummaryForDescription', () => {
128164
it('returns no-changes message for empty diff', () => {
129165
const result = formatDiffSummaryForDescription(emptyDiffSummary())

0 commit comments

Comments
 (0)