up
This commit is contained in:
+83
-6
@@ -37,6 +37,8 @@ async function fixture(t: TestContext, secure = true) {
|
||||
offline: false,
|
||||
server: 'https://server.test',
|
||||
introURL: 'https://media.test/intro.wav',
|
||||
omitScenario: false,
|
||||
omitStory: false,
|
||||
musicOverride: null as Record<string, unknown> | null,
|
||||
mediaHandler: null as ((url: string) => Promise<Response>) | null,
|
||||
failMedia: false,
|
||||
@@ -51,6 +53,7 @@ async function fixture(t: TestContext, secure = true) {
|
||||
roles: ['organizer'],
|
||||
remote: {
|
||||
gameID: 7,
|
||||
introAudio: 'https://media.test/intro.wav',
|
||||
mode: 2,
|
||||
command: 1,
|
||||
stateVersion: '9007199254740993',
|
||||
@@ -139,12 +142,16 @@ async function fixture(t: TestContext, secure = true) {
|
||||
game: {
|
||||
ID: 7,
|
||||
name: model.title,
|
||||
scenario: {
|
||||
story: {
|
||||
introduction: { audio: model.introURL },
|
||||
conclusion: { video: '' },
|
||||
},
|
||||
},
|
||||
scenario: model.omitScenario
|
||||
? null
|
||||
: {
|
||||
story: model.omitStory
|
||||
? null
|
||||
: {
|
||||
introduction: { audio: model.introURL },
|
||||
conclusion: { video: '' },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
if (path === '/api/games/7/screen-plan') {
|
||||
@@ -1255,3 +1262,73 @@ test('некорректное серверное состояние отобр
|
||||
assert.ok(message.includes('получено object'))
|
||||
assert.ok(!message.includes('SECRET'))
|
||||
})
|
||||
|
||||
for (const missing of ['scenario', 'story'] as const) {
|
||||
test(`подключение без ${missing}: медиа состояния скачиваются и воспроизводятся локально`, async (t) => {
|
||||
const f = await fixture(t)
|
||||
f.model.omitScenario = missing === 'scenario'
|
||||
f.model.omitStory = missing === 'story'
|
||||
await f.login()
|
||||
await f.online.act({ action: 'connect', gameId: 7 })
|
||||
assert.equal(f.online.snapshot().screenId, '12')
|
||||
assert.equal(f.controller.state.outputOpen, false)
|
||||
f.controller.output(true)
|
||||
await f.online.poll()
|
||||
const state = f.controller.state
|
||||
const pkg = f.store.description(state.catalog.key!)!
|
||||
assert.ok(pkg.package.media.intro)
|
||||
assert.equal(state.channels.main.desired, 'playing')
|
||||
assert.equal(
|
||||
state.channels.main.source?.url,
|
||||
`screen-app://app/packages/${pkg.key}/${pkg.package.media.intro}`,
|
||||
)
|
||||
assert.ok((await f.store.localFile(pkg.key, pkg.package.media.intro!)).path)
|
||||
const restored = new PackageStore(join(f.directory, 'packages'))
|
||||
await restored.initialize()
|
||||
assert.equal(restored.description(pkg.key)?.package.media.intro, pkg.package.media.intro)
|
||||
assert.ok((await restored.localFile(pkg.key, pkg.package.media.intro!)).path)
|
||||
})
|
||||
}
|
||||
|
||||
test('без истории и медиа текст, таймер и музыка работают; отсутствие вступления не мешает связи', async (t) => {
|
||||
const f = await fixture(t)
|
||||
f.model.omitScenario = true
|
||||
f.model.plan = parsePlan({
|
||||
steps: [
|
||||
{ mode: 8, text: 'Текст без истории' },
|
||||
{ mode: 7, timerDurationSeconds: 30, timerLabel: 'Перерыв' },
|
||||
],
|
||||
})
|
||||
f.model.remote = {
|
||||
...f.model.remote,
|
||||
mode: 8,
|
||||
text: 'Текст без истории',
|
||||
command: 0,
|
||||
introAudio: '',
|
||||
music: objectMusic(1),
|
||||
}
|
||||
await f.login()
|
||||
await f.online.act({ action: 'connect', gameId: 7 })
|
||||
f.controller.output(true)
|
||||
await f.online.poll()
|
||||
assert.equal(f.controller.state.scene.text, 'Текст без истории')
|
||||
assert.equal(f.controller.state.channels.music.desired, 'playing')
|
||||
f.model.remote = {
|
||||
...f.model.remote,
|
||||
mode: 7,
|
||||
timerDurationSeconds: 30,
|
||||
timerRemainingSeconds: 30,
|
||||
timerState: 1,
|
||||
stateVersion: '9007199254740994',
|
||||
}
|
||||
await f.online.poll()
|
||||
assert.equal(f.controller.state.scene.mode, 7)
|
||||
assert.equal(f.controller.state.timer.durationMs, 30000)
|
||||
f.model.remote = { ...f.model.remote, mode: 2, stateVersion: '9007199254740995' }
|
||||
await f.online.poll()
|
||||
assert.equal(f.controller.state.scene.mode, 2)
|
||||
assert.equal(f.controller.state.channels.main.source, null)
|
||||
assert.equal(f.controller.state.channels.music.desired, 'playing')
|
||||
assert.equal(f.online.snapshot().connection, 'connected')
|
||||
assert.equal(f.online.snapshot().preparation.error, '')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user