Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion apps/api/src/automation/sequence-journey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ const captureEvent = vi.fn();
mock.module("../observability", () => ({ ...observability, captureEvent }));

const { db } = await import("../db/client");
const { ongoingSequences, rules } = await import("../db/schema");
const { ongoingSequences, rules, sequenceEmails, sequences } = await import(
"../db/schema"
);
const { eq } = await import("drizzle-orm");
const { EventType } = await import("../config/constants");
const { sendMail } = await import("../mail/send");
const { seedTeamAndContact, truncateAll } = await import("../test/db");
Expand Down Expand Up @@ -69,6 +72,18 @@ async function subscribeAt(
) {
const { team, contact } = await seedTeamAndContact(tdb);
const { sequenceRow } = await seedSequence(tdb, { teamId: team.id, emails });
// The database stamps these with the real time, but enrollment uses the
// faked clock. Seed them at `at` so a past `at` doesn't look like the
// sequence changed after the contact entered.
const seededAt = new Date(at);
await tdb
.update(sequences)
.set({ createdAt: seededAt, updatedAt: seededAt })
.where(eq(sequences.id, sequenceRow.id));
await tdb
.update(sequenceEmails)
.set({ createdAt: seededAt, updatedAt: seededAt })
.where(eq(sequenceEmails.sequenceId, sequenceRow.id));
await tdb.insert(rules).values({
teamId: team.id,
ruleId: `rule_${crypto.randomUUID()}`,
Expand Down
7 changes: 6 additions & 1 deletion apps/api/src/mcp/parity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { describe, expect, it, mock } from "bun:test";
import { validateParityManifest } from "@codelitdev/mcp-server-kit";
import { contract, mcpParityManifest } from "@sendlit/api-contract";

mock.module("../db/client", () => ({ db: {}, pool: {} }));
// The real test database: importing the server starts Better Auth, whose OAuth
// plugin queries it in the background. Built before mocking, so the factory is
// synchronous: platform-conformance.test.ts shares this process in CI.
const { makeTestDb } = await import("../test/db");
const testDb = await makeTestDb();
mock.module("../db/client", () => ({ db: testDb, pool: {} }));

const { createSendLitMcp } = await import("./server");

Expand Down
7 changes: 6 additions & 1 deletion apps/api/src/mcp/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { describe, expect, it, mock } from "bun:test";
import { mcpParityManifest } from "@sendlit/api-contract";
import { z } from "zod";

mock.module("../db/client", () => ({ db: {}, pool: {} }));
// The real test database: importing the server starts Better Auth, whose OAuth
// plugin queries it in the background. Built before mocking, so the factory is
// synchronous and safe when other files share the process.
const { makeTestDb } = await import("../test/db");
const testDb = await makeTestDb();
mock.module("../db/client", () => ({ db: testDb, pool: {} }));

const { sendLitMcpTools } = await import("./server");
const { authorizeMcpOperation, listMcpOperationScopes, MCP_SCOPES } = await import(
Expand Down
Loading