Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions static/app/stores/groupStore.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -228,6 +229,35 @@ 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', () => {
const addMessageSpy = jest.spyOn(IndicatorStore, 'addMessage');
GroupStore.onDeleteSuccess('1337', undefined, {});

expect(addMessageSpy).toHaveBeenCalledWith('Deleted selected issues', 'success', {
duration: 4000,
});
});

it('should show specific count when itemIds is provided', () => {
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 addMessageSpy = jest.spyOn(IndicatorStore, 'addMessage');
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()', () => {
Expand Down
4 changes: 3 additions & 1 deletion static/app/stores/groupStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 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('');
Expand Down
Loading