fix(files): the token list is fresh after the sessions end, a copy again reads Copied again, the Copied button says so

This commit is contained in:
2026-10-15 05:47:00 +02:00
parent 620f84dba4
commit a248ca6c13
10 changed files with 133 additions and 6 deletions
@@ -32,6 +32,18 @@ describe("useCopyFeedback", () => {
expect(result.current.copied).toBe(false);
});
it("a copy again within the moment reads Copied for a whole moment again", async () => {
vi.useFakeTimers();
const { result } = renderHook(() => useCopyFeedback());
await act(() => result.current.copy("sfl_x"));
act(() => void vi.advanceTimersByTime(1500));
await act(() => result.current.copy("sfl_x"));
act(() => void vi.advanceTimersByTime(1000)); // past the first copy's moment
expect(result.current.copied).toBe(true);
act(() => void vi.advanceTimersByTime(1000));
expect(result.current.copied).toBe(false);
});
it("a copy the clipboard refused is a warning, and nothing reads Copied", async () => {
h.copyText.mockResolvedValueOnce(false);
const { result } = renderHook(() => useCopyFeedback());