hostMediaPreviewLogging.test.ts 1.1 KB

12345678910111213141516171819202122
  1. import { readFileSync } from "node:fs";
  2. import { describe, expect, it } from "vitest";
  3. describe("local media preview authorization logging", () => {
  4. it("allows four concurrent Range requests per Window Host", () => {
  5. const source = readFileSync(new URL("../src/host/index.ts", import.meta.url), "utf8");
  6. expect(source).toContain("activeRemoteMediaRequests >= 4");
  7. expect(source).toContain("getState: () => ({ active: activeRemoteMediaRequests, limit: 4 })");
  8. });
  9. it("records a low-frequency success event after Main returns a canonical path", () => {
  10. const source = readFileSync(new URL("../src/host/index.ts", import.meta.url), "utf8");
  11. const resultHandlerStart = source.indexOf(
  12. "if (msg.type === HostMessageTypes.LocalMediaPreviewPathAuthorizeResult)",
  13. );
  14. const resultHandlerEnd = source.indexOf("\n }", resultHandlerStart);
  15. const resultHandler = source.slice(resultHandlerStart, resultHandlerEnd);
  16. expect(resultHandlerStart).toBeGreaterThan(0);
  17. expect(resultHandler).toContain('logger.info("local media preview path authorization OK")');
  18. });
  19. });