Complete scratch iteration 004 setup and grouped route-action fixes
This commit is contained in:
@@ -99,17 +99,33 @@ async function waitForDestinationContent(page) {
|
||||
await settle(page, 1500);
|
||||
|
||||
if (!page.url().includes('/docs/')) {
|
||||
return;
|
||||
return {
|
||||
docsContentLoaded: true,
|
||||
docsContentPreview: '',
|
||||
};
|
||||
}
|
||||
|
||||
await page.waitForFunction(
|
||||
const docsContentLoaded = await page.waitForFunction(
|
||||
() => {
|
||||
const main = document.querySelector('main');
|
||||
return typeof main?.textContent === 'string' && main.textContent.replace(/\s+/g, ' ').trim().length > 64;
|
||||
const docsContent = document.querySelector('.docs-viewer__content, [data-testid="docs-content"]');
|
||||
const text = typeof docsContent?.textContent === 'string'
|
||||
? docsContent.textContent.replace(/\s+/g, ' ').trim()
|
||||
: '';
|
||||
return text.length > 64;
|
||||
},
|
||||
undefined,
|
||||
{ timeout: 10_000 },
|
||||
).catch(() => {});
|
||||
).then(() => true).catch(() => false);
|
||||
|
||||
const docsContentPreview = await page.locator('.docs-viewer__content, [data-testid="docs-content"]').first()
|
||||
.textContent()
|
||||
.then((text) => text?.replace(/\s+/g, ' ').trim().slice(0, 240) ?? '')
|
||||
.catch(() => '');
|
||||
|
||||
return {
|
||||
docsContentLoaded,
|
||||
docsContentPreview,
|
||||
};
|
||||
}
|
||||
|
||||
async function waitForSearchResolution(page, timeoutMs = 15_000) {
|
||||
@@ -195,12 +211,14 @@ async function executePrimaryAction(page, predicateLabel) {
|
||||
process.stdout.write(`[live-search-result-action-sweep] click domain=${domain} label="${actionLabel}" index=${index}\n`);
|
||||
await actionButton.click({ timeout: 10_000 }).catch(() => {});
|
||||
process.stdout.write(`[live-search-result-action-sweep] clicked domain=${domain} url=${page.url()}\n`);
|
||||
await waitForDestinationContent(page);
|
||||
const destination = await waitForDestinationContent(page);
|
||||
process.stdout.write(`[live-search-result-action-sweep] settled domain=${domain} url=${page.url()}\n`);
|
||||
return {
|
||||
matchedDomain: domain,
|
||||
actionLabel,
|
||||
url: page.url(),
|
||||
destination,
|
||||
snapshot: await snapshot(page, `${domain}:destination`),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -369,6 +387,14 @@ function collectFailures(results) {
|
||||
failures.push(`${result.label}: primary knowledge action stayed on a non-canonical docs route (${result.knowledgeAction.url}).`);
|
||||
}
|
||||
|
||||
if (
|
||||
expectations.requireKnowledgeAction &&
|
||||
result.knowledgeAction?.url?.includes('/docs/') &&
|
||||
result.knowledgeAction?.destination?.docsContentLoaded !== true
|
||||
) {
|
||||
failures.push(`${result.label}: primary knowledge action landed on a docs route without rendered documentation content.`);
|
||||
}
|
||||
|
||||
if (expectations.requireApiCopyCard) {
|
||||
const apiCard = result.latestResponse?.cards?.find((card) =>
|
||||
card.actions?.[0]?.label === 'Copy Curl');
|
||||
|
||||
Reference in New Issue
Block a user