37 lines
1.8 KiB
JavaScript
37 lines
1.8 KiB
JavaScript
// A runtime event with a task target expands to its metadata and links to
|
|
// the task. The seed's work requests park and record the event; the feed is
|
|
// filtered to it so settings noise cannot push it off the page. Without it
|
|
// there is nothing to exercise, so the check skips instead of failing.
|
|
const assert = require('node:assert/strict');
|
|
const { DEFAULT_WINDOW_MS, trackAudit } = require('./helpers/audit-helpers.cjs');
|
|
|
|
module.exports = async ({ page, go, skip }) => {
|
|
trackAudit(page);
|
|
|
|
await go('/org/audit?kind=parked');
|
|
await page.locator('[data-row-key]').first().waitFor();
|
|
const from = new Date(Date.now() - DEFAULT_WINDOW_MS).toISOString();
|
|
// The feed page size is 100: only rows in this response are rendered.
|
|
const feed = await page.evaluate(
|
|
async (iso) => (await fetch(`/api/audit?limit=100&kind=parked&from=${encodeURIComponent(iso)}`)).json(),
|
|
from,
|
|
);
|
|
const records = feed.records || [];
|
|
const runtime = records.find((row) => row.category === 'runtime' && row.target?.kind === 'task' && row.target?.id);
|
|
if (!runtime) {
|
|
skip('no runtime event with a task target in the feed');
|
|
}
|
|
|
|
const row = page.locator(`[data-row-key="${runtime.id}"]`);
|
|
await row.waitFor();
|
|
await row.scrollIntoViewIfNeeded();
|
|
await row.locator('td').first().click();
|
|
assert.equal(await row.getAttribute('aria-expanded'), 'true', 'runtime row did not expand');
|
|
const detail = row.locator('xpath=following-sibling::tr[1]');
|
|
await detail.locator('dl dt', { hasText: 'Target' }).first().waitFor();
|
|
assert.match(await detail.innerText(), /Table/, 'runtime metadata has no table row');
|
|
const link = detail.getByRole('link', { name: runtime.target.label || runtime.target.id, exact: true });
|
|
assert.equal(await link.count(), 1, 'runtime target is not a link');
|
|
assert.equal(await link.getAttribute('href'), `/tasks/${runtime.target.id}`);
|
|
};
|