Compare commits

...

11 Commits

Author SHA1 Message Date
Dante
f5a669ff0d Merge branch 'main' into feature/migrate-primevue-chip 2026-03-29 16:32:57 +09:00
dante01yoon
2266827248 test: add unit tests for SearchFilterChip and DownloadItem
SearchFilterChip (5 tests): badge rendering, semantic class
mapping, remove event, fallback class.
DownloadItem (4 tests): cancelled/error tag display, remove
button, in-progress state, file path label.
2026-03-28 18:53:42 +09:00
dante01yoon
614f482c18 refactor: replace PrimeVue Chip with custom Tag component
- SearchFilterChip: PrimeVue Chip+Badge → Tag (removable) + Badge
- NodeSearchItem: PrimeVue Chip → Tag (aliased as ChipTag to avoid
  name collision with PrimeVue Tag, which migrates in a follow-up PR)
- DownloadItem: PrimeVue Chip (removable) → Tag (removable)
- Update E2E selectors from .p-chip-remove-icon to accessible
  getByRole('button', { name: 'Remove' })
2026-03-28 18:45:31 +09:00
dante01yoon
e4286aabf3 test: add golden screenshot for template overlay tags 2026-03-28 16:49:50 +09:00
dante01yoon
ed14722fe2 fix: use TestIds selectors and fix remaining story label mismatch 2026-03-28 16:36:53 +09:00
dante01yoon
69e35c00f3 test: add E2E screenshot test for template card overlay tags 2026-03-28 16:28:50 +09:00
dante01yoon
7721a78087 fix: apply overlay shape to template dialog tags 2026-03-28 16:22:01 +09:00
dante01yoon
ec19b49cc3 fix: stop click propagation on remove button and fix story labels 2026-03-28 16:20:40 +09:00
dante01yoon
0d3f272e6a feat: add overlay shape variant for tags on images
Add overlay shape (bg-zinc-500/40, text-white/90) for tags that
sit on top of image thumbnails. Used in SampleModelSelector.
Pending Figma design system confirmation.
2026-03-28 16:12:54 +09:00
dante01yoon
5319441b24 fix: align Tag variants with Figma design system states
Replace custom overlay variant with Figma-defined states:
- default: full opacity, foreground text
- unselected: opacity-70, muted-foreground text
- selected: full opacity with remove button (via removable prop)
Hover state handled via CSS :hover, not a prop.
2026-03-28 16:06:36 +09:00
dante01yoon
921226f79f feat: add Tag component from design system and rename SquareChip
Add Tag component with CVA variants matching Figma design system:
- square (rounded-sm) and rounded (pill) shapes
- removable state with X close button
- icon slot support

Rename SquareChip to Tag across all consumers and stories.
Includes unit tests (5 tests) covering rendering, removable
behavior, and icon slot.
2026-03-28 15:49:52 +09:00
7 changed files with 176 additions and 21 deletions

View File

