refactor: ponytail audit

This commit is contained in:
Amruth Pillai
2026-07-27 20:26:16 +02:00
parent bb1fb3a7d6
commit 9110e86997
157 changed files with 1082 additions and 2177 deletions
+5 -5
View File
@@ -24,7 +24,7 @@ describe("useConfirm", () => {
const { result } = renderHook(() => useConfirm(), { wrapper });
let promise!: Promise<boolean>;
await act(async () => {
await act(() => {
promise = result.current("Are you sure?");
});
expect(promise).toBeInstanceOf(Promise);
@@ -34,7 +34,7 @@ describe("useConfirm", () => {
const { result } = renderHook(() => useConfirm(), { wrapper });
let promise!: Promise<boolean>;
await act(async () => {
await act(() => {
promise = result.current("Heading");
});
@@ -44,7 +44,7 @@ describe("useConfirm", () => {
const buttons = Array.from(document.body.querySelectorAll<HTMLButtonElement>("button"));
const cancel = buttons.find((b) => /cancel/i.test(b.textContent ?? ""));
await act(async () => {
await act(() => {
(cancelBtn as HTMLButtonElement | null)?.click() ?? cancel?.click();
});
@@ -55,14 +55,14 @@ describe("useConfirm", () => {
const { result } = renderHook(() => useConfirm(), { wrapper });
let promise!: Promise<boolean>;
await act(async () => {
await act(() => {
promise = result.current("Heading", { confirmText: "Yes" });
});
const buttons = Array.from(document.body.querySelectorAll<HTMLButtonElement>("button"));
const yes = buttons.find((b) => /yes/i.test(b.textContent ?? ""));
await act(async () => {
await act(() => {
yes?.click();
});
+1 -1
View File
@@ -43,7 +43,7 @@ export function ConfirmDialogProvider({ children }: ConfirmDialogProviderProps)
cancelText: undefined,
});
const confirm = React.useCallback(async (title: string, options?: ConfirmOptions): Promise<boolean> => {
const confirm = React.useCallback((title: string, options?: ConfirmOptions): Promise<boolean> => {
return new Promise<boolean>((resolve) => {
setState({
open: true,
+1 -1
View File
@@ -48,7 +48,7 @@ export function useFormBlocker<TStore extends BlockableFormStore>(
return isDirty && !isSubmitting;
}, [isDirty, isSubmitting]);
const confirmClose = useCallback(async () => {
const confirmClose = useCallback(() => {
if (!shouldBlock()) return true;
return confirm(t`Are you sure you want to close this dialog?`, {
+6 -6
View File
@@ -34,11 +34,11 @@ describe("usePrompt", () => {
const { result } = renderHook(() => usePrompt(), { wrapper });
let promise!: Promise<string | null>;
await act(async () => {
await act(() => {
promise = result.current("Name?");
});
await act(async () => {
await act(() => {
clickButton(/cancel/i);
});
@@ -49,11 +49,11 @@ describe("usePrompt", () => {
const { result } = renderHook(() => usePrompt(), { wrapper });
let promise!: Promise<string | null>;
await act(async () => {
await act(() => {
promise = result.current("Name?", { defaultValue: "Initial" });
});
await act(async () => {
await act(() => {
clickButton(/confirm/i);
});
@@ -64,7 +64,7 @@ describe("usePrompt", () => {
const { result } = renderHook(() => usePrompt(), { wrapper });
let promise!: Promise<string | null>;
await act(async () => {
await act(() => {
promise = result.current("Heading", { defaultValue: "preset" });
});
@@ -72,7 +72,7 @@ describe("usePrompt", () => {
const input = document.body.querySelector("input") as HTMLInputElement | null;
expect(input?.value).toBe("preset");
await act(async () => {
await act(() => {
clickButton(/confirm/i);
});
+1 -1
View File
@@ -67,7 +67,7 @@ export function PromptDialogProvider({ children }: PromptDialogProviderProps) {
return () => window.clearTimeout(timeoutId);
}, [state.open]);
const prompt = React.useCallback(async (title: string, options?: PromptOptions): Promise<string | null> => {
const prompt = React.useCallback((title: string, options?: PromptOptions): Promise<string | null> => {
return new Promise<string | null>((resolve) => {
setState({
open: true,