-
Notifications
You must be signed in to change notification settings - Fork 673
Expand file tree
/
Copy pathextensionService.test.ts
More file actions
61 lines (52 loc) · 1.87 KB
/
Copy pathextensionService.test.ts
File metadata and controls
61 lines (52 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { describe, expect, it, vi } from 'vitest'
import { defineComponent } from 'vue'
import { useBottomPanelStore } from '@/stores/workspace/bottomPanelStore'
import type { ComfyExtension } from '@/types/comfy'
import { shouldLoadExtension, useExtensionService } from './extensionService'
describe('shouldLoadExtension', () => {
it.for(['/extensions/cloud/rum.js', '/extensions/cloud/sentry.js'])(
'skips the inlined Cloud extension %s in cloud builds',
(extension) => {
expect(shouldLoadExtension(extension, true)).toBe(false)
}
)
it.for(['/extensions/cloud/rum.js', '/extensions/cloud/sentry.js'])(
'keeps the legacy path %s available outside cloud builds',
(extension) => {
expect(shouldLoadExtension(extension, false)).toBe(true)
}
)
it('skips core extensions that load through the core entry point', () => {
expect(shouldLoadExtension('/extensions/core/foo.js', false)).toBe(false)
})
it('loads other extensions', () => {
expect(shouldLoadExtension('/extensions/comfyui-foo/main.js', true)).toBe(
true
)
})
})
describe('registerExtension', () => {
it('does not re-run registration side effects for a duplicate name', () => {
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {})
try {
const extension: ComfyExtension = {
name: 'dup.ext',
bottomPanelTabs: [
{
id: 'dup.tab',
title: 'Dup',
type: 'vue',
component: defineComponent({ render: () => null })
}
]
}
const extensionService = useExtensionService()
extensionService.registerExtension(extension)
extensionService.registerExtension(extension)
const bottomPanelStore = useBottomPanelStore()
expect(bottomPanelStore.panels.terminal.tabs).toHaveLength(1)
} finally {
warnSpy.mockRestore()
}
})
})