test(pwa): add PWA install spec (manifest, icons, SW registration)

This commit is contained in:
Tyler
2026-06-17 14:35:31 -06:00
parent 6fc641a8d4
commit 827b9ef318
+37
View File
@@ -0,0 +1,37 @@
// tests/mobile-admin/pwa-install.spec.ts
import { test, expect } from "@playwright/test";
test.use({ viewport: { width: 390, height: 844 } }); // iPhone 13
test("PWA manifest is valid and all icons resolve", async ({ page, request }) => {
await page.goto("/admin/login");
const manifestLink = await page.locator('link[rel="manifest"]').getAttribute("href");
expect(manifestLink).toBe("/manifest.json");
const manifestRes = await request.get("/manifest.json");
expect(manifestRes.status()).toBe(200);
const manifest = await manifestRes.json();
expect(manifest.name).toBe("Route Commerce");
expect(manifest.theme_color).toBe("#166534");
for (const icon of manifest.icons) {
const r = await request.get(icon.src);
expect(r.status(), `icon ${icon.src} should resolve`).toBe(200);
}
});
test("apple-touch-icon is present in head", async ({ page }) => {
await page.goto("/admin/login");
const appleTouch = await page.locator('link[rel="apple-touch-icon"]').count();
expect(appleTouch).toBeGreaterThan(0);
});
test("service worker registers successfully", async ({ page }) => {
await page.goto("/admin/login");
const swReady = await page.evaluate(async () => {
if (!("serviceWorker" in navigator)) return false;
const reg = await navigator.serviceWorker.ready;
return !!reg.active;
});
expect(swReady).toBe(true);
});