Skip to content

Commit

Permalink
Update desktop tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OKendigelyan committed Sep 26, 2024
1 parent 1ae6f1d commit 16efe96
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/desktop/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export default {
rootDir: "./",
testTimeout: 20000,
bail: false,
setupFilesAfterEnv: ["<rootDir>/src/setupTests.ts"],
setupFilesAfterEnv: ["<rootDir>/src/setupTests.tsx"],
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jest.mock("@umami/state", () => ({
}));

const MOCK_TEZOS_TOOLKIT = {};
const password = "Qwerty123123!23vcxz";
let store: UmamiStore;

beforeEach(() => {
Expand Down Expand Up @@ -124,7 +125,7 @@ describe("<MultisigPendingOperation />", () => {

expect(jest.mocked(estimate)).toHaveBeenCalledWith(operation, MAINNET);

await act(() => user.type(screen.getByTestId("password"), "mockPass"));
await act(() => user.type(screen.getByTestId("password"), password));

const submitButton = screen.getByRole("button", {
name: "Execute transaction",
Expand Down Expand Up @@ -187,7 +188,7 @@ describe("<MultisigPendingOperation />", () => {

expect(jest.mocked(estimate)).toHaveBeenCalledWith(operations, MAINNET);

await act(() => user.type(screen.getByTestId("password"), "mockPass"));
await act(() => user.type(screen.getByTestId("password"), password));

const submitButton = screen.getByRole("button", {
name: "Approve transaction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { noop } from "lodash";
import { EnterAndConfirmPassword } from "./EnterAndConfirmPassword";
import { act, render, screen, userEvent } from "../../../../mocks/testUtils";

const mockPassword = "Qwerty123123!23vcxz";

const fixture = (isLoading: boolean) => (
<EnterAndConfirmPassword isLoading={isLoading} onSubmit={noop} />
);
Expand All @@ -24,12 +26,12 @@ describe("<EnterAndConfirmPassword />", () => {
describe("Form", () => {
test("Working verification", async () => {
render(fixture(false));
await checkPasswords("password", "password", true);
await checkPasswords(mockPassword, mockPassword, true);
});

test("Not matching password", async () => {
render(fixture(false));
await checkPasswords("password", "password1", false);
await checkPasswords(mockPassword, "password1", false);
});

test("Not meeting password policy", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { noop } from "lodash";
import { EnterPassword } from "./EnterPassword";
import { act, render, screen, userEvent } from "../../../../mocks/testUtils";

const mockPassword = "Qwerty123123!23vcxz";

const fixture = (isLoading: boolean) => <EnterPassword isLoading={isLoading} onSubmit={noop} />;

const checkPasswords = async (password: string, expected: boolean) => {
Expand All @@ -19,7 +21,7 @@ describe("<EnterPassword />", () => {
describe("Form", () => {
test("Working verification", async () => {
render(fixture(false));
await checkPasswords("password", true);
await checkPasswords(mockPassword, true);
});

test("Not meeting password policy", async () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/SendFlow/SignButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const SignButton = ({
<Box width="100%">
<FormProvider {...form}>
<FormControl isInvalid={!!errors.password} marginY="16px">
<PasswordInput data-testid="password" inputName="password" />
<PasswordInput data-testid="password" inputName="password" minLength={0} />
{errors.password && <FormErrorMessage>{errors.password.message}</FormErrorMessage>}
</FormControl>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ MockDate.set("2023-03-27T14:15:09.760Z");

jest.mock("./env", () => ({ IS_DEV: false }));

jest.mock("@umami/components", () => ({
...jest.requireActual("@umami/components"),
usePasswordValidation: () => ({
validatePassword: () => true,
PasswordStrengthBar: <div>PasswordStrengthBar</div>,
}),
}));

beforeEach(() => {
// Add missing browser APIs
Object.defineProperties(global, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const request: SignPayloadRequestOutput = {
};

const account = mockMnemonicAccount(1);
const password = "Qwerty123123!23vcxz";

let store: UmamiStore;

Expand Down

0 comments on commit 16efe96

Please sign in to comment.