Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export {
RESOURCE_TILE_FILL,
RESOURCE_TILE_PLAIN,
ResourceTile,
} from '@/app/workspace/[workspaceId]/components/resource-tile/resource-tile'
} from '@sim/emcn'

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,27 @@ vi.mock('@sim/emcn/icons', () => ({

vi.mock('@sim/emcn', () => ({
Badge: ({ children }: { children?: ReactNode }) => <span>{children}</span>,
ResourceRow: ({
icon,
title,
description,
badge,
trailing,
}: {
icon?: ReactNode
title: ReactNode
description?: ReactNode
badge?: ReactNode
trailing?: ReactNode
}) => (
<div>
{icon}
<span>{title}</span>
{description}
{badge}
{trailing}
</div>
),
Chip: ({
children,
variant: _variant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,41 @@ vi.mock('@sim/browser-protocol', () => ({
}))

vi.mock('@sim/emcn', () => ({
/** `SettingsResourceRow` composes its tile classes with `cn`. */
cn: (...classes: unknown[]) => classes.filter(Boolean).join(' '),
ResourceRow: ({
title,
description,
icon,
trailing,
onClick,
clickLabel,
disabled,
}: {
title: ReactNode
description?: ReactNode
icon?: ReactNode
trailing?: ReactNode
onClick?: () => void
clickLabel?: string
disabled?: boolean
}) => (
<div>
{onClick && !disabled ? (
<button type='button' aria-label={clickLabel} onClick={onClick}>
{icon}
{title}
{description}
</button>
) : (
<span>
{icon}
{title}
{description}
</span>
)}
{trailing}
</div>
),
Chip: ({
children,
disabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,41 @@ const { mockBridge, mockSearch, mockToast } = vi.hoisted(() => ({
}))

vi.mock('@sim/emcn', () => ({
/** `SettingsResourceRow` composes its tile classes with `cn`. */
cn: (...classes: unknown[]) => classes.filter(Boolean).join(' '),
ResourceRow: ({
title,
description,
icon,
trailing,
onClick,
clickLabel,
disabled,
}: {
title: ReactNode
description?: ReactNode
icon?: ReactNode
trailing?: ReactNode
onClick?: () => void
clickLabel?: string
disabled?: boolean
}) => (
<div>
{onClick && !disabled ? (
<button type='button' aria-label={clickLabel} onClick={onClick}>
{icon}
{title}
{description}
</button>
) : (
<span>
{icon}
{title}
{description}
</span>
)}
{trailing}
</div>
),
ArrowLeft: () => <span />,
ArrowRight: () => <span />,
ChipConfirmModal: ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
export {
RESOURCE_LIST_GRID,
RESOURCE_LIST_STACK,
RESOURCE_ROW_ARROW_CLASSES,
SettingsResourceRow,
} from './settings-resource-row'
export { RESOURCE_LIST_GRID, RESOURCE_LIST_STACK, RESOURCE_ROW_ARROW_CLASSES } from '@sim/emcn'
export { SettingsResourceRow } from './settings-resource-row'
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @vitest-environment jsdom
*/
import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it } from 'vitest'
import { SettingsResourceRow } from '@/app/workspace/[workspaceId]/settings/components/settings-resource-row/settings-resource-row'

describe('SettingsResourceRow', () => {
it('renders a real Next link beside interactive trailing controls', () => {
const html = renderToStaticMarkup(
<SettingsResourceRow
title='Knowledge base'
description='Connected resource'
href='/workspace/example/knowledge'
clickLabel='Open knowledge base'
navigable
trailing={<button type='button'>More actions</button>}
/>
)
const container = document.createElement('div')
container.innerHTML = html

const link = container.querySelector('a')
const action = container.querySelector('button')
expect(link?.getAttribute('href')).toBe('/workspace/example/knowledge')
expect(link?.getAttribute('aria-label')).toBe('Open knowledge base')
expect(link?.getAttribute('aria-describedby')).toBe(container.querySelector('span[id]')?.id)
expect(link?.contains(action ?? null)).toBe(false)
expect(action?.textContent).toBe('More actions')
})
})
Loading
Loading