kaikai_test/test/mobile-offline-drafts.test.js
2026-05-14 18:53:53 +08:00

30 lines
1.1 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
const html = await readFile(new URL("../public/mobile.html", import.meta.url), "utf8");
const css = await readFile(new URL("../public/mobile.css", import.meta.url), "utf8");
const js = await readFile(new URL("../public/mobile.js", import.meta.url), "utf8");
test("mobile page exposes offline draft fields and list", () => {
assert.match(html, /id="mobile-note"/);
assert.match(html, /id="save-offline-button"/);
assert.match(html, /id="offline-count"/);
assert.match(html, /id="offline-list"/);
assert.match(html, /id="clear-offline-button"/);
});
test("mobile app stores offline drafts locally", () => {
assert.match(js, /MOBILE_DRAFTS_KEY/);
assert.match(js, /localStorage/);
assert.match(js, /saveOfflineDraft/);
assert.match(js, /renderOfflineDrafts/);
assert.match(js, /readOfflineDrafts/);
});
test("mobile offline drafts have distinct compact styling", () => {
assert.match(css, /\.offline-panel/);
assert.match(css, /\.offline-item/);
assert.match(css, /\.draft-actions/);
});