Skip to content

Commit

Permalink
🚑️ Fix day being removed when counter is running up
Browse files Browse the repository at this point in the history
  • Loading branch information
karlosos committed Nov 6, 2023
1 parent 5dcea1d commit 72c182c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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
});
});
5 changes: 4 additions & 1 deletion src/app/features/TimeEntries/store/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 72c182c

Please sign in to comment.