mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +00:00
test: assert PWA manifest branding
This commit is contained in:
parent
8fdce3c65a
commit
d49d0fe7c1
2 changed files with 35 additions and 1 deletions
33
config/pwa-manifest.test.ts
Normal file
33
config/pwa-manifest.test.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { readFileSync, existsSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const root = path.resolve(__dirname, "..");
|
||||
const manifest = JSON.parse(readFileSync(path.join(root, "public/manifest.json"), "utf-8")) as {
|
||||
name: string;
|
||||
short_name: string;
|
||||
theme_color: string;
|
||||
icons: Array<{ src: string }>;
|
||||
};
|
||||
const indexHtml = readFileSync(path.join(root, "index.html"), "utf-8");
|
||||
|
||||
describe("PWA install metadata", () => {
|
||||
it("identifies the app as Sea Haven, not template branding", () => {
|
||||
expect(manifest.name).toContain("Sea Haven");
|
||||
expect(manifest.short_name).not.toBe("React App");
|
||||
expect(manifest.name).not.toContain("Create React App");
|
||||
});
|
||||
|
||||
it("uses the design-system theme color, matching index.html", () => {
|
||||
expect(manifest.theme_color).toBe("#1c75bc");
|
||||
expect(indexHtml).toContain(`<meta name="theme-color" content="${manifest.theme_color}" />`);
|
||||
});
|
||||
|
||||
it("only references icon files that exist in public/", () => {
|
||||
for (const icon of manifest.icons) {
|
||||
expect(existsSync(path.join(root, "public", icon.src)), `missing public/${icon.src}`).toBe(
|
||||
true,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
"vite.config.ts",
|
||||
"vitest.config.ts",
|
||||
"config/api-url-contract.ts",
|
||||
"config/api-url-contract.test.ts"
|
||||
"config/api-url-contract.test.ts",
|
||||
"config/pwa-manifest.test.ts"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue