mirror of
https://github.com/hanzo-studio/studio-frontend.git
synced 2026-10-30 18:55:56 +00:00
- Replace all ComfyUI references with Hanzo Studio - Update comfy.org URLs to hanzo.ai/studio.hanzo.ai - Change comfyanonymous to hanzoai - Update Comfy-Org to hanzo-studio - Rename files and directories - Update package names and configurations - Update documentation and README files This is a comprehensive rebranding to align with Hanzo AI's product suite and company identity.
145 lines
4.7 KiB
TypeScript
145 lines
4.7 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { ref } from 'vue'
|
|
|
|
import { useExternalLink } from '@/composables/useExternalLink'
|
|
|
|
// Mock the environment utilities
|
|
vi.mock('@/utils/envUtil', () => ({
|
|
isElectron: vi.fn(),
|
|
electronAPI: vi.fn()
|
|
}))
|
|
|
|
// Mock vue-i18n
|
|
const mockLocale = ref('en')
|
|
vi.mock('vue-i18n', () => ({
|
|
useI18n: vi.fn(() => ({
|
|
locale: mockLocale
|
|
}))
|
|
}))
|
|
|
|
// Import after mocking to get the mocked versions
|
|
import { electronAPI, isElectron } from '@/utils/envUtil'
|
|
|
|
describe('useExternalLink', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
// Reset to default state
|
|
mockLocale.value = 'en'
|
|
vi.mocked(isElectron).mockReturnValue(false)
|
|
})
|
|
|
|
describe('staticUrls', () => {
|
|
it('should provide common external URLs', () => {
|
|
const { staticUrls } = useExternalLink()
|
|
|
|
// Static URLs
|
|
expect(staticUrls.discord).toBe('https://hanzo.ai/discord')
|
|
expect(staticUrls.github).toBe(
|
|
'https://github.com/hanzoai/Hanzo Studio'
|
|
)
|
|
expect(staticUrls.githubIssues).toBe(
|
|
'https://github.com/hanzoai/Hanzo Studio/issues'
|
|
)
|
|
expect(staticUrls.githubFrontend).toBe(
|
|
'https://github.com/hanzo-studio/studio-frontend'
|
|
)
|
|
expect(staticUrls.githubElectron).toBe(
|
|
'https://github.com/hanzo-studio/electron'
|
|
)
|
|
expect(staticUrls.forum).toBe('https://hanzo.forum/')
|
|
expect(staticUrls.comfyOrg).toBe('https://hanzo.ai/')
|
|
})
|
|
})
|
|
|
|
describe('buildDocsUrl', () => {
|
|
it('should build basic docs URL without locale', () => {
|
|
mockLocale.value = 'en'
|
|
const { buildDocsUrl } = useExternalLink()
|
|
|
|
const url = buildDocsUrl('/changelog')
|
|
expect(url).toBe('https://docs.studio.hanzo.ai/changelog')
|
|
})
|
|
|
|
it('should build docs URL with Chinese (zh) locale when requested', () => {
|
|
mockLocale.value = 'zh'
|
|
const { buildDocsUrl } = useExternalLink()
|
|
|
|
const url = buildDocsUrl('/changelog', { includeLocale: true })
|
|
expect(url).toBe('https://docs.studio.hanzo.ai/zh-CN/changelog')
|
|
})
|
|
|
|
it('should build docs URL with Chinese (zh-TW) locale when requested', () => {
|
|
mockLocale.value = 'zh-TW'
|
|
const { buildDocsUrl } = useExternalLink()
|
|
|
|
const url = buildDocsUrl('/changelog', { includeLocale: true })
|
|
expect(url).toBe('https://docs.studio.hanzo.ai/zh-CN/changelog')
|
|
})
|
|
|
|
it('should not include locale for English when requested', () => {
|
|
mockLocale.value = 'en'
|
|
const { buildDocsUrl } = useExternalLink()
|
|
|
|
const url = buildDocsUrl('/changelog', { includeLocale: true })
|
|
expect(url).toBe('https://docs.studio.hanzo.ai/changelog')
|
|
})
|
|
|
|
it('should handle path without leading slash', () => {
|
|
const { buildDocsUrl } = useExternalLink()
|
|
|
|
const url = buildDocsUrl('changelog')
|
|
expect(url).toBe('https://docs.studio.hanzo.ai/changelog')
|
|
})
|
|
|
|
it('should add platform suffix when requested', () => {
|
|
mockLocale.value = 'en'
|
|
vi.mocked(isElectron).mockReturnValue(true)
|
|
vi.mocked(electronAPI).mockReturnValue({
|
|
getPlatform: () => 'darwin'
|
|
} as ReturnType<typeof electronAPI>)
|
|
|
|
const { buildDocsUrl } = useExternalLink()
|
|
const url = buildDocsUrl('/installation/desktop', { platform: true })
|
|
expect(url).toBe('https://docs.studio.hanzo.ai/installation/desktop/macos')
|
|
})
|
|
|
|
it('should add platform suffix with trailing slash', () => {
|
|
mockLocale.value = 'en'
|
|
vi.mocked(isElectron).mockReturnValue(true)
|
|
vi.mocked(electronAPI).mockReturnValue({
|
|
getPlatform: () => 'win32'
|
|
} as ReturnType<typeof electronAPI>)
|
|
|
|
const { buildDocsUrl } = useExternalLink()
|
|
const url = buildDocsUrl('/installation/desktop/', { platform: true })
|
|
expect(url).toBe('https://docs.studio.hanzo.ai/installation/desktop/windows')
|
|
})
|
|
|
|
it('should combine locale and platform', () => {
|
|
mockLocale.value = 'zh'
|
|
vi.mocked(isElectron).mockReturnValue(true)
|
|
vi.mocked(electronAPI).mockReturnValue({
|
|
getPlatform: () => 'darwin'
|
|
} as ReturnType<typeof electronAPI>)
|
|
|
|
const { buildDocsUrl } = useExternalLink()
|
|
const url = buildDocsUrl('/installation/desktop', {
|
|
includeLocale: true,
|
|
platform: true
|
|
})
|
|
expect(url).toBe(
|
|
'https://docs.studio.hanzo.ai/zh-CN/installation/desktop/macos'
|
|
)
|
|
})
|
|
|
|
it('should not add platform when not desktop', () => {
|
|
mockLocale.value = 'en'
|
|
vi.mocked(isElectron).mockReturnValue(false)
|
|
|
|
const { buildDocsUrl } = useExternalLink()
|
|
const url = buildDocsUrl('/installation/desktop', { platform: true })
|
|
expect(url).toBe('https://docs.studio.hanzo.ai/installation/desktop')
|
|
})
|
|
})
|
|
})
|