From 827b9ef318d468c2008306375269addc6ce3aa9e Mon Sep 17 00:00:00 2001 From: Tyler Date: Wed, 17 Jun 2026 14:35:31 -0600 Subject: [PATCH] test(pwa): add PWA install spec (manifest, icons, SW registration) --- tests/mobile-admin/pwa-install.spec.ts | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/mobile-admin/pwa-install.spec.ts diff --git a/tests/mobile-admin/pwa-install.spec.ts b/tests/mobile-admin/pwa-install.spec.ts new file mode 100644 index 0000000..19a67ec --- /dev/null +++ b/tests/mobile-admin/pwa-install.spec.ts @@ -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); +});