52 lines
1.8 KiB
JavaScript
52 lines
1.8 KiB
JavaScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
const testDir = path.dirname(fileURLToPath(import.meta.url));
|
|
const projectRoot = path.resolve(testDir, "../..");
|
|
|
|
function readProjectFile(...segments) {
|
|
return fs.readFileSync(path.join(projectRoot, ...segments), "utf8");
|
|
}
|
|
|
|
function readProjectJson(...segments) {
|
|
return JSON.parse(readProjectFile(...segments));
|
|
}
|
|
|
|
describe("PWA Android metadata", () => {
|
|
it("targets the current Android API level for native wrapper installs", () => {
|
|
const gradleSource = readProjectFile("app", "build.gradle");
|
|
const stagingGradleSource = readProjectFile("output", "staging", "app", "build.gradle");
|
|
const twaManifest = readProjectJson("twa-manifest.json");
|
|
|
|
expect(gradleSource).toContain("targetSdkVersion 36");
|
|
expect(gradleSource).toContain("versionCode 7");
|
|
expect(gradleSource).toContain('versionName "7"');
|
|
expect(stagingGradleSource).toContain("targetSdkVersion 36");
|
|
expect(twaManifest.appVersionCode).toBe(7);
|
|
expect(twaManifest.appVersionName).toBe("7");
|
|
expect(twaManifest.appVersion).toBe("7");
|
|
});
|
|
|
|
it("uses a stable production PWA manifest identity", () => {
|
|
const publicManifest = readProjectJson("public", "manifest.json");
|
|
const embeddedManifest = readProjectJson("app", "src", "main", "res", "raw", "web_app_manifest.json");
|
|
const stagingEmbeddedManifest = readProjectJson(
|
|
"output",
|
|
"staging",
|
|
"app",
|
|
"src",
|
|
"main",
|
|
"res",
|
|
"raw",
|
|
"web_app_manifest.json"
|
|
);
|
|
|
|
expect(publicManifest.id).toBe("/");
|
|
expect(embeddedManifest.id).toBe("/");
|
|
expect(stagingEmbeddedManifest.id).toBe("/");
|
|
expect(JSON.stringify([publicManifest, embeddedManifest, stagingEmbeddedManifest])).not.toContain("pleno-pwa-test");
|
|
});
|
|
});
|