import { readFileSync } from 'node:fs' import { describe, expect, it } from 'vitest' const viewSource = readFileSync( new URL('./SpringboardView.vue', import.meta.url), 'utf8', ) const appSource = readFileSync(new URL('../App.vue', import.meta.url), 'utf8') const appIconSource = readFileSync( new URL('../components/AppIcon.vue', import.meta.url), 'utf8', ) const folderIconSource = readFileSync( new URL('../components/HomeFolderIcon.vue', import.meta.url), 'utf8', ) const mainCss = readFileSync( new URL('../assets/main.css', import.meta.url), 'utf8', ) const tokensCss = readFileSync( new URL('../ui/tokens.css', import.meta.url), 'utf8', ) const foundationCss = readFileSync( new URL('../ui/foundation.css', import.meta.url), 'utf8', ) const builtInWallpaperCss = mainCss.slice( mainCss.indexOf('.wallpaper--midnight'), mainCss.indexOf('.wallpaper--custom'), ) const folderOverlayBlock = viewSource.match(//)?.[0] ?? '' function handlerName(block: string, event: string): string { return ( block.match(new RegExp(`@${event}="([A-Za-z][A-Za-z0-9_]*)"`))?.[1] ?? '' ) } function functionSource(name: string): string { if (!name) return '' const start = viewSource.indexOf(`function ${name}(`) if (start < 0) return '' const next = viewSource.indexOf('\nfunction ', start + 1) return viewSource.slice(start, next < 0 ? viewSource.length : next) } describe('Springboard page swipe contract', () => { it('keeps app and widget labels on the larger shared home typography', () => { expect(tokensCss).toContain('--sky-home-label-font-size: 13px;') expect(tokensCss).toContain('--sky-home-label-height: 16px;') expect(mainCss).toMatch( /\.app-icon-label\s*\{[\s\S]*?font-size:\s*var\(--sky-home-label-font-size\);/, ) expect(foundationCss).toMatch( /\.sky-widget-frame__label\s*\{[\s\S]*?font-size:\s*var\(--sky-home-label-font-size\);/, ) }) it('keeps the built-in wallpapers visually restrained', () => { expect(builtInWallpaperCss).not.toMatch(/(?:conic|repeating-\w+)-gradient/) expect(builtInWallpaperCss.match(/radial-gradient/g)).toHaveLength(12) expect(builtInWallpaperCss.match(/linear-gradient/g)).toHaveLength(12) }) it('replaces the home status row with the edit controls', () => { expect(viewSource).toContain("emit('editModeChange', editing)") expect(viewSource).toContain("emit('editModeChange', false)") expect(appSource).toContain( '@edit-mode-change="springboardEditing = $event"', ) expect(appSource).toMatch( /v-if="\s*!isLocked && !\(isHomeRoute && springboardEditing\)\s*"/, ) expect(mainCss).toMatch( /\.springboard-edit-add\s*\{[^}]*top:\s*14px;[^}]*left:\s*28px;[^}]*width:\s*58px;[^}]*height:\s*30px;/s, ) expect(mainCss).toMatch( /\.springboard-edit-done\s*\{[^}]*top:\s*14px;[^}]*right:\s*28px;[^}]*width:\s*58px;[^}]*height:\s*30px;/s, ) expect(viewSource).toContain( '