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: 29 additions & 1 deletion src/cli/messenger/mentions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const message = (id: string, text: string, sent: string): Message => ({
reactions: null,
})

const setup = async (extra: Record<string, string> = {}) => {
const setup = async (extra: Record<string, string> = {}, seeded: Message[] = []) => {
const root = mkdtempSync(join(tmpdir(), "mentions-cli-"))
const env = {
...process.env,
Expand All @@ -60,6 +60,7 @@ const setup = async (extra: Record<string, string> = {}) => {
"смета: https://docs.google.com/spreadsheets/d/1SyntheticFileId_abc/edit",
"2026-10-02T10:00:00.000Z",
),
...seeded,
],
{ via: "history" },
)
Expand Down Expand Up @@ -112,6 +113,33 @@ describe("mentions", () => {
expect((await chat("mentions", "rebuild", "vehicle")).code).not.toBe(0)
})

it("pages confirmed places through the shared CLI and stops at the end", async () => {
const chat = await setup({}, [
message("3", "12 Fictional Example Street", "2026-10-03T10:00:00.000Z"),
message("4", "34 Synthetic Sample Road", "2026-10-04T10:00:00.000Z"),
])
const mentions = await chat("mentions", "list", "kind:place", "--json")
expect(mentions.code, mentions.stderr).toBe(0)
const candidates = JSON.parse(mentions.stdout).items as { id: number }[]
expect(candidates).toHaveLength(2)
for (const candidate of candidates) {
const confirmed = await chat("mentions", "confirm", String(candidate.id), "--as-owner", "--json")
expect(confirmed.code, confirmed.stderr).toBe(0)
}
const pages = []
for (const page of [1, 2, 3]) {
const result = await chat("mentions", "places", "--limit", "1", "--page", String(page), "--json")
expect(result.code, result.stderr).toBe(0)
pages.push(JSON.parse(result.stdout))
}
expect(pages[0].items).toHaveLength(1)
expect(pages[1].items).toHaveLength(1)
expect(pages[0].items[0].id).not.toBe(pages[1].items[0].id)
expect(pages[2].items).toEqual([])
expect(pages[0].page.has_more).toBe(true)
expect(pages[1].page.has_more).toBe(false)
})

it("refuses a kind it does not know and a mention of nothing, and lists its fields in help", async () => {
const chat = await setup()
expect((await chat("mentions", "list", "kind:fax")).code).not.toBe(0)
Expand Down
Loading