fix(driver): support installation over insecure HTTP

This commit is contained in:
t8y2 committed 2026-08-01 19:56:36 +08:00
1 parent 1bd223074c
commit 44e4050852
4 files changed
+48 -6

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { uuid } from "@/lib/common/utils";
describe("uuid", () => {
afterEach(() => {
vi.unstubAllGlobals();
});
it("uses crypto.randomUUID when available", () => {
const randomUUID = vi.fn(() => "123e4567-e89b-42d3-a456-426614174000");
vi.stubGlobal("crypto", { randomUUID });
expect(uuid()).toBe("123e4567-e89b-42d3-a456-426614174000");
expect(randomUUID).toHaveBeenCalledOnce();
});
it("generates a UUID when crypto.randomUUID is unavailable", () => {
vi.stubGlobal("crypto", {});
expect(uuid()).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);
});
});