@fugood/bricks-project 2.24.0-beta.6 → 2.24.0-beta.8

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.
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@fugood/bricks-project",
3
- "version": "2.24.0-beta.6",
3
+ "version": "2.24.0-beta.8",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "build": "bun scripts/build.js"
7
7
  },
8
8
  "dependencies": {
9
- "@fugood/bricks-cli": "^2.24.0-beta.6",
9
+ "@fugood/bricks-cli": "^2.24.0-beta.8",
10
10
  "@huggingface/gguf": "^0.3.2",
11
11
  "@iarna/toml": "^3.0.0",
12
12
  "@modelcontextprotocol/sdk": "^1.15.0",
@@ -19,5 +19,5 @@
19
19
  "lodash": "^4.17.4",
20
20
  "uuid": "^8.3.1"
21
21
  },
22
- "gitHead": "893f3e56ec87e71bfc093434c9a8517fca6c0f99"
22
+ "gitHead": "c611e18b2c6dccf46a84efd88b959bf5c2cba3ad"
23
23
  }
@@ -4,15 +4,16 @@ E2E testing and scheduled execution for BRICKS applications. Simulates user beha
4
4
 
5
5
  ## Automation Types
6
6
 
7
- | Type | Description |
8
- |------|-------------|
9
- | `launch` | Run on application launch (restarts app when run manually) |
10
- | `anytime` | Execute anytime via manual trigger |
11
- | `cron` | Scheduled execution using crontab expressions |
7
+ | Type | Description |
8
+ | --------- | ---------------------------------------------------------- |
9
+ | `launch` | Run on application launch (restarts app when run manually) |
10
+ | `anytime` | Execute anytime via manual trigger |
11
+ | `cron` | Scheduled execution using crontab expressions |
12
12
 
13
13
  ## Simulation Actions
14
14
 
15
15
  Automations can simulate:
16
+
16
17
  - **Brick Press**: Tap/click on bricks
17
18
  - **Key Events**: Key up/down for keyboard input
18
19
  - **HTTP Request**: API calls
@@ -21,6 +22,7 @@ Automations can simulate:
21
22
  ## Assertions
22
23
 
23
24
  Automations can validate:
25
+
24
26
  - **Brick Exists**: Check if brick is rendered
25
27
  - **Event Triggered**: Verify event from Brick/Generator/Canvas
26
28
  - **Canvas Changed**: Confirm canvas navigation
