Skip to content

feat: add nested-when fixture with Playwright tests#7361

Open
janechu wants to merge 3 commits intomainfrom
users/janechu/nested-when
Open

feat: add nested-when fixture with Playwright tests#7361
janechu wants to merge 3 commits intomainfrom
users/janechu/nested-when

Conversation

@janechu
Copy link
Copy Markdown
Collaborator

@janechu janechu commented Apr 1, 2026

Summary

Adds a nested-when fixture to the fast-html test suite demonstrating nested <f-when> directives with SSR hydration.

Changes

packages/fast-html/test/fixtures/when/main.ts

  • Added NestedWhenElement class with @observable properties: error, showProgress, enableContinue, clickCount
  • Added handleClick arrow function that increments clickCount
  • Registered via RenderableFASTElement(NestedWhenElement).defineAsync({ name: 'nested-when', templateOptions: 'defer-and-hydrate' })

packages/fast-html/test/fixtures/when/index.html

  • Added <f-template name="nested-when"> with nested <f-when> directives for error/progress/continue-button states
  • Added <nested-when id="nested-when"> with pre-rendered shadow DOM containing hydration comment markers
    • Root template UUID: nW0x5kp2Qm

packages/fast-html/test/fixtures/when/when.spec.ts

  • Removed .only from an existing test
  • Added 5 Playwright tests covering:
    1. Initial state (progress visible, error/button hidden)
    2. Error state (error div + retry button, progress hidden) with full state transitions
    3. showProgress=false shows continue button (not disabled)
    4. Toggling showProgress switches between progress and button
    5. Toggling error switches between error/retry and normal state

Notes

  • Tests use await expect(element).not.toHaveAttribute('needs-hydration') before modifying properties to ensure hydration is complete before property changes, avoiding a race condition where pre-rendered DOM is visible before FAST bindings are wired up.

- Added NestedWhenElement class with @observable error, showProgress,
  enableContinue, clickCount properties and handleClick arrow function
- Added <f-template name="nested-when"> with nested <f-when> directives
  for error/progress/continue-button states
- Added pre-rendered shadow DOM with hydration comment markers using
- Added 5 Playwright tests covering initial state, error state,
  showProgress toggle, error toggle, and button interaction
- Tests wait for needs-hydration removal before property changes to
  avoid race conditions during hydration

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
janechu and others added 2 commits March 31, 2026 21:36
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@janechu janechu force-pushed the users/janechu/nested-when branch from 9174268 to 9b84df5 Compare April 1, 2026 04:59
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.

1 participant