Skip to content

Commit

Permalink
CRDCDH-1740 Init refactor of History Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
amattu2 committed Oct 18, 2024
1 parent 33120e9 commit 8e65060
Show file tree
Hide file tree
Showing 5 changed files with 303 additions and 156 deletions.
39 changes: 39 additions & 0 deletions src/components/HistoryDialog/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,45 @@ describe("Implementation Requirements", () => {
).toHaveAttribute("title", "2024-09-05T14:45:00Z");
});

it("should render the name for each history item if provided", () => {
const history: HistoryBase<MockStatuses>[] = [
{
status: "uploaded",
dateTime: "2024-09-25T14:45:00Z",
userID: "test",
userName: "Test User",
},
{
status: "downloaded",
dateTime: "2024-09-11T14:45:00Z",
userID: "test",
userName: "Another User",
},
];

const { getByTestId } = render(<HistoryDialog {...BaseProps} history={history} />);

expect(
within(getByTestId("history-item-0")).getByTestId("history-item-0-name")
).toHaveTextContent("Test User");

expect(
within(getByTestId("history-item-1")).getByTestId("history-item-1-name")
).toHaveTextContent("Another User");
});

it("should not render the name for each history item if not provided", () => {
const history: HistoryBase<MockStatuses>[] = [
{ status: "uploaded", dateTime: "2024-09-25T14:45:00Z", userID: "test" },
{ status: "downloaded", dateTime: "2024-09-11T14:45:00Z", userID: "test" },
];

const { queryByTestId } = render(<HistoryDialog {...BaseProps} history={history} />);

expect(queryByTestId("history-item-0-name")).not.toBeInTheDocument();
expect(queryByTestId("history-item-1-name")).not.toBeInTheDocument();
});

it("should fallback to #FFF if getTextColor is not a function", () => {
const history: HistoryBase<MockStatuses>[] = [
{ status: "uploaded", dateTime: "2024-09-05T14:45:00Z", userID: "test", reviewComment: "" },
Expand Down
Loading

0 comments on commit 8e65060

Please sign in to comment.