Skip to content
Merged
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 @@ -151,7 +151,14 @@ describe('dataset-config/card-item', () => {
renderItem(dataset)

const card = screen.getByText(dataset.name).closest('.group') as HTMLElement
const actionButtons = within(card).getAllByRole('button', { hidden: true })
const editButton = within(card).getByRole('button', {
name: 'common.operation.edit',
hidden: true,
})
const removeButton = within(card).getByRole('button', {
name: 'common.operation.remove',
hidden: true,
})

expect(screen.getByText(dataset.name))!.toBeInTheDocument()
expect(
Expand All @@ -160,7 +167,8 @@ describe('dataset-config/card-item', () => {
),
)!.toBeInTheDocument()
expect(screen.getByText('dataset.externalTag'))!.toBeInTheDocument()
expect(actionButtons).toHaveLength(2)
expect(editButton).toBeInTheDocument()
expect(removeButton).toBeInTheDocument()
})

it('should open settings drawer from edit action and close after saving', async () => {
Expand All @@ -169,8 +177,11 @@ describe('dataset-config/card-item', () => {
const { onSave } = renderItem(dataset)

const card = screen.getByText(dataset.name).closest('.group') as HTMLElement
const [editButton] = within(card).getAllByRole('button', { hidden: true })
await user.click(editButton!)
const editButton = within(card).getByRole('button', {
name: 'common.operation.edit',
hidden: true,
})
await user.click(editButton)

expect(await screen.findByText('Mock settings modal'))!.toBeInTheDocument()
fireEvent.click(await screen.findByText('Save changes'))
Expand All @@ -189,8 +200,10 @@ describe('dataset-config/card-item', () => {
const { onRemove } = renderItem(dataset)

const card = screen.getByText(dataset.name).closest('.group') as HTMLElement
const buttons = within(card).getAllByRole('button', { hidden: true })
const deleteButton = buttons.at(-1)!
const deleteButton = within(card).getByRole('button', {
name: 'common.operation.remove',
hidden: true,
})

expect(deleteButton.className).not.toContain('action-btn-destructive')

Expand Down Expand Up @@ -225,8 +238,11 @@ describe('dataset-config/card-item', () => {
renderItem(dataset)

const card = screen.getByText(dataset.name).closest('.group') as HTMLElement
const [editButton] = within(card).getAllByRole('button', { hidden: true })
await user.click(editButton!)
const editButton = within(card).getByRole('button', {
name: 'common.operation.edit',
hidden: true,
})
await user.click(editButton)
expect(screen.getByText('Mock settings modal'))!.toBeInTheDocument()

const overlay = [...document.querySelectorAll('[class]')].find(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,25 @@ const Item: FC<ItemProps> = ({ config, onSave, onRemove, readonly = false, edita
<div className="ml-2 hidden shrink-0 items-center space-x-1 group-hover:flex">
{editable && !readonly && (
<ActionButton
aria-label={t(($) => $['operation.edit'], { ns: 'common' })}
onClick={(e) => {
e.stopPropagation()
setShowSettingsModal(true)
}}
>
<RiEditLine className="size-4 shrink-0 text-text-tertiary" />
<RiEditLine aria-hidden="true" className="size-4 shrink-0 text-text-tertiary" />
</ActionButton>
)}
{!readonly && (
<ActionButton
aria-label={t(($) => $['operation.remove'], { ns: 'common' })}
onClick={() => onRemove(config.id)}
state={isDeleting ? ActionButtonState.Destructive : ActionButtonState.Default}
onMouseEnter={() => setIsDeleting(true)}
onMouseLeave={() => setIsDeleting(false)}
>
<RiDeleteBinLine
aria-hidden="true"
className={cn(
'size-4 shrink-0 text-text-tertiary',
isDeleting && 'text-text-destructive',
Expand Down