Files
pitchfast/tests/campaigns-board-layout.test.ts

43 lines
1.4 KiB
TypeScript

import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import test from "node:test";
const campaignsBoardPath = join(
process.cwd(),
"components",
"campaigns",
"campaigns-board.tsx",
);
test("campaign board renders campaigns as responsive cards", async () => {
const source = await readFile(campaignsBoardPath, "utf8");
assert.doesNotMatch(source, /<table\b/i);
assert.doesNotMatch(source, /<thead\b/i);
assert.doesNotMatch(source, /<tbody\b/i);
assert.doesNotMatch(source, /<tr\b/i);
assert.doesNotMatch(source, /<td\b/i);
assert.doesNotMatch(source, /<th\b/i);
assert.doesNotMatch(source, /md:hidden/i);
assert.doesNotMatch(source, /md:block/i);
assert.match(source, /className="grid gap-3 sm:grid-cols-2 xl:grid-cols-3"/);
assert.match(source, /<Card[^>]+aria-labelledby=\{campaignTitleId\}/);
assert.match(source, /id=\{campaignTitleId\}/);
assert.match(source, /openEditDialog\(campaign\)/);
assert.match(source, /toggleCampaign\(campaign\)/);
assert.match(source, /runCampaign\(campaign\)/);
});
test("campaign board surfaces recent run logs", async () => {
const source = await readFile(campaignsBoardPath, "utf8");
assert.match(source, /api\.runs\.list/);
assert.match(source, /type:\s*"campaign"/);
assert.match(source, /Aktuelle Run-Logs/);
assert.match(source, /run\.errorSummary/);
assert.match(source, /campaign_cron_skipped/);
});