Fix tests

This commit is contained in:
Konstantin Wohlwend 2026-04-14 03:11:19 -07:00
parent 0dac3dba58
commit c7b6b597ce
2 changed files with 12 additions and 6 deletions

View File

@ -1,3 +1,4 @@
import { randomUUID } from "crypto";
import { describe } from "vitest";
import { it } from "../../../../../helpers";
import { Auth, backendContext, createMailbox, niceBackendFetch, waitForOutboxEmailWithStatus } from "../../../../backend-helpers";
@ -45,13 +46,14 @@ describe("POST /api/v1/internal/feedback", () => {
it("should send feedback without authentication (dev tool)", async ({ expect }) => {
const recipientMailbox = createMailbox("team@stack-auth.com");
const subject = "[Support] devtool-user@example.com";
const senderEmail = `devtool-user-${randomUUID()}@example.com`;
const subject = `[Support] ${senderEmail}`;
const response = await niceBackendFetch("/api/v1/internal/feedback", {
method: "POST",
body: {
name: "Dev Tool User",
email: "devtool-user@example.com",
email: senderEmail,
message: "Unauthenticated feedback from the dev tool.",
feedback_type: "feedback",
},
@ -75,18 +77,19 @@ describe("POST /api/v1/internal/feedback", () => {
const messages = await recipientMailbox.waitForMessagesWithSubject(subject);
expect(messages).toHaveLength(1);
expect(messages[0].body?.text).toContain("Dev Tool User");
expect(messages[0].body?.text).toContain("devtool-user@example.com");
expect(messages[0].body?.text).toContain(senderEmail);
expect(messages[0].body?.text).toContain("Unauthenticated feedback from the dev tool.");
});
it("should send bug reports with correct label", async ({ expect }) => {
const recipientMailbox = createMailbox("team@stack-auth.com");
const subject = "[Bug Report] bug@example.com";
const reporterEmail = `bug-${randomUUID()}@example.com`;
const subject = `[Bug Report] ${reporterEmail}`;
const response = await niceBackendFetch("/api/v1/internal/feedback", {
method: "POST",
body: {
email: "bug@example.com",
email: reporterEmail,
message: "Something is broken.",
feedback_type: "bug",
},
@ -109,7 +112,7 @@ describe("POST /api/v1/internal/feedback", () => {
const messages = await recipientMailbox.waitForMessagesWithSubject(subject);
expect(messages).toHaveLength(1);
expect(messages[0].subject).toBe("[Bug Report] bug@example.com");
expect(messages[0].subject).toBe(subject);
});
it("should reject invalid payloads", async ({ expect }) => {

View File

@ -258,3 +258,6 @@ A: The app link wrapper in `docs-mintlify/snippets/docs-apps-home-grid.jsx` used
Q: How should the sidebar Apps filter behave when there are no matches?
A: In `docs-mintlify/snippets/docs-apps-home-grid.jsx`, track visible rows while filtering and show a small inline empty state (`No more results. Clear filter`) when query is non-empty and visible count is zero; wire `Clear filter` to reset the input, rerun filtering, and refocus the input.
Q: Why did internal feedback E2E tests expect 1 Inbucket message but get 2?
A: Inbucket persists mail across runs. `Mailbox.waitForMessagesWithSubject` waits until at least one match then returns **all** messages whose subject includes the string. Fixed subjects like `[Support] devtool-user@example.com` accumulate, so assertions should use a unique subject per run (e.g. `randomUUID()` in the sender email) or a baseline count before/after.