-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hold-pages' of github.com:NYPL/research-catalog into SC…
…C-3762/patron-eligibility-errors
- Loading branch information
Showing
18 changed files
with
383 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
import { Button } from "@nypl/design-system-react-components" | ||
import { forwardRef } from "react" | ||
|
||
type AddButtonProps = { | ||
inputType?: string | ||
label: string | ||
onClick: () => void | ||
} | ||
|
||
const AddButton = ({ inputType, label, onClick }: AddButtonProps) => { | ||
return ( | ||
<Button | ||
id={inputType ? `add-${inputType}-button` : "add-button"} | ||
buttonType="text" | ||
onClick={onClick} | ||
size="large" | ||
sx={{ | ||
justifyContent: "flex-start", | ||
width: { base: "100%", md: "300px" }, | ||
paddingLeft: { base: "m", md: "unset" }, | ||
paddingTop: "xs", | ||
paddingBottom: "xs", | ||
paddingRight: "xs", | ||
}} | ||
> | ||
{label} | ||
</Button> | ||
) | ||
} | ||
const AddButton = forwardRef<HTMLButtonElement, AddButtonProps>( | ||
({ inputType, label, onClick }, ref) => { | ||
return ( | ||
<Button | ||
ref={ref} | ||
id={inputType ? `add-${inputType}-button` : "add-button"} | ||
buttonType="text" | ||
onClick={onClick} | ||
size="large" | ||
sx={{ | ||
justifyContent: "flex-start", | ||
width: { base: "100%", md: "300px" }, | ||
paddingLeft: "xs", | ||
paddingTop: "xs", | ||
paddingBottom: "xs", | ||
paddingRight: "xs", | ||
}} | ||
> | ||
{label} | ||
</Button> | ||
) | ||
} | ||
) | ||
|
||
AddButton.displayName = "AddButton" | ||
|
||
export default AddButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,36 @@ | ||
import { Button, Icon } from "@nypl/design-system-react-components" | ||
import { forwardRef } from "react" | ||
|
||
type EditButtonProps = { | ||
buttonId: string | ||
buttonLabel: string | ||
onClick: () => void | ||
} | ||
|
||
const EditButton = ({ buttonId, onClick }: EditButtonProps) => { | ||
return ( | ||
<Button | ||
id={buttonId} | ||
buttonType="text" | ||
onClick={onClick} | ||
sx={{ | ||
paddingLeft: "xs", | ||
paddingRight: "xs", | ||
marginLeft: "xxl", | ||
}} | ||
> | ||
<Icon name="editorMode" align="left" size="medium" /> | ||
Edit | ||
</Button> | ||
) | ||
} | ||
const EditButton = forwardRef<HTMLButtonElement, EditButtonProps>( | ||
({ buttonLabel, buttonId, onClick }, ref) => { | ||
return ( | ||
<Button | ||
ref={ref} | ||
id={buttonId} | ||
aria-label={buttonLabel} | ||
buttonType="text" | ||
onClick={onClick} | ||
sx={{ | ||
marginTop: { base: "unset", lg: "-xs" }, | ||
paddingTop: "0", | ||
paddingBottom: "0", | ||
paddingLeft: "xs", | ||
paddingRight: "xs", | ||
}} | ||
> | ||
<Icon name="editorMode" align="left" size="medium" /> | ||
Edit | ||
</Button> | ||
) | ||
} | ||
) | ||
|
||
EditButton.displayName = "EditButton" | ||
|
||
export default EditButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,9 @@ describe("email form", () => { | |
render(component) | ||
fireEvent.click(screen.getByRole("button", { name: /edit/i })) | ||
|
||
expect(screen.getAllByLabelText("Update emails")[0]).toBeInTheDocument() | ||
expect( | ||
screen.getByLabelText("Update primary email address") | ||
).toBeInTheDocument() | ||
expect( | ||
screen.getByDisplayValue("[email protected]") | ||
).toBeInTheDocument() | ||
|
@@ -60,12 +62,37 @@ describe("email form", () => { | |
expect(screen.queryByText(/edit/)).not.toBeInTheDocument() | ||
}) | ||
|
||
it("manages focus", async () => { | ||
render(component) | ||
fireEvent.click(screen.getByRole("button", { name: /edit/i })) | ||
|
||
await waitFor(() => | ||
expect(screen.getByLabelText("Update email address 2")).toHaveFocus() | ||
) | ||
|
||
fireEvent.click(screen.getByRole("button", { name: /cancel/i })) | ||
|
||
await waitFor(() => | ||
expect(screen.getByRole("button", { name: /edit/i })).toHaveFocus() | ||
) | ||
|
||
fireEvent.click(screen.getByRole("button", { name: /edit/i })) | ||
|
||
fireEvent.click(screen.getByText("+ Add an email address")) | ||
|
||
await waitFor(() => expect(screen.getAllByRole("textbox")[2]).toHaveFocus()) | ||
|
||
fireEvent.click(screen.getAllByLabelText("Remove email")[1]) | ||
|
||
await waitFor(() => expect(screen.getAllByRole("textbox")[1]).toHaveFocus()) | ||
}) | ||
|
||
it("validates email input correctly", () => { | ||
render(component) | ||
|
||
fireEvent.click(screen.getByRole("button", { name: /edit/i })) | ||
|
||
const input = screen.getAllByLabelText("Update emails")[0] | ||
const input = screen.getByLabelText("Update primary email address") | ||
fireEvent.change(input, { target: { value: "invalid-email" } }) | ||
|
||
expect( | ||
|
@@ -84,7 +111,7 @@ describe("email form", () => { | |
screen.getByRole("button", { name: /\+ add an email address/i }) | ||
) | ||
|
||
expect(screen.getAllByLabelText("Update emails").length).toBe( | ||
expect(screen.getAllByRole("textbox").length).toBe( | ||
processedPatron.emails.length + 1 | ||
) | ||
}) | ||
|
@@ -106,7 +133,7 @@ describe("email form", () => { | |
|
||
fireEvent.click(screen.getByRole("button", { name: /edit/i })) | ||
|
||
const input = screen.getAllByLabelText("Update emails")[0] | ||
const input = screen.getByLabelText("Update primary email address") | ||
fireEvent.change(input, { target: { value: "[email protected]" } }) | ||
|
||
fireEvent.click(screen.getByRole("button", { name: /save changes/i })) | ||
|
@@ -128,7 +155,7 @@ describe("email form", () => { | |
|
||
fireEvent.click(screen.getByRole("button", { name: /edit/i })) | ||
|
||
const input = screen.getAllByLabelText("Update emails")[0] | ||
const input = screen.getByLabelText("Update primary email address") | ||
fireEvent.change(input, { target: { value: "[email protected]" } }) | ||
|
||
fireEvent.click(screen.getByRole("button", { name: /cancel/i })) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.