From 8f13db0bd1010eb894a3c4a949438c7fa22a92f3 Mon Sep 17 00:00:00 2001 From: dev-shahed Date: Wed, 15 Oct 2025 00:15:10 +0600 Subject: [PATCH 1/4] fix(issues): show correct notification when deleting all issues in query - Fix incorrect count in deletion notification when 'all in query' is selected - When itemIds is undefined (all in query), show generic 'Deleted all selected issues' message - Previously showed count of loaded items (25) instead of actual deleted count - Add comprehensive tests to verify the fix Fixes issue where notification showed '25 issues deleted' when more than 25 issues were actually deleted from the backend. --- static/app/stores/groupStore.spec.tsx | 31 +++++++++++++++++++++++++++ static/app/stores/groupStore.tsx | 4 +++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/static/app/stores/groupStore.spec.tsx b/static/app/stores/groupStore.spec.tsx index 74615ea4651050..17bf3e301c259e 100644 --- a/static/app/stores/groupStore.spec.tsx +++ b/static/app/stores/groupStore.spec.tsx @@ -228,6 +228,37 @@ describe('GroupStore', () => { expect(GroupStore.trigger).toHaveBeenCalledTimes(1); expect(GroupStore.trigger).toHaveBeenCalledWith(new Set(['1', '2', '3'])); }); + + it('should show generic message when itemIds is undefined (all in query selected)', () => { + const IndicatorStore = require('sentry/stores/indicatorStore').default; + const addMessageSpy = jest.spyOn(IndicatorStore, 'addMessage'); + + GroupStore.onDeleteSuccess('1337', undefined, {}); + + expect(addMessageSpy).toHaveBeenCalledWith('Deleted all selected issues', 'success', {duration: 4000}); + }); + + it('should show specific count when itemIds is provided', () => { + const IndicatorStore = require('sentry/stores/indicatorStore').default; + const addMessageSpy = jest.spyOn(IndicatorStore, 'addMessage'); + + GroupStore.onDeleteSuccess('1337', ['1', '2'], {}); + + expect(addMessageSpy).toHaveBeenCalledWith('Deleted 2 Issues', 'success', {duration: 4000}); + }); + + it('should show shortId for single issue deletion', () => { + const IndicatorStore = require('sentry/stores/indicatorStore').default; + const addMessageSpy = jest.spyOn(IndicatorStore, 'addMessage'); + + // Mock the GroupStore.get method to return a group with shortId + const mockGroup = g('1', {shortId: 'ABC-123'}); + jest.spyOn(GroupStore, 'get').mockReturnValue(mockGroup); + + GroupStore.onDeleteSuccess('1337', ['1'], {}); + + expect(addMessageSpy).toHaveBeenCalledWith('Deleted ABC-123', 'success', {duration: 4000}); + }); }); describe('onAssignToSuccess()', () => { diff --git a/static/app/stores/groupStore.tsx b/static/app/stores/groupStore.tsx index 5350b3f581215d..592dc6d531454f 100644 --- a/static/app/stores/groupStore.tsx +++ b/static/app/stores/groupStore.tsx @@ -365,7 +365,9 @@ const storeConfig: GroupStoreDefinition = { onDeleteSuccess(_changeId, itemIds, _response) { const ids = this.itemIdsOrAll(itemIds); - if (ids.length > 1) { + if (itemIds === undefined) { + showAlert(t('Deleted all selected issues'), 'success'); + } else if (ids.length > 1) { showAlert(t('Deleted %d Issues', ids.length), 'success'); } else { const shortId = ids.map(item => GroupStore.get(item)?.shortId).join(''); From d4d07c42ce579191a5b3c6bcf580841813e02347 Mon Sep 17 00:00:00 2001 From: dev-shahed Date: Wed, 15 Oct 2025 00:23:35 +0600 Subject: [PATCH 2/4] fix(groupStore): update deletion notification message for clarity - Changed notification message from 'Deleted all selected issues' to 'Deleted selected issues' for better accuracy. - Updated corresponding test to reflect the new message. --- static/app/stores/groupStore.spec.tsx | 10 +++++----- static/app/stores/groupStore.tsx | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/static/app/stores/groupStore.spec.tsx b/static/app/stores/groupStore.spec.tsx index 17bf3e301c259e..1549f60aaea2ec 100644 --- a/static/app/stores/groupStore.spec.tsx +++ b/static/app/stores/groupStore.spec.tsx @@ -232,16 +232,16 @@ describe('GroupStore', () => { it('should show generic message when itemIds is undefined (all in query selected)', () => { const IndicatorStore = require('sentry/stores/indicatorStore').default; const addMessageSpy = jest.spyOn(IndicatorStore, 'addMessage'); - + GroupStore.onDeleteSuccess('1337', undefined, {}); - expect(addMessageSpy).toHaveBeenCalledWith('Deleted all selected issues', 'success', {duration: 4000}); + expect(addMessageSpy).toHaveBeenCalledWith('Deleted selected issues', 'success', {duration: 4000}); }); it('should show specific count when itemIds is provided', () => { const IndicatorStore = require('sentry/stores/indicatorStore').default; const addMessageSpy = jest.spyOn(IndicatorStore, 'addMessage'); - + GroupStore.onDeleteSuccess('1337', ['1', '2'], {}); expect(addMessageSpy).toHaveBeenCalledWith('Deleted 2 Issues', 'success', {duration: 4000}); @@ -250,11 +250,11 @@ describe('GroupStore', () => { it('should show shortId for single issue deletion', () => { const IndicatorStore = require('sentry/stores/indicatorStore').default; const addMessageSpy = jest.spyOn(IndicatorStore, 'addMessage'); - + // Mock the GroupStore.get method to return a group with shortId const mockGroup = g('1', {shortId: 'ABC-123'}); jest.spyOn(GroupStore, 'get').mockReturnValue(mockGroup); - + GroupStore.onDeleteSuccess('1337', ['1'], {}); expect(addMessageSpy).toHaveBeenCalledWith('Deleted ABC-123', 'success', {duration: 4000}); diff --git a/static/app/stores/groupStore.tsx b/static/app/stores/groupStore.tsx index 592dc6d531454f..bbfc1f4ab9cbc1 100644 --- a/static/app/stores/groupStore.tsx +++ b/static/app/stores/groupStore.tsx @@ -366,7 +366,7 @@ const storeConfig: GroupStoreDefinition = { const ids = this.itemIdsOrAll(itemIds); if (itemIds === undefined) { - showAlert(t('Deleted all selected issues'), 'success'); + showAlert(t('Deleted selected issues'), 'success'); } else if (ids.length > 1) { showAlert(t('Deleted %d Issues', ids.length), 'success'); } else { From ec78bb9edf9145e187faca304c62ad20914da318 Mon Sep 17 00:00:00 2001 From: dev-shahed Date: Wed, 15 Oct 2025 20:23:38 +0600 Subject: [PATCH 3/4] fix(tests): convert require to import in groupStore.spec.tsx --- static/app/stores/groupStore.spec.tsx | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/static/app/stores/groupStore.spec.tsx b/static/app/stores/groupStore.spec.tsx index 1549f60aaea2ec..c5a15677222287 100644 --- a/static/app/stores/groupStore.spec.tsx +++ b/static/app/stores/groupStore.spec.tsx @@ -3,6 +3,7 @@ import {GroupFixture} from 'sentry-fixture/group'; import {ProjectFixture} from 'sentry-fixture/project'; import GroupStore from 'sentry/stores/groupStore'; +import IndicatorStore from 'sentry/stores/indicatorStore'; import type {TimeseriesValue} from 'sentry/types/core'; import type {Group, GroupStats} from 'sentry/types/group'; import {GroupActivityType} from 'sentry/types/group'; @@ -229,35 +230,35 @@ describe('GroupStore', () => { expect(GroupStore.trigger).toHaveBeenCalledWith(new Set(['1', '2', '3'])); }); - it('should show generic message when itemIds is undefined (all in query selected)', () => { - const IndicatorStore = require('sentry/stores/indicatorStore').default; + it('should show generic message when itemIds is undefined', () => { const addMessageSpy = jest.spyOn(IndicatorStore, 'addMessage'); - GroupStore.onDeleteSuccess('1337', undefined, {}); - expect(addMessageSpy).toHaveBeenCalledWith('Deleted selected issues', 'success', {duration: 4000}); + expect(addMessageSpy).toHaveBeenCalledWith( + 'Deleted selected issues', + 'success', + {duration: 4000} + ); }); it('should show specific count when itemIds is provided', () => { - const IndicatorStore = require('sentry/stores/indicatorStore').default; const addMessageSpy = jest.spyOn(IndicatorStore, 'addMessage'); - GroupStore.onDeleteSuccess('1337', ['1', '2'], {}); - expect(addMessageSpy).toHaveBeenCalledWith('Deleted 2 Issues', 'success', {duration: 4000}); + expect(addMessageSpy).toHaveBeenCalledWith('Deleted 2 Issues', 'success', { + duration: 4000, + }); }); it('should show shortId for single issue deletion', () => { - const IndicatorStore = require('sentry/stores/indicatorStore').default; const addMessageSpy = jest.spyOn(IndicatorStore, 'addMessage'); - - // Mock the GroupStore.get method to return a group with shortId const mockGroup = g('1', {shortId: 'ABC-123'}); jest.spyOn(GroupStore, 'get').mockReturnValue(mockGroup); - GroupStore.onDeleteSuccess('1337', ['1'], {}); - expect(addMessageSpy).toHaveBeenCalledWith('Deleted ABC-123', 'success', {duration: 4000}); + expect(addMessageSpy).toHaveBeenCalledWith('Deleted ABC-123', 'success', { + duration: 4000, + }); }); }); From a0b80b0b029b95b57ca605697baf22eb4a5f6bd4 Mon Sep 17 00:00:00 2001 From: dev-shahed Date: Wed, 15 Oct 2025 20:46:47 +0600 Subject: [PATCH 4/4] fix: apply prettier formatting --- static/app/stores/groupStore.spec.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/static/app/stores/groupStore.spec.tsx b/static/app/stores/groupStore.spec.tsx index c5a15677222287..bdebc318c808f6 100644 --- a/static/app/stores/groupStore.spec.tsx +++ b/static/app/stores/groupStore.spec.tsx @@ -234,11 +234,9 @@ describe('GroupStore', () => { const addMessageSpy = jest.spyOn(IndicatorStore, 'addMessage'); GroupStore.onDeleteSuccess('1337', undefined, {}); - expect(addMessageSpy).toHaveBeenCalledWith( - 'Deleted selected issues', - 'success', - {duration: 4000} - ); + expect(addMessageSpy).toHaveBeenCalledWith('Deleted selected issues', 'success', { + duration: 4000, + }); }); it('should show specific count when itemIds is provided', () => {