@@ -100,25 +102,58 @@ const testLoginFlow: AutomationTest = {
100
102
 
101
103
  ## Test Methods
102
104
 
103
- | Method | Signature | Description |
104
- |--------|-----------|-------------|
105
- | `brick_press` | `[subspace, brick, options?]` | Simulate brick press |
106
- | `brick_exists` | `[subspace, brick, frame?]` | Check brick exists |
107
- | `wait_until_brick_exists` | `[subspace, brick, timeout?, frame?]` | Wait for brick |
108
- | `wait_until_event_trigger` | `[subspace, sender, eventKey, timeout?]` | Wait for event |
109
- | `wait_until_canvas_change` | `[subspace, canvas, timeout?]` | Wait for canvas |
110
- | `keydown` | `[keyCode, pressedKey?, flags?]` | Key down event |
111
- | `keyup` | `[keyCode, pressedKey?, flags?]` | Key up event |
112
- | `http_request` | `[url, options?]` | HTTP request |
113
- | `assert_property` | `[subspace, property, value]` | Assert data value |
114
- | `wait_until_property_change` | `[subspace, property, value, timeout?]` | Wait for value |
115
- | `execute_action` | `[subspace, handler, action, params?, options?]` | Execute action |
116
- | `match_screenshot` | `[name, threshold?, maxRetry?]` | Screenshot compare |
117
- | `delay` | `[subspace?, property?, defaultValue?]` | Delay execution |
105
+ | Method | Signature | Description |
106
+ | ---------------------------- | ------------------------------------------------ | -------------------- |
107
+ | `brick_press` | `[subspace, brick, options?]` | Simulate brick press |
108
+ | `brick_exists` | `[subspace, brick, frame?]` | Check brick exists |
109
+ | `wait_until_brick_exists` | `[subspace, brick, timeout?, frame?]` | Wait for brick |
110
+ | `wait_until_event_trigger` | `[subspace, sender, eventKey, timeout?]` | Wait for event |
111
+ | `wait_until_canvas_change` | `[subspace, canvas, timeout?]` | Wait for canvas |
112
+ | `keydown` | `[keyCode, pressedKey?, flags?]` | Key down event |
113
+ | `keyup` | `[keyCode, pressedKey?, flags?]` | Key up event |
114
+ | `http_request` | `[url, options?]` | HTTP request |
115
+ | `assert_property` | `[subspace, property, value]` | Assert data value |
116
+ | `wait_until_property_change` | `[subspace, property, value, timeout?]` | Wait for value |
117
+ | `execute_action` | `[subspace, handler, action, params?, options?]` | Execute action |
118
+ | `match_screenshot` | `[name, threshold?, maxRetry?]` | Screenshot compare |
119
+ | `delay` | `[subspace?, property?, defaultValue?]` | Delay execution |
120
+
121
+ ### execute_action Params
122
+
123
+ The `params` object in `execute_action` uses **runtime event property keys** from `event-props.ts`, NOT the action config `input` names from type definitions.
124
+
125
+ ```typescript
126
+ // CORRECT — use runtime event property key
127
+ run: ['execute_action', () => subspace0, bricks.bInput.id, 'BRICK_TEXT_INPUT_SET_TEXT',
128
+ { BRICK_TEXT_INPUT_TEXT: 'hello' }]
129
+
130
+ // WRONG — action config input name doesn't work in automation
131
+ run: ['execute_action', () => subspace0, bricks.bInput.id, 'BRICK_TEXT_INPUT_SET_TEXT',
132
+ { text: 'hello' }]
133
+ ```
134
+
135
+ Reference `event-props.ts` for the correct runtime keys (e.g., `BRICK_TEXT_INPUT_TEXT`, `GENERATOR_MQTT_PAYLOAD`).
136
+
137
+ ### Prefer UI Interactions Over Direct Generator Calls
138
+
139
+ For realistic E2E testing, prefer simulating user actions (set text input + press button) over calling generator actions directly:
140
+
141
+ ```typescript
142
+ // GOOD — simulates real user behavior
143
+ { run: ['execute_action', () => sub, bricks.bInput.id, 'BRICK_TEXT_INPUT_SET_TEXT',
144
+ { BRICK_TEXT_INPUT_TEXT: 'hello' }] },
145
+ { run: ['brick_press', () => sub, () => bricks.bSendBtn] },
146
+ { run: ['wait_until_property_change', () => sub, () => data.dPayload, 'hello', 10000] },
147
+
148
+ // AVOID — bypasses UI, doesn't test the full flow
149
+ { run: ['execute_action', () => sub, generators.gClient.id, 'GENERATOR_MQTT_PUBLISH',
150
+ { topic: 'test', payload: 'hello', qos: '0' }] },
151
+ ```
118
152
 
119
153
  ## Recording Automations
120
154
 
121
155
  In BRICKS Editor Preview mode:
156
+
122
157
  1. Perform operations normally
123
158
  2. Open menu (right-bottom corner)
124
159
  3. Select "Record Events as Automation"
@@ -127,12 +162,15 @@ In BRICKS Editor Preview mode:
127
162
  ## Running Automations
128
163
 
129
164
  ### Manual Run
165
+
130
166
  `Menu` → `Automations` → Select automation → `Run`
131
167
 
132
168
  ### On Launch
169
+
133
170
  `Bind Device` → `Select Automation` (only `launch` or `cron` types)
134
171
 
135
172
  ### Scheduled (Cron)
173
+
136
174
  `Bind Device` → `Cron Automation` (allows multi-select)
137
175
 
138
176
  Use [crontab.guru](https://crontab.guru) to build cron expressions.
@@ -156,6 +194,7 @@ Visual regression testing with screenshot comparison:
156
194
  ```
157
195
 
158
196
  Screenshots can be stored:
197
+
159
198
  - Local file system
160
199
  - Media Flow workspace
161
200
 
@@ -165,11 +204,18 @@ First run captures baseline. Use "Run with Update" to update baseline.
165
204
 
166
205
  Automations work with Modules. Use Manual Run in Preview mode for module testing.
167
206
 
207
+ ## Important Notes
208
+
209
+ - **Automation map key**: Always use `'AUTOMATION_MAP_DEFAULT'` as the automation map ID (not `makeId()`). The preview test runner reads from `automationMap['AUTOMATION_MAP_DEFAULT']?.map`.
210
+ - **Valid makeId types**: Use `'test'` for AutomationTest, `'test_case'` for TestCase, `'test_var'` for TestVariable. Do NOT use `'automation_test'` or `'automation_test_map'`.
211
+ - **handler in execute_action**: Pass the entity's `.id` string (e.g., `bricks.bInput.id`), not a getter function.
212
+
168
213
  ## Best Practices
169
214
 
170
215
  1. **Test culture**: Create automations for every significant flow
171
216
  2. **CI/CD integration**: Use `launch` automations for deployment validation
172
- 3. **Incremental waits**: Use `EXPECT_*` steps with appropriate timeouts
217
+ 3. **Incremental waits**: Use `wait_until_property_change` with appropriate timeouts
173
218
  4. **Visual testing**: Add screenshot comparisons for critical UI states
174
219
  5. **Cron monitoring**: Schedule health checks for production displays
175
220
  6. **Isolation**: Each automation should be independent and idempotent
221
+ 7. **UI-first testing**: Simulate real user interactions (text input, button press) rather than calling generators directly
@@ -42,13 +42,17 @@ let config = JSON.parse(await readFile(`${cwd}/.bricks/build/application-config.
42
42
  let testId = values['test-id'] || null
43
43
  if (!testId && values['test-title-like']) {
44
44
  const titleLike = values['test-title-like'].toLowerCase()
45
- const testMap = config.test_map || {}
46
- const found = Object.entries(testMap).find(([, test]) =>
47
- test.title?.toLowerCase().includes(titleLike),
48
- )
49
- if (found) {
50
- ;[testId] = found
51
- } else {
45
+ const automationMap = config.automation_map || {}
46
+ for (const group of Object.values(automationMap)) {
47
+ const found = Object.entries(group.map || {}).find(([, test]) =>
48
+ test.title?.toLowerCase().includes(titleLike),
49
+ )
50
+ if (found) {
51
+ ;[testId] = found
52
+ break
53
+ }
54
+ }
55
+ if (!testId) {
52
56
  throw new Error(`No automation found matching title: ${values['test-title-like']}`)
53
57
  }
54
58
  }
package/utils/calc.ts CHANGED
@@ -33,11 +33,12 @@ export const generateDataCalculationMapEditorInfo = (
33
33
  nodes.forEach((node) => {
34
34
  // Count and track inputs
35
35
  if ('inputs' in node) {
36
- const inputs = node.inputs.reduce((sum, input) => {
37
- if (input === null) return sum
38
- if (Array.isArray(input)) return sum + input.length
39
- return sum + 1
40
- }, 0)
36
+ let inputs = 0
37
+ for (const input of node.inputs) {
38
+ if (input === null) continue
39
+ if (Array.isArray(input)) inputs += input.length
40
+ else inputs += 1
41
+ }
41
42
  inputCounts.set(node, inputs)
42
43
 
43
44
  // Track connections
@@ -60,11 +61,12 @@ export const generateDataCalculationMapEditorInfo = (
60
61
 
61
62
  // Count outputs
62
63
  if ('outputs' in node) {
63
- const outputs = node.outputs.reduce((sum, output) => {
64
- if (output === null) return sum
65
- if (Array.isArray(output)) return sum + output.length
66
- return sum + 1
67
- }, 0)
64
+ let outputs = 0
65
+ for (const output of node.outputs) {
66
+ if (output === null) continue
67
+ if (Array.isArray(output)) outputs += output.length
68
+ else outputs += 1
69
+ }
68
70
  outputCounts.set(node, outputs)
69
71
  } else {
70
72
  outputCounts.set(node, 0)