Skip to content
Merged
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
30 changes: 28 additions & 2 deletions packages/junior-evals/src/fixture/insert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { onTestFinished } from "vitest";
import { createMemoryStore, type MemoryDb } from "@sentry/junior-memory";
import { createSlackSource } from "@sentry/junior-plugin-api";
import { createUserTokenStore } from "@/chat/capabilities/factory";
import { getDb, getSqlExecutor } from "@/chat/db";
import { getConversationStore, getDb, getSqlExecutor } from "@/chat/db";
import { createSlackDestination } from "@/chat/destination";
import { createEventAutomation } from "@/chat/event-automations/store";
import { createWatch } from "@/chat/events/store";
Expand Down Expand Up @@ -40,7 +40,10 @@ export interface SlackChannel {
*/
const FIXTURE_START_DATE = "2026-05-04";

/** The Slack timestamp of the message that stored a setup memory. */
/**
* The Slack timestamp of the setup message that stored a memory or created an
* automation.
*/
const FIXTURE_MESSAGE_TS = "1780000000.000100";

/**
Expand Down Expand Up @@ -99,6 +102,27 @@ async function insertSlackIdentity(author: Required<SlackAuthor>) {
});
}

/**
* Store the Slack thread where a person created an automation. Like the live
* Slack event of that thread, it records the channel as public. Automation
* runs do not record channel visibility, so without it their Conversations in
* the channel are private.
*/
async function insertCreationThread(destination: SlackChannel) {
await getConversationStore().recordActivity({
conversationId: `slack:${destination.channelId}:${FIXTURE_MESSAGE_TS}`,
destination,
sessionSource: createSlackSource({
channelId: destination.channelId,
teamId: destination.teamId,
threadTs: FIXTURE_MESSAGE_TS,
visibility: "public",
}),
source: "slack",
visibility: "public",
});
}

/**
* Store a scheduled automation that a Slack person created. It is weekly and
* next runs in a week unless `due` or `once` says otherwise.
Expand Down Expand Up @@ -162,6 +186,7 @@ export async function insertScheduledAutomation(args: {
task: { text: args.task },
updatedAtMs: nowMs - 60_000,
};
await insertCreationThread(args.destination);
await saveScheduledAutomation(getDb(), automation);
return { id };
}
Expand All @@ -180,6 +205,7 @@ export async function insertEventAutomation(args: {
const author = resolveAuthor(args.createdBy);
const identity = await insertSlackIdentity(author);
const id = `evt_${fixtureId("event-automation", 20)}`;
await insertCreationThread(args.destination);
await createEventAutomation(getDb(), {
id,
createdAtMs: Date.now() - 60_000,
Expand Down
Loading