Skip to content

Resolve CLI test suite IDs against the live dropdown#620

Merged
tracygardner merged 2 commits intoflipcomputing:mainfrom
commercetest:julianharty/address-issue-619
May 8, 2026
Merged

Resolve CLI test suite IDs against the live dropdown#620
tracygardner merged 2 commits intoflipcomputing:mainfrom
commercetest:julianharty/address-issue-619

Conversation

@julianharty
Copy link
Copy Markdown
Contributor

@julianharty julianharty commented May 8, 2026

Running npm run test:api @<suite> for any suite whose dropdown ID is the bare name (e.g. @sensing, @materials, @physics) failed with a 30s Playwright timeout and a misleading "did not find some options" message. Three suites in tests/tests.html use @-prefixed dropdown IDs (@new, @notslow, @onlyslow), but for ~20 others the @-prefix is the mocha grep pattern, not the dropdown ID. The runner passed the user's argument straight to page.selectOption, so either form had to match the dropdown exactly.

Replace the static AVAILABLE_SUITES lookup with resolveSuite(id, dropdownIds) that:

  • Reads the actual dropdown options after the page loads.
  • Accepts either @<id> or <id> and resolves to whichever matches.
  • Polls for up to 30s, matching Playwright's default selectOption timeout, because tests.html's loadAllTests populates the dropdown incrementally (each option is appended before its module is awaited).
  • On miss, throws immediately with the full list of valid IDs and a hint about the @/grep-pattern distinction, replacing the opaque "did not find some options" timeout.

Also remove the movement: "translation" alias. movement and translation are separate suites with separate test files (movement.test.js vs transform.translate.test.js); the alias caused npm run test:api movement to silently run translation tests instead of the 10 movement tests.

Fixes #619

Summary by CodeRabbit

  • Tests
    • More reliable test-suite selection for pages with dynamically populated dropdowns.
    • Improved resolution of requested suite identifiers (accepts bare IDs and tag-style names) and clearer diagnostics when a match can't be found.
    • Delayed selection until the page presents options, reducing timing-related failures and improving console/status messages during test startup.

Running `npm run test:api @<suite>` for any suite whose dropdown ID is
the bare name (e.g. `@sensing`, `@materials`, `@physics`) failed with a
30s Playwright timeout and a misleading "did not find some options"
message. Three suites in tests/tests.html use `@`-prefixed dropdown IDs
(`@new`, `@notslow`, `@onlyslow`), but for ~20 others the `@`-prefix is
the mocha grep pattern, not the dropdown ID. The runner passed the
user's argument straight to `page.selectOption`, so either form had to
match the dropdown exactly.

Replace the static AVAILABLE_SUITES lookup with `resolveSuite(id,
dropdownIds)` that:
  - Reads the actual dropdown options after the page loads.
  - Accepts either `@<id>` or `<id>` and resolves to whichever matches.
  - Polls for up to 30s, matching Playwright's default selectOption
    timeout, because tests.html's loadAllTests populates the dropdown
    incrementally (each option is appended before its module is awaited).
  - On miss, throws immediately with the full list of valid IDs and a
    hint about the `@`/grep-pattern distinction, replacing the opaque
    "did not find some options" timeout.

Also remove the `movement: "translation"` alias. `movement` and
`translation` are separate suites with separate test files
(movement.test.js vs transform.translate.test.js); the alias caused
`npm run test:api movement` to silently run translation tests instead
of the 10 movement tests.

Fixes flipcomputing#619

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 59217f2c-be1a-46fe-b919-495a679cf0ed

📥 Commits

Reviewing files that changed from the base of the PR and between f6425b0 and eaa1299.

📒 Files selected for processing (1)
  • scripts/run-api-tests.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/run-api-tests.mjs

📝 Walkthrough

Walkthrough

Delays mapping the CLI suite argument until after the test page's dropdown is populated: adds resolveSuite to accept @tag or bare IDs, polls #testSelect for up to 30s to resolve the requested suite, then logs diagnostics and selects the resolved dropdown value.

Changes

Suite Resolution and Dropdown Polling

