Skip to content

Commit 17e008e

Browse files
Add browser refresh to JSON cookie test to trigger hydration bug
- Refresh browser after setting each JSON cookie value - Re-acquire DOM elements after refresh to test cookie hydration - Ensures test properly exercises the universal-cookies JSON parsing bug - Addresses feedback from masenf to test the actual bug scenario Co-Authored-By: masen@reflex.dev <masen@reflex.dev>
1 parent deee031 commit 17e008e

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/integration/test_client_storage.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,25 +827,61 @@ def set_sub(var: str, value: str):
827827
json_dict = '{"access_token": "redacted", "refresh_token": "redacted", "created_at": 1234567890, "expires_in": 3600}'
828828
set_sub("c1", json_dict)
829829
AppHarness.expect(lambda: c1.text == json_dict)
830+
831+
driver.refresh()
832+
poll_for_token()
833+
c1 = driver.find_element(By.ID, "c1")
834+
c2 = driver.find_element(By.ID, "c2")
835+
AppHarness.expect(lambda: c1.text == json_dict)
830836

831837
json_array = '["item1", "item2", "item3"]'
832838
set_sub("c2", json_array)
833839
AppHarness.expect(lambda: c2.text == json_array)
840+
841+
driver.refresh()
842+
poll_for_token()
843+
c1 = driver.find_element(By.ID, "c1")
844+
c2 = driver.find_element(By.ID, "c2")
845+
AppHarness.expect(lambda: c2.text == json_array)
834846

835847
complex_json = '{"user": {"id": 123, "name": "test"}, "settings": {"theme": "dark", "notifications": true}, "data": [1, 2, 3]}'
836848
set_sub("c1", complex_json)
837849
AppHarness.expect(lambda: c1.text == complex_json)
850+
851+
driver.refresh()
852+
poll_for_token()
853+
c1 = driver.find_element(By.ID, "c1")
854+
c2 = driver.find_element(By.ID, "c2")
855+
AppHarness.expect(lambda: c1.text == complex_json)
838856

839857
json_with_escapes = (
840858
'{"message": "Hello \\"world\\"", "path": "/api/v1", "count": 42}'
841859
)
842860
set_sub("c2", json_with_escapes)
843861
AppHarness.expect(lambda: c2.text == json_with_escapes)
862+
863+
driver.refresh()
864+
poll_for_token()
865+
c1 = driver.find_element(By.ID, "c1")
866+
c2 = driver.find_element(By.ID, "c2")
867+
AppHarness.expect(lambda: c2.text == json_with_escapes)
844868

845869
empty_json_obj = "{}"
846870
set_sub("c1", empty_json_obj)
847871
AppHarness.expect(lambda: c1.text == empty_json_obj)
872+
873+
driver.refresh()
874+
poll_for_token()
875+
c1 = driver.find_element(By.ID, "c1")
876+
c2 = driver.find_element(By.ID, "c2")
877+
AppHarness.expect(lambda: c1.text == empty_json_obj)
848878

849879
empty_json_array = "[]"
850880
set_sub("c2", empty_json_array)
851881
AppHarness.expect(lambda: c2.text == empty_json_array)
882+
883+
driver.refresh()
884+
poll_for_token()
885+
c1 = driver.find_element(By.ID, "c1")
886+
c2 = driver.find_element(By.ID, "c2")
887+
AppHarness.expect(lambda: c2.text == empty_json_array)

0 commit comments

Comments
 (0)