Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kj-controller/tests/e2e/test_sing_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def test_done_lists_all_submitted_songs(self, page, live_server, live_token):
def test_request_another_returns_to_search(self, page, live_server, live_token):
r1 = self._submit_one(live_server, live_token)
page.goto(f"{live_server}/sing/?t={live_token}")
page.wait_for_function("!!window.__sing_state")
page.evaluate(
"(payload) => localStorage.setItem('sing_my_request_ids', JSON.stringify(payload))",
{"token": live_token, "ids": [r1["id"]]},
Expand All @@ -148,6 +149,7 @@ def test_request_another_without_a_name_asks_for_the_name(self, page, live_serve
# My songs → "Request another song" → search, and every send 400'd
# with singer_name is required. It must get the name screen instead.
page.goto(f"{live_server}/sing/?t={live_token}")
page.wait_for_function("!!window.__sing_state")
page.evaluate("localStorage.setItem('sing_name', '')")
page.evaluate("() => { window.__sing_state.name = ''; window.__sing_state.step = 'done'; window.__sing_render(); }")
page.locator('[data-testid="request-another"]').click()
Expand All @@ -156,6 +158,7 @@ def test_request_another_without_a_name_asks_for_the_name(self, page, live_serve

def test_search_step_without_a_name_renders_the_name_screen(self, page, live_server, live_token):
page.goto(f"{live_server}/sing/?t={live_token}")
page.wait_for_function("!!window.__sing_state")
page.evaluate("() => { window.__sing_state.name = ''; window.__sing_state.step = 'search'; window.__sing_render(); }")
expect(page.locator('input[type="search"]')).to_have_count(0)
expect(page.get_by_label("First name + last initial")).to_be_visible()
Expand Down Expand Up @@ -1694,6 +1697,7 @@ def test_host_link_renames_this_phone(self, page, live_server, live_token):
import urllib.request as _ur
# A fresh tab with no name, on My songs.
page.goto(f"{live_server}/sing/?t={live_token}")
page.wait_for_function("!!window.__sing_state")
page.evaluate("() => { window.__sing_state.name = ''; window.__sing_state.step = 'done'; window.__sing_render(); }")
code_line = page.locator('[data-testid="phone-code"]')
expect(code_line).to_contain_text(re.compile(r"\d{4}"))
Expand Down
4 changes: 4 additions & 0 deletions kj-controller/tests/e2e/test_sing_i18n_footer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
def _login(page, live_server, live_token, name="Alice"):
page.goto(f"{live_server}/sing/?t={live_token}")
expect(page.locator("#sing-root")).to_be_visible()
# sing.js awaits its translations before exposing its state, and the
# page's load event doesn't wait for that: without this, a cold message
# fetch makes the next evaluate hit an undefined __sing_state.
page.wait_for_function("!!window.__sing_state")
page.evaluate("(n) => localStorage.setItem('sing_name', n)", name)
page.evaluate("localStorage.setItem('sing_phone', '')")
page.evaluate("window.__sing_state.name = localStorage.getItem('sing_name') || ''")
Expand Down
Loading