Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OKendigelyan committed Sep 25, 2024
1 parent e223fd7 commit 58736f6
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe("ChangePassword Form", () => {
});
});

it("requires 8 characters", async () => {
it("requires 12 characters", async () => {
render(fixture());

const newPasswordInput = screen.getByTestId("new-password");
Expand All @@ -55,7 +55,7 @@ describe("ChangePassword Form", () => {

await waitFor(() => {
expect(screen.getByTestId("new-password-error")).toHaveTextContent(
"Your password must be at least 8 characters long"
"Your password must be at least 12 characters long"
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export const MasterPasswordModal = ({ onSubmit }: MasterPasswordModalProps) => {
data-testid="master-password"
inputName="password"
label="Password"
minLength={0}
placeholder="Enter your password"
required="Password is required"
/>
</ModalBody>
<ModalFooter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jest.mock("@umami/state", () => ({
changeMnemonicPassword: jest.fn(),
}));

const currentPassword = "Qwerty123123!23vcxz";
const newPassword = "Qwerty123123!23vcxz32llll";

describe("<ChangePasswordMenu />", () => {
describe("currentPassword", () => {
it("is empty by default", async () => {
Expand Down Expand Up @@ -47,7 +50,7 @@ describe("<ChangePasswordMenu />", () => {
});
});

it("requires 8 characters", async () => {
it("requires 12 characters", async () => {
const user = userEvent.setup();
await renderInDrawer(<ChangePasswordMenu />);

Expand All @@ -57,7 +60,7 @@ describe("<ChangePasswordMenu />", () => {

await waitFor(() => {
expect(screen.getByTestId("new-password-error")).toHaveTextContent(
"Your password must be at least 8 characters long"
"Your password must be at least 12 characters long"
);
});
});
Expand Down Expand Up @@ -108,9 +111,9 @@ describe("<ChangePasswordMenu />", () => {
const newPasswordInput = screen.getByTestId("new-password");
const newPasswordConfirmationInput = screen.getByTestId("new-password-confirmation");

await user.type(currentPasswordInput, "myOldPassword");
await user.type(newPasswordInput, "myNewPassword");
await user.type(newPasswordConfirmationInput, "myNewPassword");
await user.type(currentPasswordInput, currentPassword);
await user.type(newPasswordInput, newPassword);
await user.type(newPasswordConfirmationInput, newPassword);

expect(screen.getByRole("button", { name: "Update Password" })).toBeEnabled();
});
Expand All @@ -123,15 +126,15 @@ describe("<ChangePasswordMenu />", () => {
const newPasswordInput = screen.getByTestId("new-password");
const newPasswordConfirmationInput = screen.getByTestId("new-password-confirmation");

await user.type(currentPasswordInput, "myOldPassword");
await user.type(newPasswordInput, "myNewPassword");
await user.type(newPasswordConfirmationInput, "myNewPassword");
await user.type(currentPasswordInput, currentPassword);
await user.type(newPasswordInput, newPassword);
await user.type(newPasswordConfirmationInput, newPassword);

await user.click(screen.getByRole("button", { name: "Update Password" }));

expect(changeMnemonicPassword).toHaveBeenCalledWith({
currentPassword: "myOldPassword",
newPassword: "myNewPassword",
currentPassword: currentPassword,
newPassword: newPassword,
});
});
});
Expand Down
5 changes: 3 additions & 2 deletions apps/web/src/components/Menu/Menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jest.mock("@umami/state", () => ({

let store: UmamiStore;
const account = mockImplicitAccount(0);
const password = "Qwerty123123!23vcxz";

beforeEach(() => {
store = makeStore();
Expand Down Expand Up @@ -96,8 +97,8 @@ describe("<Menu />", () => {

await user.click(screen.getByText("Save Backup"));

await user.type(screen.getByLabelText("Set Password"), "password");
await user.type(screen.getByLabelText("Confirm Password"), "password");
await user.type(screen.getByLabelText("Set Password"), password);
await user.type(screen.getByLabelText("Confirm Password"), password);
await user.click(screen.getByRole("button", { name: "Save Backup" }));

expect(mockDownloadBackupFile).toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jest.mock("@umami/state", () => ({
useIsPasswordSet: jest.fn(),
}));

const password = "password";
const password = "Qwerty123123!23vcxz";

beforeEach(() => {
jest.mocked(useGetDecryptedMnemonic).mockReturnValue(() => Promise.resolve(mnemonic1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const SetupPassword = ({ mode }: SetupPasswordProps) => {
const downloadBackupFile = useDownloadBackupFile();

const form = useMultiForm<FormFields>({
mode: "onChange",
mode: "all",
defaultValues: {
derivationPath: defaultDerivationPathTemplate,
curve: "ed25519",
Expand Down Expand Up @@ -201,6 +201,7 @@ export const SetupPassword = ({ mode }: SetupPasswordProps) => {
checkPasswordStrength={!isPasswordSet}
inputName="password"
label={isPasswordSet ? "Password" : "Set Password"}
required="Password is required"
/>
{!isPasswordSet && (
<PasswordInput
Expand Down
24 changes: 12 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 58736f6

Please sign in to comment.