Skip to content

Commit 7e9f901

Browse files
chore: process feedback comments
1 parent 0785631 commit 7e9f901

5 files changed

Lines changed: 105 additions & 23 deletions

File tree

.claude/commands/mendix/e2e-spec.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ You are helping the developer write or improve Playwright e2e specs for a Mendix
66

77
- Specs live at: `packages/pluggableWidgets/<widget>/e2e/*.spec.js`
88
- Playwright strict mode is ON
9-
- Full rules: `docs/requirements/e2e-test-guidelines.md`
9+
10+
> `<widget>` throughout this document is the package folder name, e.g. `badge-web`, `datagrid-web`.
1011
1112
## Discovering selectors and navigation from the test project
1213

1314
Before writing selectors, look up the actual widget names and menu labels in the `.mpr`:
1415

1516
```bash
1617
# Full overview: modules, pages, entities, navigation menu labels
17-
bash automation/mxcli/mx-testproject.sh inspect <widget>
18+
bash automation/mxcli/mx-testproject.sh inspect badge-web # replace with actual widget name
1819

1920
# Widget structure of a specific page (reveals .mx-name-* values)
2021
bash automation/mxcli/mx-testproject.sh exec <widget> "DESCRIBE PAGE <Module>.<PageName>"
@@ -23,7 +24,7 @@ bash automation/mxcli/mx-testproject.sh exec <widget> "DESCRIBE PAGE <Module>.<P
2324
bash automation/mxcli/mx-testproject.sh list-pages <widget>
2425

2526
# Search for a widget name across all project strings
26-
bash automation/mxcli/mx-testproject.sh search <widget> "<keyword>"
27+
bash automation/mxcli/mx-testproject.sh search <widget> 'keyword'
2728
```
2829

2930
The `inspect` output includes `DESCRIBE NAVIGATION Responsive` at the end — use those exact strings in `page.getByRole("menuitem", { name: "..." })`.
@@ -41,17 +42,19 @@ Standard naming convention per widget:
4142

4243
```bash
4344
# Full CI run (Docker):
44-
pnpm --filter @mendix/<widget> run e2e
45+
pnpm --filter @mendix/badge-web run e2e # replace with actual widget name
4546

46-
# Skip re-downloading the test project:
47+
# Skip re-downloading the test project (useful when iterating locally):
4748
pnpm --filter @mendix/<widget> run e2e --no-setup-project
4849

49-
# Skip re-downloading and rebuilding:
50+
# Skip re-downloading and rebuilding (fastest iteration; requires local test project files):
5051
pnpm --filter @mendix/<widget> run e2e --no-setup-project --no-update-project
5152
```
5253

5354
⚠️ Pass flags directly — do NOT use `pnpm run e2e -- --no-setup-project`. The `--` separator causes yargs-parser to ignore the flags.
5455

56+
> Use `--no-setup-project --no-update-project` when you have the test project files locally and want to commit them to the `testProjects` repository after confirming tests pass.
57+
5558
## Checklist
5659

5760
- [ ] Import from `@mendix/run-e2e/fixtures` — NOT `@playwright/test`

