mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Server stops phoning Sentry home after opt-out (release-health sessions + client reports off); settings saves diff-send only changed keys so a stale tab cannot revert an instance-wide opt-out; disabling analytics hides the feedback UI immediately; optIn resumes PostHog after re-enable; onboarding survey writes time out at 15s; inline tool-feedback prompt arms a shown-cooldown.
27 lines
816 B
TypeScript
27 lines
816 B
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { withTimeout } from "@/lib/with-timeout";
|
|
|
|
beforeEach(() => {
|
|
vi.useFakeTimers();
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.useRealTimers();
|
|
});
|
|
|
|
describe("withTimeout", () => {
|
|
it("resolves with the promise value when it settles before the deadline", async () => {
|
|
await expect(withTimeout(Promise.resolve("ok"), 1000)).resolves.toBe("ok");
|
|
});
|
|
|
|
it("rejects when the promise is still pending past the deadline", async () => {
|
|
const neverSettles = new Promise<string>(() => {});
|
|
const settled = withTimeout(neverSettles, 1000).then(
|
|
() => "resolved",
|
|
(err: Error) => `rejected:${err.message}`,
|
|
);
|
|
await vi.advanceTimersByTimeAsync(1000);
|
|
expect(await settled).toMatch(/rejected:.*timed out/i);
|
|
});
|
|
});
|