mirror of
https://github.com/bitbaum/bip-kit.git
synced 2026-12-03 22:57:06 +01:00
Votes (needed / not needed) on roadmap items, comments on changelog entries, and suggestions with duplicate detection as you type — for every product that renders its roadmap and changelog through bip-kit. Headless: a FeedbackStore contract the product implements over its own database (memoryStore is the reference), shared rules (screenText, honeypot, one stance per voter, findSimilar without a model, Wilson ranking), a Web-standard GET/POST handler, and client components whose every word is a prop. RoadmapItem.id and ChangelogEntry.id (optional) keep one tally across translations. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { createElement as h } from "react";
|
|
import { renderToString } from "react-dom/server";
|
|
import { FeedbackProvider, StanceButtons, CommentThread, SuggestBox } from "../dist/react/index.js";
|
|
|
|
test("the feedback components render inside a provider, with the app's labels", () => {
|
|
const html = renderToString(
|
|
h(
|
|
FeedbackProvider,
|
|
{
|
|
endpoint: "/api/feedback",
|
|
targetIds: ["roadmap:teams"],
|
|
labels: { needed: "Brauche ich" },
|
|
},
|
|
h(StanceButtons, { targetId: "roadmap:teams" }),
|
|
h(CommentThread, { targetId: "roadmap:teams" }),
|
|
h(SuggestBox),
|
|
),
|
|
);
|
|
assert.match(html, /Brauche ich/);
|
|
assert.match(html, /Not needed/, "an unset label falls back to the default");
|
|
assert.match(html, /aria-pressed="false"/);
|
|
assert.match(html, /name="website"[^>]*aria-hidden="true"|aria-hidden="true"[^>]*name="website"/);
|
|
});
|
|
|
|
test("outside a provider it says what is wrong instead of rendering nothing", () => {
|
|
assert.throws(() => renderToString(h(StanceButtons, { targetId: "x" })), /FeedbackProvider/);
|
|
});
|