import { describe, expect, test } from 'bun:test' import { existsSync, readdirSync, readFileSync } from 'node:fs' import { resolve } from 'node:path' import { describeAuthError, isLoginResponse, isTwoFactorChallenge, safeAuthRedirect } from '../../storage/framework/defaults/functions/auth' const dashboardComponents = resolve( 'storage/framework/defaults/resources/components/Dashboard', ) const dashboardResourceViews = resolve( 'storage/framework/defaults/resources/views/dashboard', ) const dashboardViews = resolve( 'storage/framework/defaults/views/dashboard', ) const dashboardComponentBarrel = resolve( 'storage/framework/defaults/resources/components/Dashboard/index.ts', ) function componentSource(path: string): string { return readFileSync(resolve(dashboardComponents, path), 'utf8') } function staticClassLists(source: string): string[][] { return Array.from(source.matchAll(/(?:^|\s)class="([^"]*)"/g), match => match[1]!.split(/\s+/).filter(Boolean)) } interface TestSignal { (): T set: (value: T) => void } function testSignal(initial: T): TestSignal { let value = initial const signal = (() => value) as TestSignal signal.set = (next: T) => { value = next } return signal } function loginDashboardHarness(options: { login: (credentials: unknown) => Promise verify: (challengeToken: string, code: string) => Promise redirect?: string next?: string navigate?: (target: string, options: unknown) => void }) { const source = componentSource('Auth/LoginDashboard.stx') const script = source.match(/