-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Input password component layout to avoid password manager butt…
…on overlap with visibility button (#12398) * Update Input password component visibilty button * Update layout to prevent password manager buttons from overlapping with visiblity button * Apply consistent layout to both password and non-password inputs * Add Input component unit test * Update InputProps to interface * Ensure input component can be assigned type * Add aria label to visiblity button in password input * Fix type issues with testutils render
- Loading branch information
Showing
4 changed files
with
123 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { render } from "utils/testutils"; | ||
|
||
import { Input } from "./Input"; | ||
|
||
describe("<Input />", () => { | ||
test("renders text input", async () => { | ||
const value = "[email protected]"; | ||
const { getByTestId, queryByTestId } = await render(<Input type="text" defaultValue={value} />); | ||
|
||
expect(getByTestId("input")).toHaveAttribute("type", "text"); | ||
expect(getByTestId("input")).toHaveValue(value); | ||
expect(queryByTestId("toggle-password-visibility-button")).toBeFalsy(); | ||
}); | ||
|
||
test("renders another type of input", async () => { | ||
const type = "number"; | ||
const value = 888; | ||
const { getByTestId, queryByTestId } = await render(<Input type={type} defaultValue={value} />); | ||
|
||
expect(getByTestId("input")).toHaveAttribute("type", type); | ||
expect(getByTestId("input")).toHaveValue(value); | ||
expect(queryByTestId("toggle-password-visibility-button")).toBeFalsy(); | ||
}); | ||
|
||
test("renders password input with visibilty button", async () => { | ||
const value = "eight888"; | ||
const { getByTestId, getByRole } = await render(<Input type="password" defaultValue={value} />); | ||
|
||
expect(getByTestId("input")).toHaveAttribute("type", "password"); | ||
expect(getByTestId("input")).toHaveValue(value); | ||
expect(getByRole("img", { hidden: true })).toHaveAttribute("data-icon", "eye"); | ||
}); | ||
|
||
test("renders visible password when visibility button is clicked", async () => { | ||
const value = "eight888"; | ||
const { getByTestId, getByRole } = await render(<Input type="password" defaultValue={value} />); | ||
|
||
getByTestId("toggle-password-visibility-button")?.click(); | ||
|
||
expect(getByTestId("input")).toHaveAttribute("type", "text"); | ||
expect(getByTestId("input")).toHaveValue(value); | ||
expect(getByRole("img", { hidden: true })).toHaveAttribute("data-icon", "eye-slash"); | ||
}); | ||
}); |
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