use super::{
ClientProbe, DependencyRead, QuestionSeed, cdp, common, seed_questions, serve_with_client_probe,
};
use magi::ask::{Question, QuestionStatus, Questions};
use magi::queue::{HoldSource, Queue, Source, Task, TaskStatus};
use magi::talk::{self, Talks};
use serde_json::json;
use std::path::PathBuf;
use std::time::Duration;
const WAIT: Duration = Duration::from_secs(30);
const LOADING: &str = "document.querySelector('#dependencies-message')?.textContent.includes('Loading dependencies') && document.querySelector('#dependencies-explorer').hidden";
const EXPLORER: &str = "location.hash.startsWith('#/dependencies') && !document.querySelector('#view-dependencies')?.hidden && !document.querySelector('#dependencies-explorer')?.hidden && document.querySelectorAll('#dependencies-overview .dep-card').length > 0";
const DIRECT_QUESTION: &str = "20261121-140452-1111";
const FIRST_QUESTION: &str = "20261121-140453-2222";
const CHAT_QUESTION: &str = "20261121-140454-3333";
const UNDELIVERED_QUESTION: &str = "20261121-140455-4444";
const ANSWERED_QUESTION: &str = "20261121-140456-5555";
async fn key(browser: &mut cdp::Browser, page: &cdp::Page, key: &str, vk: u32) {
for kind in ["keyDown", "keyUp"] {
browser
.call(
Some(&page.session),
"Input.dispatchKeyEvent",
json!({
"type": kind, "key": key, "code": key, "windowsVirtualKeyCode": vk,
"text": if key == "Enter" && kind == "keyDown" { "\r" } else { "" },
}),
)
.await
.unwrap();
}
}
async fn maybe_screenshot(browser: &mut cdp::Browser, page: &cdp::Page, name: &str) {
let Ok(dir) = std::env::var("MAGI_DEP_SHOTS_DIR") else {
return;
};
if dir.is_empty() {
return;
}
let dir = PathBuf::from(dir);
std::fs::create_dir_all(&dir).unwrap();
let res = browser
.call(
Some(&page.session),
"Page.captureScreenshot",
json!({ "format": "png", "captureBeyondViewport": false }),
)
.await
.unwrap();
let b64 = res["data"].as_str().expect("screenshot base64");
let bytes = decode_base64(b64);
std::fs::write(dir.join(name), bytes).unwrap();
}
fn decode_base64(input: &str) -> Vec<u8> {
let mut out = Vec::with_capacity(input.len() * 3 / 4);
let mut buf: u32 = 0;
let mut bits: u8 = 0;
for b in input.bytes() {
let val = match b {
b'A'..=b'Z' => b - b'A',
b'a'..=b'z' => b - b'a' + 26,
b'0'..=b'9' => b - b'0' + 52,
b'+' => 62,
b'/' => 63,
b'=' | b'\n' | b'\r' => continue,
_ => continue,
};
buf = (buf << 6) | u32::from(val);
bits += 6;
if bits >= 8 {
bits -= 8;
out.push((buf >> bits) as u8);
}
}
out
}
async fn assert_no_horizontal_overflow(browser: &mut cdp::Browser, page: &cdp::Page, label: &str) {
let report = browser
.eval(
page,
r#"(() => {
const doc = document.documentElement;
const overflow = doc.scrollWidth > window.innerWidth;
const culprits = [];
for (const node of document.querySelectorAll('#view-dependencies *')) {
const style = getComputedStyle(node);
if (style.display === 'none' || style.visibility === 'hidden') continue;
const r = node.getBoundingClientRect();
if (r.width === 0 && r.height === 0) continue;
if (r.right > window.innerWidth + 1) {
culprits.push({ tag: node.tagName, cls: node.className, right: Math.round(r.right), innerWidth: window.innerWidth });
if (culprits.length >= 5) break;
}
}
return { overflow, scrollWidth: doc.scrollWidth, innerWidth: window.innerWidth, culprits };
})()"#,
)
.await
.unwrap();
assert_eq!(
report["overflow"],
json!(false),
"horizontal overflow at {label}: {report}"
);
assert_eq!(
report["culprits"],
json!([]),
"element spilling beyond viewport at {label}: {report}"
);
}
#[tokio::test]
async fn dependencies_page_vertical_explorer_dense_fixture_and_states() {
let Some(chrome) = cdp::find_chrome() else {
assert!(std::env::var_os("CI").is_none(), "Chrome required in CI");
eprintln!("SKIP Dependencies: no Chrome");
return;
};
let guard = common::home_lock().await;
let fx = common::fixture(guard, common::Judges::Unanimous, false);
let home = fx.tmp.path().join("magi-home");
let queue = Queue::at(home.join("queue"));
let talks = Talks::at(home.join("talks"));
let (dep_tx, dep_gate) = tokio::sync::watch::channel(DependencyRead::Wait);
let base = serve_with_client_probe(
&home,
queue.clone(),
talks.clone(),
home.join("runs"),
&fx.repo,
ClientProbe::Dependencies {
dependencies: dep_gate,
},
)
.await;
let mut browser = cdp::Browser::launch(&chrome).await.expect("Chrome");
let url = format!("{base}#/dependencies");
let empty = browser.open_page(&url, 390, 844, true).await.unwrap();
browser.wait_for(&empty, LOADING, WAIT).await.unwrap();
dep_tx.send_replace(DependencyRead::Pass);
browser
.wait_for(
&empty,
"!document.querySelector('#dependencies-empty').hidden && document.querySelector('#dependencies-status').hidden",
WAIT,
)
.await
.unwrap();
dep_tx.send_replace(DependencyRead::Fail);
browser
.eval(&empty, "deck.loadDependencies()")
.await
.unwrap();
browser
.wait_for(
&empty,
r#"(() => {
const msg = document.querySelector('#dependencies-message')?.textContent || '';
return !document.querySelector('#dependencies-status').hidden
&& !document.querySelector('#dependencies-retry').hidden
&& msg.includes('Refresh failed')
&& msg.includes('No active dependencies were present')
&& !msg.includes('Showing the last successful snapshot');
})()"#,
WAIT,
)
.await
.unwrap();
dep_tx.send_replace(DependencyRead::Pass);
browser
.wait_for(
&empty,
"!document.querySelector('#dependencies-empty').hidden && document.querySelector('#dependencies-status').hidden",
WAIT,
)
.await
.unwrap();
browser.close_page(&empty).await;
let repo_alpha = fx.repo.clone();
let repo_beta = fx.tmp.path().join("beta-frontend");
let repo_infra = fx.tmp.path().join("infra-ops");
std::fs::create_dir_all(&repo_beta).unwrap();
std::fs::create_dir_all(&repo_infra).unwrap();
let agent = fx.config.agents[0].id.clone();
let mut talk =
talk::begin(&talks, &fx.config, repo_alpha.clone(), Some(&agent)).expect("seed talk");
talk::record(&mut talk, &talks, "Discuss deployment approval", Vec::new()).expect("seed turn");
let talk_id = talk.id.clone();
seed_questions(
&home,
&[
QuestionSeed {
id: FIRST_QUESTION,
run: "",
node: "test",
seat: "test",
summary: "Unrelated question comes first",
asked_at: "2026-11-21T14:04:53Z",
choices: &["yes"],
},
QuestionSeed {
id: DIRECT_QUESTION,
run: "",
node: "test",
seat: "test",
summary: "本番デプロイのロールバック方針とスキーマ互換性を確定してください",
asked_at: "2026-11-21T14:04:52Z",
choices: &["yes"],
},
],
);
let qs = Questions::at(home.join("questions"));
let mut chat_q = Question::new(
"run-chat".into(),
"triage".into(),
"triage".into(),
"Chat-routed approval for API v2 migration cutover".into(),
"Confirm cutover window in owning task chat.".into(),
vec![],
);
chat_q.id = CHAT_QUESTION.into();
chat_q.routed_task = Some("2026-held-owner".into());
chat_q.routed_chat = Some(talk_id.clone());
qs.put(&mut chat_q).unwrap();
let mut undelivered_q = Question::new(
"run-undeliv".into(),
"triage".into(),
"triage".into(),
"Undelivered routed decision awaiting chat delivery".into(),
"Detail".into(),
vec![],
);
undelivered_q.id = UNDELIVERED_QUESTION.into();
undelivered_q.routed_task = Some("2026-held-owner".into());
qs.put(&mut undelivered_q).unwrap();
let mut answered_q = Question::new(
"run-ans".into(),
"triage".into(),
"triage".into(),
"Answered cache invalidation policy awaiting scheduler reconcile".into(),
"Detail".into(),
vec![],
);
answered_q.id = ANSWERED_QUESTION.into();
answered_q.status = QuestionStatus::Answered;
qs.put(&mut answered_q).unwrap();
std::fs::create_dir_all(queue.root()).unwrap();
std::fs::write(queue.root().join("a-ambig9.removed"), "removed").unwrap();
std::fs::write(queue.root().join("b-ambig9.removed"), "removed").unwrap();
let put_task =
|title: &str, repo: &PathBuf, status: TaskStatus, deps: &[&str], reason: Option<&str>| {
let mut task = Task::new(
title.into(),
format!("Inspect {title}"),
repo.clone(),
Source::Human,
);
match status {
TaskStatus::Blocked => {
task.block(
deps.iter().map(|s| (*s).to_owned()).collect(),
reason.map(str::to_owned),
);
}
TaskStatus::Held => {
task.status = TaskStatus::Held;
task.hold_reason = reason.map(str::to_owned);
task.hold_source = Some(HoldSource::Manual);
}
other => {
task.status = other;
}
}
queue.put(&mut task).unwrap();
task
};
let held_root = put_task(
"認証トークン更新パイプラインの仕様承認待ち(手動ホールド)",
&repo_alpha,
TaskStatus::Held,
&[],
Some("Waiting on security review sign-off before releasing migration"),
);
let done_root = put_task(
"Completed prerequisite migration script awaiting reconcile",
&repo_alpha,
TaskStatus::Done,
&[],
None,
);
for i in 0..4 {
put_task(
&format!("Parallel worker task {i} waiting on direct question"),
&repo_beta,
TaskStatus::Blocked,
&[DIRECT_QUESTION],
Some("Blocked on rollback confirmation"),
);
}
let mut prev_id = DIRECT_QUESTION.to_string();
for i in 0..15 {
let link = put_task(
&format!("Chain step {i}: 段階的なデータベース移行検証ステップ"),
&repo_alpha,
TaskStatus::Blocked,
&[&prev_id],
Some("Sequential rollout step waiting on previous verification"),
);
prev_id = link.id;
}
let branch_a = put_task(
"Branch A: フロントエンドのトークン自動更新クライアント実装",
&repo_beta,
TaskStatus::Blocked,
&[&prev_id, &held_root.id, CHAT_QUESTION],
Some("Requires both rollback policy and security sign-off"),
);
let branch_b = put_task(
"Branch B: Backend session validator and audit telemetry",
&repo_alpha,
TaskStatus::Blocked,
&[&prev_id, &done_root.id, ANSWERED_QUESTION],
Some("Waiting on settled prerequisite reconciliation"),
);
let top_title = "A long dependency title that wraps across multiple readable lines with 日本語の説明文も含む統合リリース作業";
let mut top = put_task(
top_title,
&repo_beta,
TaskStatus::Blocked,
&[
&branch_a.id,
&branch_b.id,
&prev_id,
"missing-ref-9999",
"ambig9",
UNDELIVERED_QUESTION,
],
Some("Final release integration waiting on both branches and unresolved refs"),
);
let ext_held = put_task(
"External held config prerequisite outside cycle",
&repo_infra,
TaskStatus::Held,
&[],
Some("Needs manual infrastructure quota check"),
);
let mut cyc_a = put_task(
"Cycle member Alpha: schema lock owner",
&repo_infra,
TaskStatus::Blocked,
&[],
Some("Waiting on Cycle member Beta"),
);
let cyc_b = put_task(
"Cycle member Beta: worker drain",
&repo_infra,
TaskStatus::Blocked,
&[&cyc_a.id, &ext_held.id],
Some("Waiting on Cycle member Alpha and external quota"),
);
cyc_a.blocked_by = vec![cyc_b.id.clone()];
queue.put(&mut cyc_a).unwrap();
put_task(
"Downstream release task stuck behind cycle",
&repo_infra,
TaskStatus::Blocked,
&[&cyc_a.id],
Some("Cannot proceed until cycle is broken"),
);
let mut self_cyc = put_task(
"Self-referencing blocked task",
&repo_infra,
TaskStatus::Blocked,
&[],
Some("Accidental self-dependency"),
);
self_cyc.blocked_by = vec![self_cyc.id.clone()];
queue.put(&mut self_cyc).unwrap();
let running_root = put_task(
"Background CI image rebuild currently running",
&repo_infra,
TaskStatus::Running,
&[],
None,
);
put_task(
"Deploy preview environment after image rebuild",
&repo_infra,
TaskStatus::Blocked,
&[&running_root.id],
Some("Waiting for running image rebuild"),
);
dep_tx.send_replace(DependencyRead::Fail);
let phone = browser.open_page(&url, 390, 844, true).await.unwrap();
browser
.wait_for(
&phone,
r#"(() => {
const msg = document.querySelector('#dependencies-message')?.textContent || '';
return msg.includes('Could not load dependencies')
&& !msg.includes('snapshot')
&& document.querySelector('#dependencies-explorer').hidden
&& !document.querySelector('#dependencies-retry').hidden;
})()"#,
WAIT,
)
.await
.unwrap();
dep_tx.send_replace(DependencyRead::Pass);
browser
.eval(
&phone,
"document.querySelector('#dependencies-retry').click()",
)
.await
.unwrap();
browser.wait_for(&phone, EXPLORER, WAIT).await.unwrap();
assert_no_horizontal_overflow(&mut browser, &phone, "390px overview").await;
let checks_390 = browser
.eval(
&phone,
&format!(
r##"(() => {{
const text = document.querySelector('#view-dependencies').textContent;
const titles = [...document.querySelectorAll('#dependencies-overview .dep-title')];
const minTitleFont = Math.min(...titles.map(t => parseFloat(getComputedStyle(t).fontSize)));
const wrappedTitle = titles.some(t => t.getBoundingClientRect().height > parseFloat(getComputedStyle(t).lineHeight) * 1.3);
const chatLink = document.querySelector('#dependencies-overview a[href="#/chat/{talk_id}"]');
const directQLink = document.querySelector('#dependencies-overview a[href="#/questions/{DIRECT_QUESTION}"]');
const missingCard = document.querySelector('[data-root-key="missing:missing-ref-9999"]');
const ambigCard = document.querySelector('[data-root-key="ambiguous:ambig9"]');
const undelivCard = document.querySelector('[data-root-key="{UNDELIVERED_QUESTION}"]');
return {{
noSvgGraph: !document.querySelector('.dep-graph') && !document.querySelector('#view-queue .dep-graph'),
hasTitle: document.title.includes('Dependencies'),
hasBuckets: Boolean(document.querySelector('[data-bucket="action"]'))
&& Boolean(document.querySelector('[data-bucket="progressing"]'))
&& Boolean(document.querySelector('[data-bucket="settling"]')),
minTitleFont,
wrappedTitle,
hasJpTitle: text.includes('認証トークン更新パイプライン'),
hasReason: text.includes('Waiting on security review sign-off'),
hasDirectQLink: Boolean(directQLink),
hasChatQLink: Boolean(chatLink),
missingNoLink: Boolean(missingCard) && !missingCard.querySelector('a[href]'),
ambigNoLink: Boolean(ambigCard) && ambigCard.textContent.includes('ambiguous') && !ambigCard.querySelector('a[href]'),
undelivNoLink: Boolean(undelivCard) && undelivCard.textContent.includes('Pending chat delivery') && !undelivCard.querySelector('a[href]'),
hasCycles: text.includes('Dependency cycle') && text.includes('Self-dependency cycle'),
hasComponents: text.includes('Component #1') && text.includes('Component #2'),
}};
}})()"##
),
)
.await
.unwrap();
for (k, v) in checks_390.as_object().unwrap() {
if k == "minTitleFont" {
assert!(
v.as_f64().unwrap() >= 14.0,
"title font too small: {checks_390}"
);
} else {
assert_eq!(v, &json!(true), "390px check failed for {k}: {checks_390}");
}
}
maybe_screenshot(&mut browser, &phone, "01-phone-390-overview.png").await;
browser
.eval(
&phone,
&format!(
r#"document.querySelector('[data-root-key="{DIRECT_QUESTION}"] button[aria-expanded]').click()"#
),
)
.await
.unwrap();
browser
.wait_for(
&phone,
&format!(
r#"document.querySelector('[data-root-key="{DIRECT_QUESTION}"] .dep-chain-item') !== null"#
),
WAIT,
)
.await
.unwrap();
assert_no_horizontal_overflow(&mut browser, &phone, "390px expanded chain").await;
browser
.eval(
&phone,
&format!(
r#"document.querySelector('[data-root-key="{DIRECT_QUESTION}"]').scrollIntoView({{ block: 'start' }})"#
),
)
.await
.unwrap();
maybe_screenshot(&mut browser, &phone, "02-phone-390-expanded.png").await;
browser
.eval(
&phone,
&format!(
r#"(() => {{
window.savedBtn = document.querySelector('[data-dep-control-key="root:expand:{DIRECT_QUESTION}"]');
savedBtn.focus({{ preventScroll: true }});
window.scrollTo({{ top: 120 }});
}})()"#
),
)
.await
.unwrap();
browser
.eval(&phone, "deck.loadDependencies({ background: true })")
.await
.unwrap();
browser
.wait_for(&phone, "!deck.dependenciesState.loading", WAIT)
.await
.unwrap();
assert_eq!(
browser.eval(&phone, "savedBtn.isConnected").await.unwrap(),
json!(true),
"unchanged refresh must not rebuild DOM"
);
dep_tx.send_replace(DependencyRead::Fail);
browser
.eval(&phone, "deck.loadDependencies({ background: true })")
.await
.unwrap();
browser
.wait_for(
&phone,
r#"document.querySelector('#dependencies-message').textContent.includes('Showing the last successful snapshot') && savedBtn.isConnected"#,
WAIT,
)
.await
.unwrap();
top.title = format!("{top_title} after refresh");
queue.put(&mut top).unwrap();
dep_tx.send_replace(DependencyRead::Pass);
browser
.eval(
&phone,
"document.querySelector('#dependencies-retry').click()",
)
.await
.unwrap();
browser
.wait_for(
&phone,
&format!(
r#"!savedBtn.isConnected
&& document.querySelector('#dependencies-status').hidden
&& document.activeElement?.getAttribute('data-dep-control-key') === 'root:expand:{DIRECT_QUESTION}'
&& document.querySelector('[data-root-key="{DIRECT_QUESTION}"] .dep-chain-item') !== null"#
),
WAIT,
)
.await
.unwrap();
browser
.eval(
&phone,
r#"(() => {
const input = document.querySelector('#dependencies-search-input');
for (const ch of 'after refresh') {
input.value += ch;
input.dispatchEvent(new Event('input', { bubbles: true }));
}
})()"#,
)
.await
.unwrap();
browser
.wait_for(
&phone,
&format!(
r#"document.querySelector('[data-dep-control-key="match:focus:{}"]') !== null && location.hash.includes('q=after')"#,
top.id
),
WAIT,
)
.await
.unwrap();
browser
.eval(
&phone,
&format!(
r#"document.querySelector('[data-dep-control-key="match:focus:{}"]').click()"#,
top.id
),
)
.await
.unwrap();
browser
.wait_for(
&phone,
&format!(
r#"!document.querySelector('#dependencies-inspector').hidden
&& location.hash.includes('focus={}')
&& document.querySelector('#dependencies-inspector').textContent.includes('Upstream')
&& document.querySelector('#dependencies-inspector').textContent.includes('Downstream')
&& document.querySelector('#dependencies-inspector').textContent.includes('Branch A')
&& document.querySelector('#dependencies-inspector').textContent.includes('missing-ref-9999')
&& document.querySelector('#dependencies-inspector').textContent.includes('Chain step 0')"#,
top.id
),
WAIT,
)
.await
.unwrap();
assert_no_horizontal_overflow(&mut browser, &phone, "390px focused inspector").await;
maybe_screenshot(&mut browser, &phone, "03-phone-390-inspector.png").await;
let prev_origin = browser
.eval(&phone, "performance.timeOrigin")
.await
.unwrap();
browser
.call(Some(&phone.session), "Page.reload", json!({}))
.await
.unwrap();
browser
.wait_for(
&phone,
&format!(
r#"performance.timeOrigin !== {prev_origin}
&& document.querySelector('#dependencies-inspector')?.hidden === false
&& document.querySelector('#dependencies-inspector').textContent.includes('after refresh')"#
),
WAIT,
)
.await
.unwrap();
let task_href = format!("#/tasks/{}", top.id);
browser
.eval(
&phone,
&format!(
r#"document.querySelector('#dependencies-inspector a[href="{task_href}"]').focus()"#
),
)
.await
.unwrap();
key(&mut browser, &phone, "Enter", 13).await;
let task_detail = format!(
"location.hash === '{task_href}' && document.querySelector('#view-task').dataset.taskId === '{}' && document.querySelector('#task-h').textContent.includes('after refresh')",
top.id
);
browser.wait_for(&phone, &task_detail, WAIT).await.unwrap();
browser.eval(&phone, "history.back()").await.unwrap();
browser
.wait_for(
&phone,
&format!("location.hash.includes('focus={}') && !document.querySelector('#dependencies-inspector').hidden", top.id),
WAIT,
)
.await
.unwrap();
browser.eval(&phone, "history.forward()").await.unwrap();
browser.wait_for(&phone, &task_detail, WAIT).await.unwrap();
browser.eval(&phone, "history.back()").await.unwrap();
browser
.wait_for(
&phone,
&format!("location.hash.includes('focus={}')", top.id),
WAIT,
)
.await
.unwrap();
browser
.eval(
&phone,
&format!(
r#"document.querySelector('#dependencies-inspector [data-dep-focus="{}"]').click()"#,
branch_a.id
),
)
.await
.unwrap();
browser
.wait_for(
&phone,
&format!(
r#"location.hash.includes('focus={}')
&& document.querySelector('#dependencies-inspector').textContent.includes('Downstream')
&& document.querySelector('#dependencies-inspector').textContent.includes('after refresh')"#,
branch_a.id
),
WAIT,
)
.await
.unwrap();
browser
.eval(
&phone,
r#"document.querySelector('[data-dep-control-key="inspector:back"]').click()"#,
)
.await
.unwrap();
browser
.wait_for(
&phone,
"document.querySelector('#dependencies-inspector').hidden",
WAIT,
)
.await
.unwrap();
browser
.eval(
&phone,
"document.querySelector('#dependencies-search-clear').click()",
)
.await
.unwrap();
browser.wait_for(&phone, EXPLORER, WAIT).await.unwrap();
browser
.eval(
&phone,
&format!(
r#"(() => {{
const data = deck.dependenciesState.data;
const node = data.nodes.find(n => n.key === '{}');
window.selectedComponentBefore = node.component_id;
const select = document.querySelector('#dependencies-component');
select.value = data.components.find(c => c.id === node.component_id).anchor;
select.dispatchEvent(new Event('change', {{ bubbles: true }}));
window.selectedComponentHash = location.hash;
}})()"#,
cyc_a.id
),
)
.await
.unwrap();
for i in 0..4 {
put_task(
&format!("Additional self-cycle dependent {i}"),
&repo_infra,
TaskStatus::Blocked,
&[&self_cyc.id],
None,
);
}
browser
.eval(&phone, "deck.loadDependencies({ background: true })")
.await
.unwrap();
browser
.wait_for(
&phone,
&format!(
r#"!deck.dependenciesState.loading
&& deck.dependenciesState.data.nodes.find(n => n.key === '{}').component_id !== selectedComponentBefore
&& location.hash === selectedComponentHash
&& document.querySelector('[data-root-key="{}"]')
&& !document.querySelector('[data-root-key="{DIRECT_QUESTION}"]')"#,
cyc_a.id, ext_held.id
),
WAIT,
)
.await
.unwrap();
browser
.eval(
&phone,
r#"(() => {
const select = document.querySelector('#dependencies-component');
select.value = '';
select.dispatchEvent(new Event('change', { bubbles: true }));
})()"#,
)
.await
.unwrap();
let q_href = format!("#/questions/{DIRECT_QUESTION}");
browser
.eval(
&phone,
&format!(
r#"document.querySelector('#dependencies-overview a[href="{q_href}"]').focus()"#
),
)
.await
.unwrap();
key(&mut browser, &phone, "Enter", 13).await;
browser
.wait_for(
&phone,
&format!(
"location.hash === '{q_href}' && document.activeElement.closest('.ask')?.dataset.questionId === '{DIRECT_QUESTION}'"
),
WAIT,
)
.await
.unwrap();
browser.eval(&phone, "history.back()").await.unwrap();
browser.wait_for(&phone, EXPLORER, WAIT).await.unwrap();
let chat_href = format!("#/chat/{talk_id}");
browser
.eval(
&phone,
&format!(
r#"document.querySelector('#dependencies-overview a[href="{chat_href}"]').click()"#
),
)
.await
.unwrap();
browser
.wait_for(
&phone,
&format!(
"location.hash === '{chat_href}' && !document.querySelector('#view-talk').hidden"
),
WAIT,
)
.await
.unwrap();
browser.eval(&phone, "history.back()").await.unwrap();
browser.wait_for(&phone, EXPLORER, WAIT).await.unwrap();
browser
.call(
Some(&phone.session),
"Emulation.setDeviceMetricsOverride",
json!({ "width": 320, "height": 844, "deviceScaleFactor": 1, "mobile": true }),
)
.await
.unwrap();
browser
.wait_for(&phone, "innerWidth === 320", WAIT)
.await
.unwrap();
assert_no_horizontal_overflow(&mut browser, &phone, "320px overview").await;
maybe_screenshot(&mut browser, &phone, "04-phone-320-overview.png").await;
check_nav_keyboard(&mut browser, &phone, true).await;
browser.close_page(&phone).await;
let desktop = browser.open_page(&url, 1280, 900, false).await.unwrap();
browser.wait_for(&desktop, EXPLORER, WAIT).await.unwrap();
assert_no_horizontal_overflow(&mut browser, &desktop, "1280px overview").await;
browser
.eval(
&desktop,
&format!(
r#"document.querySelector('[data-root-key="{DIRECT_QUESTION}"] button[data-dep-focus]').click()"#
),
)
.await
.unwrap();
browser
.wait_for(
&desktop,
r#"!document.querySelector('#dependencies-inspector').hidden
&& !document.querySelector('#dependencies-overview').hidden
&& document.querySelector('#dependencies-inspector').textContent.includes('Downstream')"#,
WAIT,
)
.await
.unwrap();
assert_no_horizontal_overflow(&mut browser, &desktop, "1280px split inspector").await;
assert_eq!(
browser
.eval(
&desktop,
r#"(() => {
const o = document.querySelector('#dependencies-overview').getBoundingClientRect();
const i = document.querySelector('#dependencies-inspector').getBoundingClientRect();
return o.right <= i.left + 2 && i.right <= window.innerWidth;
})()"#,
)
.await
.unwrap(),
json!(true),
"desktop should render overview and inspector side by side"
);
maybe_screenshot(&mut browser, &desktop, "05-desktop-1280-split.png").await;
check_nav_keyboard(&mut browser, &desktop, false).await;
browser.close_page(&desktop).await;
dep_tx.send_replace(DependencyRead::Pass);
let corrupt = queue.root().join("unreadable-task.json");
std::fs::write(&corrupt, "corrupt").unwrap();
top.blocked_by.push("unreadable-task".into());
queue.put(&mut top).unwrap();
let partial = browser.open_page(&url, 390, 844, true).await.unwrap();
browser
.wait_for(
&partial,
r#"document.querySelector('#dependencies-partial')?.hidden === false
&& document.querySelector('[data-root-key="unavailable:unreadable-task"]')
&& document.querySelector('[data-root-key="missing:missing-ref-9999"]')
&& !document.querySelector('#dependencies-explorer').hidden"#,
WAIT,
)
.await
.unwrap();
browser.close_page(&partial).await;
}
async fn check_nav_keyboard(browser: &mut cdp::Browser, page: &cdp::Page, mobile: bool) {
let nav = if mobile { ".dock" } else { ".rail" };
browser
.eval(page, "location.hash = '#/queue'")
.await
.unwrap();
browser
.wait_for(page, "!document.querySelector('#view-queue').hidden", WAIT)
.await
.unwrap();
browser
.eval(
page,
&format!("document.querySelector('{nav} [data-nav=queue]').focus()"),
)
.await
.unwrap();
key(browser, page, "Tab", 9).await;
assert_eq!(
browser
.eval(page, "document.activeElement.dataset.nav")
.await
.unwrap(),
"dependencies"
);
key(browser, page, "Enter", 13).await;
browser.wait_for(page, EXPLORER, WAIT).await.unwrap();
assert_eq!(
browser
.eval(
page,
&format!("document.querySelector('{nav} [data-nav=dependencies]').getAttribute('aria-current')"),
)
.await
.unwrap(),
"page"
);
assert_eq!(
browser
.eval(
page,
&format!(
r#"Array.from(document.querySelectorAll('{nav} a')).every(a => {{
const r = a.getBoundingClientRect();
return r.left >= 0 && r.right <= innerWidth && r.height >= 44 && (!{mobile} || r.width >= 44);
}})"#
),
)
.await
.unwrap(),
json!(true),
"navigation touch targets (mobile={mobile})"
);
}