Handle walkthrough element lookup errors

This commit is contained in:
2026-08-01 04:40:48 -05:00
parent d45a51d2e8
commit a43a78900b
3 changed files with 18 additions and 5 deletions
+14
View File
@@ -424,6 +424,20 @@ database, whose accumulated state no longer matches the demo dataset they
were written against. Unaffected by the test-database split, which
deliberately leaves the walkthroughs on the app database. Re-check after a
`make stack-fresh` + `./test/seed-demo.sh`.)
(Update 2026-08-01, during `test-stack-integration-profiles` verification:
the Must-defeats-skip pattern from item (2) recurs in
`TestGrantNonPlanWalkthrough` — grant_nonplan_test.go:30 `MustElementX`
panics on timeout before the `form == nil` skip at :33 can run, so an
unseeded or aged DB fails the test instead of skipping. The parallel guard
at :47 is fine (`MustElements` returns an empty slice without panicking),
as are org_types_test.go (`MustAttribute` legitimately returns nil for an
absent attribute) and helpers_test.go (`rod.Try`). products_test.go:47 has
the same dead `== nil` check after `MustElement`, though it shadows a
failure message, not a skip. Fixed same day: both call sites converted to
non-Must variants; verified live against the aged stack DB, where
`TestGrantNonPlanWalkthrough` now skips cleanly on the exact path that
previously panicked, and `TestProductsWalkthrough` phase 1 passes through
the converted call.)
### HTMX handler file structure cleanup
Labels: `refactor`
@@ -27,10 +27,10 @@ func TestGrantNonPlanWalkthrough(t *testing.T) {
loginAsOperator(t, page, base, "/operator/organizations")
_ = gotoFirstOrgComposite(t, page, base)
form := page.Timeout(10 * time.Second).MustElementX(
form, err := page.Timeout(10 * time.Second).ElementX(
`//form[contains(@hx-post, "/grant/create")]`,
)
if form == nil {
if err != nil {
t.Skip("no non-plan grant form on first org composite — possibly no add-on/usage products")
}
@@ -43,9 +43,8 @@ func TestProductsWalkthrough(t *testing.T) {
page.MustElement(`#createProductForm button[type=submit]`).MustClick()
// Wait for the form re-render with at least one is-invalid field.
invalid := page.Timeout(10 * time.Second).MustElement(`#createProductForm .is-invalid`)
if invalid == nil {
t.Fatalf("phase 1: expected an .is-invalid field after empty submission")
if _, err := page.Timeout(10 * time.Second).Element(`#createProductForm .is-invalid`); err != nil {
t.Fatalf("phase 1: expected an .is-invalid field after empty submission: %v", err)
}
// Verify the per-field feedback markup is also rendered (per
// operator-ux-conventions.md §6).