docs: [verified] move metric contracts under Measurement
Build and publish Eldorado documentation / build (pull_request) Successful in 41s
Build and publish Eldorado documentation / build (pull_request) Successful in 41s
This commit is contained in:
1 parent
b9c2047c61
commit
85852f0744
45 files changed
+1101
-433
No files matched your search
@@ -0,0 +1,79 @@
|
||||
const {chromium} = require('playwright');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
(async () => {
|
||||
const base = process.argv[2] || 'http://127.0.0.1:4173';
|
||||
const prefix = '/eldorado-v1/documentation';
|
||||
const manifest = JSON.parse(fs.readFileSync('research/ai-adoption/measurement-migration.json','utf8'));
|
||||
const output = `.cache/metric-pages-${process.argv[3] || 'local'}`;
|
||||
fs.mkdirSync(output,{recursive:true});
|
||||
const browser = await chromium.launch({headless:true,executablePath:process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE,args:['--no-sandbox']});
|
||||
const results = [];
|
||||
try {
|
||||
for (const width of [1440,390]) {
|
||||
const context = await browser.newContext({viewport:{width,height:900}});
|
||||
try {
|
||||
const page = await context.newPage();
|
||||
const errors = [];
|
||||
page.on('pageerror',e => errors.push(e.message));
|
||||
for (const m of manifest.metrics) {
|
||||
const url = `${base}${prefix}${m.url}`;
|
||||
assert.equal((await page.goto(url,{waitUntil:'networkidle'})).status(),200);
|
||||
assert.equal(await page.locator('article h1').innerText(),m.title);
|
||||
assert.equal(await page.locator('link[rel="canonical"]').getAttribute('href'),`https://pages.apps.lego-cloud.eu${prefix}${m.url}`);
|
||||
const table = page.locator('article table');
|
||||
assert.equal(await table.count(),1);
|
||||
assert.equal(await table.locator('tbody tr').count(),11);
|
||||
const article = await page.locator('article').innerText();
|
||||
assert(article.includes(m.status === 'prototype' ? 'Prototype calculation' : 'Unimplemented metric'));
|
||||
assert(article.includes('no live telemetry'));
|
||||
assert.equal(await page.locator('.breadcrumbs a').filter({hasText:'Measurement'}).getAttribute('href'),`${prefix}/strategy/measurement/`);
|
||||
assert(!await page.evaluate(() => document.documentElement.scrollWidth > innerWidth));
|
||||
await page.goto(`${base}${prefix}/strategy/reference/measurement-contracts/#${m.oldAnchor}`,{waitUntil:'networkidle'});
|
||||
await page.waitForURL(url);
|
||||
await page.locator('article h1').waitFor();
|
||||
results.push({width,metric:m.oldAnchor,canonical:true,redirect:true,fields:11});
|
||||
}
|
||||
for (const suffix of ['', '#unknown-anchor', '#__proto__']) {
|
||||
await page.goto(`${base}${prefix}/strategy/reference/measurement-contracts/${suffix}`,{waitUntil:'networkidle'});
|
||||
await page.waitForURL(`${base}${prefix}/strategy/measurement/`);
|
||||
}
|
||||
for (const [anchor,target] of [
|
||||
['collection-and-safeguards','collection-and-safeguards/'],
|
||||
['decide-what-counts-before-counting','collection-and-safeguards/#decide-what-counts-before-counting'],
|
||||
['baseline-and-interpretation','collection-and-safeguards/#baseline-and-interpretation'],
|
||||
['event-and-privacy-contract','collection-and-safeguards/#event-and-privacy-contract'],
|
||||
['run-the-synthetic-measurement-example','synthetic-example/'],
|
||||
['metric-contracts','#metric-definitions'],
|
||||
]) {
|
||||
await page.goto(`${base}${prefix}/strategy/reference/measurement-contracts/#${anchor}`,{waitUntil:'networkidle'});
|
||||
await page.waitForURL(`${base}${prefix}/strategy/measurement/${target}`);
|
||||
if (target.includes('#')) await page.locator(`#${target.split('#')[1]}`).waitFor();
|
||||
}
|
||||
await page.goto(`${base}${prefix}/strategy/measurement/supported-bundle-coverage/`,{waitUntil:'networkidle'});
|
||||
await page.locator('.breadcrumbs a').filter({hasText:'Measurement'}).click();
|
||||
await page.waitForURL(`${base}${prefix}/strategy/measurement/`);
|
||||
if (width < 997) await page.getByRole('button',{name:'Toggle navigation bar'}).click();
|
||||
const menu = page.locator('.theme-doc-sidebar-menu').filter({visible:true});
|
||||
const category = menu.locator('.theme-doc-sidebar-item-category').filter({has:page.getByRole('link',{name:'Measurement',exact:true})}).last();
|
||||
const caret = category.locator(':scope > .menu__list-item-collapsible > button.menu__caret');
|
||||
await caret.click();
|
||||
await category.getByRole('link',{name:'Validated task success',exact:true}).waitFor({state:'hidden'});
|
||||
await caret.focus(); await page.keyboard.press('Enter');
|
||||
await category.getByRole('link',{name:'Validated task success',exact:true}).waitFor({state:'visible'});
|
||||
await menu.getByRole('link',{name:'Measurement',exact:true}).click();
|
||||
await page.waitForURL(`${base}${prefix}/strategy/measurement/`);
|
||||
await page.locator('article h1').waitFor();
|
||||
if (width < 997) await page.getByRole('button',{name:'Close navigation bar'}).waitFor({state:'hidden'});
|
||||
await page.locator('#metric-definitions').scrollIntoViewIfNeeded();
|
||||
await page.screenshot({path:`${output}/${width}-index.png`});
|
||||
await page.goto(`${base}${prefix}/strategy/measurement/supported-bundle-coverage/`,{waitUntil:'networkidle'});
|
||||
await page.screenshot({path:`${output}/${width}-metric.png`,fullPage:true});
|
||||
assert.deepEqual(errors,[]);
|
||||
} finally {await context.close();}
|
||||
}
|
||||
assert.equal(results.length,32);
|
||||
fs.writeFileSync(`${output}/results.json`,JSON.stringify(results,null,2));
|
||||
console.log('PASS: 16 metric pages × 2 widths; canonical metadata, contract fields, status, all legacy metric/shared/fallback redirects and linked Measurement keyboard navigation');
|
||||
} finally {await browser.close();}
|
||||
})().catch(e => {console.error(e);process.exitCode=1;});
|
||||
Reference in new issue
Block a user