|
1 | 1 | import { Schema } from "effect"; |
2 | 2 | import { describe, expect, it } from "vite-plus/test"; |
3 | 3 |
|
4 | | -import { PreviewAutomationHost, PreviewAutomationStatus } from "./previewAutomation.ts"; |
| 4 | +import { EnvironmentId, ThreadId } from "./baseSchemas.ts"; |
| 5 | +import { |
| 6 | + PreviewAutomationHost, |
| 7 | + PreviewAutomationInvalidSelectorError, |
| 8 | + PreviewAutomationStatus, |
| 9 | +} from "./previewAutomation.ts"; |
| 10 | +import { ProviderInstanceId } from "./providerInstance.ts"; |
5 | 11 |
|
6 | 12 | const decodeAutomationHost = Schema.decodeUnknownSync(PreviewAutomationHost); |
7 | 13 | const decodeAutomationStatus = Schema.decodeUnknownSync(PreviewAutomationStatus); |
@@ -42,3 +48,38 @@ describe("PreviewAutomationStatus", () => { |
42 | 48 | ).toEqual({ width: 412, height: 915 }); |
43 | 49 | }); |
44 | 50 | }); |
| 51 | + |
| 52 | +describe("PreviewAutomationInvalidSelectorError", () => { |
| 53 | + const invalidSelector = (selectorKind: "locator" | "selector") => |
| 54 | + new PreviewAutomationInvalidSelectorError({ |
| 55 | + operation: "click", |
| 56 | + environmentId: EnvironmentId.make("environment-1"), |
| 57 | + threadId: ThreadId.make("thread-1"), |
| 58 | + providerSessionId: "session-1", |
| 59 | + providerInstanceId: ProviderInstanceId.make("claude"), |
| 60 | + clientId: "desktop", |
| 61 | + connectionId: "connection-1", |
| 62 | + requestId: "request-1", |
| 63 | + timeoutMs: 15_000, |
| 64 | + remoteTag: "Error", |
| 65 | + remoteMessageLength: 0, |
| 66 | + cause: null, |
| 67 | + selectorKind, |
| 68 | + selectorLength: 42, |
| 69 | + }); |
| 70 | + |
| 71 | + it("tells agents which locator forms are accepted and where CSS goes", () => { |
| 72 | + const { message } = invalidSelector("locator"); |
| 73 | + expect(message).toContain("aria-ref="); |
| 74 | + expect(message).toMatch(/role/); |
| 75 | + expect(message).toMatch(/text/); |
| 76 | + expect(message).toMatch(/CSS[^.]*\bselector\b/); |
| 77 | + }); |
| 78 | + |
| 79 | + it("points an invalid CSS selector at the locator alternative", () => { |
| 80 | + const { message } = invalidSelector("selector"); |
| 81 | + expect(message).toMatch(/CSS/); |
| 82 | + expect(message).toMatch(/\blocator\b/); |
| 83 | + expect(message).toContain("aria-ref="); |
| 84 | + }); |
| 85 | +}); |
0 commit comments