diff --git a/frontend/src/component/changeRequest/ChangeRequest/SegmentTooltipLink.tsx b/frontend/src/component/changeRequest/ChangeRequest/SegmentTooltipLink.tsx
index dab7c7a826..8c77f90303 100644
--- a/frontend/src/component/changeRequest/ChangeRequest/SegmentTooltipLink.tsx
+++ b/frontend/src/component/changeRequest/ChangeRequest/SegmentTooltipLink.tsx
@@ -27,15 +27,15 @@ export const SegmentDiff: FC<{
change: IChangeRequestUpdateSegment | IChangeRequestDeleteSegment;
currentSegment?: ISegment;
}> = ({ change, currentSegment }) => {
- const changeRequestStrategy =
+ const changeRequestSegment =
change.action === 'deleteSegment' ? undefined : change.payload;
return (
diff --git a/frontend/src/component/events/EventDiff/EventDiff.test.tsx b/frontend/src/component/events/EventDiff/EventDiff.test.tsx
new file mode 100644
index 0000000000..d4d0ea0b79
--- /dev/null
+++ b/frontend/src/component/events/EventDiff/EventDiff.test.tsx
@@ -0,0 +1,49 @@
+import { render } from 'utils/testRenderer';
+import React from 'react';
+import { screen } from '@testing-library/react';
+import EventDiff from './EventDiff';
+
+test('Show no changes', async () => {
+ render();
+
+ expect(screen.getByText('(no changes)')).toBeInTheDocument();
+});
+
+test('Show new data added diff', async () => {
+ render();
+
+ expect(screen.getByText('+ segments: []')).toBeInTheDocument();
+});
+
+test('Show new data removed diff', async () => {
+ render();
+
+ expect(screen.getByText('- segments (deleted)')).toBeInTheDocument();
+});
+
+test('Show new data changes diff', async () => {
+ render(
+
+ );
+
+ expect(screen.getByText('- segments: "a"')).toBeInTheDocument();
+ expect(screen.getByText('+ segments: "b"')).toBeInTheDocument();
+});
+
+test('Show new data only', async () => {
+ render(
+
+ );
+
+ expect(screen.getByText('{ "segments": [] }')).toBeInTheDocument();
+});
+
+test('Show old data only', async () => {
+ render(
+
+ );
+
+ expect(screen.getByText('{ "segments": [] }')).toBeInTheDocument();
+});
diff --git a/frontend/src/component/events/EventDiff/EventDiff.tsx b/frontend/src/component/events/EventDiff/EventDiff.tsx
index ac9424dcf0..1e9da03a1a 100644
--- a/frontend/src/component/events/EventDiff/EventDiff.tsx
+++ b/frontend/src/component/events/EventDiff/EventDiff.tsx
@@ -96,14 +96,14 @@ const EventDiff = ({
};
};
- let changes;
+ let changes: any[] = [];
if (diffs) {
changes = diffs
.map(buildDiff)
.sort(sort)
.map(({ value }) => value);
- } else {
+ } else if (entry.data == null || entry.preData == null) {
// Just show the data if there is no diff yet.
const data = entry.data || entry.preData;
changes = [