feat: add ordered mobile Today queue (#279)
This commit is contained in:
1 parent
b11ec6a732
commit
cc38b3d0f6
6 files changed
+250
-15
No files matched your search
@@ -2989,13 +2989,14 @@ async def test_mobile_filters_wrap_show_counts_and_persist_for_the_session():
|
||||
|
||||
assert '.work-filters { display:flex; gap:8px; flex-wrap:wrap; }' in html
|
||||
assert 'data-work-count="all"' in html
|
||||
assert 'data-work-count="today"' in html
|
||||
assert 'data-work-count="attention"' in html
|
||||
assert 'data-work-count="issue"' in html
|
||||
assert 'data-work-count="pull"' in html
|
||||
assert 'data-work-count="review"' in html
|
||||
assert 'data-work-count="update"' in html
|
||||
assert 'data-work-count="later"' in html
|
||||
assert "['all', 'attention', 'issue', 'pull', 'review', 'update', 'later', 'draft'].includes(savedFilter)" in html
|
||||
assert "['all', 'today', 'attention', 'issue', 'pull', 'review', 'update', 'later', 'draft'].includes(savedFilter)" in html
|
||||
assert 'data-work-count="draft"' in html
|
||||
assert 'sessionStorage.getItem(WORK_FILTER_KEY)' in html
|
||||
assert 'sessionStorage.setItem(WORK_FILTER_KEY, selectedWorkFilter)' in html
|
||||
|
||||
@@ -91,10 +91,11 @@ async function dispatchNotificationClick(route) {{
|
||||
return json.loads(completed.stdout)
|
||||
|
||||
|
||||
def test_deadline_attention_flow_ships_in_a_new_shell_cache():
|
||||
def test_today_queue_ships_in_a_new_shell_cache():
|
||||
source = WORKER.read_text()
|
||||
|
||||
assert "stackchain-dashboard-shell-v19" in source
|
||||
assert "stackchain-dashboard-shell-v20" in source
|
||||
assert "BASE + 'static/today-work.js'" in source
|
||||
|
||||
|
||||
def test_background_sync_event_flushes_closed_app_issue_outbox_only_for_its_tag():
|
||||
@@ -194,6 +195,7 @@ def test_install_precaches_complete_subpath_scoped_app_shell():
|
||||
"/dashboard/static/authored-outbox.js",
|
||||
"/dashboard/static/offline-work.js",
|
||||
"/dashboard/static/my-work.js",
|
||||
"/dashboard/static/today-work.js",
|
||||
"/dashboard/static/later-work.js",
|
||||
"/dashboard/static/detail-defer.js",
|
||||
"/dashboard/static/pick-work.js",
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
import json
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from src.views import dashboard
|
||||
|
||||
|
||||
TODAY_WORK = Path(__file__).parents[1] / "frontend" / "today-work.js"
|
||||
|
||||
|
||||
def run_node(script):
|
||||
return subprocess.run(
|
||||
["node", "-e", script], check=True, capture_output=True, text=True
|
||||
).stdout
|
||||
|
||||
|
||||
def test_today_queue_is_account_scoped_ordered_unique_and_bounded():
|
||||
script = f"""
|
||||
const createTodayWork = require({json.dumps(str(TODAY_WORK))});
|
||||
const values = new Map();
|
||||
const storage = {{
|
||||
getItem: key => values.has(key) ? values.get(key) : null,
|
||||
setItem: (key, value) => values.set(key, value),
|
||||
removeItem: key => values.delete(key),
|
||||
}};
|
||||
let login = 'timmy';
|
||||
const queue = createTodayWork({{storage, getLogin: () => login, limit: 3}});
|
||||
const issue = number => ({{kind:'issue', repository:'stackchain/dashboard', number, title:'Issue ' + number}});
|
||||
const first = queue.add(issue(1));
|
||||
const duplicate = queue.add(issue(1));
|
||||
queue.add(issue(2));
|
||||
queue.add(issue(3));
|
||||
const full = queue.add(issue(4));
|
||||
queue.move(issue(3), 'up');
|
||||
queue.move(issue(3), 'up');
|
||||
const timmy = queue.reconcile([issue(1), issue(2), issue(3), issue(4)]).map(item => item.number);
|
||||
const persisted = createTodayWork({{storage, getLogin: () => login, limit: 3}})
|
||||
.reconcile([issue(1), issue(2), issue(3)]).map(item => item.number);
|
||||
login = 'alexander';
|
||||
const isolated = queue.reconcile([issue(1), issue(2), issue(3)]).map(item => item.number);
|
||||
process.stdout.write(JSON.stringify({{first, duplicate, full, timmy, persisted, isolated}}));
|
||||
"""
|
||||
|
||||
assert json.loads(run_node(script)) == {
|
||||
"first": "added",
|
||||
"duplicate": "exists",
|
||||
"full": "full",
|
||||
"timmy": [3, 1, 2],
|
||||
"persisted": [3, 1, 2],
|
||||
"isolated": [],
|
||||
}
|
||||
|
||||
|
||||
def test_today_queue_exposes_reorder_boundaries_for_touch_controls():
|
||||
script = f"""
|
||||
const createTodayWork = require({json.dumps(str(TODAY_WORK))});
|
||||
const values = new Map();
|
||||
const storage = {{
|
||||
getItem: key => values.get(key) || null,
|
||||
setItem: (key, value) => values.set(key, value),
|
||||
removeItem: key => values.delete(key),
|
||||
}};
|
||||
const queue = createTodayWork({{storage, getLogin: () => 'timmy'}});
|
||||
const item = number => ({{kind:'issue', repository:'stackchain/dashboard', number}});
|
||||
queue.add(item(1)); queue.add(item(2)); queue.add(item(3));
|
||||
process.stdout.write(JSON.stringify([
|
||||
queue.position(item(1)), queue.position(item(2)), queue.position(item(3)), queue.position(item(9))
|
||||
]));
|
||||
"""
|
||||
|
||||
assert json.loads(run_node(script)) == [
|
||||
{"can_up": False, "can_down": True},
|
||||
{"can_up": True, "can_down": True},
|
||||
{"can_up": True, "can_down": False},
|
||||
{"can_up": False, "can_down": False},
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_dashboard_runs_the_curated_today_queue_as_a_mobile_work_flow():
|
||||
html = await dashboard()
|
||||
|
||||
assert '<script src="static/today-work.js"></script>' in html
|
||||
assert 'data-work-filter="today"' in html
|
||||
assert 'data-work-count="today"' in html
|
||||
assert "const todayWork = createTodayWork({" in html
|
||||
assert "const filter = todayMyWork.length ? 'today' : (counts.attention ? 'attention' : 'all');" in html
|
||||
assert "selectedWorkFilter === 'today' ? todayMyWork : activeMyWork" in html
|
||||
assert 'data-today-add' in html
|
||||
assert 'data-today-remove' in html
|
||||
assert 'data-today-move="up"' in html
|
||||
assert 'data-today-move="down"' in html
|
||||
assert 'Today is limited to 5 items' in html
|
||||
assert '.today-actions button' in html and 'min-height:44px' in html
|
||||
Reference in new issue
Block a user