fix
This commit is contained in:
@@ -55,6 +55,8 @@ async function fixture(t: TestContext, secure = true) {
|
||||
introURL: 'https://media.test/intro.wav',
|
||||
omitScenario: false,
|
||||
omitStory: false,
|
||||
scenarioId: null as number | null,
|
||||
scenarioError: 0,
|
||||
musicOverride: null as Record<string, unknown> | null,
|
||||
mediaHandler: null as ((url: string) => Promise<Response>) | null,
|
||||
failMedia: false,
|
||||
@@ -161,6 +163,7 @@ async function fixture(t: TestContext, secure = true) {
|
||||
return json({}, 401)
|
||||
if (model.refreshExpired) return json({}, 401)
|
||||
if (path === '/api/users/me') return json({ user: { roles: model.roles } })
|
||||
if (path === '/api/scenarios/23') return model.scenarioError ? json({}, model.scenarioError) : json({ scenario: { ID: 23, image: 'https://media.test/cover.png', story: { background: 'https://media.test/background.png', introduction: { audio: model.introURL }, questions: [{ answer: 'PRIVATE-ANSWER' }] } } })
|
||||
if (path === '/api/games')
|
||||
return json({
|
||||
games: [
|
||||
@@ -187,6 +190,7 @@ async function fixture(t: TestContext, secure = true) {
|
||||
scenario: model.omitScenario
|
||||
? null
|
||||
: {
|
||||
...(model.scenarioId ? { ID: model.scenarioId } : {}),
|
||||
story: model.omitStory
|
||||
? null
|
||||
: {
|
||||
@@ -389,6 +393,39 @@ test('чистый профиль предлагает адрес сайта п
|
||||
assert.equal(f.online.snapshot().server, 'https://evening-detective.crabs-games.art')
|
||||
})
|
||||
|
||||
test('полный сценарий скачивает фон и введение до подключения и сохраняет их без сети', async (t) => {
|
||||
const f = await fixture(t)
|
||||
f.model.scenarioId = 23
|
||||
f.model.omitStory = true
|
||||
await f.login()
|
||||
await f.online.act({ action: 'select-game', gameId: 7 })
|
||||
const state = f.online.snapshot()
|
||||
assert.equal(state.screenId, null)
|
||||
assert.equal(state.materialsWarning, '')
|
||||
assert.ok(state.materials.some((m) => m.usages.some((u) => u.name === 'Фон') && m.status === 'ready'))
|
||||
assert.ok(state.materials.some((m) => m.usages.some((u) => u.name === 'Вступление') && m.status === 'ready'))
|
||||
assert.ok(state.materials.every((m) => m.status === 'ready'))
|
||||
assert.equal(JSON.stringify(f.store.list()).includes('PRIVATE-ANSWER'), false)
|
||||
assert.equal(f.model.bindings.length, 0)
|
||||
await f.online.close()
|
||||
f.model.offline = true
|
||||
await f.store.initialize()
|
||||
await f.online.initialize()
|
||||
assert.ok(f.online.snapshot().materials.every((m) => m.status === 'ready'))
|
||||
assert.ok(f.online.snapshot().materials.some((m) => m.usages.some((u) => u.name === 'Вступление')))
|
||||
})
|
||||
|
||||
test('недоступный полный сценарий не выдаётся за готовность всех материалов', async (t) => {
|
||||
const f = await fixture(t)
|
||||
f.model.scenarioId = 23
|
||||
f.model.omitStory = true
|
||||
f.model.scenarioError = 403
|
||||
await f.login()
|
||||
await f.online.act({ action: 'select-game', gameId: 7 })
|
||||
assert.match(f.online.snapshot().materialsWarning, /неполный список/)
|
||||
assert.equal(f.online.snapshot().notice, '')
|
||||
})
|
||||
|
||||
test('список материалов показывает отдельную загрузку, ошибку, повтор и кеш после перезапуска', async (t) => {
|
||||
const f = await fixture(t)
|
||||
await f.login()
|
||||
|
||||
Reference in New Issue
Block a user