Layer / File(s) Summary
Suite Resolution Helper
scripts/run-api-tests.mjs
Adds suiteAliases and resolveSuite(id, dropdownIds) that normalize requested suite IDs (handling @tag and bare forms) and match them against dropdown option values; preserves raw requestedSuite until resolution.
Dropdown Polling and Resolution
scripts/run-api-tests.mjs
Updates runTests to repeatedly read #testSelect option values via page.evaluate, retry resolution with resolveSuite until a ~30s deadline, and throw a descriptive error listing available dropdown IDs if not found.
Diagnostics and Suite Selection
scripts/run-api-tests.mjs
After resolving, derive suiteInfo/patternInfo from AVAILABLE_SUITES, print suite name/pattern when verbose, and call page.selectOption("#testSelect", resolvedSuiteId) with the resolved dropdown ID.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I peek inside the dropdown's hive,
I wait and nudge until the options arrive,
@tags or bare — I match them true,
At last the suite is chosen — off we do! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: resolving CLI test suite IDs against the dropdown instead of using a static map.
Linked Issues check ✅ Passed The PR directly addresses all requirements from issue #619: resolves CLI arguments against live dropdown, handles both @prefix and bare names, replaces timeouts with immediate errors listing valid IDs, and removes the movement→translation alias.
Out of Scope Changes check ✅ Passed All changes are scoped to the test runner script and directly support the linked issue objectives without introducing unrelated functionality.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
scripts/run-api-tests.mjs (1)

163-171: ⚡ Quick win

resolveSuite only resolves @foo → foo, not the reverse foo → @foo``.

The function handles the primary PR use-case (@sensingsensing) but has no path for the inverse: a user who types notslow, new, or onlyslow (without @) will hit the 30-second poll and receive a confusing "not in the dropdown" error, because the three special dropdown entries are @notslow, @onlyslow, @new.

♻️ Proposed fix — add the `bare → `@bare`` fallback
 function resolveSuite(id, dropdownIds) {
   const aliased = suiteAliases[id] || id;
   if (dropdownIds.includes(aliased)) return aliased;
   if (aliased.startsWith("@")) {
     const bare = aliased.slice(1);
     if (dropdownIds.includes(bare)) return bare;
-  }
+  } else {
+    const withAt = "@" + aliased;
+    if (dropdownIds.includes(withAt)) return withAt;
+  }
   return null;
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/run-api-tests.mjs` around lines 163 - 171, The resolveSuite function
currently only maps aliased IDs beginning with "@" to their bare forms but
doesn't handle the inverse (e.g., user types "notslow" while dropdown contains
"@notslow"); update resolveSuite to check both the aliased and its "@"-prefixed
counterpart: after computing aliased = suiteAliases[id] || id, first return
aliased if dropdownIds.includes(aliased), then if dropdownIds.includes("@" +
aliased) return "@" + aliased; keep the existing branch that strips "@" when
aliased startsWith("@") and returns the bare value if present; ensure the
function still returns null when no match is found.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@scripts/run-api-tests.mjs`:
- Around line 163-171: The resolveSuite function currently only maps aliased IDs
beginning with "@" to their bare forms but doesn't handle the inverse (e.g.,
user types "notslow" while dropdown contains "@notslow"); update resolveSuite to
check both the aliased and its "@"-prefixed counterpart: after computing aliased
= suiteAliases[id] || id, first return aliased if dropdownIds.includes(aliased),
then if dropdownIds.includes("@" + aliased) return "@" + aliased; keep the
existing branch that strips "@" when aliased startsWith("@") and returns the
bare value if present; ensure the function still returns null when no match is
found.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c385425c-aa07-4a69-8807-d664adf783d0

📥 Commits

Reviewing files that changed from the base of the PR and between e96964b and f6425b0.

📒 Files selected for processing (1)
  • scripts/run-api-tests.mjs

CodeRabbit noted:
```
resolveSuite only resolves @foo → foo, not the reverse foo → @foo``.

The function handles the primary PR use-case (@SenSing → sensing) but has no path for the inverse: a user who types notslow, new, or onlyslow (without @) will hit the 30-second poll and receive a confusing "not in the dropdown" error, because the three special dropdown entries are @notslow, @onlyslow, @new.
```
I've added the code it suggested and tested the resolution in both
directions - they worked.
@tracygardner tracygardner merged commit fe34190 into flipcomputing:main May 8, 2026
9 checks passed
@julianharty julianharty deleted the julianharty/address-issue-619 branch May 8, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Various bugs running API tests

2 participants