wyreframe 0.1.0 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE +692 -0
  2. package/README.md +65 -5
  3. package/package.json +8 -7
  4. package/src/index.ts +425 -0
  5. package/src/renderer/Renderer.gen.tsx +49 -0
  6. package/src/renderer/Renderer.mjs +41 -1
  7. package/src/renderer/Renderer.res +78 -0
  8. package/src/parser/Core/__tests__/Bounds_test.mjs +0 -326
  9. package/src/parser/Core/__tests__/Bounds_test.res +0 -412
  10. package/src/parser/Core/__tests__/Grid_test.mjs +0 -322
  11. package/src/parser/Core/__tests__/Grid_test.res +0 -319
  12. package/src/parser/Core/__tests__/Types_test.mjs +0 -614
  13. package/src/parser/Core/__tests__/Types_test.res +0 -650
  14. package/src/parser/Detector/__tests__/BoxTracer_test.mjs +0 -70
  15. package/src/parser/Detector/__tests__/BoxTracer_test.res +0 -92
  16. package/src/parser/Detector/__tests__/HierarchyBuilder_test.mjs +0 -489
  17. package/src/parser/Detector/__tests__/HierarchyBuilder_test.res +0 -849
  18. package/src/parser/Detector/__tests__/ShapeDetector_test.mjs +0 -377
  19. package/src/parser/Detector/__tests__/ShapeDetector_test.res +0 -563
  20. package/src/parser/Interactions/__tests__/InteractionMerger_test.mjs +0 -576
  21. package/src/parser/Interactions/__tests__/InteractionMerger_test.res +0 -646
  22. package/src/parser/Scanner/__tests__/Grid_manual.mjs +0 -214
  23. package/src/parser/Scanner/__tests__/Grid_manual.res +0 -141
  24. package/src/parser/Semantic/Elements/__tests__/ButtonParser_test.mjs +0 -189
  25. package/src/parser/Semantic/Elements/__tests__/ButtonParser_test.res +0 -257
  26. package/src/parser/Semantic/Elements/__tests__/CheckboxParser_test.mjs +0 -202
  27. package/src/parser/Semantic/Elements/__tests__/CheckboxParser_test.res +0 -250
  28. package/src/parser/Semantic/Elements/__tests__/CodeTextParser_manual.mjs +0 -293
  29. package/src/parser/Semantic/Elements/__tests__/CodeTextParser_manual.res +0 -134
  30. package/src/parser/Semantic/Elements/__tests__/InputParser_test.mjs +0 -253
  31. package/src/parser/Semantic/Elements/__tests__/InputParser_test.res +0 -304
  32. package/src/parser/Semantic/Elements/__tests__/LinkParser_test.mjs +0 -289
  33. package/src/parser/Semantic/Elements/__tests__/LinkParser_test.res +0 -402
  34. package/src/parser/Semantic/Elements/__tests__/TextParser_test.mjs +0 -149
  35. package/src/parser/Semantic/Elements/__tests__/TextParser_test.res +0 -167
  36. package/src/parser/Semantic/__tests__/ASTBuilder_test.mjs +0 -187
  37. package/src/parser/Semantic/__tests__/ASTBuilder_test.res +0 -192
  38. package/src/parser/Semantic/__tests__/ParserRegistry_test.mjs +0 -154
  39. package/src/parser/Semantic/__tests__/ParserRegistry_test.res +0 -191
  40. package/src/parser/Semantic/__tests__/SemanticParser_integration_test.mjs +0 -768
  41. package/src/parser/Semantic/__tests__/SemanticParser_integration_test.res +0 -1069
  42. package/src/parser/Semantic/__tests__/SemanticParser_manual.mjs +0 -1329
  43. package/src/parser/Semantic/__tests__/SemanticParser_manual.res +0 -544
  44. package/src/parser/__tests__/GridScanner_integration.test.mjs +0 -632
  45. package/src/parser/__tests__/GridScanner_integration.test.res +0 -816
  46. package/src/parser/__tests__/Performance.test.mjs +0 -244
  47. package/src/parser/__tests__/Performance.test.res +0 -371
  48. package/src/parser/__tests__/PerformanceFixtures.mjs +0 -200
  49. package/src/parser/__tests__/PerformanceFixtures.res +0 -284
  50. package/src/parser/__tests__/WyreframeParser_integration.test.mjs +0 -770
  51. package/src/parser/__tests__/WyreframeParser_integration.test.res +0 -1008
  52. package/src/parser/__tests__/fixtures/alignment-test.txt +0 -9
  53. package/src/parser/__tests__/fixtures/all-elements.txt +0 -16
  54. package/src/parser/__tests__/fixtures/login-scene.txt +0 -17
  55. package/src/parser/__tests__/fixtures/multi-scene.txt +0 -25
  56. package/src/parser/__tests__/fixtures/nested-boxes.txt +0 -15
  57. package/src/parser/__tests__/fixtures/simple-box.txt +0 -5
  58. package/src/parser/__tests__/fixtures/with-dividers.txt +0 -14
