feat: prioritize actionable update triage (Closes #773)
This commit is contained in:
1 parent
84302d6f1e
commit
d54f58bf36
5 files changed
+112
-9
No files matched your search
+56
-4
@@ -44,6 +44,56 @@ AGENDA_SESSION_LAUNCHER = Path(__file__).parents[1] / "frontend" / "agenda-sessi
|
||||
UPDATE_TRIAGE_LAUNCHER = Path(__file__).parents[1] / "frontend" / "update-triage-launcher.js"
|
||||
|
||||
|
||||
def test_updates_rank_actionable_work_before_newer_routine_activity():
|
||||
payload = {
|
||||
"user": {"login": "timmy"},
|
||||
"issues": [
|
||||
{"number": 1, "title": "Critical incident", "repository": "stackchain/api",
|
||||
"labels": ["P0"], "assignees": [], "updated_at": "2026-08-01T10:00:00Z"},
|
||||
{"number": 2, "title": "Overdue assignment", "repository": "stackchain/api",
|
||||
"labels": [], "assignees": ["timmy"], "due_date": "2026-08-06T23:59:59Z",
|
||||
"updated_at": "2026-08-05T10:00:00Z"},
|
||||
{"number": 3, "title": "Assigned follow-up", "repository": "stackchain/api",
|
||||
"labels": [], "assignees": ["timmy"], "updated_at": "2026-08-06T10:00:00Z"},
|
||||
],
|
||||
"pull_requests": [
|
||||
{"number": 4, "title": "Requested review", "repository": "stackchain/web",
|
||||
"labels": [], "assignees": [], "work_reasons": ["review_requested"],
|
||||
"updated_at": "2026-08-02T10:00:00Z"},
|
||||
],
|
||||
"notifications": [
|
||||
{"id": 11, "number": 1, "repository": "stackchain/api", "unread": True,
|
||||
"subject_type": "Issue", "url": "https://forge.example/api/issues/1"},
|
||||
{"id": 12, "number": 2, "repository": "stackchain/api", "unread": True,
|
||||
"subject_type": "Issue", "url": "https://forge.example/api/issues/2"},
|
||||
{"id": 13, "number": 3, "repository": "stackchain/api", "unread": True,
|
||||
"subject_type": "Issue", "url": "https://forge.example/api/issues/3"},
|
||||
{"id": 14, "number": 4, "repository": "stackchain/web", "unread": True,
|
||||
"subject_type": "PullRequest", "url": "https://forge.example/web/pulls/4"},
|
||||
{"id": 15, "number": 5, "repository": "stackchain/web", "unread": True,
|
||||
"subject_type": "Issue", "title": "Newest routine update",
|
||||
"updated_at": "2026-08-07T11:00:00Z", "url": "https://forge.example/web/issues/5"},
|
||||
],
|
||||
}
|
||||
script = f"""
|
||||
const buildMyWork = require({json.dumps(str(MY_WORK))});
|
||||
const updates = buildMyWork({json.dumps(payload)}, new Date('2026-08-07T12:00:00Z'))
|
||||
.filter(item => item.has_update)
|
||||
.map(item => ({{title:item.title, update_reason:item.update_reason}}));
|
||||
process.stdout.write(JSON.stringify(updates));
|
||||
"""
|
||||
result = subprocess.run(["node", "-e", script], capture_output=True, text=True)
|
||||
|
||||
assert result.returncode == 0, result.stderr
|
||||
assert json.loads(result.stdout) == [
|
||||
{"title": "Critical incident", "update_reason": "Critical"},
|
||||
{"title": "Requested review", "update_reason": "Review requested"},
|
||||
{"title": "Overdue assignment", "update_reason": "Overdue"},
|
||||
{"title": "Assigned follow-up", "update_reason": "Assigned to you"},
|
||||
{"title": "Newest routine update", "update_reason": ""},
|
||||
]
|
||||
|
||||
|
||||
def test_update_triage_launch_waits_for_complete_single_flight_discovery():
|
||||
script = f"""
|
||||
const createLauncher = require({json.dumps(str(UPDATE_TRIAGE_LAUNCHER))});
|
||||
@@ -4530,10 +4580,12 @@ process.stdout.write(JSON.stringify({{
|
||||
output = json.loads(result.stdout)
|
||||
|
||||
assert len(output["queue"]) == 2
|
||||
assert [item["key"] for item in output["updates"]] == ["stackchain/web#8", "stackchain/api#7"]
|
||||
assert output["updates"][0]["kind"] == "update"
|
||||
assert output["updates"][1]["kind"] == "issue"
|
||||
assert output["updates"][1]["url"].endswith("#issuecomment-9")
|
||||
assert [item["key"] for item in output["updates"]] == ["stackchain/api#7", "stackchain/web#8"]
|
||||
assert output["updates"][0]["kind"] == "issue"
|
||||
assert output["updates"][0]["update_reason"] == "Assigned to you"
|
||||
assert output["updates"][0]["url"].endswith("#issuecomment-9")
|
||||
assert output["updates"][1]["kind"] == "update"
|
||||
assert output["updates"][1]["update_reason"] == ""
|
||||
assert output["counts"] == {
|
||||
"all": 2, "attention": 2, "issue": 1, "pull": 0, "review": 0, "update": 2
|
||||
}
|
||||
|
||||
@@ -17,6 +17,30 @@ def run_session(script):
|
||||
return json.loads(result.stdout)
|
||||
|
||||
|
||||
def test_update_triage_progress_exposes_the_current_actionability_reason():
|
||||
result = run_session("""
|
||||
const values = new Map();
|
||||
const items = [
|
||||
{notification_id:7, update_reason:'Review requested'},
|
||||
{notification_id:8, update_reason:''},
|
||||
];
|
||||
const progress = [];
|
||||
const session = createSession({
|
||||
storage:{getItem:key=>values.get(key)||null,setItem:(key,value)=>values.set(key,value),removeItem:key=>values.delete(key)},
|
||||
getLogin:()=> 'timmy', getItems:()=>items, onOpen:()=>{},
|
||||
onProgress:value=>progress.push(value), onFinish:()=>{},
|
||||
});
|
||||
session.start();
|
||||
session.completeAndNext();
|
||||
process.stdout.write(JSON.stringify(progress));
|
||||
""")
|
||||
|
||||
assert result == [
|
||||
{"index": 1, "total": 2, "reason": "Review requested"},
|
||||
{"index": 2, "total": 2},
|
||||
]
|
||||
|
||||
|
||||
def test_update_triage_persists_account_bound_pass_and_resumes_by_identity():
|
||||
result = run_session("""
|
||||
const values = new Map();
|
||||
|
||||
Reference in new issue
Block a user