diff --git a/src/app/features/TimeEntries/TimeEntriesList/__tests__/TimeEntriesList.test.tsx b/src/app/features/TimeEntries/TimeEntriesList/__tests__/TimeEntriesList.test.tsx index 1d244af..40d4840 100644 --- a/src/app/features/TimeEntries/TimeEntriesList/__tests__/TimeEntriesList.test.tsx +++ b/src/app/features/TimeEntries/TimeEntriesList/__tests__/TimeEntriesList.test.tsx @@ -1,5 +1,6 @@ import { render, screen, within } from "@testing-library/react"; import connectStore from "../../../../testUtils/connectStore"; +import userEvent from "@testing-library/user-event"; import { timeEntriesFixture } from "../../store/fixtures"; import { TimeEntriesList } from "../TimeEntriesList"; @@ -54,4 +55,20 @@ describe("TimeEntriesList", () => { expect(within(groupedRow!).getByText("00:03:05")).toBeInTheDocument(); expect(within(groupedRow!).getByRole("checkbox")).toBeDisabled(); }); + + it("WHEN time is counting THEN all items are displayer", async () => { + // arrange + arrange(); + const user = userEvent.setup(); + + // act + const playButtons = screen.getAllByTestId("PlayCircleIcon"); + await user.click(playButtons[0]); + + // assert + expect(screen.getByText("2022-08-19")).toBeInTheDocument(); + expect(screen.getByText("03:46:53")).toBeInTheDocument(); // grouped time per day 1 + expect(screen.getByText("2022-08-18")).toBeInTheDocument(); + expect(screen.getByText("02:03:16")).toBeInTheDocument(); // grouped time per day 2 + }); }); diff --git a/src/app/features/TimeEntries/store/selectors.ts b/src/app/features/TimeEntries/store/selectors.ts index 035e562..b1c3fe3 100644 --- a/src/app/features/TimeEntries/store/selectors.ts +++ b/src/app/features/TimeEntries/store/selectors.ts @@ -41,7 +41,10 @@ export const selectTimeEntriesGroupedByDate = createSelector( // remove last (incomplete) day if there are more elements remaining // this way we don't have incomplete groups - if (timeEntries.length !== allTimeEntries.length) { + const allCompletedTimeEntries = allTimeEntries.filter( + (entry) => entry.stopTime + ); + if (timeEntries.length !== allCompletedTimeEntries.length) { const lastKey = Array.from(groupedByDate.keys()).pop(); if (lastKey) { groupedByDate.delete(lastKey);