Add Axum backend experiment
This commit is contained in:
26
alt/rust/browser-smoke.mjs
Normal file
26
alt/rust/browser-smoke.mjs
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env node
|
||||
import assert from 'node:assert/strict';
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
const base = process.argv[2] || 'http://127.0.0.1:3000';
|
||||
const query = process.env.SMOKE_QUERY;
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
const page = await browser.newPage({ viewport: { width: 1280, height: 800 } });
|
||||
const pageErrors = [];
|
||||
page.on('pageerror', error => pageErrors.push(error.message));
|
||||
try {
|
||||
const response = await page.goto(base, { waitUntil: 'domcontentloaded', timeout: 30000 });
|
||||
assert.equal(response?.status(), 200, 'index page should load');
|
||||
assert.equal(await page.title(), 'YT Player');
|
||||
assert.equal(await page.locator('meta[name="ytp-build"]').getAttribute('content'), (await (await fetch(new URL('/api/version', base))).json()).buildTag);
|
||||
assert.equal(await page.locator('#searchInput').count(), 1, 'search control should mount');
|
||||
if (query) {
|
||||
await page.locator('#searchInput').fill(query);
|
||||
await page.locator('#searchInput').press('Enter');
|
||||
await page.waitForFunction(() => document.querySelectorAll('#cards .card').length > 0, { timeout: 15000 });
|
||||
}
|
||||
assert.deepEqual(pageErrors, [], 'page should not throw during boot or search');
|
||||
console.log(JSON.stringify({ ok: true, url: base, title: await page.title(), searchCards: await page.locator('#cards .card').count(), pageErrors }));
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
Reference in New Issue
Block a user