From f7c81801458e3ab86a3d0474c9b228bc1736ab19 Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Mon, 22 Jan 2024 11:13:49 +0400 Subject: [PATCH] Chore: omit snapshot property from event payload (#5972) This PR hides the "snapshot" data from the diff overview we show in the UI in a change request. --- .../StrategyTooltipLink.test.tsx | 54 +++++++++++++++++++ .../StrategyTooltipLink.tsx | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 frontend/src/component/changeRequest/ChangeRequest/StrategyTooltipLink/StrategyTooltipLink.test.tsx diff --git a/frontend/src/component/changeRequest/ChangeRequest/StrategyTooltipLink/StrategyTooltipLink.test.tsx b/frontend/src/component/changeRequest/ChangeRequest/StrategyTooltipLink/StrategyTooltipLink.test.tsx new file mode 100644 index 0000000000..820df39048 --- /dev/null +++ b/frontend/src/component/changeRequest/ChangeRequest/StrategyTooltipLink/StrategyTooltipLink.test.tsx @@ -0,0 +1,54 @@ +import { render } from 'utils/testRenderer'; +import { screen, within } from '@testing-library/react'; +import { StrategyDiff } from './StrategyTooltipLink'; +import { IFeatureStrategy } from 'interfaces/strategy'; +import { IChangeRequestUpdateStrategy } from 'component/changeRequest/changeRequest.types'; + +test('Should not render the `snapshot` property', async () => { + const existingStrategy: IFeatureStrategy = { + name: 'flexibleRollout', + constraints: [], + variants: [], + parameters: { + groupId: 'aaa', + rollout: '71', + stickiness: 'default', + }, + sortOrder: 0, + id: '31572930-2db7-461f-813b-3eedc200cb33', + title: '', + disabled: false, + segments: [], + }; + + const change: IChangeRequestUpdateStrategy = { + id: 39, + action: 'updateStrategy' as const, + payload: { + id: '31572930-2db7-461f-813b-3eedc200cb33', + name: 'flexibleRollout', + title: '', + disabled: false, + segments: [], + snapshot: existingStrategy, + variants: [], + parameters: { + groupId: 'aaa', + rollout: '38', + stickiness: 'default', + }, + constraints: [], + }, + createdAt: new Date('2024-01-18T07:58:36.314Z'), + createdBy: { + id: 1, + username: 'admin', + imageUrl: + 'https://gravatar.com/avatar/8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918?s=42&d=retro&r=g', + }, + }; + + render(); + + expect(screen.queryByText(/snapshot/)).toBeNull(); +}); diff --git a/frontend/src/component/changeRequest/ChangeRequest/StrategyTooltipLink/StrategyTooltipLink.tsx b/frontend/src/component/changeRequest/ChangeRequest/StrategyTooltipLink/StrategyTooltipLink.tsx index ccc10f3954..5b2c742d82 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/StrategyTooltipLink/StrategyTooltipLink.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/StrategyTooltipLink/StrategyTooltipLink.tsx @@ -42,7 +42,7 @@ export const StrategyDiff: FC<{