fix: flush durable outboxes after reconnect (Closes #927)
CI / lint (pull_request) Successful in 1m59s
CI / build-release (pull_request) Successful in 6s
CI / browser-journey (pull_request) Successful in 56s
CI / release-candidate (pull_request) Has been skipped

This commit is contained in:
timmy committed 2026-08-16 01:32:11 +00:00
1 parent 76eed47487
commit 64e764b996
6 files changed
+92 -7

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
import json
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
RECONNECT = ROOT / "frontend" / "reconnect-outboxes.js"
def run_node(script: str) -> dict:
result = subprocess.run(
["node", "-e", script], cwd=ROOT, text=True, capture_output=True, check=True
)
return json.loads(result.stdout)
def test_successful_reconnect_restores_identity_and_flushes_unchanged_outboxes():
result = run_node(
f"""
const createReconnectOutboxes = require({json.dumps(str(RECONNECT))});
const calls = [];
const reconnect = createReconnectOutboxes({{
refresh: async () => ({{context:{{user:{{login:'timmy'}}}}}}),
restoreIdentity: login => calls.push(['identity', login]),
flushIssue: () => calls.push(['issue']),
flushAuthored: () => calls.push(['authored']),
flushNotificationReads: () => calls.push(['notification-read']),
}});
reconnect().then(result => process.stdout.write(JSON.stringify({{result, calls}})));
"""
)
assert result == {
"result": True,
"calls": [
["identity", "timmy"],
["issue"],
["authored"],
["notification-read"],
],
}
def test_dashboard_uses_reconnect_flush_after_live_identity_refresh():
index = (ROOT / "frontend" / "index.html").read_text()
dashboard = (ROOT / "frontend" / "dashboard.js").read_text()
assert '<script src="static/reconnect-outboxes.js"></script>' in index
assert "const reconnectOutboxes = createReconnectOutboxes({" in dashboard
assert "restoreIdentity: login => { activeFlushLogin = login; confirmedOwnerLogin = login; }" in dashboard
assert "window.addEventListener('online', reconnectOutboxes);" in dashboard
+1
View File
@@ -930,6 +930,7 @@ def test_install_precaches_complete_subpath_scoped_app_shell():
"/dashboard/static/draft-capacity-dialog.js",
"/dashboard/static/outbox-coordinator.js",
"/dashboard/static/issue-outbox.js",
"/dashboard/static/reconnect-outboxes.js",
"/dashboard/static/authored-outbox.js",
"/dashboard/static/offline-issue-close.js",
"/dashboard/static/offline-issue-blocker.js",