Skip to content

fix: update tests for useClipboard to minimize risks of flakes #13250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 15, 2024
Merged
Prev Previous commit
refactor: split off type alias for clarity
  • Loading branch information
Parkreiner committed May 15, 2024
commit 58beffc2c71a08092ec4926d994644a972ef495b
4 changes: 3 additions & 1 deletion site/src/hooks/useClipboard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ function renderUseClipboard<TInput extends UseClipboardInput>(inputs: TInput) {
);
}

type RenderResult = ReturnType<typeof renderUseClipboard>["result"];

// execCommand is the workaround for copying text to the clipboard on HTTP-only
// connections
const originalExecCommand = global.document.execCommand;
Expand Down Expand Up @@ -184,7 +186,7 @@ describe.each(secureContextValues)("useClipboard - secure: %j", (isSecure) => {
});

const assertClipboardUpdateLifecycle = async (
result: ReturnType<typeof renderUseClipboard>["result"],
result: RenderResult,
textToCheck: string,
): Promise<void> => {
await act(() => result.current.copyToClipboard());
Expand Down
Loading