Skip to content

Commit

Permalink
Rename passwordOnSeparateScreen to showPasswordOnSeparateScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
jayasanka-sack committed Dec 6, 2023
1 parent 53145eb commit 915f30e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/apps/esm-login-app/__mocks__/config.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export const mockConfig: ConfigSchema = {
links: {
loginSuccess: "${openmrsSpaBase}/home",
},
passwordOnSeparateScreen: true,
showPasswordOnSeparateScreen: true,
};
4 changes: 2 additions & 2 deletions packages/apps/esm-login-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const configSchema = {
_description: "Alt text, shown on hover",
},
},
passwordOnSeparateScreen: {
showPasswordOnSeparateScreen: {
_type: Type.Boolean,
_default: true,
_description:
Expand All @@ -98,5 +98,5 @@ export interface ConfigSchema {
src: string;
alt: string;
};
passwordOnSeparateScreen: boolean;
showPasswordOnSeparateScreen: boolean;
}
12 changes: 6 additions & 6 deletions packages/apps/esm-login-app/src/login/login.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface LoginProps extends LoginReferrer {}

const Login: React.FC<LoginProps> = () => {
const config = useConfig();
const { passwordOnSeparateScreen } = config;
const { showPasswordOnSeparateScreen } = config;
const isLoginEnabled = useConnectivity();
const { t } = useTranslation();
const { user } = useSession();
Expand All @@ -56,7 +56,7 @@ const Login: React.FC<LoginProps> = () => {

const showUsername = location.pathname === "/login";
const showPassword =
!passwordOnSeparateScreen || location.pathname === "/login/confirm";
!showPasswordOnSeparateScreen || location.pathname === "/login/confirm";

const handleLogin = useCallback(
(session: Session) => {
Expand Down Expand Up @@ -199,7 +199,7 @@ const Login: React.FC<LoginProps> = () => {
/>
)}
<Tile className={styles["login-card"]}>
{passwordOnSeparateScreen && showPassword ? (
{showPasswordOnSeparateScreen && showPassword ? (
<div className={styles["back-button-div"]}>
<Button
className={styles["back-button"]}
Expand Down Expand Up @@ -234,7 +234,7 @@ const Login: React.FC<LoginProps> = () => {
required
/>
{/* For password managers */}
{passwordOnSeparateScreen && (
{showPasswordOnSeparateScreen && (
<input
id="password"
style={hidden}
Expand All @@ -244,7 +244,7 @@ const Login: React.FC<LoginProps> = () => {
onChange={changePassword}
/>
)}
{passwordOnSeparateScreen && (
{showPasswordOnSeparateScreen && (
<Button
className={styles.continueButton}
renderIcon={(props) => <ArrowRight size={24} {...props} />}
Expand Down Expand Up @@ -275,7 +275,7 @@ const Login: React.FC<LoginProps> = () => {
showPasswordLabel="Show password"
/>
{/* For password managers */}
{passwordOnSeparateScreen && (
{showPasswordOnSeparateScreen && (
<input
id="username"
type="text"
Expand Down
10 changes: 5 additions & 5 deletions packages/apps/esm-login-app/src/login/login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ describe("Login", () => {
await user.click(screen.getByRole("button", { name: /log in/i }));
});

it("should render the both the username and password fields when the passwordOnSeparateScreen config is false", async () => {
it("should render the both the username and password fields when the showPasswordOnSeparateScreen config is false", async () => {
mockedUseConfig.mockReturnValue({
...mockConfig,
passwordOnSeparateScreen: false,
showPasswordOnSeparateScreen: false,
});

renderWithRouter(
Expand All @@ -194,7 +194,7 @@ describe("Login", () => {
expect(loginButton).toBeInTheDocument();
});

it("should not render the password field when the passwordOnSeparateScreen config is true (default)", async () => {
it("should not render the password field when the showPasswordOnSeparateScreen config is true (default)", async () => {
mockedUseConfig.mockReturnValue({
...mockConfig,
});
Expand All @@ -218,11 +218,11 @@ describe("Login", () => {
expect(loginButton).not.toBeInTheDocument();
});

it("should be able to login when the passwordOnSeparateScreen config is false", async () => {
it("should be able to login when the showPasswordOnSeparateScreen config is false", async () => {
mockedLogin.mockReturnValue(Promise.resolve({ some: "data" }));
mockedUseConfig.mockReturnValue({
...mockConfig,
passwordOnSeparateScreen: false,
showPasswordOnSeparateScreen: false,
});
const user = userEvent.setup();
mockedLogin.mockClear();
Expand Down

0 comments on commit 915f30e

Please sign in to comment.