char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
92d1bb0c9
char/aliceai-t5-moe
1import { expect , test } from '@playwright/test' ; 2 3test . describe ( 'PWA Service Worker' , () => { 4test ( 'service worker is registered' , async ({ page}) => { 5await page . goto ( '/' ); 6 7const swURL = await page . evaluate ( async () => { 8const registration = await Promise . race ([ 9// eslint-disable-next-line @typescript-eslint/ban-ts-comment 10// @ts-ignore - type inference differs from browser runtime 11navigator . serviceWorker . ready , 12new Promise (( _ , reject ) => 13setTimeout (() => reject ( new Error ( 'Service worker registration failed: timeout' )), 15000 ) 14) 15]); 16 17// @ts-expect-error registration is of type unknown 18return registration . active ?. scriptURL ; 19}); 20 21expect ( swURL ). toBeTruthy (); 22expect ( swURL ). toContain ( '/sw.js' ); 23}); 24 25test ( 'service worker has precache configured' , async ({ page}) => { 26await page . goto ( '/' ); 27 28await page . evaluate ( async () => { 29await navigator . serviceWorker . ready ; 30}); 31 32const swActive = await page . evaluate ( async () => { 33const reg = await navigator . serviceWorker . ready ; 34 35return reg . active ?. scriptURL ?? null ; 36}); 37 38expect ( swActive ). toBeTruthy (); 39 40const swResponse = await page . request . get ( swActive ! ); 41const swContent = await swResponse . text (); 42 43// Precache contains SvelteKit content-hashed bundle paths 44expect ( swContent ). toMatch ( / "_app\/immutable\/bundle\.[a-zA-Z0-9_-]+\.js" / ); 45expect ( swContent ). toMatch ( / "_app\/immutable\/assets\/bundle\.[a-zA-Z0-9_-]+\.css" / ); 46expect ( swContent ). toMatch ( / "manifest\.webmanifest" / ); 47expect ( swContent ). toMatch ( / "_app\/version\.json" / ); 48// NavigationRoute is intentionally absent — server API endpoints 49// (e.g. /slots, /models) must not be intercepted by the PWA and 50// should return JSON directly from the server. 51expect ( swContent ). not . toMatch ( / NavigationRoute / ); 52expect ( swContent ). toMatch ( / api-cache / ); 53}); 54 55test ( 'offline mode - page loads when offline after caching' , async ({ browser}) => { 56const context = await browser . newContext (); 57const offlinePage = await context . newPage (); 58 59await offlinePage . goto ( '/' ); 60await offlinePage . waitForLoadState ( 'networkidle' ); 61 62await offlinePage . evaluate ( async () => { 63await navigator . serviceWorker . ready ; 64}); 65 66await offlinePage . waitForTimeout ( 2000 ); 67 68await context . setOffline ( true ); 69await offlinePage . goto ( '/' ); 70 71const bodyText = await offlinePage . locator ( 'body' ). textContent (); 72 73expect ( bodyText ). toBeTruthy (); 74 75await context . close (); 76}); 77 78test ( 'version.json is accessible and contains version' , async ({ page}) => { 79const versionResponse = await page . request . get ( '/_app/version.json' ); 80 81expect ( versionResponse . ok ()). toBeTruthy (); 82 83const versionData = await versionResponse . json (); 84 85expect ( versionData ). toHaveProperty ( 'version' ); 86expect ( typeof versionData . version ). toBe ( 'string' ); 87expect ( versionData . version . length ). toBeGreaterThan ( 0 ); 88}); 89 90test ( 'manifest.webmanifest is accessible and valid' , async ({ page}) => { 91const response = await page . request . get ( '/manifest.webmanifest' ); 92 93expect ( response . ok ()). toBeTruthy (); 94 95const manifest = await response . json (); 96 97expect ( manifest ). toHaveProperty ( 'name' , 'llama-ui' ); 98expect ( manifest ). toHaveProperty ( 'short_name' , 'llama-ui' ); 99expect ( manifest ). toHaveProperty ( 'start_url' , './' ); 100expect ( manifest ). toHaveProperty ( 'display' , 'standalone' ); 101expect ( manifest . icons ). toBeTruthy (); 102expect ( manifest . icons . length ). toBeGreaterThan ( 0 ); 103}); 104 105test ( 'index.html contains content-hashed bundle references' , async ({ page}) => { 106const response = await page . request . get ( '/' ); 107 108expect ( response . ok ()). toBeTruthy (); 109 110const html = await response . text (); 111 112// SvelteKit outputs content-hashed bundle names in _app/immutable/ 113expect ( html ). toMatch ( / href="(\.\/|\/)_app\/immutable\/bundle\.[a-zA-Z0-9_-]+\.js" / ); 114expect ( html ). toMatch ( / href="(\.\/|\/)_app\/immutable\/assets\/bundle\.[a-zA-Z0-9_-]+\.css" / ); 115expect ( html ). toMatch ( / import\("(\.\/|\/)_app\/immutable\/bundle\.[a-zA-Z0-9_-]+\.js"\) / ); 116}); 117});