mirror of
https://github.com/morluto/rea
synced 2026-10-25 22:08:11 -04:00
018ab2c5d9
Resolve stable lexical and URL targets using shared effects, and preserve unresolved request expressions as partial facts. Carry their uncertainty through workers, artifact graphs, and the CLI. Scope partial endpoint identity to the source site. Refs: #3451, #3534 Co-authored-by: Hemang Varshney <218273197+hemv-857@users.noreply.github.com>
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { analyzeJavaScriptStaticSource } from "./javascriptStaticAnalysis.js";
|
|
|
|
const endpoints = (source: string) =>
|
|
analyzeJavaScriptStaticSource(source).endpoints.map(
|
|
({ kind, value, mechanism }) => ({ kind, value, mechanism }),
|
|
);
|
|
|
|
describe("server-sent event endpoints", () => {
|
|
it("reports EventSource URLs like WebSocket URLs", () => {
|
|
expect(
|
|
endpoints(`
|
|
new WebSocket("wss://chat.example/ws");
|
|
new EventSource("/api/chat/stream");
|
|
new window.EventSource("https://chat.example/events", { withCredentials: true });
|
|
`),
|
|
).toEqual([
|
|
{
|
|
kind: "network",
|
|
value: "wss://chat.example/ws",
|
|
mechanism: "call:WebSocket",
|
|
},
|
|
{
|
|
kind: "network",
|
|
value: "/api/chat/stream",
|
|
mechanism: "call:EventSource",
|
|
},
|
|
{
|
|
kind: "network",
|
|
value: "https://chat.example/events",
|
|
mechanism: "call:window.EventSource",
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("retains a dynamic EventSource target as partial source evidence", () => {
|
|
expect(
|
|
analyzeJavaScriptStaticSource("new EventSource(url);").endpoints,
|
|
).toEqual([
|
|
expect.objectContaining({
|
|
value: "url",
|
|
mechanism: "call:EventSource",
|
|
resolution: "partial",
|
|
}),
|
|
]);
|
|
});
|
|
});
|