- Supervisor -> Feedback (supervisors and admins, campus-scoped): every event's form with answered of asked, response rate, average rating and last reminder; per event the results per question (with the AI summary), each response, and on named forms who was asked and who has answered. - Remind those who haven't answered (or one person on a named form): a fresh link, plus the form to anyone eligible who hasn't had it; nobody gets the form or a reminder twice within 24 hours. The 3-day job is unchanged. - Anonymous forms show no names and no list of who has answered. - FeedbackInvite.reminderCount (migration 20261103120000_feedback_reminders); access log action feedback_responses; help page; dashboard and Ctrl+K links. - Roadmap: the AI helpers on the privacy pages are dropped; 2.1.0 is the feedback page. - Tests: tests/feedbackPage.test.ts, e2e/feedback.spec.ts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
3.3 KiB
TypeScript
61 lines
3.3 KiB
TypeScript
import { test, expect, loginAs, api, v2, seed, API } from "./fixtures";
|
|
|
|
// 2.1.0: Supervisor → Feedback. The seed puts a named feedback form on "E2E Last Sunday", sent
|
|
// two days ago to Thandi (who answers here) and Lerato (who doesn't).
|
|
|
|
type PublicForm = { fields: { id: string; type: string }[] };
|
|
type AccessLog = { rows: { action: string; what: string; records: number | null; actor: string }[] };
|
|
|
|
test.describe("feedback page", () => {
|
|
test("see the answers, who hasn't answered, and remind them", async ({ page }) => {
|
|
const token = seed().feedback.tokens.user;
|
|
const form = await (await page.request.get(`${API}/api/v2/feedback-forms/${token}`)).json() as { data: PublicForm };
|
|
const [rating, text] = form.data.fields;
|
|
const sent = await page.request.post(`${API}/api/v2/feedback-forms/${token}`, {
|
|
headers: { "Content-Type": "application/json" },
|
|
data: JSON.stringify({ answers: { [rating.id]: 5, [text.id]: "Loved the worship" } }),
|
|
});
|
|
expect(sent.ok()).toBe(true);
|
|
|
|
await loginAs(page, "supervisor");
|
|
await page.goto("/dashboard/supervisor/feedback");
|
|
const row = page.getByRole("row", { name: /E2E Last Sunday/ });
|
|
await expect(row).toContainText("1 of 2");
|
|
await expect(row).toContainText("5.0");
|
|
await row.getByRole("button", { name: "E2E Last Sunday" }).click();
|
|
|
|
await expect(page.getByRole("heading", { name: "E2E Last Sunday" })).toBeVisible();
|
|
await expect(page.getByText("Loved the worship")).toBeVisible();
|
|
await expect(page.getByText("— Thandi Test")).toBeVisible();
|
|
|
|
await page.getByRole("tab", { name: /Responses/ }).click();
|
|
await expect(page.getByRole("article").filter({ hasText: "Thandi Test" })).toContainText("★★★★★");
|
|
|
|
await page.getByRole("tab", { name: /People/ }).click();
|
|
const lerato = page.getByRole("row", { name: /Lerato Late/ });
|
|
await expect(lerato).toContainText("Not yet");
|
|
await expect(page.getByRole("row", { name: /Thandi Test/ }).getByRole("button", { name: "Remind" })).toHaveCount(0);
|
|
|
|
page.once("dialog", d => d.accept());
|
|
await lerato.getByRole("button", { name: "Remind" }).click();
|
|
await expect(page.getByRole("status")).toHaveText("Reminded 1 person.");
|
|
await expect(lerato).toContainText("1 · last");
|
|
await expect(lerato.getByRole("button", { name: "Remind" })).toBeDisabled();
|
|
await expect(page.getByRole("button", { name: /Remind those who haven't answered/ })).toBeDisabled();
|
|
|
|
// Reminding again the same day sends nothing.
|
|
const again = await api<{ data: { reminded: number; message: string } }>(page, "supervisor", "POST", `/api/v2/events/${seed().events.past}/feedback/remind`, {});
|
|
expect(again.data.reminded).toBe(0);
|
|
expect(again.data.message).toMatch(/last 24 hours/);
|
|
|
|
// Opening a named form's answers is in the access log.
|
|
const log = await v2<AccessLog>(page, "admin", "GET", "/api/v2/privacy/access-log");
|
|
expect(log.rows.find(r => r.action === "feedback_responses")).toMatchObject({ what: "Feedback answers: E2E Last Sunday", records: 1, actor: "Sam Supervisor" });
|
|
});
|
|
|
|
test("staff can't see feedback", async ({ page }) => {
|
|
const res = await page.request.get(`${API}/api/v2/feedback`, { headers: { Authorization: `Bearer ${seed().users.staff.token}` } });
|
|
expect(res.status()).toBe(403);
|
|
});
|
|
});
|