.claude/commands/mendix/e2e-workflow.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,34 @@ If no widget name is provided, ask the user which widget they are working on (e.
77
## Prerequisites
88

99
- `automation/tools/mxcli` must exist. If missing, run: `bash automation/mxcli/setup.sh`
10-
- The `.mpr` test project must be **closed in Studio Pro** before any mxcli edits
10+
- The `.mpr` test project must be **closed in Studio Pro** before any mxcli edits. Check with:
11+
```bash
12+
ls packages/pluggableWidgets/<widget>/tests/testProject/.mendix-cache/lock 2>/dev/null \
13+
&& echo "⚠️ Studio Pro lock file present — close the project first" \
14+
|| echo "OK — no lock file"
15+
```
1116
- Docker must be running for the full CI e2e run
1217

1318
---
1419

15-
## Phase 1 — Inspect the test project
20+
## Phase 1 — Download and inspect the test project
21+
22+
Download the test project (if not already present):
23+
24+
```bash
25+
pnpm --filter @mendix/<widget> run e2edev --setup-project
26+
```
27+
28+
If this fails with `404 Not Found` / `Cannot find test project in GitHub repository`, the branch does not exist yet in `mendix/testProjects`. In that case:
29+
30+
1. Copy an existing chart/widget MPR as a base (e.g. from `column-chart-web/tests/testProject/`).
31+
2. Place it at `packages/pluggableWidgets/<widget>/tests/testProject/<WidgetName>.mpr`.
32+
3. Copy the `widgets/`, `deployment/`, `theme/`, and `themesource/` folders from the same source.
33+
4. Replace the source widget's `.mpk` in `widgets/` with the new widget's built `.mpk` (run `pnpm --filter @mendix/<widget> run release` first).
34+
5. Adapt the domain model and microflows via mxcli (see `mendix:edit-test-project`).
35+
6. After Studio Pro has opened the MPR and registered the new widget type, push a new branch `<widget>` to `mendix/testProjects` so CI can download it.
36+
37+
Then inspect:
1638

1739
```bash
1840
bash automation/mxcli/mx-testproject.sh inspect <widget>
@@ -24,6 +46,8 @@ This shows modules, pages, entities, and navigation menu labels in one call. For
2446
bash automation/mxcli/mx-testproject.sh exec <widget> "DESCRIBE PAGE <Module>.<PageName>"
2547
```
2648
49+
> **Note**: `DESCRIBE PAGE` may show an empty body for pages that only contain pluggable widgets. Use `automation/tools/mxcli bson dump -p <MPR> --type page --object <Module>.<Page>` and grep for widget names to verify content. See `mendix:edit-test-project` for details.
50+
2751
**Output**: map of modules, pages, navigation labels, and `.mx-name-*` widget names.
2852
2953
---

.claude/commands/mendix/edit-test-project.md

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ Ask the user (or infer from context): which widget, and what scenario requires a
2222
ls packages/pluggableWidgets/<widget>/tests/testProject/*.mpr | grep -v backup
2323
```
2424

25-
Remind the user to close the project in Studio Pro before continuing.
25+
Verify Studio Pro is **not** holding the project open before any mxcli writes:
26+
27+
```bash
28+
ls packages/pluggableWidgets/<widget>/tests/testProject/.mendix-cache/lock 2>/dev/null \
29+
&& echo "⚠️ Studio Pro lock file present — close the project first" \
30+
|| echo "OK — no lock file"
31+
```
2632

2733
## Step 3 — Inspect current state
2834

@@ -33,12 +39,17 @@ bash automation/mxcli/mx-testproject.sh inspect <widget>
3339
# Targeted queries:
3440
automation/tools/mxcli -p <MPR_PATH> -c "SHOW PAGES IN <Module>"
3541
automation/tools/mxcli -p <MPR_PATH> -c "SHOW ENTITIES IN <Module>"
36-
automation/tools/mxcli -p <MPR_PATH> -c "SHOW ROLES IN <Module>"
37-
automation/tools/mxcli -p <MPR_PATH> -c "SHOW NANOFLOWS IN <Module>"
42+
automation/tools/mxcli -p <MPR_PATH> -c "SHOW MICROFLOWS IN <Module>"
3843
automation/tools/mxcli -p <MPR_PATH> -c "DESCRIBE PAGE <Module>.<PageName>"
39-
bash automation/mxcli/mx-testproject.sh search <widget> "<keyword>"
44+
bash automation/mxcli/mx-testproject.sh search <widget> 'keyword'
4045
```
4146

47+
> **`DESCRIBE PAGE` caveat**: pages containing only pluggable widgets (no built-in widgets like `DATAVIEW`, `LAYOUTGRID`, etc.) may render as an empty body even when widget content exists in the MPR. Use `automation/tools/mxcli bson dump -p <MPR> --type page --object <Module>.<Page>` and grep for widget names to verify content was written.
48+
49+
> **`SEARCH` quoting**: use single-quoted strings — `SEARCH 'keyword'`, not `SEARCH "keyword"`. Double quotes cause a parse error.
50+
51+
> **`SHOW ROLES IN <Module>`** — this MDL statement does not exist. Use `SHOW MODULES` output to see module source; roles are returned inline. To query roles programmatically use the catalog: `SELECT Name FROM CATALOG.USER_ROLES`.
52+
4253
Run a baseline lint before editing:
4354

4455
```bash
@@ -93,13 +104,18 @@ test.beforeEach(async ({ page }) => {
93104
});
94105
```
95106

96-
For **brand-new empty pages** created by mxcli, direct URL works:
107+
For **brand-new empty pages** created by mxcli, the URL is auto-generated from the page name. Discover it with:
97108

98-
```js
99-
await page.goto("/p/my-new-page");
109+
```bash
110+
automation/tools/mxcli -p <MPR_PATH> -c "DESCRIBE PAGE <Module>.<PageName>"
111+
# Look for the `url:` field in the output, e.g. url: 'my-page-name'
100112
```
101113

102-
After edits: Studio Pro shows "Project was modified externally" — click **Reload**.
114+
Then navigate directly in the spec:
115+
116+
```js
117+
await page.goto("/p/my-page-name");
118+
```
103119

104120
## Step 5 — Rebuild and validate
105121

@@ -114,11 +130,11 @@ Continue with `mendix:e2e-workflow` from Phase 4 (build → run → validate).
114130
| List modules | `SHOW MODULES` |
115131
| List pages | `SHOW PAGES IN Module` |
116132
| List entities | `SHOW ENTITIES IN Module` |
117-
| List roles | `SHOW ROLES IN Module` |
133+
| List microflows | `SHOW MICROFLOWS IN Module` |
118134
| List nanoflows | `SHOW NANOFLOWS IN Module` |
119135
| Describe page widgets | `DESCRIBE PAGE Module.PageName` |
120136
| Describe navigation menu | `DESCRIBE NAVIGATION Responsive` |
121-
| Search project strings | `SEARCH "keyword"` |
137+
| Search project strings | `SEARCH 'keyword'` |
122138
| Show callers of microflow | `SHOW CALLERS OF Module.MicroflowName` |
123139
| Show callers (transitive) | `SHOW CALLERS OF Module.MicroflowName TRANSITIVE` |
124140
| Show references to element | `SHOW REFERENCES TO Module.ElementName` |
@@ -134,10 +150,40 @@ Continue with `mendix:e2e-workflow` from Phase 4 (build → run → validate).
134150
| Validate MDL syntax + refs | `mxcli check changes.mdl -p app.mpr --references` |
135151
| Preview changes as diff | `mxcli diff -p app.mpr changes.mdl` |
136152

153+
## Pluggable widget limitations
154+
155+
mxcli can only create pluggable widget instances (`PLUGGABLEWIDGET '...' name (...)`) when the MPR **already contains an existing instance** of that widget type (Studio Pro registers the BSON template the first time the widget is imported). If no instance exists yet, mxcli fails with `template not found: <widgetname>`.
156+
157+
**Workaround for a brand-new widget in a new test project:**
158+
159+
1. Create the page with **named containers** and placeholder `DYNAMICTEXT` widgets (these are built-in and always work).
160+
2. Open the `.mpr` in Studio Pro — it will register the widget type from the `.mpk` in `tests/testProject/widgets/`.
161+
3. Inside each container, replace the placeholder with the actual pluggable widget instance.
162+
4. After Studio Pro saves, run `automation/tools/mxcli widget init -p <MPR>` to cache the widget definition.
163+
5. Future `PLUGGABLEWIDGET` statements for that widget will then work via mxcli.
164+
165+
**Widget management commands:**
166+
167+
```bash
168+
# Register widget definitions from all .mpk files in the project's widgets/ dir
169+
automation/tools/mxcli widget init -p <MPR_PATH>
170+
171+
# Extract a .def.json skeleton from a specific .mpk (does not bootstrap the BSON template)
172+
automation/tools/mxcli widget extract --mpk <path>.mpk
173+
174+
# List all registered widget definitions and their MDL keywords
175+
automation/tools/mxcli widget list -p <MPR_PATH>
176+
177+
# Generate MDL syntax docs for a specific widget
178+
automation/tools/mxcli widget docs -p <MPR_PATH> <mdl-name>
179+
```
180+
181+
The `widget list` output shows the MDL keyword (e.g. `bubblechart`) needed in `PLUGGABLEWIDGET` blocks. The keyword lookup is case-insensitive but the widget ID string is exact.
182+
137183
## Warnings
138184

139-
- `CREATE OR MODIFY PAGE ... {}` wipes all widget content — never use on existing pages
140-
- Do NOT run mxcli while Studio Pro has the project open
185+
- Do NOT run mxcli while Studio Pro has the project open — check for the lock file (Step 2)
141186
- New pages need `GRANT VIEW ON PAGE` — missing it causes mxbuild exit code 3
142187
- `automation/tools/mxcli` is gitignored — run `bash automation/mxcli/setup.sh` on first checkout
188+
- `PLUGGABLEWIDGET` requires an existing instance in the MPR — use named containers as placeholders for brand-new widgets and configure them in Studio Pro first
143189
- Test project changes may require updating the `testProjects` repo branch for CI — flag this to the user

.claude/settings.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010
"mcp__plugin_playwright_playwright__browser_type",
1111
"mcp__plugin_playwright_playwright__browser_fill_form",
1212
"mcp__plugin_playwright_playwright__browser_press_key",
13-
"mcp__plugin_playwright_playwright__browser_evaluate",
14-
"Bash(bash automation/mxcli/mx-testproject.sh*)",
13+
"Bash(bash automation/mxcli/mx-testproject.sh inspect *)",
14+
"Bash(bash automation/mxcli/mx-testproject.sh list-pages *)",
15+
"Bash(bash automation/mxcli/mx-testproject.sh search *)",
16+
"Bash(bash automation/mxcli/mx-testproject.sh lint *)",
17+
"Bash(bash automation/mxcli/mx-testproject.sh report *)",
18+
"Bash(bash automation/mxcli/mx-testproject.sh callers *)",
19+
"Bash(bash automation/mxcli/mx-testproject.sh refs *)",
1520
"Bash(bash automation/mxcli/setup.sh*)",
1621
"Bash(automation/tools/mxcli -p * -c \"SHOW*\")",
1722
"Bash(automation/tools/mxcli -p * -c \"DESCRIBE*\")",

automation/mxcli/mx-testproject.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ case "$SUBCOMMAND" in
8484
| grep '^|' | grep -v '| Module ' | grep -v '^|---' \
8585
| grep -v '| System ' | grep -v '| Atlas_' \
8686
| awk -F'|' 'NR==1{gsub(/ /,"",$2); print $2}' || true)"
87-
if [[ -n "$MODULE" ]]; then
87+
if [[ -z "$MODULE" ]]; then
88+
echo "Warning: could not auto-detect a non-System/non-Atlas module." >&2
89+
echo "Run: bash automation/mxcli/mx-testproject.sh exec ${WIDGET} \"SHOW MODULES\"" >&2
90+
else
8891
echo "=== Pages in ${MODULE} ==="
8992
run_mdl "SHOW PAGES IN ${MODULE}"
9093
echo ""
@@ -112,6 +115,7 @@ case "$SUBCOMMAND" in
112115
echo "Usage: exec <widget> \"<MDL statement>\"" >&2
113116
exit 1
114117
fi
118+
echo "⚠️ Applying MDL directly — no diff preview. Use 'diff' subcommand first for mutating statements." >&2
115119
run_mdl "$MDL"
116120
;;
117121
search)

0 commit comments

Comments
 (0)