Explain search outcomes and provide a direct version selection action
Magent CI/CD / verify (push) Successful in 1m50s
Magent CI/CD / deploy-prod (push) Skipped
Magent CI/CD / deploy-beta (push) Skipped

This commit is contained in:
2026-09-13 12:16:28 +12:00
parent f57058eb26
commit e3332bec1f
4 changed files with 65 additions and 11 deletions
+3 -3
View File
@@ -28,7 +28,7 @@ const base = process.env.REVIEW_BASE || 'http://localhost:3114';
allowed = permission; await page.setViewportSize({ width, height: 950 });
await page.goto(base + '/requests/42');
await page.getByRole('button', { name: 'Search and choose a download', exact: true }).first().click();
await page.getByRole('button', { name: 'Dismiss activity' }).click();
await page.getByRole('button', { name: allowed ? 'Choose a version' : 'View search results', exact: true }).click();
const picker = page.getByRole('dialog', { name: 'Choose an available download' }); await picker.waitFor();
await picker.getByText('WEBDL-2160p is not wanted in profile', { exact: true }).waitFor();
assert.equal(await picker.getByText('Best pick', { exact: true }).count(), 0);
@@ -47,9 +47,9 @@ const base = process.env.REVIEW_BASE || 'http://localhost:3114';
assert.equal(writes.length, before);
page.once('dialog', dialog => dialog.accept());
await picker.getByRole('button', { name: 'Download outside profile' }).click();
await page.getByRole('dialog', { name: 'Done', exact: true }).getByText('Your download has been sent.', { exact: true }).waitFor();
await page.getByRole('dialog', { name: 'Waiting to start', exact: true }).getByText('Your download has been sent.', { exact: true }).waitFor();
assert.equal(await page.locator('.activity-dialog-events').count(), 0);
assert.equal(await page.getByRole('dialog', { name: 'Done', exact: true }).getByRole('progressbar').getAttribute('aria-valuenow'), '100');
assert.equal(await page.getByRole('dialog', { name: 'Waiting to start', exact: true }).getByRole('progressbar').getAttribute('aria-valuenow'), '100');
assert.equal(writes.at(-1).ignoreProfileLimits, true);
assert.equal(writes.at(-1).selectionToken, 'signed-fixture');
}
+39
View File
@@ -0,0 +1,39 @@
const assert = require('node:assert/strict');
const { chromium } = require(process.env.PLAYWRIGHT_PACKAGE || 'playwright');
const base = process.env.REVIEW_BASE || 'http://localhost:3114';
(async () => {
const browser = await chromium.launch();
try {
const context = await browser.newContext();
await context.addCookies([{ name: 'magent_logged_in', value: '1', url: base }]);
let scenario = 'empty'; let allowed = true; const writes = [], errors = [];
await context.route('**/api/**', async route => {
const request = route.request(), path = new URL(request.url()).pathname;
const reply = json => route.fulfill({ json });
if (path === '/api/auth/me') return reply({ username: 'Viewer', role: 'user', features: { requests: true, ignore_profile_limits: allowed } });
if (path.endsWith('/snapshot')) return reply({ request_id: '42', title: 'Trying', request_type: 'tv', state: 'ADDED_TO_ARR', timeline: [], actions: [{ id: 'search_releases', label: 'Search and choose a download', requires_confirmation: false }], presentation: { status: { label: 'Waiting', meaning: 'Two missing episodes.' }, nextStep: { title: 'Search', description: 'Find missing episodes.', actionIds: ['search_releases'] }, pipeline: [] } });
if (path.endsWith('/language')) return reply({ language: null });
if (path.includes('/operations/')) return reply({ id: path.split('/').pop(), status: 'complete', events: [] });
if (path.endsWith('/actions/search')) return scenario === 'error' ? route.fulfill({ status: 502, json: { detail: 'Service unavailable' } }) : reply({ status: 'ok', outcome: 'attention', releases: [], nextOffset: null });
if (path.endsWith('/actions/grab')) { writes.push(request.postDataJSON()); return reply({ status: 'ok', message: 'Selected release sent to Sonarr.' }); }
if (path.includes('/events/stream')) return route.fulfill({ contentType: 'text/event-stream', body: ': fixture\n\n' });
return reply({});
});
const page = await context.newPage(); page.on('pageerror', e => errors.push(e.message));
for (const width of [1440, 390]) {
for (const test of ['empty', 'error']) {
scenario = test;
await page.setViewportSize({width, height: 950});
await page.goto(base + '/requests/42');
await page.getByRole('button', {name: 'Search and choose a download', exact:true}).first().click();
const dialog = page.getByRole('dialog', {name: test === 'empty' ? 'Nothing available yet' : 'Search could not finish', exact:true});
await dialog.waitFor();
assert.equal(await dialog.getByRole('button', {name:'Choose a version'}).count(), 0);
await dialog.getByText(test === 'empty' ? 'You can try again later.' : 'Try again shortly. If it keeps happening, contact an admin.', {exact:true}).waitFor();
assert(await dialog.evaluate(el => el.scrollWidth <= el.clientWidth));
}
}
assert.deepEqual(errors, []);
console.log('Passed: empty search and unavailable service outcomes on desktop/mobile; no unavailable selection action or overflow. APIs intercepted.');
} finally { await browser.close(); }
})().catch(e => { console.error(e); process.exitCode = 1; });