@@ -85,7 +85,10 @@ export class ComfyNodeSearchBox {
}
async removeFilter(index: number) {
await this.filterChips.nth(index).locator('.p-chip-remove-icon').click()
await this.filterChips
.nth(index)
.getByRole('button', { name: 'Remove' })
.click()
}
/**

View File

@@ -110,7 +110,7 @@ test.describe('Node search box', { tag: '@node' }, () => {
async ({ comfyPage }) => {
await comfyPage.canvasOps.disconnectEdge()
await expect(comfyPage.searchBox.input).toHaveCount(1)
await comfyPage.page.locator('.p-chip-remove-icon').click()
await comfyPage.searchBox.removeFilter(0)
await comfyPage.searchBox.fillAndSelectFirstNode('KSampler', {
exact: true
})

View File

@@ -0,0 +1,61 @@
import { render, screen } from '@testing-library/vue'
import userEvent from '@testing-library/user-event'
import { describe, expect, it, vi } from 'vitest'
import { createI18n } from 'vue-i18n'
import SearchFilterChip from './SearchFilterChip.vue'
const i18n = createI18n({
legacy: false,
locale: 'en',
messages: { en: { g: { remove: 'Remove' } } }
})
function renderChip(
props: { text: string; badge: string; badgeClass: string },
onRemove?: (...args: unknown[]) => void
) {
return render(SearchFilterChip, {
props: { ...props, ...(onRemove ? { onRemove } : {}) },
global: { plugins: [i18n] }
})
}
describe('SearchFilterChip', () => {
it('renders badge and text', () => {
renderChip({ text: 'MODEL', badge: 'I', badgeClass: 'i-badge' })
expect(screen.getByText('MODEL')).toBeInTheDocument()
expect(screen.getByText('I')).toBeInTheDocument()
})
it('applies semantic badge class for input type', () => {
renderChip({ text: 'CLIP', badge: 'I', badgeClass: 'i-badge' })
const badge = screen.getByText('I')
expect(badge.className).toContain('bg-green-500')
})
it('applies semantic badge class for output type', () => {
renderChip({ text: 'IMAGE', badge: 'O', badgeClass: 'o-badge' })
const badge = screen.getByText('O')
expect(badge.className).toContain('bg-red-500')
})
it('shows remove button and emits remove on click', async () => {
const user = userEvent.setup()
const onRemove = vi.fn()
renderChip({ text: 'MODEL', badge: 'I', badgeClass: 'i-badge' }, onRemove)
await user.click(screen.getByRole('button', { name: 'Remove' }))
expect(onRemove).toHaveBeenCalledOnce()
})
it('falls back to raw badgeClass when no semantic mapping', () => {
renderChip({
text: 'CUSTOM',
badge: 'X',
badgeClass: 'custom-class'
})
const badge = screen.getByText('X')
expect(badge.className).toContain('custom-class')
})
})

View File

@@ -1,17 +1,23 @@
<template>
<Chip removable @remove="emit('remove', $event)">
<Badge size="small" :class="semanticBadgeClass">
{{ badge }}
</Badge>
{{ text }}
</Chip>
<Tag
:label="text"
shape="rounded"
removable
class="bg-surface-700"
@remove="emit('remove', $event)"
>
<template #icon>
<Badge :label="badge" :class="semanticBadgeClass" />
</template>
</Tag>
</template>
<script setup lang="ts">
import Badge from 'primevue/badge'
import Chip from 'primevue/chip'
import { computed } from 'vue'
import Badge from '@/components/common/Badge.vue'
import Tag from '@/components/chip/Tag.vue'
export interface SearchFilter {
text: string
badge: string

View File

@@ -37,18 +37,17 @@
:value="formatNumberWithSuffix(nodeFrequency, { roundToInt: true })"
severity="secondary"
/>
<Chip
<ChipTag
v-if="nodeDef.nodeSource.type !== NodeSourceType.Unknown"
:label="nodeDef.nodeSource.displayText"
class="text-sm font-light"
>
{{ nodeDef.nodeSource.displayText }}
</Chip>
/>
</div>
</div>
</template>
<script setup lang="ts">
import Chip from 'primevue/chip'
import ChipTag from '@/components/chip/Tag.vue'
import Tag from 'primevue/tag'
import { computed } from 'vue'

View File

@@ -0,0 +1,86 @@
import { render, screen } from '@testing-library/vue'
import { createTestingPinia } from '@pinia/testing'
import { describe, expect, it } from 'vitest'
import { createI18n } from 'vue-i18n'
import { DownloadStatus } from '@comfyorg/comfyui-electron-types'
import type { ElectronDownload } from '@/stores/electronDownloadStore'
import DownloadItem from './DownloadItem.vue'
const i18n = createI18n({
legacy: false,
locale: 'en',
messages: {
en: {
g: { remove: 'Remove' },
electronFileDownload: {
cancelled: 'Cancelled',
pause: 'Pause',
resume: 'Resume',
cancel: 'Cancel'
}
}
}
})
function renderDownloadItem(download: ElectronDownload) {
return render(DownloadItem, {
props: { download },
global: {
plugins: [createTestingPinia(), i18n],
stubs: {
ProgressBar: true
}
}
})
}
describe('DownloadItem', () => {
it('shows cancelled tag with remove button for cancelled downloads', () => {
renderDownloadItem({
url: 'http://example.com/model.bin',
filename: 'model.bin',
savePath: '/models/checkpoints/model.bin',
status: DownloadStatus.CANCELLED
})
expect(screen.getByText('Cancelled')).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Remove' })).toBeInTheDocument()
})
it('shows cancelled tag for error downloads', () => {
renderDownloadItem({
url: 'http://example.com/model.bin',
filename: 'model.bin',
savePath: '/models/checkpoints/model.bin',
status: DownloadStatus.ERROR
})
expect(screen.getByText('Cancelled')).toBeInTheDocument()
})
it('does not show cancelled tag for in-progress downloads', () => {
renderDownloadItem({
url: 'http://example.com/model.bin',
filename: 'model.bin',
savePath: '/models/checkpoints/model.bin',
status: DownloadStatus.IN_PROGRESS,
progress: 0.5
})
expect(screen.queryByText('Cancelled')).not.toBeInTheDocument()
})
it('displays file path label', () => {
renderDownloadItem({
url: 'http://example.com/model.bin',
filename: 'model.bin',
savePath: '/models/checkpoints/model.bin',
status: DownloadStatus.CANCELLED
})
expect(screen.getByText('checkpoints/model.bin')).toBeInTheDocument()
})
})

View File

@@ -4,13 +4,12 @@
{{ getDownloadLabel(download.savePath ?? '') }}
</div>
<div v-if="['cancelled', 'error'].includes(download.status ?? '')">
<Chip
class="mt-2 h-6 bg-red-700 text-sm font-light"
<Tag
:label="t('electronFileDownload.cancelled')"
class="mt-2 bg-red-700 text-sm font-light"
removable
@remove="handleRemoveDownload"
>
{{ t('electronFileDownload.cancelled') }}
</Chip>
/>
</div>
<div
v-if="
@@ -67,8 +66,9 @@
</template>
<script setup lang="ts">
import Chip from 'primevue/chip'
import ProgressBar from 'primevue/progressbar'
import Tag from '@/components/chip/Tag.vue'
import { useI18n } from 'vue-i18n'
import Button from '@/components/ui/button/Button.vue'