Liquid Glass for the web: the rim refraction, light and motion of iOS 27 glass on any rounded element. React bindings and pill tabs. MIT.
| 5 | import app from "./app.config"; |
| 6 | import { listWritten, publicDir, render } from "./scripts/agent-docs"; |
| 7 |
| 8 | // Run with `npm test`. |
| 9 | describe("Liquid Glass site", () => { |
| 10 | it("looks up an option for agents", async () => { |
| 11 | const workspace = createTestWorkspace(app); |
| 12 | const { output } = await workspace.invokeSiteTool("liquid-glass.reference", { name: "swell" }, { visitorId: "vis_agent" }); |
| 13 | const result = output as { matches: { name: string; group: string }[]; names: string[] }; |
| 14 | expect(result.matches).toEqual([expect.objectContaining({ name: "swell", group: "Glass options" })]); |
| 15 | expect(result.names).toContain("handle.magnify(factor)"); |
| 16 | }); |
| 17 |
| 18 | it("finds methods and tabs options by their bare names", async () => { |
| 19 | const workspace = createTestWorkspace(app); |
| 20 | const lookup = async (name: string) => |
| 21 | ((await workspace.invokeSiteTool("liquid-glass.reference", { name }, { visitorId: "vis_agent" })).output as { matches: { name: string }[] }).matches.map( |
| 22 | (match) => match.name, |
| 23 | ); |
| 24 | expect(await lookup("magnify")).toEqual(["magnify(factor)"]); |
| 25 | expect(await lookup("tabs.orientation")).toEqual(["orientation"]); |
| 26 | expect(await lookup("LiquidGlass")).toEqual(["<LiquidGlass />"]); |
| 27 | }); |
| 28 |
| 29 | it("writes a snippet for a set of options", async () => { |
| 30 | const workspace = createTestWorkspace(app); |
| 31 | const { output } = await workspace.invokeSiteTool( |
| 32 | "liquid-glass.snippet", |
| 33 | { floating: "dialog", swell: true, samples: 4, geometry: { maxFall: 0.5 } }, |
| 34 | { visitorId: "vis_agent" }, |
| 35 | ); |
| 36 | const code = (output as { code: string }).code; |
| 37 | expect(code).toContain('floating="dialog"'); |
| 38 | expect(code).toContain("swell"); |
| 39 | expect(code).toContain("samples={4}"); |
| 40 | expect(code).toContain("geometry={{ maxFall: 0.5 }}"); |
| 41 | }); |
| 42 |
| 43 | it("serves agent docs that match site/api.ts (run `npm run docs` if this fails)", () => { |
| 44 | const files = render(); |
| 45 | for (const [path, content] of files) { |
| 46 | expect(readFileSync(join(publicDir, path), "utf8"), path).toBe(content); |
| 47 | } |
| 48 | expect(listWritten().sort()).toEqual([...files.keys()].filter((path) => path.startsWith("docs/")).sort()); |
| 49 | }); |
| 50 | }); |
| 51 |