mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 23:56:07 +00:00
test: tighten nextcloud talk send receipt assertions
This commit is contained in:
@@ -58,6 +58,7 @@ function expectProvidedMessageCfgThreading(cfg: unknown): void {
|
||||
|
||||
describe("nextcloud-talk send cfg threading", () => {
|
||||
const fetchMock = vi.fn<typeof fetch>();
|
||||
const fixedSentAt = 1_800_000_000_000;
|
||||
const defaultAccount = {
|
||||
accountId: "default",
|
||||
baseUrl: "https://nextcloud.example.com",
|
||||
@@ -76,6 +77,7 @@ describe("nextcloud-talk send cfg threading", () => {
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.setSystemTime(fixedSentAt);
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
// Route the SSRF guard mock through the global fetch mock.
|
||||
hoisted.mockFetchGuard.mockImplementation(async (p: { url: string; init?: RequestInit }) => {
|
||||
@@ -95,6 +97,7 @@ describe("nextcloud-talk send cfg threading", () => {
|
||||
afterEach(() => {
|
||||
fetchMock.mockReset();
|
||||
hoisted.mockFetchGuard.mockReset();
|
||||
vi.useRealTimers();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
@@ -114,25 +117,34 @@ describe("nextcloud-talk send cfg threading", () => {
|
||||
direction: "outbound",
|
||||
});
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
expect(result).toMatchObject({
|
||||
expect(result).toEqual({
|
||||
messageId: "12345",
|
||||
roomToken: "abc123",
|
||||
timestamp: 1_706_000_000,
|
||||
});
|
||||
expect(result.receipt).toMatchObject({
|
||||
primaryPlatformMessageId: "12345",
|
||||
platformMessageIds: ["12345"],
|
||||
parts: [
|
||||
{
|
||||
platformMessageId: "12345",
|
||||
kind: "text",
|
||||
raw: {
|
||||
receipt: {
|
||||
platformMessageIds: ["12345"],
|
||||
primaryPlatformMessageId: "12345",
|
||||
parts: [
|
||||
{
|
||||
index: 0,
|
||||
kind: "text",
|
||||
platformMessageId: "12345",
|
||||
raw: {
|
||||
channel: "nextcloud-talk",
|
||||
conversationId: "abc123",
|
||||
messageId: "12345",
|
||||
},
|
||||
},
|
||||
],
|
||||
raw: [
|
||||
{
|
||||
channel: "nextcloud-talk",
|
||||
conversationId: "abc123",
|
||||
messageId: "12345",
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
sentAt: fixedSentAt,
|
||||
},
|
||||
roomToken: "abc123",
|
||||
timestamp: 1_706_000_000,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -149,8 +161,32 @@ describe("nextcloud-talk send cfg threading", () => {
|
||||
});
|
||||
|
||||
expectProvidedMessageCfgThreading(cfg);
|
||||
expect(result).toMatchObject({
|
||||
expect(result).toEqual({
|
||||
messageId: "12346",
|
||||
receipt: {
|
||||
platformMessageIds: ["12346"],
|
||||
primaryPlatformMessageId: "12346",
|
||||
parts: [
|
||||
{
|
||||
index: 0,
|
||||
kind: "text",
|
||||
platformMessageId: "12346",
|
||||
raw: {
|
||||
channel: "nextcloud-talk",
|
||||
conversationId: "abc123",
|
||||
messageId: "12346",
|
||||
},
|
||||
},
|
||||
],
|
||||
raw: [
|
||||
{
|
||||
channel: "nextcloud-talk",
|
||||
conversationId: "abc123",
|
||||
messageId: "12346",
|
||||
},
|
||||
],
|
||||
sentAt: fixedSentAt,
|
||||
},
|
||||
roomToken: "abc123",
|
||||
timestamp: 1_706_000_001,
|
||||
});
|
||||
@@ -166,14 +202,31 @@ describe("nextcloud-talk send cfg threading", () => {
|
||||
replyTo: "parent-1",
|
||||
});
|
||||
|
||||
expect(result.receipt).toMatchObject({
|
||||
expect(result.receipt).toEqual({
|
||||
platformMessageIds: ["12347"],
|
||||
primaryPlatformMessageId: "12347",
|
||||
replyToId: "parent-1",
|
||||
parts: [
|
||||
{
|
||||
platformMessageId: "12347",
|
||||
index: 0,
|
||||
kind: "text",
|
||||
replyToId: "parent-1",
|
||||
platformMessageId: "12347",
|
||||
raw: {
|
||||
channel: "nextcloud-talk",
|
||||
conversationId: "abc123",
|
||||
messageId: "12347",
|
||||
},
|
||||
},
|
||||
],
|
||||
raw: [
|
||||
{
|
||||
channel: "nextcloud-talk",
|
||||
conversationId: "abc123",
|
||||
messageId: "12347",
|
||||
},
|
||||
],
|
||||
sentAt: fixedSentAt,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user