Skip to content

Commit 0a2f567

Browse files
christian-byrnejtydhr88Chenlei Hugithub-actionshuchenlei
authored
Cherry pick API node fixes (#3839)
Co-authored-by: Terry Jia <[email protected]> Co-authored-by: Chenlei Hu <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: Chenlei Hu <[email protected]> Co-authored-by: Comfy Org PR Bot <[email protected]>
1 parent b38b388 commit 0a2f567

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+22097
-1867
lines changed

public/assets/favicon.ico

15 KB
Binary file not shown.
-2.84 KB
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Loading
Lines changed: 9 additions & 0 deletions
Loading

src/components/common/NoResultsPlaceholder.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="flex flex-col items-center">
66
<i :class="icon" style="font-size: 3rem; margin-bottom: 1rem" />
77
<h3>{{ title }}</h3>
8-
<p class="whitespace-pre-line text-center">
8+
<p :class="textClass" class="whitespace-pre-line text-center">
99
{{ message }}
1010
</p>
1111
<Button
@@ -29,6 +29,7 @@ const props = defineProps<{
2929
icon?: string
3030
title: string
3131
message: string
32+
textClass?: string
3233
buttonLabel?: string
3334
}>()
3435
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import { mount } from '@vue/test-utils'
2+
import Avatar from 'primevue/avatar'
3+
import PrimeVue from 'primevue/config'
4+
import { beforeEach, describe, expect, it } from 'vitest'
5+
import { createApp, nextTick } from 'vue'
6+
import { createI18n } from 'vue-i18n'
7+
8+
import UserAvatar from './UserAvatar.vue'
9+
10+
const i18n = createI18n({
11+
legacy: false,
12+
locale: 'en',
13+
messages: {
14+
en: {
15+
auth: {
16+
login: {
17+
userAvatar: 'User Avatar'
18+
}
19+
}
20+
}
21+
}
22+
})
23+
24+
describe('UserAvatar', () => {
25+
beforeEach(() => {
26+
const app = createApp({})
27+
app.use(PrimeVue)
28+
})
29+
30+
const mountComponent = (props: any = {}) => {
31+
return mount(UserAvatar, {
32+
global: {
33+
plugins: [PrimeVue, i18n],
34+
components: { Avatar }
35+
},
36+
props
37+
})
38+
}
39+
40+
it('renders correctly with photo Url', async () => {
41+
const wrapper = mountComponent({
42+
photoUrl: 'https://example.com/avatar.jpg'
43+
})
44+
45+
const avatar = wrapper.findComponent(Avatar)
46+
expect(avatar.exists()).toBe(true)
47+
expect(avatar.props('image')).toBe('https://example.com/avatar.jpg')
48+
expect(avatar.props('icon')).toBeNull()
49+
})
50+
51+
it('renders with default icon when no photo Url is provided', () => {
52+
const wrapper = mountComponent({
53+
photoUrl: undefined
54+
})
55+
56+
const avatar = wrapper.findComponent(Avatar)
57+
expect(avatar.exists()).toBe(true)
58+
expect(avatar.props('image')).toBeNull()
59+
expect(avatar.props('icon')).toBe('pi pi-user')
60+
})
61+
62+
it('renders with default icon when provided photo Url is null', () => {
63+
const wrapper = mountComponent({
64+
photoUrl: null
65+
})
66+
67+
const avatar = wrapper.findComponent(Avatar)
68+
expect(avatar.exists()).toBe(true)
69+
expect(avatar.props('image')).toBeNull()
70+
expect(avatar.props('icon')).toBe('pi pi-user')
71+
})
72+
73+
it('falls back to icon when image fails to load', async () => {
74+
const wrapper = mountComponent({
75+
photoUrl: 'https://example.com/broken-image.jpg'
76+
})
77+
78+
const avatar = wrapper.findComponent(Avatar)
79+
expect(avatar.props('icon')).toBeNull()
80+
81+
// Simulate image load error
82+
avatar.vm.$emit('error')
83+
await nextTick()
84+
85+
expect(avatar.props('icon')).toBe('pi pi-user')
86+
})
87+
88+
it('uses provided ariaLabel', () => {
89+
const wrapper = mountComponent({
90+
photoUrl: 'https://example.com/avatar.jpg',
91+
ariaLabel: 'Custom Label'
92+
})
93+
94+
const avatar = wrapper.findComponent(Avatar)
95+
expect(avatar.attributes('aria-label')).toBe('Custom Label')
96+
})
97+
98+
it('falls back to i18n translation when no ariaLabel is provided', () => {
99+
const wrapper = mountComponent({
100+
photoUrl: 'https://example.com/avatar.jpg'
101+
})
102+
103+
const avatar = wrapper.findComponent(Avatar)
104+
expect(avatar.attributes('aria-label')).toBe('User Avatar')
105+
})
106+
})
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<template>
2+
<Avatar
3+
:image="photoUrl ?? undefined"
4+
:icon="hasAvatar ? undefined : 'pi pi-user'"
5+
shape="circle"
6+
:aria-label="ariaLabel ?? $t('auth.login.userAvatar')"
7+
@error="handleImageError"
8+
/>
9+
</template>
10+
11+
<script setup lang="ts">
12+
import Avatar from 'primevue/avatar'
13+
import { computed, ref } from 'vue'
14+
15+
const { photoUrl, ariaLabel } = defineProps<{
16+
photoUrl?: string | null
17+
ariaLabel?: string
18+
}>()
19+
20+
const imageError = ref(false)
21+
const handleImageError = () => {
22+
imageError.value = true
23+
}
24+
const hasAvatar = computed(() => photoUrl && !imageError.value)
25+
</script>

src/components/dialog/content/ErrorDialogContent.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
icon="pi pi-exclamation-circle"
66
:title="title"
77
:message="error.exceptionMessage"
8+
:text-class="'break-words max-w-[60vw]'"
89
/>
910
<template v-if="error.extensionFile">
1011
<span>{{ t('errorDialog.extensionFileHint') }}:</span>

0 commit comments

Comments
 (0)