Files
Magent/scripts/review_request_language_ui.cjs
T
Assclaw 6a84e68a03
Magent CI/CD / verify (push) Successful in 1m53s
Magent CI/CD / deploy-prod (push) Skipped
Magent CI/CD / deploy-beta (push) Successful in 55s
Show request submission progress in a focused follow-up dialog
2026-09-15 14:02:08 +12:00

60 lines
4.1 KiB
JavaScript

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 = [], errors = [];
await context.route('**/api/**', async route => {
const path = new URL(route.request().url()).pathname;
const media = { title: "Pan's Labyrinth", type: 'movie', tmdbId: 1417, year: 2006, seasons: [], originalLanguage: { code: 'es' } };
if (path === '/api/auth/me') return route.fulfill({ json: { username: 'Admin', role: 'admin' } });
if (path.startsWith('/api/operations/')) return route.fulfill({ json: { status: 'complete', events: [] } });
if (path === '/api/requests/search') return route.fulfill({ json: { results: [media] } });
if (path === '/api/requests/request-options') return route.fulfill({ json: { media, destination: { collector: 'Radarr', serverName: 'Movies', defaultProfileId: 6, profiles: [] } } });
if (path === '/api/requests/create') { writes.push(route.request().postDataJSON()); await new Promise(resolve => setTimeout(resolve, 1200)); return route.fulfill({ json: { requestId: 12 } }); }
return route.fulfill({ json: {} });
});
const page = await context.newPage();
page.on('pageerror', e => errors.push(e.message));
for (const width of [1440, 390]) {
await page.setViewportSize({ width, height: 900 });
await page.goto(base + '/new-requests');
await page.getByRole('button', { name: /Film.*Movie/ }).click();
await page.getByLabel('Title', { exact: true }).fill('Pans Labyrinth');
await page.getByRole('button', { name: 'Search Seerr' }).click();
await page.getByRole('button', { name: /Pan's Labyrinth/ }).click();
await page.getByRole('heading', { name: 'Choose your audio language' }).waitFor();
assert(await page.locator('.request-language-notice').getByText('Spanish', { exact: true }).isVisible());
const consent = page.getByRole('radio', { name: /Original Spanish audio/ });
assert(await page.getByRole('button', { name: 'Request movie', exact: true }).isDisabled());
assert(!await consent.isChecked());
await consent.check();
await page.getByRole('button', { name: 'Change title', exact: true }).click();
await page.getByRole('button', { name: /Pan's Labyrinth/ }).click();
await page.getByRole('heading', { name: 'Choose your audio language' }).waitFor();
assert(!await consent.isChecked(), 'Consent resets when changing titles');
await consent.check();
assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
await page.getByRole('button', { name: 'Request movie', exact: true }).click();
const dialog = page.getByRole('dialog');
await dialog.getByRole('heading', { name: 'Sending your request' }).waitFor();
assert(await dialog.getByRole('progressbar').isVisible());
await dialog.getByRole('heading', { name: 'Request received', exact: true }).waitFor();
assert(await dialog.getByRole('button', { name: 'Follow your request' }).isVisible());
assert(await dialog.evaluate(el => el.scrollWidth <= el.clientWidth));
await page.keyboard.press('Escape');
assert(!await dialog.isVisible());
await page.getByRole('button', { name: 'View request progress' }).click();
await dialog.getByRole('button', { name: 'Follow your request' }).click();
await page.waitForURL('**/requests/12');
}
assert.equal(writes.length, 2);
assert(writes.every(w => w.acceptOriginalLanguage === true && w.tmdbId === 1417 && !w.profileId));
assert.deepEqual(errors, []);
console.log('Passed: desktop/mobile warning, Spanish metadata, explicit consent, reset on title change and request payload. All APIs intercepted.');
} finally { await browser.close(); }
})().catch(e => { console.error(e); process.exitCode = 1; });