Skip to content

Commit 67f04bc

Browse files
author
secooond
committed
fix(msteams): repair file-send test fixtures with proper app and OneDrive mocks
- Replace adapter:{} with app:createMockApp() in both new tests so sendMSTeamsActivityWithReference receives a real app parameter - Add uploadAndShareOneDrive to mockState for proper mock control - Mock OneDrive upload result so the production path reaches the threaded send call - Add uploadAndShareOneDrive to beforeEach reset Refs: #88836
1 parent 8827fd6 commit 67f04bc

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

extensions/msteams/src/send.test.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const mockState = vi.hoisted(() => ({
2020
deleteMSTeamsActivityWithReference: vi.fn(async () => {}),
2121
uploadAndShareSharePoint: vi.fn(),
2222
getDriveItemProperties: vi.fn(),
23+
uploadAndShareOneDrive: vi.fn(),
2324
buildTeamsFileInfoCard: vi.fn(),
2425
createMSTeamsTokenProvider: vi.fn(),
2526
}));
@@ -86,7 +87,7 @@ vi.mock("./runtime.js", () => ({
8687
vi.mock("./graph-upload.js", () => ({
8788
uploadAndShareSharePoint: mockState.uploadAndShareSharePoint,
8889
getDriveItemProperties: mockState.getDriveItemProperties,
89-
uploadAndShareOneDrive: vi.fn(),
90+
uploadAndShareOneDrive: mockState.uploadAndShareOneDrive,
9091
}));
9192

9293
vi.mock("./graph-chat.js", () => ({
@@ -237,6 +238,7 @@ describe("sendMessageMSTeams", () => {
237238
mockState.deleteMSTeamsActivityWithReference.mockReset();
238239
mockState.uploadAndShareSharePoint.mockReset();
239240
mockState.getDriveItemProperties.mockReset();
241+
mockState.uploadAndShareOneDrive.mockReset();
240242
mockState.buildTeamsFileInfoCard.mockReset();
241243

242244
mockState.extractFilename.mockResolvedValue("fallback.bin");
@@ -384,8 +386,9 @@ describe("sendMessageMSTeams", () => {
384386

385387
it("routes SharePoint file card sends to the channel thread when replyStyle is thread", async () => {
386388
const threadRootId = "thread-root-message-1";
389+
const app = createMockApp();
387390
mockState.resolveMSTeamsSendContext.mockResolvedValue({
388-
adapter: {},
391+
app,
389392
appId: "app-id",
390393
conversationId: "19:[email protected]",
391394
ref: {
@@ -417,7 +420,7 @@ describe("sendMessageMSTeams", () => {
417420

418421
// The SharePoint file card send must include threadActivityId for thread routing.
419422
expect(mockState.sendMSTeamsActivityWithReference).toHaveBeenCalledWith(
420-
expect.any(Object),
423+
app,
421424
expect.any(Object),
422425
expect.any(Object),
423426
expect.objectContaining({
@@ -428,8 +431,9 @@ describe("sendMessageMSTeams", () => {
428431

429432
it("routes OneDrive fallback file sends to the channel thread when replyStyle is thread", async () => {
430433
const threadRootId = "thread-root-message-2";
434+
const app = createMockApp();
431435
mockState.resolveMSTeamsSendContext.mockResolvedValue({
432-
adapter: {},
436+
app,
433437
appId: "app-id",
434438
conversationId: "19:[email protected]",
435439
ref: {
@@ -452,6 +456,11 @@ describe("sendMessageMSTeams", () => {
452456
kind: "file",
453457
});
454458
mockState.requiresFileConsent.mockReturnValue(false);
459+
mockState.uploadAndShareOneDrive.mockResolvedValueOnce({
460+
itemId: "od-item-1",
461+
shareUrl: "https://1drv.example.com/share/doc.pdf",
462+
name: "doc.pdf",
463+
});
455464

456465
await sendMessageMSTeams({
457466
cfg: {} as OpenClawConfig,
@@ -462,7 +471,7 @@ describe("sendMessageMSTeams", () => {
462471

463472
// The OneDrive fallback send must include threadActivityId for thread routing.
464473
expect(mockState.sendMSTeamsActivityWithReference).toHaveBeenCalledWith(
465-
expect.any(Object),
474+
app,
466475
expect.any(Object),
467476
expect.any(Object),
468477
expect.objectContaining({

0 commit comments

Comments
 (0)