Skip to content

Commit

Permalink
Show print button when hideDropZone is true
Browse files Browse the repository at this point in the history
  • Loading branch information
jamdelion committed Oct 7, 2024
1 parent da15b40 commit 39a545f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { act, screen, waitFor, within } from "@testing-library/react";
import { UserEvent } from "@testing-library/user-event/dist/types/setup/setup";
import axios from "axios";
import { useStore } from "pages/FlowEditor/lib/store";
import { FullStore } from "pages/FlowEditor/lib/store";
import { FullStore, useStore } from "pages/FlowEditor/lib/store";
import React from "react";
import { setup } from "testUtils";
import { Breadcrumbs } from "types";
Expand Down Expand Up @@ -60,6 +59,18 @@ describe("Basic state and setup", () => {
expect(results).toHaveNoViolations();
});

it("does not show a print button if hideDropZone is false", async () => {
const { queryByText } = setup(
<FileUploadAndLabelComponent
title="Test title"
fileTypes={[mockFileTypes.AlwaysRequired, mockFileTypes.NotRequired]}
// hideDropZone is false by default
/>,
);
const printButton = queryByText("Print this page");
expect(printButton).toBeNull();
});

test("shows help buttons for header and applicable file", async () => {
const { getAllByTestId } = setup(
<FileUploadAndLabelComponent
Expand Down Expand Up @@ -141,6 +152,17 @@ describe("Info-only mode with hidden drop zone", () => {
expect(results).toHaveNoViolations();
});

it("shows a print button", async () => {
const { getByText } = setup(
<FileUploadAndLabelComponent
title="Test title"
fileTypes={[mockFileTypes.AlwaysRequired, mockFileTypes.NotRequired]}
hideDropZone={true}
/>,
);
expect(getByText("Print this page")).toBeVisible();
});

test("shows help buttons for header and applicable file", async () => {
const { getAllByTestId } = setup(
<FileUploadAndLabelComponent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
import PrintIcon from "@mui/icons-material/Print";
import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import List from "@mui/material/List";
Expand Down Expand Up @@ -271,6 +272,17 @@ function Component(props: Props) {
</Box>
</ErrorWrapper>
</FullWidthWrapper>
{props.hideDropZone && (
<Button
variant="contained"
color="secondary"
startIcon={<PrintIcon />}
size="large"
onClick={() => window.print()}
>
Print this page
</Button>
)}
</Card>
);
}
Expand Down

0 comments on commit 39a545f

Please sign in to comment.