2026-05-05 11:29:18 -04:00
|
|
|
import { describe, expect, it, vi, beforeEach } from 'vitest'
|
|
|
|
|
import { mount } from '@vue/test-utils'
|
|
|
|
|
import { createPinia, setActivePinia } from 'pinia'
|
|
|
|
|
import { PackageState, type PackageDataEntry } from '@/types/api'
|
|
|
|
|
import { useAppLauncherStore } from '@/stores/appLauncher'
|
|
|
|
|
import AppIconGrid from '../AppIconGrid.vue'
|
|
|
|
|
|
|
|
|
|
const mockWindowOpen = vi.fn()
|
|
|
|
|
|
|
|
|
|
vi.stubGlobal('open', mockWindowOpen)
|
|
|
|
|
|
|
|
|
|
function makePkg(id: string): PackageDataEntry {
|
|
|
|
|
return {
|
|
|
|
|
state: PackageState.Running,
|
|
|
|
|
manifest: {
|
|
|
|
|
id,
|
|
|
|
|
title: id,
|
|
|
|
|
version: '1.0.0',
|
|
|
|
|
description: { short: '', long: '' },
|
|
|
|
|
'release-notes': '',
|
|
|
|
|
license: '',
|
|
|
|
|
'wrapper-repo': '',
|
|
|
|
|
'upstream-repo': '',
|
|
|
|
|
'support-site': '',
|
|
|
|
|
'marketing-site': '',
|
|
|
|
|
'donation-url': null,
|
|
|
|
|
interfaces: { main: { ui: true } },
|
|
|
|
|
} as unknown as PackageDataEntry['manifest'],
|
|
|
|
|
'static-files': { license: '', instructions: '', icon: '' },
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('AppIconGrid', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
setActivePinia(createPinia())
|
|
|
|
|
vi.clearAllMocks()
|
|
|
|
|
localStorage.clear()
|
2026-05-19 17:20:32 -04:00
|
|
|
Object.defineProperty(window, 'innerWidth', {
|
|
|
|
|
value: 1024,
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true,
|
|
|
|
|
})
|
2026-05-05 11:29:18 -04:00
|
|
|
Object.defineProperty(window, 'location', {
|
|
|
|
|
value: { hostname: '192.168.1.198' },
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('opens LND companion UI in the app panel', async () => {
|
|
|
|
|
const wrapper = mount(AppIconGrid, {
|
|
|
|
|
props: { apps: [['lnd', makePkg('lnd')]] },
|
|
|
|
|
global: {
|
|
|
|
|
plugins: [createPinia()],
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await wrapper.get('.app-icon-item').trigger('click')
|
|
|
|
|
|
|
|
|
|
expect(mockWindowOpen).not.toHaveBeenCalled()
|
|
|
|
|
expect(useAppLauncherStore().panelAppId).toBe('lnd')
|
|
|
|
|
})
|
2026-05-19 17:20:32 -04:00
|
|
|
|
2026-05-19 18:29:04 -04:00
|
|
|
it('routes desktop new-tab apps through app session on mobile', async () => {
|
2026-05-19 17:20:32 -04:00
|
|
|
Object.defineProperty(window, 'innerWidth', {
|
|
|
|
|
value: 390,
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const wrapper = mount(AppIconGrid, {
|
|
|
|
|
props: { apps: [['gitea', makePkg('gitea')]] },
|
|
|
|
|
global: {
|
|
|
|
|
plugins: [createPinia()],
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await wrapper.get('.app-icon-item').trigger('click')
|
|
|
|
|
|
|
|
|
|
expect(mockWindowOpen).not.toHaveBeenCalled()
|
2026-05-19 18:29:04 -04:00
|
|
|
expect(useAppLauncherStore().panelAppId).toBeNull()
|
2026-05-19 17:20:32 -04:00
|
|
|
})
|
2026-05-05 11:29:18 -04:00
|
|
|
})
|