test local resource row focus

This commit is contained in:
lix-2026
2026-05-24 02:40:15 +08:00
parent ae6bbc9656
commit 6904588055
3 changed files with 29 additions and 2 deletions
@@ -562,6 +562,24 @@ async function main() {
.first()
.textContent({ timeout: UI_TIMEOUT_MS })
.catch(() => "");
const rowState = await pdfAssetRow.evaluate((row) => ({
rowId: row.getAttribute("data-row-id") || "",
selected: row.getAttribute("data-selected") || "",
active: row.getAttribute("data-active") || "",
focused: row.getAttribute("data-focused") || "",
}));
const selectedRows = await page.locator('#sidebar-file-tree-root .tree-row[data-selected="true"]').evaluateAll((rows) => (
rows.map((row) => ({
rowId: row.getAttribute("data-row-id") || "",
text: row.textContent || "",
}))
));
const activeRows = await page.locator('#sidebar-file-tree-root .tree-row[data-active="true"]').evaluateAll((rows) => (
rows.map((row) => ({
rowId: row.getAttribute("data-row-id") || "",
text: row.textContent || "",
}))
));
assert(
popupCountAfter === popupCountBefore,
@@ -569,13 +587,20 @@ async function main() {
);
assert(resourceTabVisible, "点击附件 row 后应显示主编辑区 resource tab host");
assert((resourceTabTitle || "").includes("report-a.pdf"), `资源 tab 标题应包含 report-a.pdf,实际: ${resourceTabTitle}`);
assert.equal(rowState.selected, "true", `点击附件 row 后应保持选中该 row,实际: ${JSON.stringify({ rowState, selectedRows })}`);
assert.equal(rowState.active, "true", `点击附件 row 后应保持 active 在该 row,实际: ${JSON.stringify({ rowState, activeRows })}`);
assert.deepEqual(selectedRows.map((row) => row.rowId), [rowState.rowId], `打开资源后不应跳选其他 row: ${JSON.stringify(selectedRows)}`);
assert.deepEqual(activeRows.map((row) => row.rowId), [rowState.rowId], `打开资源后 active row 不应跳到其他 row: ${JSON.stringify(activeRows)}`);
checks[checkId] = {
ok: true,
message: "无 active Markdown document 时,点击附件 row 后主编辑区 resource tab 打开且不产生 popup",
message: "无 active Markdown document 时,点击附件 row 后主编辑区 resource tab 打开,且 File Tree active/selected 保持在该附件 row",
popupCount: popupCountAfter - popupCountBefore,
resourceTabVisible,
resourceTabTitle,
rowState,
selectedRows,
activeRows,
};
} catch (err) {
overallOk = false;