fix: reconcile batch b smoke evidence
This commit is contained in:
@@ -66,6 +66,27 @@ async function browserSearch(page, root, query) {
|
||||
}, { rootUri: fileUrl(root), queryText: query });
|
||||
}
|
||||
|
||||
async function capturePanelDiagnostics(page) {
|
||||
try {
|
||||
return await page.evaluate(function() {
|
||||
var bl = document.querySelector('[data-testid="wolai-page-settings-local-index-backlinks"]');
|
||||
var tg = document.querySelector('[data-testid="wolai-page-settings-local-index-tags"]');
|
||||
var st = document.querySelector('[data-testid="wolai-page-settings-local-index-status"]');
|
||||
var popover = document.querySelector('[data-testid="wolai-page-settings-popover"]');
|
||||
return {
|
||||
backlinksHtml: bl ? bl.innerHTML : '(missing)',
|
||||
tagsHtml: tg ? tg.innerHTML : '(missing)',
|
||||
statusText: st ? st.textContent : '(missing)',
|
||||
popoverExists: Boolean(popover),
|
||||
popoverHidden: popover ? popover.hidden : null,
|
||||
locationHref: window.location.href,
|
||||
};
|
||||
});
|
||||
} catch (_) {
|
||||
return { error: 'evaluate failed' };
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
fs.mkdirSync(OUTPUT_DIR, { recursive: true });
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), "mnote-local-search-smoke-"));
|
||||
@@ -127,21 +148,51 @@ async function run() {
|
||||
state: "visible",
|
||||
timeout: UI_TIMEOUT_MS,
|
||||
});
|
||||
|
||||
// 拦截 API 请求与页面错误做诊断
|
||||
var diagApiResponses = {};
|
||||
page.on('response', function onDiag(resp) {
|
||||
var url = resp.url();
|
||||
if (url.includes('/api/search/local-index/backlinks') || url.includes('/api/search/local-index/tags')) {
|
||||
resp.json().then(function(body) { diagApiResponses[url] = body; }).catch(function() {});
|
||||
}
|
||||
});
|
||||
page.on('pageerror', function onPageError(err) { diagApiResponses._pageError = String(err); });
|
||||
page.on('console', function onConsole(msg) {
|
||||
if (msg.type() === 'error') { diagApiResponses._consoleErrors = (diagApiResponses._consoleErrors || []).concat([msg.text()]); }
|
||||
});
|
||||
|
||||
await page.locator('[data-testid="wolai-page-settings-trigger"]').click({ timeout: UI_TIMEOUT_MS });
|
||||
await page.locator('[data-page-settings-tab="index"]').click({ timeout: UI_TIMEOUT_MS });
|
||||
await page.waitForFunction(() => {
|
||||
const backlinks = document.querySelector('[data-testid="wolai-page-settings-local-index-backlinks"]');
|
||||
const tags = document.querySelector('[data-testid="wolai-page-settings-local-index-tags"]');
|
||||
return Boolean(
|
||||
backlinks && backlinks.textContent && backlinks.textContent.includes("Search Smoke")
|
||||
&& tags && tags.textContent && tags.textContent.includes("#alpha"),
|
||||
);
|
||||
}, null, { timeout: UI_TIMEOUT_MS });
|
||||
debug.localIndexPanel = await page.evaluate(() => ({
|
||||
backlinks: document.querySelector('[data-testid="wolai-page-settings-local-index-backlinks"]')?.textContent || "",
|
||||
tags: document.querySelector('[data-testid="wolai-page-settings-local-index-tags"]')?.textContent || "",
|
||||
status: document.querySelector('[data-testid="wolai-page-settings-local-index-status"]')?.textContent || "",
|
||||
}));
|
||||
|
||||
// 等待本地索引面板渲染;超时时捕获 DOM 诊断再抛
|
||||
try {
|
||||
await page.waitForFunction(() => {
|
||||
var bl = document.querySelector('[data-testid="wolai-page-settings-local-index-backlinks"]');
|
||||
var tg = document.querySelector('[data-testid="wolai-page-settings-local-index-tags"]');
|
||||
return Boolean(
|
||||
bl && bl.textContent && bl.textContent.includes("README.md")
|
||||
&& bl.textContent.includes("[Target](docs/search-target.md)")
|
||||
&& tg && tg.textContent && tg.textContent.includes("#alpha"),
|
||||
);
|
||||
}, null, { timeout: UI_TIMEOUT_MS });
|
||||
} catch (waitError) {
|
||||
debug.diagApiResponses = diagApiResponses;
|
||||
debug.failedPanelState = await capturePanelDiagnostics(page);
|
||||
throw waitError;
|
||||
}
|
||||
|
||||
debug.localIndexPanel = await page.evaluate(function() {
|
||||
var bl = document.querySelector('[data-testid="wolai-page-settings-local-index-backlinks"]');
|
||||
var tg = document.querySelector('[data-testid="wolai-page-settings-local-index-tags"]');
|
||||
var st = document.querySelector('[data-testid="wolai-page-settings-local-index-status"]');
|
||||
return {
|
||||
backlinks: bl ? bl.innerHTML : '(missing)',
|
||||
tags: tg ? tg.innerHTML : '(missing)',
|
||||
status: st ? st.textContent : '(missing)',
|
||||
};
|
||||
});
|
||||
debug.diagApiResponses = diagApiResponses;
|
||||
|
||||
fs.renameSync(path.join(root, firstRelativePath), path.join(root, renamedRelativePath));
|
||||
const second = await browserSearch(page, root, token);
|
||||
|
||||
Reference in New Issue
Block a user