Skip to content

[DomCrawler] [Form] Fields in <template> are excluded (<turbo-stream>) #53823

@mpiot

Description

@mpiot

Symfony version(s) affected

6.4.3

Description

When using Turbo-Stream, we can want to test it directly:

  1. GET on the path that give us a Turbo-Stram response
  2. Check attributes: action, method
  3. If it's a form, test to submit it

But in tests, methods like submitForm('Save'), selectButton('Save')->form(), should give us the ability to deal with, but the method exclude all fields inside <template>.

In the file src/Symfony/Component/DomCrawler/Form.php (line 421), it exclude all in <template>, by the way, it appear impossible to use the Form methods for testing easily forms inside streams.

How to reproduce

  1. Create a form inside a Turbo-Stream
  2. Call the path that return us that

Possible Solution

  1. Remove the part: [not(ancestor::template)]
  2. Replace it by [( not(ancestor::template) or ancestor::turbo-stream )]
  3. Replace it to respect the order, in test we want to avoid catch of <template> inside a <form>, no <form> inside a <template>: [not(ancestor::template/ancestor::form)]

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions