mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
Backport of #10337 to `cloud/1.42` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10744-backport-cloud-1-42-feat-App-mode-Switch-to-Nodes-2-0-when-entering-builder-3336d73d365081b0829fc9d00a55b8f0) by [Unito](https://www.unito.io) Co-authored-by: pythongosssss <125205205+pythongosssss@users.noreply.github.com>
79 lines
2.2 KiB
TypeScript
79 lines
2.2 KiB
TypeScript
import { mount } from '@vue/test-utils'
|
|
import type { ComponentProps } from 'vue-component-type-helpers'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { createI18n } from 'vue-i18n'
|
|
|
|
import NotificationPopup from './NotificationPopup.vue'
|
|
|
|
const i18n = createI18n({
|
|
legacy: false,
|
|
locale: 'en',
|
|
messages: {
|
|
en: { g: { close: 'Close' } }
|
|
}
|
|
})
|
|
|
|
function mountPopup(
|
|
props: ComponentProps<typeof NotificationPopup> = {
|
|
title: 'Test'
|
|
},
|
|
slots: Record<string, string> = {}
|
|
) {
|
|
return mount(NotificationPopup, {
|
|
global: { plugins: [i18n] },
|
|
props,
|
|
slots
|
|
})
|
|
}
|
|
|
|
describe('NotificationPopup', () => {
|
|
it('renders title', () => {
|
|
const wrapper = mountPopup({ title: 'Hello World' })
|
|
expect(wrapper.text()).toContain('Hello World')
|
|
})
|
|
|
|
it('has role="status" for accessibility', () => {
|
|
const wrapper = mountPopup()
|
|
expect(wrapper.find('[role="status"]').exists()).toBe(true)
|
|
})
|
|
|
|
it('renders subtitle when provided', () => {
|
|
const wrapper = mountPopup({ title: 'T', subtitle: 'v1.2.3' })
|
|
expect(wrapper.text()).toContain('v1.2.3')
|
|
})
|
|
|
|
it('renders icon when provided', () => {
|
|
const wrapper = mountPopup({
|
|
title: 'T',
|
|
icon: 'icon-[lucide--rocket]'
|
|
})
|
|
expect(wrapper.find('i.icon-\\[lucide--rocket\\]').exists()).toBe(true)
|
|
})
|
|
|
|
it('emits close when close button clicked', async () => {
|
|
const wrapper = mountPopup({ title: 'T', showClose: true })
|
|
await wrapper.find('[aria-label="Close"]').trigger('click')
|
|
expect(wrapper.emitted('close')).toHaveLength(1)
|
|
})
|
|
|
|
it('renders default slot content', () => {
|
|
const wrapper = mountPopup({ title: 'T' }, { default: 'Body text here' })
|
|
expect(wrapper.text()).toContain('Body text here')
|
|
})
|
|
|
|
it('renders footer slots', () => {
|
|
const wrapper = mountPopup(
|
|
{ title: 'T' },
|
|
{ 'footer-start': 'Left side', 'footer-end': 'Right side' }
|
|
)
|
|
expect(wrapper.text()).toContain('Left side')
|
|
expect(wrapper.text()).toContain('Right side')
|
|
})
|
|
|
|
it('positions bottom-right when specified', () => {
|
|
const wrapper = mountPopup({ title: 'T', position: 'bottom-right' })
|
|
const root = wrapper.find('[role="status"]')
|
|
expect(root.attributes('data-position')).toBe('bottom-right')
|
|
})
|
|
})
|