@@ -1,257 +0,0 @@
1
- // ButtonParser_test.res
2
- // Unit tests for ButtonParser module
3
- //
4
- // Tests button recognition, text extraction, and edge cases
5
-
6
- open Vitest
7
-
8
- describe("ButtonParser", () => {
9
- let testPosition = Types.Position.make(5, 10)
10
- let testBounds: Types.Bounds.t = {
11
- top: 0,
12
- left: 0,
13
- bottom: 10,
14
- right: 30,
15
- }
16
-
17
- describe("slugify", () => {
18
- test("converts simple text to lowercase with hyphens", t => {
19
- t->expect(ButtonParser.slugify("Submit Form"))->Expect.toBe("submit-form")
20
- })
21
-
22
- test("handles single words", t => {
23
- t->expect(ButtonParser.slugify("Login"))->Expect.toBe("login")
24
- })
25
-
26
- test("removes special characters", t => {
27
- t->expect(ButtonParser.slugify("Create Account!"))->Expect.toBe("create-account")
28
- })
29
-
30
- test("handles multiple spaces", t => {
31
- t->expect(ButtonParser.slugify("Log In"))->Expect.toBe("log-in")
32
- })
33
-
34
- test("removes leading and trailing spaces", t => {
35
- t->expect(ButtonParser.slugify(" Cancel "))->Expect.toBe("cancel")
36
- })
37
-
38
- test("handles mixed case", t => {
39
- t->expect(ButtonParser.slugify("SAVE Changes"))->Expect.toBe("save-changes")
40
- })
41
-
42
- test("removes consecutive hyphens", t => {
43
- t->expect(ButtonParser.slugify("Submit--Form"))->Expect.toBe("submit-form")
44
- })
45
- })
46
-
47
- describe("canParse", () => {
48
- test("returns true for basic button syntax", t => {
49
- t->expect(ButtonParser.canParse("[ Submit ]"))->Expect.toBe(true)
50
- })
51
-
52
- test("returns true for button without spaces", t => {
53
- t->expect(ButtonParser.canParse("[Login]"))->Expect.toBe(true)
54
- })
55
-
56
- test("returns true for button with extra whitespace", t => {
57
- t->expect(ButtonParser.canParse("[ Create Account ]"))->Expect.toBe(true)
58
- })
59
-
60
- test("returns true for multiword button", t => {
61
- t->expect(ButtonParser.canParse("[ Log In ]"))->Expect.toBe(true)
62
- })
63
-
64
- test("returns false for text without brackets", t => {
65
- t->expect(ButtonParser.canParse("Submit"))->Expect.toBe(false)
66
- })
67
-
68
- test("returns false for only opening bracket", t => {
69
- t->expect(ButtonParser.canParse("[ Submit"))->Expect.toBe(false)
70
- })
71
-
72
- test("returns false for only closing bracket", t => {
73
- t->expect(ButtonParser.canParse("Submit ]"))->Expect.toBe(false)
74
- })
75
-
76
- test("returns false for empty string", t => {
77
- t->expect(ButtonParser.canParse(""))->Expect.toBe(false)
78
- })
79
-
80
- test("returns true for button with content before/after", t => {
81
- t->expect(ButtonParser.canParse("Click [ Submit ] to continue"))->Expect.toBe(true)
82
- })
83
- })
84
-
85
- describe("parse", () => {
86
- test("parses basic button correctly", t => {
87
- let result = ButtonParser.parse("[ Submit ]", testPosition, testBounds)
88
-
89
- switch result {
90
- | Some(Types.Button({id, text, position, align})) => {
91
- t->expect(id)->Expect.toBe("submit")
92
- t->expect(text)->Expect.toBe("Submit")
93
- t->expect(position)->Expect.toEqual(testPosition)
94
- // Alignment is calculated based on position within bounds
95
- // position col=10, bounds right=30, so ~33% = Center
96
- t->expect(align)->Expect.toEqual(Types.Center)
97
- }
98
- | _ => t->expect(true)->Expect.toBe(false) // fail: Expected Button element
99
- }
100
- })
101
-
102
- test("parses button without spaces", t => {
103
- let result = ButtonParser.parse("[Login]", testPosition, testBounds)
104
-
105
- switch result {
106
- | Some(Types.Button({id, text, position: _, align: _})) => {
107
- t->expect(id)->Expect.toBe("login")
108
- t->expect(text)->Expect.toBe("Login")
109
- }
110
- | _ => t->expect(true)->Expect.toBe(false) // fail: Expected Button element
111
- }
112
- })
113
-
114
- test("parses button with extra whitespace", t => {
115
- let result = ButtonParser.parse("[ Create Account ]", testPosition, testBounds)
116
-
117
- switch result {
118
- | Some(Types.Button({id, text, position: _, align: _})) => {
119
- t->expect(id)->Expect.toBe("create-account")
120
- t->expect(text)->Expect.toBe("Create Account")
121
- }
122
- | _ => t->expect(true)->Expect.toBe(false) // fail: Expected Button element
123
- }
124
- })
125
-
126
- test("parses multiword button text", t => {
127
- let result = ButtonParser.parse("[ Log In ]", testPosition, testBounds)
128
-
129
- switch result {
130
- | Some(Types.Button({id, text, position: _, align: _})) => {
131
- t->expect(id)->Expect.toBe("log-in")
132
- t->expect(text)->Expect.toBe("Log In")
133
- }
134
- | _ => t->expect(true)->Expect.toBe(false) // fail: Expected Button element
135
- }
136
- })
137
-
138
- test("trims leading and trailing whitespace from button text", t => {
139
- let result = ButtonParser.parse("[ Cancel ]", testPosition, testBounds)
140
-
141
- switch result {
142
- | Some(Types.Button({id, text, position: _, align: _})) => {
143
- t->expect(text)->Expect.toBe("Cancel")
144
- t->expect(id)->Expect.toBe("cancel")
145
- }
146
- | _ => t->expect(true)->Expect.toBe(false) // fail: Expected Button element
147
- }
148
- })
149
-
150
- test("returns None for empty button text", t => {
151
- let result = ButtonParser.parse("[ ]", testPosition, testBounds)
152
- t->expect(result)->Expect.toEqual(None)
153
- })
154
-
155
- test("returns None for button with only whitespace", t => {
156
- let result = ButtonParser.parse("[ ]", testPosition, testBounds)
157
- t->expect(result)->Expect.toEqual(None)
158
- })
159
-
160
- test("returns None for text without brackets", t => {
161
- let result = ButtonParser.parse("Submit", testPosition, testBounds)
162
- t->expect(result)->Expect.toEqual(None)
163
- })
164
-
165
- test("returns None for incomplete button syntax (missing closing bracket)", t => {
166
- let result = ButtonParser.parse("[ Submit", testPosition, testBounds)
167
- t->expect(result)->Expect.toEqual(None)
168
- })
169
-
170
- test("returns None for incomplete button syntax (missing opening bracket)", t => {
171
- let result = ButtonParser.parse("Submit ]", testPosition, testBounds)
172
- t->expect(result)->Expect.toEqual(None)
173
- })
174
-
175
- test("handles button with special characters in text", t => {
176
- let result = ButtonParser.parse("[ Save & Exit ]", testPosition, testBounds)
177
-
178
- switch result {
179
- | Some(Types.Button({id, text, position: _, align: _})) => {
180
- t->expect(text)->Expect.toBe("Save & Exit")
181
- t->expect(id)->Expect.toBe("save-exit") // Special chars removed in slug
182
- }
183
- | _ => t->expect(true)->Expect.toBe(false) // fail: Expected Button element
184
- }
185
- })
186
-
187
- test("handles button with numbers", t => {
188
- let result = ButtonParser.parse("[ Option 1 ]", testPosition, testBounds)
189
-
190
- switch result {
191
- | Some(Types.Button({id, text, position: _, align: _})) => {
192
- t->expect(text)->Expect.toBe("Option 1")
193
- t->expect(id)->Expect.toBe("option-1")
194
- }
195
- | _ => t->expect(true)->Expect.toBe(false) // fail: Expected Button element
196
- }
197
- })
198
-
199
- test("preserves position in parsed element", t => {
200
- let customPosition = Types.Position.make(3, 7)
201
- let result = ButtonParser.parse("[ Test ]", customPosition, testBounds)
202
-
203
- switch result {
204
- | Some(Types.Button({position, id: _, text: _, align: _})) => {
205
- t->expect(position)->Expect.toEqual(customPosition)
206
- }
207
- | _ => t->expect(true)->Expect.toBe(false) // fail: Expected Button element
208
- }
209
- })
210
-
211
- test("returns None for content with extra text before button", t => {
212
- let result = ButtonParser.parse("Click [ Submit ] here", testPosition, testBounds)
213
- t->expect(result)->Expect.toEqual(None)
214
- })
215
-
216
- test("handles nested brackets by matching outer brackets", t => {
217
- // This tests the edge case mentioned in requirements
218
- // The regex should match the first [...] pattern
219
- let result = ButtonParser.parse("[ [nested] ]", testPosition, testBounds)
220
-
221
- switch result {
222
- | Some(Types.Button({text, id: _, position: _, align: _})) => {
223
- // Should extract "[nested]" as the text (inner brackets preserved)
224
- t->expect(text)->Expect.toBe("[nested]")
225
- }
226
- | None => {
227
- // Or it might return None depending on regex behavior
228
- // Either behavior is acceptable for this edge case
229
- ()
230
- }
231
- }
232
- })
233
- })
234
-
235
- describe("make", () => {
236
- test("creates parser with priority 100", t => {
237
- let parser = ButtonParser.make()
238
- t->expect(parser.priority)->Expect.toBe(100)
239
- })
240
-
241
- test("created parser can parse buttons", t => {
242
- let parser = ButtonParser.make()
243
- let result = parser.parse("[ Test ]", testPosition, testBounds)
244
-
245
- switch result {
246
- | Some(Types.Button(_)) => ()
247
- | _ => t->expect(true)->Expect.toBe(false) // fail: Parser should be able to parse buttons
248
- }
249
- })
250
-
251
- test("created parser canParse works correctly", t => {
252
- let parser = ButtonParser.make()
253
- t->expect(parser.canParse("[ Button ]"))->Expect.toBe(true)
254
- t->expect(parser.canParse("Not a button"))->Expect.toBe(false)
255
- })
256
- })
257
- })
@@ -1,202 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as Types from "../../../Core/Types.mjs";
4
- import * as Vitest from "rescript-vitest/src/Vitest.mjs";
5
- import * as CheckboxParser from "../CheckboxParser.mjs";
6
-
7
- Vitest.describe("CheckboxParser", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, () => {
8
- let parser = CheckboxParser.make();
9
- Vitest.describe("canParse", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, () => {
10
- Vitest.test("recognizes checked checkbox [x]", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(parser.canParse("[x]")).toBe(true));
11
- Vitest.test("recognizes checked checkbox with uppercase X", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(parser.canParse("[X]")).toBe(true));
12
- Vitest.test("recognizes unchecked checkbox [ ]", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(parser.canParse("[ ]")).toBe(true));
13
- Vitest.test("recognizes unchecked checkbox with multiple spaces", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(parser.canParse("[ ]")).toBe(true));
14
- Vitest.test("recognizes checkbox with label", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(parser.canParse("[x] Accept terms")).toBe(true));
15
- Vitest.test("recognizes checkbox with label at end", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(parser.canParse("Accept terms [x]")).toBe(true));
16
- Vitest.test("rejects plain text", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(parser.canParse("plain text")).toBe(false));
17
- Vitest.test("rejects button syntax", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(parser.canParse("[ Button ]")).toBe(false));
18
- Vitest.test("rejects input syntax", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(parser.canParse("#email")).toBe(false));
19
- Vitest.test("rejects incomplete brackets", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
20
- t.expect(parser.canParse("[x")).toBe(false);
21
- t.expect(parser.canParse("x]")).toBe(false);
22
- });
23
- });
24
- Vitest.describe("parse - checked state", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, () => {
25
- let position = Types.Position.make(5, 10);
26
- let bounds = Types.Bounds.make(0, 0, 10, 30);
27
- Vitest.test("extracts checked state from [x]", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
28
- let match = parser.parse("[x]", position, bounds);
29
- if (match === undefined) {
30
- return t.expect(true).toBe(false);
31
- }
32
- if (match.TAG !== "Checkbox") {
33
- return t.expect(true).toBe(false);
34
- }
35
- let pos = match.position;
36
- t.expect(match.checked).toBe(true);
37
- t.expect(match.label).toBe("");
38
- t.expect(pos.row).toBe(5);
39
- t.expect(pos.col).toBe(10);
40
- });
41
- Vitest.test("handles uppercase X in [X]", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
42
- let match = parser.parse("[X]", position, bounds);
43
- if (match !== undefined && match.TAG === "Checkbox") {
44
- return t.expect(match.checked).toBe(true);
45
- } else {
46
- return t.expect(true).toBe(false);
47
- }
48
- });
49
- Vitest.test("extracts label after checked checkbox", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
50
- let match = parser.parse("[x] Accept terms and conditions", position, bounds);
51
- if (match === undefined) {
52
- return t.expect(true).toBe(false);
53
- }
54
- if (match.TAG !== "Checkbox") {
55
- return t.expect(true).toBe(false);
56
- }
57
- t.expect(match.checked).toBe(true);
58
- t.expect(match.label).toBe("Accept terms and conditions");
59
- });
60
- Vitest.test("trims whitespace from label", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
61
- let match = parser.parse("[x] Subscribe to newsletter ", position, bounds);
62
- if (match !== undefined && match.TAG === "Checkbox") {
63
- return t.expect(match.label).toBe("Subscribe to newsletter");
64
- } else {
65
- return t.expect(true).toBe(false);
66
- }
67
- });
68
- Vitest.test("handles label with special characters", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
69
- let match = parser.parse("[x] I agree to the Terms & Conditions", position, bounds);
70
- if (match !== undefined && match.TAG === "Checkbox") {
71
- return t.expect(match.label).toBe("I agree to the Terms & Conditions");
72
- } else {
73
- return t.expect(true).toBe(false);
74
- }
75
- });
76
- });
77
- Vitest.describe("parse - unchecked state", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, () => {
78
- let position = Types.Position.make(3, 5);
79
- let bounds = Types.Bounds.make(0, 0, 10, 30);
80
- Vitest.test("extracts unchecked state from [ ]", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
81
- let match = parser.parse("[ ]", position, bounds);
82
- if (match === undefined) {
83
- return t.expect(true).toBe(false);
84
- }
85
- if (match.TAG !== "Checkbox") {
86
- return t.expect(true).toBe(false);
87
- }
88
- t.expect(match.checked).toBe(false);
89
- t.expect(match.label).toBe("");
90
- });
91
- Vitest.test("handles multiple spaces in brackets", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
92
- let match = parser.parse("[ ]", position, bounds);
93
- if (match !== undefined && match.TAG === "Checkbox") {
94
- return t.expect(match.checked).toBe(false);
95
- } else {
96
- return t.expect(true).toBe(false);
97
- }
98
- });
99
- Vitest.test("extracts label after unchecked checkbox", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
100
- let match = parser.parse("[ ] Remember me", position, bounds);
101
- if (match === undefined) {
102
- return t.expect(true).toBe(false);
103
- }
104
- if (match.TAG !== "Checkbox") {
105
- return t.expect(true).toBe(false);
106
- }
107
- t.expect(match.checked).toBe(false);
108
- t.expect(match.label).toBe("Remember me");
109
- });
110
- Vitest.test("handles long labels", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
111
- let match = parser.parse("[ ] I would like to receive promotional emails and updates", position, bounds);
112
- if (match !== undefined && match.TAG === "Checkbox") {
113
- return t.expect(match.label).toBe("I would like to receive promotional emails and updates");
114
- } else {
115
- return t.expect(true).toBe(false);
116
- }
117
- });
118
- });
119
- Vitest.describe("parse - edge cases", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, () => {
120
- let position = Types.Position.make(0, 0);
121
- let bounds = Types.Bounds.make(0, 0, 5, 20);
122
- Vitest.test("handles checkbox with no label", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
123
- let match = parser.parse("[x]", position, bounds);
124
- if (match !== undefined && match.TAG === "Checkbox") {
125
- return t.expect(match.label).toBe("");
126
- } else {
127
- return t.expect(true).toBe(false);
128
- }
129
- });
130
- Vitest.test("handles extra whitespace before checkbox", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
131
- let match = parser.parse(" [x] Label", position, bounds);
132
- if (match === undefined) {
133
- return t.expect(true).toBe(false);
134
- }
135
- if (match.TAG !== "Checkbox") {
136
- return t.expect(true).toBe(false);
137
- }
138
- t.expect(match.checked).toBe(true);
139
- t.expect(match.label).toBe("Label");
140
- });
141
- Vitest.test("handles extra whitespace after label", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
142
- let match = parser.parse("[x] Label ", position, bounds);
143
- if (match !== undefined && match.TAG === "Checkbox") {
144
- return t.expect(match.label).toBe("Label");
145
- } else {
146
- return t.expect(true).toBe(false);
147
- }
148
- });
149
- Vitest.test("returns None for invalid pattern", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
150
- let result = parser.parse("not a checkbox", position, bounds);
151
- t.expect(result).toBe(undefined);
152
- });
153
- Vitest.test("returns None for button-like pattern [ Text ]", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
154
- let result = parser.parse("[ Submit ]", position, bounds);
155
- t.expect(result).toBe(undefined);
156
- });
157
- });
158
- Vitest.describe("parse - label variations", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, () => {
159
- let position = Types.Position.make(2, 3);
160
- let bounds = Types.Bounds.make(0, 0, 10, 40);
161
- Vitest.test("handles label with numbers", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
162
- let match = parser.parse("[x] Option 123", position, bounds);
163
- if (match !== undefined && match.TAG === "Checkbox") {
164
- return t.expect(match.label).toBe("Option 123");
165
- } else {
166
- return t.expect(true).toBe(false);
167
- }
168
- });
169
- Vitest.test("handles label with punctuation", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
170
- let match = parser.parse("[ ] Yes, I agree!", position, bounds);
171
- if (match !== undefined && match.TAG === "Checkbox") {
172
- return t.expect(match.label).toBe("Yes, I agree!");
173
- } else {
174
- return t.expect(true).toBe(false);
175
- }
176
- });
177
- Vitest.test("handles label with parentheses", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
178
- let match = parser.parse("[x] Enable feature (beta)", position, bounds);
179
- if (match !== undefined && match.TAG === "Checkbox") {
180
- return t.expect(match.label).toBe("Enable feature (beta)");
181
- } else {
182
- return t.expect(true).toBe(false);
183
- }
184
- });
185
- Vitest.test("handles label with quotes", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
186
- let match = parser.parse("[x] Accept \"User Agreement\"", position, bounds);
187
- if (match !== undefined && match.TAG === "Checkbox") {
188
- return t.expect(match.label).toBe("Accept \"User Agreement\"");
189
- } else {
190
- return t.expect(true).toBe(false);
191
- }
192
- });
193
- });
194
- Vitest.describe("priority", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, () => {
195
- Vitest.test("has priority of 85", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(parser.priority).toBe(85));
196
- Vitest.test("priority is higher than text parser (1)", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(parser.priority).toBeGreaterThan(1));
197
- Vitest.test("priority is lower than button parser (100)", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(parser.priority).toBeLessThan(100));
198
- Vitest.test("priority is lower than input parser (90)", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(parser.priority).toBeLessThan(90));
199
- });
200
- });
201
-
202
- /* Not a pure module */