germsvel / phoenix_test

PhoenixTest provides a unified way of writing feature tests -- regardless of whether you're testing LiveView pages or static (non-LiveView) pages.
https://hex.pm/packages/phoenix_test
MIT License
181 stars 23 forks source link

Fix uncheck/2 in nested forms #78

Closed soundmonster closed 6 months ago

soundmonster commented 6 months ago

Unchecking checkboxes in nested forms currently crashes with

** (FunctionClauseError) no function clause matching in Floki.Selector.Parser.do_parse/2

     The following arguments were given to Floki.Selector.Parser.do_parse/2:

         # 1
         [{~c"]", 1}]

         # 2
         %Floki.Selector{id: nil, type: "input", classes: [], attributes: [%Floki.Selector.AttributeSelector{match_type: :equal, attribute: "name", value: "payer", flag: nil}, %Floki.Selector.AttributeSelector{match_type: :equal, attribute: "type", value: "hidden", flag: nil}], namespace: nil, pseudo_classes: [], combinator: nil}

     Attempted function clauses (showing 10 out of 21):

         defp do_parse([], selector)
         defp do_parse([{:close_parentesis, _} | t], selector)
         defp do_parse([{:comma, _} | t], selector)
         defp do_parse([{:identifier, _, namespace}, {:namespace_pipe, _} | t], selector)
         defp do_parse([{:identifier, _, type} | t], selector)
         defp do_parse([{~c"*", _} | t], selector)
         defp do_parse([{:hash, _, id} | t], selector)
         defp do_parse([{:class, _, class} | t], selector)
         defp do_parse([{~c"[", _} | t], selector)
         defp do_parse([{:pseudo_not, _} | t], selector)
         ...
         (11 clauses not shown)

This PR escapes brackets in the hidden input name by wrapping it in single quotes.