The best way to control Claude Code, Codex and more from any computer or phone

main
ts 115 lines 3.51 KB
Raw
1 import { describe, expect, it } from "@effect/vitest";
2
3 import { layoutChecks, type Snapshot, type SnapshotNode } from "./checks.ts";
4
5 const APP = "com.t3tools.t3code.dev";
6 const node = (index: number, fields: Omit<SnapshotNode, "index">): SnapshotNode => ({
7 index,
8 hittable: true,
9 kind: "button",
10 ...fields,
11 });
12
13 const failing = (snapshot: Snapshot) =>
14 Object.fromEntries(
15 layoutChecks(snapshot, APP)
16 .filter((item) => !item.pass)
17 .map((item) => [item.name, item.detail]),
18 );
19
20 describe("layoutChecks", () => {
21 it("flags broken chrome but not scrolled content, nested controls or duplicates", () => {
22 const snapshot: Snapshot = {
23 appBundleId: APP,
24 viewport: { width: 400, height: 800 },
25 nodes: [
26 node(0, {
27 kind: "application",
28 hittable: false,
29 rect: { x: 0, y: 0, width: 400, height: 800 },
30 }),
31 node(1, {
32 kind: "scroll-area",
33 parentIndex: 0,
34 rect: { x: 0, y: 0, width: 400, height: 700 },
35 }),
36 node(2, {
37 label: "Row past the edge",
38 parentIndex: 1,
39 rect: { x: 0, y: 680, width: 400, height: 60 },
40 }),
41 node(3, { label: "Send", parentIndex: 0, rect: { x: 340, y: 770, width: 80, height: 40 } }),
42 node(4, {
43 label: "Card",
44 parentIndex: 0,
45 rect: { x: 10, y: 100, width: 200, height: 100 },
46 }),
47 node(5, { label: "Inner", parentIndex: 4, rect: { x: 20, y: 110, width: 50, height: 40 } }),
48 node(6, { label: "Twin", parentIndex: 0, rect: { x: 10, y: 300, width: 80, height: 40 } }),
49 node(7, { label: "Twin", parentIndex: 0, rect: { x: 10, y: 300, width: 80, height: 40 } }),
50 node(8, {
51 label: "Plan",
52 parentIndex: 0,
53 rect: { x: 100, y: 400, width: 100, height: 40 },
54 }),
55 node(9, {
56 label: "Stop",
57 parentIndex: 0,
58 rect: { x: 120, y: 405, width: 100, height: 40 },
59 }),
60 node(10, {
61 kind: "text-field",
62 label: "Message",
63 parentIndex: 0,
64 rect: { x: 0, y: 600, width: 300, height: 40 },
65 }),
66 node(12, {
67 label: "Row of a covered screen",
68 parentIndex: 1,
69 rect: { x: 100, y: 400, width: 100, height: 40 },
70 }),
71 node(11, {
72 kind: "keyboard",
73 hittable: false,
74 rect: { x: 0, y: 500, width: 400, height: 300 },
75 }),
76 ],
77 };
78
79 expect(failing(snapshot)).toEqual({
80 "no control cut off by the screen edge": '"Send" at 340,770 80×40',
81 "no controls stacked on each other": '"Plan" and "Stop"',
82 "no input under the keyboard": '"Message" at 0,600 300×40',
83 });
84 });
85
86 it("flags an error screen and controls under Android system bars", () => {
87 const snapshot: Snapshot = {
88 appBundleId: APP,
89 viewport: { width: 1080, height: 2400 },
90 nodes: [
91 node(0, {
92 kind: "text",
93 label: "Render Error",
94 rect: { x: 0, y: 200, width: 600, height: 60 },
95 }),
96 node(1, {
97 kind: "text",
98 systemBar: "status",
99 bundleId: "com.android.systemui",
100 rect: { x: 0, y: 0, width: 1080, height: 60 },
101 }),
102 node(2, {
103 label: "Search",
104 bundleId: APP,
105 rect: { x: 900, y: 10, width: 120, height: 80 },
106 }),
107 ],
108 };
109
110 expect(Object.keys(failing(snapshot))).toEqual([
111 "no error screen",
112 "no control under a system bar",
113 ]);
114 });
115 });