const { test } = require("node:test"); const assert = require("node:assert"); const { renderLoginPage, renderDashboardPage, renderTempKeyPage } = require("../src/adminView"); test("renderLoginPage includes a master key input form", () => { const html = renderLoginPage(); assert.ok(html.includes('name="masterKey"')); assert.ok(html.includes(" { const html = renderLoginPage("Master Keyが正しくありません"); assert.ok(html.includes("Master Keyが正しくありません")); }); test("renderDashboardPage lists each record's key, account, and status", () => { const html = renderDashboardPage({ records: [{ key: "lineworks-form-sync", account: "svc@example.co.jp", status: "有効", expiresAt: "2026-08-24T01:00:00.000Z" }], message: null, }); assert.ok(html.includes("lineworks-form-sync")); assert.ok(html.includes("svc@example.co.jp")); assert.ok(html.includes("有効")); }); test("renderDashboardPage includes a new-registration form with only an account field (連携キーはアカウントのローカル部から自動生成、入力不要)", () => { const html = renderDashboardPage({ records: [], message: null }); assert.ok(html.includes('name="account"')); assert.ok(!html.includes('name="key"')); }); test("renderDashboardPage includes a temp-key issuance button (Master Keyを共有せずに済む導線)", () => { const html = renderDashboardPage({ records: [], message: null }); assert.ok(html.includes('action="/auth/temp-key"')); }); test("renderTempKeyPage shows the shareable one-time login URL", () => { const html = renderTempKeyPage({ url: "https://lwauth29.next-hd.net/auth/login?tempKey=abc" }); assert.ok(html.includes("https://lwauth29.next-hd.net/auth/login?tempKey=abc")); });