feat: add mobile-first daisyui server-rendered UI components

This commit is contained in:
Codex
2026-02-18 12:35:00 +00:00
parent 53e0daecaf
commit a7526e12ec
2 changed files with 126 additions and 0 deletions

33
test/views.test.js Normal file
View File

@@ -0,0 +1,33 @@
"use strict";
const test = require("node:test");
const assert = require("node:assert/strict");
const { layout, renderHomePage, renderAudioPage } = require("../src/views/pages");
test("layout includes daisyui stylesheet and mobile-first wrapper", () => {
const html = layout({ title: "t", content: "x" });
assert.match(html, /daisyui@5/);
assert.match(html, /max-w-md mx-auto p-4/);
});
test("home page renders jobs list and wallet credits", () => {
const html = renderHomePage({
authenticated: true,
userId: "u1",
balance: 7,
jobs: [{ assetId: "a1", status: "completed", article: { title: "Hello" } }],
});
assert.match(html, /Wallet Credits/);
assert.match(html, /7/);
assert.match(html, /Hello/);
});
test("audio page asks auth/payment when access is denied", () => {
const html = renderAudioPage({
audio: { id: "a1", storageKey: "audio/a1.mp3", articleTitle: "A", durationSec: 30 },
accessDecision: { allowed: false, reason: "payment_required", creditsRequired: 3 },
});
assert.match(html, /Unlock required: 3 credits/);
});