Fix test_memo_client_counter after the client-state rename

Merged
MA
2d ago
+21-18

Fixes the integration-app-harness-playwright failures on #7694 after a7400b3 merged main in (failing run).

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Why the test failed

test_memo_client_counter hard-coded the JavaScript identifier a client state var binds its value to, e.g. "Δcounter + 1" for ClientStateVar.create("Δcounter", default=0, global_ref=False). Merging main brought in #6936, which changed two things:

  • The legacy wrapper now drops the name when global_ref=False is passed, so the var gets a generated store name (cs$0).
  • The emitted identifier carries the RxClientState suffix.

The hook became const [cs$0RxClientState, setCs$0] = useClientState(0, "cs$0") while the click handler still read Δcounter. That bare identifier is not a binding anywhere in the component, so the browser resolved it through named element access to the <button id="Δcounter">, and the counter rendered "[object HTMLButtonElement]1". The eval variants failed the same way. The previous commit on the branch passed this workflow (run 41491674721).

Changes

  • Build the increment expression from str(counter.value), with a {value} placeholder for the direct read and a {source} placeholder (the identifier as a JSON string literal) for the eval and nested-eval reads, so the test follows whatever identifier Reflex emits.
  • Use rx.client_state(0) and .set(...) instead of the deprecated ClientStateVar.create and set_value, which also removes the deprecation warnings from the run.
  • rx.client_state rejects non-ASCII names, so the Unicode case becomes a plain scoped counter named by its button ID. Unicode bindings in the Babel dependency prune are still covered by test_react_compiler_callback_dependencies, which writes Δvalue bindings directly.

Generated code after the change:

const [cs$0RxClientState, setCs$0] = useClientState(0, "cs$0")
(() => (setCs$0(cs$0RxClientState + 1)))
(() => (setCs$1(eval("cs$1RxClientState") + 1)))
(() => (setCs$2((() => eval("cs$2RxClientState"))() + 1)))

Testing

  • uv run pytest tests/integration/tests_playwright/test_memo.py -k test_memo_client_counter: 12 passed (dev and prod, compiler on and off, three counters each).
  • uv run ruff check, uv run ruff format --check, and uv run pyright on the test file: clean.
  • uv run reflex-release changelog-check: no packaged source changes, so no news fragment is required.

Generated by Claude Code