mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-11 16:45:13 +00:00
# Which Problems Are Solved Invalid formatting in the login codebase due to invalid prettier configuration # How the Problems Are Solved Fxed .prettierignore wildcards for login source files # Additional Changes Removed .prettierrc file because there is already a prettier.config.mjs file # Additional Context
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { cleanup, render } from "@testing-library/react";
|
|
import { create } from "@zitadel/client";
|
|
import { PasswordComplexitySettingsSchema } from "@zitadel/proto/zitadel/settings/v2/password_settings_pb";
|
|
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
import { ChangePasswordForm } from "./change-password-form";
|
|
|
|
vi.mock("next/navigation", () => ({
|
|
useRouter: () => ({ push: vi.fn() }),
|
|
}));
|
|
|
|
vi.mock("next-intl", () => ({
|
|
useTranslations: () => (key: string) => key,
|
|
}));
|
|
|
|
vi.mock("@/lib/server/password", () => ({
|
|
checkSessionAndSetPassword: vi.fn(),
|
|
sendPassword: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("@/lib/client", () => ({
|
|
handleServerActionResponse: vi.fn(),
|
|
}));
|
|
|
|
const defaultComplexitySettings = create(PasswordComplexitySettingsSchema, {
|
|
minLength: 8n,
|
|
requiresUppercase: false,
|
|
requiresLowercase: false,
|
|
requiresNumber: false,
|
|
requiresSymbol: false,
|
|
});
|
|
|
|
describe("ChangePasswordForm", () => {
|
|
afterEach(cleanup);
|
|
|
|
test("should autofocus the current password input on mount", () => {
|
|
const { getByTestId } = render(
|
|
<ChangePasswordForm
|
|
passwordComplexitySettings={defaultComplexitySettings}
|
|
sessionId="session-1"
|
|
loginName="[email protected]"
|
|
/>,
|
|
);
|
|
expect(getByTestId("password-change-current-text-input")).toHaveFocus();
|
|
});
|
|
});
|