feat: defer from mobile detail sheets (#256)
This commit is contained in:
1 parent
61168dbfd4
commit
fdb39e43ad
5 files changed
+124
-3
No files matched your search
@@ -10,6 +10,7 @@ from src.views import dashboard
|
||||
|
||||
MY_WORK = Path(__file__).parents[1] / "frontend" / "my-work.js"
|
||||
LATER_WORK = Path(__file__).parents[1] / "frontend" / "later-work.js"
|
||||
DETAIL_DEFER = Path(__file__).parents[1] / "frontend" / "detail-defer.js"
|
||||
REVIEW_SHEET = Path(__file__).parents[1] / "frontend" / "review-sheet.js"
|
||||
ISSUE_SHEET = Path(__file__).parents[1] / "frontend" / "issue-sheet.js"
|
||||
CREATE_ISSUE_SHEET = Path(__file__).parents[1] / "frontend" / "create-issue-sheet.js"
|
||||
@@ -838,6 +839,65 @@ process.stdout.write(JSON.stringify({{
|
||||
}
|
||||
|
||||
|
||||
def test_detail_defer_closes_normal_triage_but_keeps_session_open_for_reconcile():
|
||||
script = f"""
|
||||
const createDetailDefer = require({json.dumps(str(DETAIL_DEFER))});
|
||||
const calls = [];
|
||||
let sessionActive = false;
|
||||
const controller = createDetailDefer({{
|
||||
laterWork: {{
|
||||
presetUntil:preset => new Date(preset === 'today' ? '2026-08-08T16:00:00Z' : '2026-08-09T09:00:00Z'),
|
||||
defer:(item, until) => {{ calls.push(['defer', item.title, until.toISOString()]); return true; }},
|
||||
}},
|
||||
session: {{ active:() => sessionActive }},
|
||||
close:() => calls.push(['close']),
|
||||
refresh:() => calls.push(['refresh']),
|
||||
focus:() => calls.push(['focus']),
|
||||
announce:message => calls.push(['announce', message]),
|
||||
formatTime:value => value.toISOString(),
|
||||
}});
|
||||
const item = {{kind:'issue',repository:'stackchain/api',number:17,title:'Read first'}};
|
||||
const outside = controller.defer(item, 'today');
|
||||
sessionActive = true;
|
||||
const session = controller.defer(item, 'tomorrow');
|
||||
process.stdout.write(JSON.stringify({{outside,session,calls}}));
|
||||
"""
|
||||
|
||||
result = subprocess.run(
|
||||
["node", "-e", script], check=True, capture_output=True, text=True
|
||||
)
|
||||
|
||||
assert json.loads(result.stdout) == {
|
||||
"outside": True,
|
||||
"session": True,
|
||||
"calls": [
|
||||
["defer", "Read first", "2026-08-08T16:00:00.000Z"],
|
||||
["close"],
|
||||
["refresh"],
|
||||
["announce", "Deferred until 2026-08-08T16:00:00.000Z. It stays unread and unchanged in Gitea."],
|
||||
["focus"],
|
||||
["defer", "Read first", "2026-08-09T09:00:00.000Z"],
|
||||
["refresh"],
|
||||
["announce", "Deferred until 2026-08-09T09:00:00.000Z. It stays unread and unchanged in Gitea."],
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_mobile_detail_sheets_offer_touch_safe_defer_without_a_gitea_mutation():
|
||||
html = await dashboard()
|
||||
|
||||
assert '<script src="static/detail-defer.js"></script>' in html
|
||||
assert html.count('class="detail-defer"') == 4
|
||||
assert html.count('data-detail-defer-preset="today"') == 4
|
||||
assert html.count('data-detail-defer-preset="tomorrow"') == 4
|
||||
assert 'const detailDefer = createDetailDefer({' in html
|
||||
assert 'selectedUpdate || selectedReview || selectedIssue || selectedPull' in html
|
||||
assert "detailDefer.defer(item, button.dataset.detailDeferPreset)" in html
|
||||
assert ".detail-defer summary, .detail-defer button { min-height:44px;" in html
|
||||
assert "fetch(" not in DETAIL_DEFER.read_text()
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_mobile_my_work_wires_touch_safe_non_mutating_later_actions():
|
||||
html = await dashboard()
|
||||
|
||||
@@ -70,10 +70,10 @@ async function dispatchSync(tag) {{
|
||||
return json.loads(completed.stdout)
|
||||
|
||||
|
||||
def test_background_authored_sync_ships_in_a_new_shell_cache():
|
||||
def test_detail_defer_ships_in_a_new_shell_cache():
|
||||
source = WORKER.read_text()
|
||||
|
||||
assert "stackchain-dashboard-shell-v14" in source
|
||||
assert "stackchain-dashboard-shell-v15" in source
|
||||
|
||||
|
||||
def test_background_sync_event_flushes_closed_app_issue_outbox_only_for_its_tag():
|
||||
@@ -114,6 +114,7 @@ def test_install_precaches_complete_subpath_scoped_app_shell():
|
||||
"/dashboard/static/offline-work.js",
|
||||
"/dashboard/static/my-work.js",
|
||||
"/dashboard/static/later-work.js",
|
||||
"/dashboard/static/detail-defer.js",
|
||||
"/dashboard/static/pick-work.js",
|
||||
"/dashboard/static/conversation.js",
|
||||
"/dashboard/static/issue-sheet.js",
|
||||
|
||||
Reference in new issue
Block a user