-
Notifications
You must be signed in to change notification settings - Fork 539
refactor: migrate PrimeVue Chip to custom Tag component #10673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dante01yoon
wants to merge
11
commits into
main
Choose a base branch
from
feature/migrate-primevue-chip
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
921226f
feat: add Tag component from design system and rename SquareChip
dante01yoon 5319441
fix: align Tag variants with Figma design system states
dante01yoon 0d3f272
feat: add overlay shape variant for tags on images
dante01yoon ec19b49
fix: stop click propagation on remove button and fix story labels
dante01yoon 7721a78
fix: apply overlay shape to template dialog tags
dante01yoon 69e35c0
test: add E2E screenshot test for template card overlay tags
dante01yoon ed14722
fix: use TestIds selectors and fix remaining story label mismatch
dante01yoon e4286aa
test: add golden screenshot for template overlay tags
dante01yoon 614f482
refactor: replace PrimeVue Chip with custom Tag component
dante01yoon 2266827
test: add unit tests for SearchFilterChip and DownloadItem
dante01yoon f5a669f
Merge branch 'main' into feature/migrate-primevue-chip
dante01yoon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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') | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/components/sidebar/tabs/modelLibrary/DownloadItem.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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() | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
Comment on lines
6
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a status-specific label for error state. Line 6 includes 💡 Proposed fix- <Tag
- :label="t('electronFileDownload.cancelled')"
+ <Tag
+ :label="
+ t(
+ download.status === 'error'
+ ? 'electronFileDownload.error'
+ : 'electronFileDownload.cancelled'
+ )
+ "
class="mt-2 bg-red-700 text-sm font-light"
removable
`@remove`="handleRemoveDownload"
/>🤖 Prompt for AI Agents |
||
| 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' | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid asserting Tailwind utility classes in component tests.
These assertions couple tests to implementation styling (
className) instead of user-visible behavior, which makes them brittle during visual refactors.As per coding guidelines: "
**/*.{test,spec}.ts: Do not write tests dependent on non-behavioral features like utility classes or styles."Also applies to: 37-41, 52-60
🤖 Prompt for AI Agents