From 6a86cccda00dcb51e938dfdfd1505953274c47af Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Mon, 1 Sep 2025 08:55:43 +0300 Subject: [PATCH] Fix playbooks not getting updated by websocket (#9088) (#9093) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 4978269156bcfa1d35572fd4a7a50110d2ceab3a) Co-authored-by: Daniel Espino GarcĂ­a --- app/products/playbooks/actions/remote/runs.test.ts | 14 ++++++++++++++ app/products/playbooks/actions/remote/runs.ts | 1 + 2 files changed, 15 insertions(+) diff --git a/app/products/playbooks/actions/remote/runs.test.ts b/app/products/playbooks/actions/remote/runs.test.ts index 746604ded..19bbb709e 100644 --- a/app/products/playbooks/actions/remote/runs.test.ts +++ b/app/products/playbooks/actions/remote/runs.test.ts @@ -120,6 +120,20 @@ describe('fetchPlaybookRunsForChannel', () => { expect(handlePlaybookRuns).not.toHaveBeenCalled(); }); + it('should update the channel in the ephemeral store when there are no runs', async () => { + mockClient.fetchPlaybookRuns.mockResolvedValueOnce({ + items: [], + has_more: false, + }); + + const result = await fetchPlaybookRunsForChannel(serverUrl, channelId); + expect(result).toBeDefined(); + expect(result.error).toBeUndefined(); + expect(result.runs).toEqual([]); + expect(handlePlaybookRuns).not.toHaveBeenCalled(); + expect(EphemeralStore.getChannelPlaybooksSynced(serverUrl, channelId)).toBe(true); + }); + it('should update the channel in the ephemeral store', async () => { mockClient.fetchPlaybookRuns.mockResolvedValueOnce({ items: [mockPlaybookRun], diff --git a/app/products/playbooks/actions/remote/runs.ts b/app/products/playbooks/actions/remote/runs.ts index 6687b5685..d8327ed6d 100644 --- a/app/products/playbooks/actions/remote/runs.ts +++ b/app/products/playbooks/actions/remote/runs.ts @@ -45,6 +45,7 @@ export const fetchPlaybookRunsForChannel = async (serverUrl: string, channelId: } if (!allRuns.length) { + EphemeralStore.setChannelPlaybooksSynced(serverUrl, channelId); return {runs: []}; }