23 lines
1.4 KiB
JavaScript
23 lines
1.4 KiB
JavaScript
// Plan 012 harness check. Needs playwright (npm i --no-save playwright) and a
|
|
// Chromium: CHROMIUM=/path/to/chrome (default: the cloud image's /opt/pw-browsers one).
|
|
import { chromium } from 'playwright';
|
|
const b = await chromium.launch({ executablePath: process.env.CHROMIUM || '/opt/pw-browsers/chromium-1194/chrome-linux/chrome' });
|
|
const p = await b.newPage();
|
|
p.on('console', (m) => console.log('console:', m.text()));
|
|
await p.goto('http://localhost:8766/');
|
|
const out = await p.evaluate(async () => {
|
|
const sha = await (await fetch('/sha')).text();
|
|
const good = await OPFS.downloadVideo('good', '/api/download/good');
|
|
const bad = await OPFS.downloadVideo('bad', '/api/download/bad');
|
|
const nohash = await OPFS.downloadVideo('nohash', '/api/download/nohash');
|
|
const list = (await OPFS.listVideos()).map((x) => x.id).sort();
|
|
await DeviceDB.putFile({ videoId: 'good', cid: good.sha256, size: good.size, state: 'verified' });
|
|
const rec = await DeviceDB.getFile('good');
|
|
const byCid = await DeviceDB.getByCid(good.sha256);
|
|
await DeviceDB.deleteFile('good');
|
|
const after = await DeviceDB.listFiles();
|
|
return { shaOk: good.sha256 === sha, goodExpected: good.expectedSha === sha, bad, nohashSha: nohash.sha256 === sha, nohashExpected: nohash.expectedSha, list, rec: rec && rec.state, byCid: byCid && byCid.videoId, after: after.length };
|
|
});
|
|
console.log(JSON.stringify(out));
|
|
await b.close();
|