From f7846c2a40a5041e0b098d8fb88bb99056604458 Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Wed, 8 Apr 2026 01:25:17 +0900 Subject: [PATCH 1/2] test(query-core/mutationCache): add test for removing a mutation that does not exist in the cache --- .../src/__tests__/mutationCache.test.tsx | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/query-core/src/__tests__/mutationCache.test.tsx b/packages/query-core/src/__tests__/mutationCache.test.tsx index d2c16987bcc..0c75b461470 100644 --- a/packages/query-core/src/__tests__/mutationCache.test.tsx +++ b/packages/query-core/src/__tests__/mutationCache.test.tsx @@ -483,5 +483,32 @@ describe('mutationCache', () => { expect(testCache.getAll()).toHaveLength(0) }) + + test('should still notify removal when removing a mutation that does not exist in the cache', () => { + const testCache = new MutationCache() + const testClient = new QueryClient({ mutationCache: testCache }) + + const mutation = testCache.build(testClient, { + mutationFn: () => Promise.resolve('data'), + }) + + expect(testCache.getAll()).toHaveLength(1) + testCache.remove(mutation) + expect(testCache.getAll()).toHaveLength(0) + + // Remove again — mutation is already gone from the cache + const callback = vi.fn() + const unsubscribe = testCache.subscribe(callback) + testCache.remove(mutation) + + expect(testCache.getAll()).toHaveLength(0) + expect(callback).toHaveBeenCalledTimes(1) + expect(callback).toHaveBeenCalledWith( + expect.objectContaining({ type: 'removed', mutation }), + ) + + unsubscribe() + }) + }) }) From 7698b276622866668795d306bc032f0c8d8ce148 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 7 Apr 2026 16:27:17 +0000 Subject: [PATCH 2/2] ci: apply automated fixes --- packages/query-core/src/__tests__/mutationCache.test.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/query-core/src/__tests__/mutationCache.test.tsx b/packages/query-core/src/__tests__/mutationCache.test.tsx index 0c75b461470..a3f41d99b74 100644 --- a/packages/query-core/src/__tests__/mutationCache.test.tsx +++ b/packages/query-core/src/__tests__/mutationCache.test.tsx @@ -509,6 +509,5 @@ describe('mutationCache', () => { unsubscribe() }) - }) })