Skip to content

Commit aa9e0c8

Browse files
committed
test(terminal): lock the log-row accent rule against the block toolbar
getEntryAccentType encodes a cross-surface rule — a block must be accented the same way in the terminal as in the block toolbar — and nothing enforced it. The table covers every branch: core blocks mapped and unmapped, role-bearing and role-less integrations and triggers, the config-less subflows, and the synthesized error/validation/cancelled rows that must keep their status fill. Verified failing: reverting the guard to an unconditional return reds two of the four cases.
1 parent bda4d98 commit aa9e0c8

1 file changed

Lines changed: 49 additions & 1 deletion

File tree

  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/utils.test.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @vitest-environment node
33
*/
4-
import { describe, expect, it, vi } from 'vitest'
4+
import { afterEach, describe, expect, it, vi } from 'vitest'
55

66
vi.mock('@/blocks', () => ({
77
getBlock: vi.fn().mockReturnValue(null),
@@ -17,11 +17,13 @@ vi.mock('@/stores/constants', () => ({
1717
TERMINAL_BLOCK_COLUMN_WIDTH: { MIN: 120, DEFAULT: 200, MAX: 400 },
1818
}))
1919

20+
import { getBlock } from '@/blocks'
2021
import type { ConsoleEntry } from '@/stores/terminal'
2122
import {
2223
buildEntryTree,
2324
type EntryNode,
2425
flattenVisibleExecutionRows,
26+
getEntryAccentType,
2527
groupEntriesByExecution,
2628
} from './utils'
2729

@@ -856,3 +858,49 @@ describe('flattenVisibleExecutionRows', () => {
856858
expect(rowsExpanded[1].depth).toBe(1)
857859
})
858860
})
861+
862+
describe('getEntryAccentType', () => {
863+
const mockedGetBlock = vi.mocked(getBlock)
864+
865+
afterEach(() => {
866+
mockedGetBlock.mockReturnValue(null as never)
867+
})
868+
869+
function withCategory(category: string) {
870+
mockedGetBlock.mockReturnValue({ category } as never)
871+
}
872+
873+
it('accents a core block by its type, mapped or not', () => {
874+
withCategory('blocks')
875+
expect(getEntryAccentType('agent')).toBe('agent')
876+
/*
877+
* An unmapped core block still takes the accent path and lands on `neutral`,
878+
* which is exactly what the block toolbar does for a newly added one — the
879+
* two surfaces must not disagree while the role map catches up.
880+
*/
881+
expect(getEntryAccentType('brand_new_core_block')).toBe('brand_new_core_block')
882+
})
883+
884+
it('accents a non-core block only when it carries a canvas role', () => {
885+
withCategory('tools')
886+
expect(getEntryAccentType('table')).toBe('table')
887+
// A role-less integration keeps its own provider colour instead.
888+
expect(getEntryAccentType('gmail')).toBeUndefined()
889+
890+
withCategory('triggers')
891+
expect(getEntryAccentType('schedule')).toBe('schedule')
892+
expect(getEntryAccentType('some_vendor_trigger')).toBeUndefined()
893+
})
894+
895+
it('accents subflows, which carry a role but no registry config', () => {
896+
expect(getEntryAccentType('loop')).toBe('loop')
897+
expect(getEntryAccentType('parallel')).toBe('parallel')
898+
expect(getEntryAccentType('workflow')).toBe('workflow')
899+
})
900+
901+
it('leaves the terminal-synthesized run rows on their own status fill', () => {
902+
expect(getEntryAccentType('error')).toBeUndefined()
903+
expect(getEntryAccentType('validation')).toBeUndefined()
904+
expect(getEntryAccentType('cancelled')).toBeUndefined()
905+
})
906+
})

0 commit comments

Comments
 (0)