feat(web): icons and the web manifest are public for browsers and app installers
This commit is contained in:
@@ -62,3 +62,30 @@ test("explains how to build the app when it is missing", async (t) => {
|
||||
assert.equal(page.status, 503);
|
||||
assert.match(await page.text(), /\.\/install --web/);
|
||||
});
|
||||
|
||||
test("icons and the manifest need no sign-in; the app does", async (t) => {
|
||||
const dir = await mkdtemp(join(tmpdir(), "serve-"));
|
||||
const root = join(dir, "app");
|
||||
await mkdir(join(root, "icons"), { recursive: true });
|
||||
await writeFile(join(root, "index.html"), "<html><head></head></html>");
|
||||
await writeFile(join(root, "favicon.png"), "png");
|
||||
await writeFile(join(root, "manifest.json"), "{}");
|
||||
await writeFile(join(root, "icons", "Icon-192.png"), "png");
|
||||
await writeFile(join(root, "main.dart.js"), "app");
|
||||
const auth = join(dir, "auth.json");
|
||||
await writeFile(auth, JSON.stringify({ password: "password-1", secret: "s".repeat(40) }));
|
||||
const port = await freePort();
|
||||
const child = spawn(process.execPath, ["serve.mjs", "--port", String(port), "--root", root], {
|
||||
cwd: here,
|
||||
env: { ...process.env, PIPELINES_WEB_AUTH: "", PIPELINES_WEB_AUTH_FILE: auth },
|
||||
stdio: ["ignore", "pipe", "inherit"],
|
||||
});
|
||||
await new Promise((done) => child.stdout.once("data", done));
|
||||
t.after(() => child.kill());
|
||||
const base = `http://127.0.0.1:${port}`;
|
||||
for (const path of ["/favicon.png", "/favicon.svg", "/manifest.json", "/icons/Icon-192.png"]) {
|
||||
assert.equal((await fetch(base + path)).status, 200, path);
|
||||
}
|
||||
assert.equal((await fetch(`${base}/main.dart.js`)).status, 401);
|
||||
assert.equal((await fetch(`${base}/icons/../main.dart.js`)).status, 401);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user