45 lines
3.2 KiB
JavaScript
45 lines
3.2 KiB
JavaScript
// Read-only regression: supply two complete, compatible Ghidra output snapshots.
|
|
import {createRequire} from 'node:module';
|
|
import assert from 'node:assert/strict';
|
|
import {mkdir} from 'node:fs/promises';
|
|
const require=createRequire(import.meta.url);
|
|
const {chromium}=require(process.env.VERSTACK_PLAYWRIGHT||'/tmp/verstack-ui-check/node_modules/playwright');
|
|
const origin=process.env.VERSTACK_TEST_URL;
|
|
const before=process.env.VERSTACK_COMPARE_A,after=process.env.VERSTACK_COMPARE_B;
|
|
assert(origin&&before&&after,'Set VERSTACK_TEST_URL, VERSTACK_COMPARE_A and VERSTACK_COMPARE_B');
|
|
const screenshots=process.env.VERSTACK_SCREENSHOTS||'data/validation/workbench/screenshots';
|
|
await mkdir(screenshots,{recursive:true});
|
|
const browser=await chromium.launch({headless:true,args:['--no-sandbox']});
|
|
const page=await browser.newPage({viewport:{width:1440,height:1000}});
|
|
const errors=[];page.on('pageerror',e=>errors.push(e.message));
|
|
try {
|
|
const library=await(await page.request.get(origin+'/api/library')).json();
|
|
const a=library.find(s=>s.id===before),b=library.find(s=>s.id===after);
|
|
assert(a&&b&&a.release.repository===b.release.repository,'Select two outputs within one game');
|
|
const r=a.release;
|
|
await page.goto(origin+'/?'+new URLSearchParams({game:r.repository,release:JSON.stringify([r.repository,r.version,r.edition,r.generation])}));
|
|
await page.getByRole('button',{name:'Compare releases',exact:true}).waitFor({timeout:60000});
|
|
await page.getByRole('button',{name:'Compare releases',exact:true}).click();
|
|
await page.getByLabel('Release A',{exact:true}).selectOption(before);
|
|
await page.getByLabel('Release B',{exact:true}).selectOption(after);
|
|
await page.getByRole('button',{name:'Compare functions',exact:true}).click();
|
|
await page.getByRole('heading',{name:'Function comparison',exact:true}).waitFor({timeout:60000});
|
|
if(process.env.VERSTACK_EXPECTED_MATCHES) {
|
|
assert((await page.locator('.function-comparison').innerText()).includes(process.env.VERSTACK_EXPECTED_MATCHES+' exact body matches'));
|
|
}
|
|
await page.locator('.function-comparison .symbol-list button').first().click();
|
|
await page.locator('.function-comparison .monaco-diff-editor').waitFor({timeout:30000});
|
|
await page.screenshot({path:screenshots+'/function-comparison-desktop.png',fullPage:true});
|
|
await page.getByLabel('Function comparison group').selectOption('before');
|
|
await page.locator('.function-comparison .symbol-list button').first().click();
|
|
await page.locator('.function-comparison .monaco-editor').waitFor();
|
|
await page.getByLabel('Search compared functions').fill('no_such_symbol_987654321');
|
|
assert.equal(await page.locator('.function-comparison .symbol-list button').count(),0);
|
|
await page.setViewportSize({width:390,height:844});
|
|
await page.screenshot({path:screenshots+'/function-comparison-narrow.png',fullPage:true});
|
|
await page.getByLabel('Release B',{exact:true}).selectOption(before);
|
|
assert.equal(await page.locator('.function-comparison').count(),0,'Changing the revision clears previous evidence');
|
|
assert.deepEqual(errors,[]);
|
|
console.log('Paired Monaco code, unmatched inspection, search and revision reset passed.');
|
|
} finally {await browser.close();}
|