Skip to content

Commit

Permalink
fix(update-activity): Fix updateActivty for groupStore
Browse files Browse the repository at this point in the history
  • Loading branch information
JLuse committed Oct 3, 2023
1 parent 2500a36 commit 8c2ef32
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions static/app/actionCreators/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export function updateNote(
id: string,
oldText: string
) {
GroupStore.updateActivity(group.id, id, {data: {text: note.text}});
GroupStore.updateActivity(group.id, id, {text: note.text});

const promise = api.requestPromise(
`/organizations/${orgSlug}/issues/${group.id}/comments/${id}/`,
Expand All @@ -198,7 +198,7 @@ export function updateNote(
}
);

promise.catch(() => GroupStore.updateActivity(group.id, id, {data: {text: oldText}}));
promise.catch(() => GroupStore.updateActivity(group.id, id, {text: oldText}));

return promise;
}
Expand Down
24 changes: 23 additions & 1 deletion static/app/stores/groupStore.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {Project} from 'sentry-fixture/project';

import GroupStore from 'sentry/stores/groupStore';
import {Group, GroupStats, TimeseriesValue} from 'sentry/types';
import {Group, GroupActivityType, GroupStats, TimeseriesValue} from 'sentry/types';

const MOCK_PROJECT = TestStubs.Project();

Expand Down Expand Up @@ -227,5 +229,25 @@ describe('GroupStore', function () {
expect(GroupStore.items[0]).toEqual(assignedGroup);
});
});

describe('updateActivity()', function () {
it("should update activity data text'", function () {
GroupStore.items = [
g('1', {
activity: [
{
id: '1',
type: GroupActivityType.NOTE,
dateCreated: '',
project: Project(),
data: {text: 'Orginal Text'},
},
],
}),
];
GroupStore.updateActivity('1', '1', {text: 'Updated Text'});
expect(GroupStore.items[0].activity[0].data).toEqual({text: 'Updated Text'});
});
});
});
});
2 changes: 1 addition & 1 deletion static/app/stores/groupStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface InternalDefinition {
pendingChanges: Map<ChangeId, Change>;
removeActivity: (groupId: string, id: string) => number;
statuses: Record<string, Record<string, boolean>>;
updateActivity: (groupId: string, id: string, data: Partial<Activity>) => void;
updateActivity: (groupId: string, id: string, data: Partial<Activity['data']>) => void;
updateItems: (itemIds: ItemIds) => void;
}

Expand Down

0 comments on commit 8c2ef32

Please sign in to comment.