feat: simplify ready requests and add global search
Magent CI/CD / verify (push) Successful in 1m56s
Magent CI/CD / deploy-prod (push) Skipped
Magent CI/CD / deploy-beta (push) Successful in 48s

This commit is contained in:
2026-09-15 15:15:35 +12:00
parent dd51332f3c
commit 4ba1a5763e
10 changed files with 600 additions and 49 deletions
+80
View File
@@ -0,0 +1,80 @@
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 }]);
const writes = [];
const errors = [];
await context.route('**/api/**', async route => {
const request = route.request();
const 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, new_requests: true, stats: true, issues: true, invites: true } });
if (path === '/api/site/info') return reply({ mediaServerUrl: 'https://watch.example.test/' });
if (path === '/api/requests/search') return reply({ results: [
{ title: 'Drive', type: 'movie', tmdbId: 64690, year: 2011, requestId: 42, statusLabel: 'Ready to watch' },
{ title: 'Drive Away Dolls', type: 'movie', tmdbId: 957304, year: 2024 },
] });
if (path === '/api/requests/42/snapshot') return reply({
request_id: '42', title: 'Drive', year: 2011, request_type: 'movie', state: 'AVAILABLE', timeline: [], actions: [],
presentation: {
status: { label: 'Available to watch', meaning: 'Collection is complete and the title is available on the media server.' },
nextStep: { title: 'Ready to watch', description: 'Open the title when you are ready.', actionIds: [] },
pipeline: [{ id: 'available', label: 'Available to watch', state: 'complete', summary: 'Ready', link: 'https://watch.example.test/movie/drive' }],
},
});
if (path === '/api/requests/42/language') return reply({ language: null });
if (path === '/api/portal/items' && request.method() === 'POST') {
writes.push(request.postDataJSON());
return reply({ item: { id: 73 } });
}
return reply({});
});
const page = await context.newPage();
page.on('pageerror', error => errors.push(error.message));
for (const width of [1440, 390]) {
await page.setViewportSize({ width, height: 950 });
await page.goto(base + '/requests/42');
await page.getByText('Watch this now!', { exact: true }).waitFor();
assert.equal(await page.getByRole('heading', { name: 'Where your request is now' }).count(), 0);
assert.equal(await page.getByRole('link', { name: /Watch on Grizzlyflix/ }).getAttribute('href'), 'https://watch.example.test/movie/drive');
const search = page.getByRole('combobox', { name: 'Search titles or requests' });
assert(await search.isVisible());
await search.fill('Drive');
await page.getByRole('option', { name: /Drive.*Ready to watch/ }).waitFor();
await page.keyboard.press('Escape');
await page.getByRole('button', { name: "Tell us what's wrong" }).click();
const dialog = page.getByRole('dialog', { name: "What's wrong?" });
await dialog.getByText('Drive (2011)', { exact: true }).waitFor();
await dialog.getByLabel('Tell us what happened').fill('The movie freezes at 42 minutes.');
await dialog.getByRole('button', { name: 'Send report' }).click();
await page.getByRole('heading', { name: "Thanks, we've got it" }).waitFor();
await page.getByRole('button', { name: 'Done' }).click();
assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
if (width === 1440) {
const labels = await page.locator('.header-actions a').allTextContents();
assert(labels.indexOf('New Requests') < labels.indexOf('My Requests'));
assert(labels.indexOf('My Requests') < labels.indexOf('My Stats'));
}
}
await page.goto(base + '/welcome');
await page.getByRole('heading', { name: 'View stats & requests' }).waitFor();
await page.getByText('Check your viewing stats, follow your requests, or make a new one.', { exact: true }).waitFor();
assert.equal(writes.length, 2);
assert(writes.every(write => write.kind === 'issue' && write.title === 'Problem with Drive' && write.external_ref === '/requests/42' && write.description === 'The movie freezes at 42 minutes.'));
assert.deepEqual(errors, []);
console.log('Passed: completed request actions, linked issue dialog, global search, navigation order, welcome copy, and desktop/mobile overflow. APIs intercepted.');
} finally {
await browser.close();
}
})().catch(error => { console.error(error); process.exitCode = 1; });