38 lines
2.2 KiB
JavaScript
38 lines
2.2 KiB
JavaScript
// Browser regression: a missing-download card must discover two new episodes.
|
|
// All network data is mocked; no downloads are started.
|
|
const assert = require('node:assert/strict')
|
|
const { chromium } = require(process.env.REVIEW_PLAYWRIGHT || 'playwright')
|
|
const base = process.env.REVIEW_BASE || 'http://127.0.0.1:3101'
|
|
;(async () => {
|
|
const browser = await chromium.launch({ headless: true })
|
|
try {
|
|
const context = await browser.newContext()
|
|
await context.addCookies([{ name: 'magent_logged_in', value: '1', url: base }])
|
|
let polls = 0
|
|
await context.route('**/api/**', route => {
|
|
const path = new URL(route.request().url()).pathname
|
|
let json = { services: [] }
|
|
if (path.endsWith('/auth/me')) json = { username: 'member', role: 'user' }
|
|
if (path.endsWith('/snapshot')) json = { request_id: '12', title: 'TV tracker', request_type: 'tv', state: 'ADDED_TO_ARR', timeline: [], actions: [], presentation: {
|
|
status: { label: 'In the library queue' },
|
|
pipeline: [{ id: 'download', label: 'Download', state: 'attention', visible: true, summary: 'Previous download missing', torrents: [] }],
|
|
} }
|
|
if (path.endsWith('/download-progress')) {
|
|
polls++
|
|
json = { request_id: '12', state: 'downloading', summary: 'Downloading (2 active).', visible: true,
|
|
torrents: [9, 10].map(n => ({ hash: String(n), name: `Episode ${n}`, episodeLabel: `S05E${String(n).padStart(2, '0')}`, progress: polls > 1 ? .6 : .25 })) }
|
|
}
|
|
return route.fulfill({ json })
|
|
})
|
|
const page = await context.newPage()
|
|
await page.goto(base + '/requests/12')
|
|
await page.getByText('S05E09', { exact: true }).waitFor()
|
|
await page.getByText('S05E10', { exact: true }).waitFor()
|
|
assert.equal(await page.locator('.request-torrent').count(), 2)
|
|
await page.getByText('60% complete', { exact: true }).first().waitFor({ timeout: 10000 })
|
|
await page.setViewportSize({ width: 390, height: 844 })
|
|
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth))
|
|
console.log('PASS: missing tracker discovers two episodes and refreshes progress; mobile has no overflow.')
|
|
} finally { await browser.close() }
|
|
})().catch(error => { console.error(error); process.exitCode = 1 })
|