Skip to content

Commit 2f94aac

Browse files
committed
fix(integrations): update the mention chip test to the new color owner
The chip test asserted the wrapper still carried the descendant `[&>svg]:text-*` rule that BrandIcon now owns. Assert the absence of a competing descendant rule and check the glyph itself instead. Also give BrandIconSlot and the test's PlainIcon dedicated props interfaces.
1 parent cc48256 commit 2f94aac

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/mention/mention-chip.test.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ describe('MentionChipView', () => {
7272
.filter((cls) => cls.startsWith('text-') || cls.startsWith('[&]:text-'))
7373
expect(ownTextUtilities).toEqual([])
7474

75-
// The icon's own monochrome fallback is unrelated and must be untouched by this fix.
76-
expect(chip.className).toContain('[&>svg]:text-[var(--text-icon)]')
75+
// The icon's monochrome fallback moved into `BrandIcon`, which owns the glyph color for every
76+
// surface. A descendant color rule here would be a second, silently-losing source of truth.
77+
expect(chip.className).not.toContain('[&>svg]:text-')
78+
expect(container?.querySelector('svg')?.getAttribute('class')).toContain(
79+
'text-[var(--text-icon)]'
80+
)
7781
})
7882
})

apps/sim/blocks/brand-icon.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ vi.mocked(getAllBlocks).mockReturnValue([
1212
{ icon: DropboxIcon, iconColor: '#0061FF' },
1313
] as unknown as ReturnType<typeof getAllBlocks>)
1414

15-
function PlainIcon({ className }: { className?: string }) {
15+
interface PlainIconProps {
16+
className?: string
17+
}
18+
19+
function PlainIcon({ className }: PlainIconProps) {
1620
return <svg className={className} />
1721
}
1822

apps/sim/blocks/brand-icon.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,23 @@ export function BrandIcon({ icon: Icon, className }: BrandIconProps) {
6262
* renders hand the same component reference back and React never remounts the
6363
* slot it fills.
6464
*/
65-
const brandIconComponents = new WeakMap<StyleableIcon, ComponentType<{ className?: string }>>()
65+
const brandIconComponents = new WeakMap<StyleableIcon, ComponentType<BrandIconSlotProps>>()
66+
67+
export interface BrandIconSlotProps {
68+
/** Supplied by the host slot; sizing and layout only. */
69+
className?: string
70+
}
6671

6772
/**
6873
* Adapts a brand glyph for the `icon` prop slots that take a component rather
6974
* than an element — `ChipModalHeader`, dropdown options, command rows — so
7075
* those surfaces get the same treatment as a direct {@link BrandIcon}.
7176
*/
72-
export function withBrandIcon(icon: StyleableIcon): ComponentType<{ className?: string }> {
77+
export function withBrandIcon(icon: StyleableIcon): ComponentType<BrandIconSlotProps> {
7378
const cached = brandIconComponents.get(icon)
7479
if (cached) return cached
7580

76-
function BrandIconSlot({ className }: { className?: string }) {
81+
function BrandIconSlot({ className }: BrandIconSlotProps) {
7782
return <BrandIcon icon={icon} className={className} />
7883
}
7984
BrandIconSlot.displayName = `BrandIcon(${icon.displayName ?? icon.name ?? 'Icon'})`

0 commit comments

Comments
 (0)