Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

DEVPROD-3919 Don't show eta timer if the eta has been exceeded. #2253

Merged
merged 4 commits into from
Feb 16, 2024
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
4 changes: 4 additions & 0 deletions src/pages/task/metadata/ETATimer/ETATimer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ describe("etaTimer", () => {
expect(global.clearInterval).toHaveBeenCalledWith(expect.any(Number));
expect(jest.getTimerCount()).toBe(0);
});
it("if the eta has been exceeded, it does not render", () => {
render(<ETATimer startTime={new Date()} expectedDuration={0} />);
expect(screen.queryByTestId("task-metadata-eta")).not.toBeInTheDocument();
});
});
2 changes: 1 addition & 1 deletion src/pages/task/metadata/ETATimer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ interface ETATimerProps {
const ETATimer: React.FC<ETATimerProps> = ({ expectedDuration, startTime }) => {
const parsedStartTime = new Date(startTime);
const { endTimer, runningTime } = useRunningTime(parsedStartTime);

useEffect(() => {
if (runningTime >= expectedDuration) {
endTimer();
}
}, [runningTime, expectedDuration, endTimer]);

const eta = expectedDuration - runningTime;
if (eta < 0) return null;
return (
<MetadataItem data-cy="task-metadata-eta">
ETA: {msToDuration(eta)}
Expand Down
1 change: 0 additions & 1 deletion src/pages/task/metadata/Metadata.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ describe("metadata", () => {
},
);
expect(screen.queryByDataCy("task-metadata-estimated_start")).toBeNull();
expect(screen.getByDataCy("task-metadata-eta")).toBeInTheDocument();
expect(screen.getByDataCy("task-metadata-started")).toBeInTheDocument();
expect(screen.queryByDataCy("task-metadata-finished")).toBeNull();
expect(screen.queryByDataCy("task-trace-link")).toBeNull();
Expand Down
Loading