Live-update the account page status block after sync
Mirrors the dashboard's row update: "Sync now" on the account page refreshes the status block in place and shows a toast, instead of navigating to a separate result page. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -289,7 +289,7 @@ def test_account_sync_triggers_own_user_only(app, client: TestClient, fake_sync_
|
||||
assert fake_sync_manager.user_calls == [user_id]
|
||||
|
||||
|
||||
def test_account_sync_reports_already_running(app, client: TestClient, fake_sync_manager) -> None:
|
||||
def test_account_sync_reports_already_running_as_toast(app, client: TestClient, fake_sync_manager) -> None:
|
||||
create_user_via_admin(client)
|
||||
account_login(client, email="max@mywhoosh.example", password="mw-secret")
|
||||
app.state.sync_manager = fake_sync_manager
|
||||
@@ -299,10 +299,25 @@ def test_account_sync_reports_already_running(app, client: TestClient, fake_sync
|
||||
csrf = extract_csrf(page.text)
|
||||
response = client.post("/account/sync", data={"csrf_token": csrf})
|
||||
|
||||
assert response.status_code == 409
|
||||
assert response.status_code == 200
|
||||
assert "already running" in response.text.lower()
|
||||
|
||||
|
||||
def test_account_sync_updates_status_block_and_shows_toast(app, client: TestClient, fake_sync_manager) -> None:
|
||||
create_user_via_admin(client)
|
||||
account_login(client, email="max@mywhoosh.example", password="mw-secret")
|
||||
app.state.sync_manager = fake_sync_manager
|
||||
|
||||
page = client.get("/account")
|
||||
csrf = extract_csrf(page.text)
|
||||
response = client.post("/account/sync", data={"csrf_token": csrf})
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'id="account-status"' in response.text
|
||||
assert 'hx-swap-oob="true"' in response.text
|
||||
assert "0 imported, 0 failed" in response.text
|
||||
|
||||
|
||||
def test_account_sync_requires_login(client: TestClient) -> None:
|
||||
response = client.post("/account/sync", data={"csrf_token": "whatever"}, follow_redirects=False)
|
||||
assert response.status_code == 303
|
||||
|
||||
Reference in New Issue
Block a user