generator: translate clickAndReadStyle() helper into dom-dispatch click
Upstream tests use clickAndReadStyle(evaluate, sel, prop) to click-and-read before asserting toHaveCSS(sel, prop, val). Emit just the click — downstream toHaveCSS checks then test the post-click state. Net: transition 6→13.
This commit is contained in:
@@ -12667,6 +12667,7 @@ end")
|
|||||||
(dom-set-attr _el-div "_" "on click transition *width from 0px to 100px")
|
(dom-set-attr _el-div "_" "on click transition *width from 0px to 100px")
|
||||||
(dom-append (dom-body) _el-div)
|
(dom-append (dom-body) _el-div)
|
||||||
(hs-activate! _el-div)
|
(hs-activate! _el-div)
|
||||||
|
(dom-dispatch _el-div "click" nil)
|
||||||
(assert= (dom-get-style _el-div "width") "100px")
|
(assert= (dom-get-style _el-div "width") "100px")
|
||||||
))
|
))
|
||||||
(deftest "can transition a single property on current element using style ref"
|
(deftest "can transition a single property on current element using style ref"
|
||||||
@@ -12675,6 +12676,7 @@ end")
|
|||||||
(dom-set-attr _el-div "_" "on click transition *width from 0px to 100px")
|
(dom-set-attr _el-div "_" "on click transition *width from 0px to 100px")
|
||||||
(dom-append (dom-body) _el-div)
|
(dom-append (dom-body) _el-div)
|
||||||
(hs-activate! _el-div)
|
(hs-activate! _el-div)
|
||||||
|
(dom-dispatch _el-div "click" nil)
|
||||||
(assert= (dom-get-style _el-div "width") "100px")
|
(assert= (dom-get-style _el-div "width") "100px")
|
||||||
))
|
))
|
||||||
(deftest "can transition a single property on current element with the my prefix"
|
(deftest "can transition a single property on current element with the my prefix"
|
||||||
@@ -12683,6 +12685,7 @@ end")
|
|||||||
(dom-set-attr _el-div "_" "on click transition my *width from 0px to 100px")
|
(dom-set-attr _el-div "_" "on click transition my *width from 0px to 100px")
|
||||||
(dom-append (dom-body) _el-div)
|
(dom-append (dom-body) _el-div)
|
||||||
(hs-activate! _el-div)
|
(hs-activate! _el-div)
|
||||||
|
(dom-dispatch _el-div "click" nil)
|
||||||
(assert= (dom-get-style _el-div "width") "100px")
|
(assert= (dom-get-style _el-div "width") "100px")
|
||||||
))
|
))
|
||||||
(deftest "can transition a single property on current element with the my prefix using style ref"
|
(deftest "can transition a single property on current element with the my prefix using style ref"
|
||||||
@@ -12691,6 +12694,7 @@ end")
|
|||||||
(dom-set-attr _el-div "_" "on click transition my *width from 0px to 100px")
|
(dom-set-attr _el-div "_" "on click transition my *width from 0px to 100px")
|
||||||
(dom-append (dom-body) _el-div)
|
(dom-append (dom-body) _el-div)
|
||||||
(hs-activate! _el-div)
|
(hs-activate! _el-div)
|
||||||
|
(dom-dispatch _el-div "click" nil)
|
||||||
(assert= (dom-get-style _el-div "width") "100px")
|
(assert= (dom-get-style _el-div "width") "100px")
|
||||||
))
|
))
|
||||||
(deftest "can transition a single property on form"
|
(deftest "can transition a single property on form"
|
||||||
@@ -12699,6 +12703,7 @@ end")
|
|||||||
(dom-set-attr _el-form "_" "on click transition *width from 0px to 100px")
|
(dom-set-attr _el-form "_" "on click transition *width from 0px to 100px")
|
||||||
(dom-append (dom-body) _el-form)
|
(dom-append (dom-body) _el-form)
|
||||||
(hs-activate! _el-form)
|
(hs-activate! _el-form)
|
||||||
|
(dom-dispatch _el-form "click" nil)
|
||||||
(assert= (dom-get-style _el-form "width") "100px")
|
(assert= (dom-get-style _el-form "width") "100px")
|
||||||
))
|
))
|
||||||
(deftest "can transition a single property on form using style ref"
|
(deftest "can transition a single property on form using style ref"
|
||||||
@@ -12707,6 +12712,7 @@ end")
|
|||||||
(dom-set-attr _el-form "_" "on click transition *width from 0px to 100px")
|
(dom-set-attr _el-form "_" "on click transition *width from 0px to 100px")
|
||||||
(dom-append (dom-body) _el-form)
|
(dom-append (dom-body) _el-form)
|
||||||
(hs-activate! _el-form)
|
(hs-activate! _el-form)
|
||||||
|
(dom-dispatch _el-form "click" nil)
|
||||||
(assert= (dom-get-style _el-form "width") "100px")
|
(assert= (dom-get-style _el-form "width") "100px")
|
||||||
))
|
))
|
||||||
(deftest "can transition on another element"
|
(deftest "can transition on another element"
|
||||||
@@ -12802,6 +12808,7 @@ end")
|
|||||||
(dom-set-attr _el-div "_" "on click set startWidth to 0 then set endWidth to 100 transition *width from (startWidth)px to (endWidth)px")
|
(dom-set-attr _el-div "_" "on click set startWidth to 0 then set endWidth to 100 transition *width from (startWidth)px to (endWidth)px")
|
||||||
(dom-append (dom-body) _el-div)
|
(dom-append (dom-body) _el-div)
|
||||||
(hs-activate! _el-div)
|
(hs-activate! _el-div)
|
||||||
|
(dom-dispatch _el-div "click" nil)
|
||||||
(assert= (dom-get-style _el-div "width") "100px")
|
(assert= (dom-get-style _el-div "width") "100px")
|
||||||
))
|
))
|
||||||
(deftest "can use initial to transition to original value"
|
(deftest "can use initial to transition to original value"
|
||||||
|
|||||||
@@ -901,6 +901,23 @@ def parse_dev_body(body, elements, var_names):
|
|||||||
ops.append(f'(dom-set-inner-html {target} "{val}")')
|
ops.append(f'(dom-set-inner-html {target} "{val}")')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# clickAndReadStyle(evaluate, SEL, PROP) — upstream helper that
|
||||||
|
# dispatches a click on SEL and returns its computed style[PROP].
|
||||||
|
# Materialize the click; downstream toHaveCSS assertions then test
|
||||||
|
# the post-click state. The helper call may appear embedded in a
|
||||||
|
# larger statement (e.g. `const x = await clickAndReadStyle(...)`)
|
||||||
|
# so we use `search`, not `match`.
|
||||||
|
m = re.search(
|
||||||
|
r"clickAndReadStyle\(\s*\w+\s*,\s*(['\"])([^'\"]+)\1\s*,\s*['\"][^'\"]+['\"]\s*\)",
|
||||||
|
stmt_na,
|
||||||
|
)
|
||||||
|
if m and seen_html:
|
||||||
|
sel = re.sub(r'^#work-area\s+', '', m.group(2))
|
||||||
|
target = selector_to_sx(sel, elements, var_names)
|
||||||
|
ops.append(f'(dom-dispatch {target} "click" nil)')
|
||||||
|
# Fall through so any trailing assertions in the same split
|
||||||
|
# statement still get picked up.
|
||||||
|
|
||||||
# evaluate(() => document.querySelector(SEL).click()) — dispatch click
|
# evaluate(() => document.querySelector(SEL).click()) — dispatch click
|
||||||
# on the matched element (bubbles so ancestors see it too).
|
# on the matched element (bubbles so ancestors see it too).
|
||||||
m = re.match(
|
m = re.match(
|
||||||
|
|||||||
Reference in New Issue
Block a user