feat: pin current mobile detail item (Closes #1489)
This commit is contained in:
1 parent
b0dbcb5a25
commit
2a06cf1daa
6 files changed
+130
-1
No files matched your search
@@ -38,6 +38,7 @@ def test_operator_pins_and_reopens_frequent_work_without_phone_overflow(viewport
|
||||
pinnedSection:document.querySelector('#mobile-pinned-work'),
|
||||
pinnedList:document.querySelector('#mobile-pinned-work-list'),
|
||||
pinnedToggle:document.querySelector('#mobile-pinned-work-toggle'),
|
||||
detailPins:document.querySelectorAll('[data-current-work-pin]'),
|
||||
status:document.querySelector('#mobile-recent-work-status'),
|
||||
openRoute:route => window.opened.push(route),
|
||||
});
|
||||
@@ -81,4 +82,26 @@ def test_operator_pins_and_reopens_frequent_work_without_phone_overflow(viewport
|
||||
assert page.evaluate("window.opened") == [
|
||||
"#/my-work/issue/stackchain/stackchain-dashboard/20"
|
||||
]
|
||||
|
||||
page.evaluate("""() => {
|
||||
document.querySelector('#mobile-queue-sheet').close();
|
||||
document.querySelector('#issue-sheet').classList.add('open');
|
||||
window.recentWork.setCurrent({
|
||||
kind:'issue', repository:'stackchain/stackchain-dashboard', number:1489,
|
||||
title:'Pin the current item from mobile detail',
|
||||
});
|
||||
}""")
|
||||
detail_pin = page.get_by_role(
|
||||
"button", name="Pin Pin the current item from mobile detail"
|
||||
)
|
||||
expect(detail_pin).to_be_visible()
|
||||
bounds = detail_pin.bounding_box()
|
||||
assert bounds and bounds["height"] >= 44
|
||||
assert bounds["x"] >= 0 and bounds["x"] + bounds["width"] <= viewport["width"]
|
||||
assert page.evaluate("document.documentElement.scrollWidth <= window.innerWidth")
|
||||
detail_pin.focus()
|
||||
detail_pin.press("Enter")
|
||||
expect(detail_pin).to_have_text("Pinned")
|
||||
expect(detail_pin).to_have_attribute("aria-pressed", "true")
|
||||
assert page.evaluate("window.recentWork.pinned()[0].number") == 1489
|
||||
browser.close()
|
||||
@@ -338,6 +338,69 @@ process.stdout.write(JSON.stringify({{pinnedImmediately,immediate,opened,unpinne
|
||||
]
|
||||
|
||||
|
||||
def test_current_detail_pin_follows_route_and_toggles_offline_first():
|
||||
script = f"""
|
||||
const createRecentWork = require({json.dumps(str(RECENT_WORK))});
|
||||
const values=new Map();
|
||||
function button() {{ return {{hidden:true,textContent:'',attributes:{{}},listeners:{{}},
|
||||
setAttribute(name,value){{this.attributes[name]=String(value);}},
|
||||
addEventListener(name,callback){{this.listeners[name]=callback;}},
|
||||
click(){{this.listeners.click?.();}},
|
||||
}}; }}
|
||||
const detailPins=[button(),button(),button(),button()];
|
||||
const recent=createRecentWork({{
|
||||
storage:{{getItem:key=>values.get(key)||null,setItem:(key,value)=>values.set(key,value)}},
|
||||
getLogin:()=>'alice',detailPins,debounceMs:99999,
|
||||
}});
|
||||
const issue={{kind:'issue',repository:'stackchain/dashboard',number:1489,title:'Pin current detail'}};
|
||||
const pull={{kind:'pull',repository:'stackchain/api',number:20,title:'Ship API'}};
|
||||
recent.setCurrent(issue);
|
||||
const issueReady=detailPins.map(pin=>({{hidden:pin.hidden,text:pin.textContent,
|
||||
pressed:pin.attributes['aria-pressed'],label:pin.attributes['aria-label'],action:pin.attributes['data-current-work-pin']}}));
|
||||
detailPins[0].click();
|
||||
const pinned={{items:recent.pinned(),state:recent.state(),buttons:detailPins.map(pin=>({{text:pin.textContent,
|
||||
pressed:pin.attributes['aria-pressed'],label:pin.attributes['aria-label'],action:pin.attributes['data-current-work-pin']}}))}};
|
||||
recent.setCurrent(pull);
|
||||
const pullReady={{text:detailPins[1].textContent,label:detailPins[1].attributes['aria-label'],pressed:detailPins[1].attributes['aria-pressed']}};
|
||||
recent.setCurrent(issue);
|
||||
detailPins[2].click();
|
||||
const unpinned={{items:recent.pinned(),recent:recent.items(),state:recent.state(),text:detailPins[0].textContent}};
|
||||
recent.setCurrent(null);
|
||||
process.stdout.write(JSON.stringify({{issueReady,pinned,pullReady,unpinned,hidden:detailPins.map(pin=>pin.hidden)}}));
|
||||
"""
|
||||
payload = run_node(script)
|
||||
|
||||
assert payload["issueReady"] == [
|
||||
{
|
||||
"hidden": False,
|
||||
"text": "Pin",
|
||||
"pressed": "false",
|
||||
"label": "Pin Pin current detail",
|
||||
"action": "pin",
|
||||
}
|
||||
] * 4
|
||||
assert payload["pinned"]["items"][0]["route"] == "#/my-work/issue/stackchain/dashboard/1489"
|
||||
assert payload["pinned"]["state"] == {"pending": True, "pendingCount": 1}
|
||||
assert payload["pinned"]["buttons"] == [
|
||||
{
|
||||
"text": "Pinned",
|
||||
"pressed": "true",
|
||||
"label": "Unpin Pin current detail",
|
||||
"action": "unpin",
|
||||
}
|
||||
] * 4
|
||||
assert payload["pullReady"] == {
|
||||
"text": "Pin",
|
||||
"label": "Pin Ship API",
|
||||
"pressed": "false",
|
||||
}
|
||||
assert payload["unpinned"]["items"] == []
|
||||
assert payload["unpinned"]["recent"] == []
|
||||
assert payload["unpinned"]["state"] == {"pending": True, "pendingCount": 1}
|
||||
assert payload["unpinned"]["text"] == "Pin"
|
||||
assert payload["hidden"] == [True] * 4
|
||||
|
||||
|
||||
def test_pinned_work_is_compact_deduplicated_and_promotes_on_open():
|
||||
script = f"""
|
||||
const createRecentWork = require({json.dumps(str(RECENT_WORK))});
|
||||
@@ -417,7 +480,12 @@ def test_mobile_queues_integrates_recent_work_with_canonical_detail_routes():
|
||||
assert "mobileRecentWork.record(item)" in dashboard
|
||||
assert "mobileRecentWork.render()" in dashboard
|
||||
assert "workRoute.sync()" in dashboard
|
||||
assert html.count('data-current-work-pin') == 4
|
||||
assert "detailPins:qsa('[data-current-work-pin]')" in dashboard
|
||||
assert "mobileRecentWork.setCurrent(item)" in dashboard
|
||||
assert "mobileRecentWork.setCurrent(null)" in dashboard
|
||||
assert "[data-recent-work-route]" in css
|
||||
assert "[data-recent-work-pin]" in css
|
||||
assert "[data-current-work-pin]" in css
|
||||
assert "min-height:44px" in css
|
||||
assert "min-width:0" in css
|
||||
Reference in new issue
Block a user