feat(FN-3593): add test isolation CI enforcement, fix stuck-requeue race, a
This merge lands five FN-3593 commits establishing a test isolation contract with a new `scripts/check-test-isolation.mjs` guard that scans for accidental `beforeEach`/`afterEach`/`beforeAll`/`afterAll` in setup helpers, plus per-package `setup-test-isolation.ts` bootstraps that canonicalize the pat Fusion-Task-Id: FN-3593
This commit is contained in:
@@ -197,6 +197,71 @@ describe("MessageComposer", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("forwards wakeRecipient metadata when the wake checkbox is ticked for an agent recipient", async () => {
|
||||
render(<MessageComposer {...defaultProps} agents={mockAgents} />);
|
||||
fireEvent.change(screen.getByTestId("message-composer-recipient"), {
|
||||
target: { value: "agent-001" },
|
||||
});
|
||||
fireEvent.change(screen.getByTestId("message-composer-content"), {
|
||||
target: { value: "wake up" },
|
||||
});
|
||||
fireEvent.click(screen.getByTestId("message-composer-wake"));
|
||||
fireEvent.click(screen.getByTestId("message-composer-send"));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockSendMessage).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
metadata: { wakeRecipient: true },
|
||||
}),
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("merges wakeRecipient with replyTo metadata when replying", async () => {
|
||||
render(
|
||||
<MessageComposer
|
||||
{...defaultProps}
|
||||
agents={mockAgents}
|
||||
recipient={{ id: "agent-001", type: "agent" }}
|
||||
replyContext={{ messageId: "msg-orig", preview: "earlier message" }}
|
||||
/>,
|
||||
);
|
||||
fireEvent.change(screen.getByTestId("message-composer-content"), {
|
||||
target: { value: "follow up" },
|
||||
});
|
||||
fireEvent.click(screen.getByTestId("message-composer-wake"));
|
||||
fireEvent.click(screen.getByTestId("message-composer-send"));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockSendMessage).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
metadata: {
|
||||
replyTo: { messageId: "msg-orig" },
|
||||
wakeRecipient: true,
|
||||
},
|
||||
}),
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("omits wakeRecipient metadata when the checkbox is left unchecked", async () => {
|
||||
render(<MessageComposer {...defaultProps} agents={mockAgents} />);
|
||||
fireEvent.change(screen.getByTestId("message-composer-recipient"), {
|
||||
target: { value: "agent-001" },
|
||||
});
|
||||
fireEvent.change(screen.getByTestId("message-composer-content"), {
|
||||
target: { value: "regular" },
|
||||
});
|
||||
fireEvent.click(screen.getByTestId("message-composer-send"));
|
||||
|
||||
await waitFor(() => {
|
||||
const callArgs = mockSendMessage.mock.calls[0][0];
|
||||
expect(callArgs.metadata).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
it("passes projectId to sendMessage", async () => {
|
||||
render(<MessageComposer {...defaultProps} agents={mockAgents} projectId="proj-1" />);
|
||||
fireEvent.change(screen.getByTestId("message-composer-recipient"), {
|
||||
|
||||
@@ -1,20 +1,4 @@
|
||||
/**
|
||||
* Global test isolation: prevents dashboard tests from writing to the real ~/.fusion/ directory.
|
||||
*
|
||||
* This runs in every Vitest worker before shared setup. By forcing process.env.HOME
|
||||
* to a fresh temp directory, homedir()-derived paths resolve to isolated locations.
|
||||
* Deprecated shim: canonical test isolation is in @fusion/core vitest-setup.
|
||||
*/
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
|
||||
const tempHome = mkdtempSync(join(tmpdir(), "fn-test-home-"));
|
||||
process.env.HOME = tempHome;
|
||||
process.env.USERPROFILE = tempHome;
|
||||
if (process.platform === "win32") {
|
||||
const match = tempHome.match(/^([A-Za-z]:)(.*)$/);
|
||||
if (match) {
|
||||
process.env.HOMEDRIVE = match[1];
|
||||
process.env.HOMEPATH = match[2] || "\\";
|
||||
}
|
||||
}
|
||||
import "../../../core/src/__test-utils__/vitest-setup";
|
||||
|
||||
@@ -51,7 +51,6 @@ export default defineConfig({
|
||||
globals: true,
|
||||
include: ["app/**/*.test.{ts,tsx}", "src/**/*.test.{ts,tsx}"],
|
||||
setupFiles: [
|
||||
"./src/__tests__/setup-test-isolation.ts",
|
||||
resolve(__dirname, "../core/src/__test-utils__/vitest-setup.ts"),
|
||||
"./vitest.setup.ts",
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user