import { afterEach, describe, expect, it } from 'vitest' import { resolvePluginFrontendBase } from '../../composables/pluginFrontendBase' type InjectedPlatformWindow = Window & { __MINT_PLATFORM__?: unknown } describe('resolvePluginFrontendBase', () => { afterEach(() => { delete (window as InjectedPlatformWindow).__MINT_PLATFORM__ }) it('should use the normalized route prefix when the platform context is integrated', () => { ;(window as InjectedPlatformWindow).__MINT_PLATFORM__ = { isIntegrated: true, theme: 'light', plugin: { id: 'leaf', name: 'LEAF', version: '0.7.0', route_prefix: '/leaf///', api_prefix: '/api/leaf', }, } expect(resolvePluginFrontendBase('./')).toBe('/leaf/') }) it('should preserve the caller fallback when the platform context is absent', () => { expect(resolvePluginFrontendBase('./')).toBe('./') }) it('should preserve the caller fallback when the platform context is standalone', () => { ;(window as InjectedPlatformWindow).__MINT_PLATFORM__ = { isIntegrated: false, theme: 'light', plugin: { id: 'leaf', name: 'LEAF', version: '0.7.0', route_prefix: '/leaf', api_prefix: '/api/leaf', }, } expect(resolvePluginFrontendBase('/dev/')).toBe('/dev/') }) it('should preserve root when the integrated route prefix is root', () => { ;(window as InjectedPlatformWindow).__MINT_PLATFORM__ = { isIntegrated: true, theme: 'light', plugin: { id: 'root', name: 'Root', version: '1.0.0', route_prefix: '/', api_prefix: '/api', }, } expect(resolvePluginFrontendBase('./')).toBe('/') }) })