This commit is contained in:
2026-10-18 18:00:12 +07:00
parent e881f10857
commit a3317dbf7a
11 changed files with 834 additions and 445 deletions
+55 -37
View File
@@ -278,6 +278,8 @@ module.exports = async function onlineSmoke({
async () => !(await evaluate('window.screenBridge.onlineState()')).busy,
'login complete',
)
await evaluate(`Array.from(document.querySelectorAll('button'))
.find(b => b.textContent.trim() === 'Сбросить')?.click()`)
await poll(
() =>
evaluate(
@@ -288,15 +290,15 @@ module.exports = async function onlineSmoke({
await poll(
() =>
evaluate(
`document.querySelectorAll('main.control > .n-card').length === 4 && document.querySelectorAll('.n-card-header__main').length === 5`,
`document.querySelectorAll('main.control > .n-card').length === 3 && document.querySelectorAll('main.control > .game-grid > .n-card').length === 2 && document.querySelectorAll('.n-card-header__main').length === 6`,
),
'five control cards',
'six control cards',
)
assert.deepEqual(
await evaluate(
`Array.from(document.querySelectorAll('.n-card-header__main')).map(e => (e.querySelector('.server-heading > span:first-child') ?? e).textContent.trim())`,
),
['Сервер', 'Игра', 'Экран', 'План экранов', 'План музыки'],
['Сервер', 'Игра', 'Экран игры', 'Экран', 'План экранов', 'План музыки'],
)
assert.equal(
await evaluate(`document.querySelectorAll('details').length`),
@@ -319,7 +321,7 @@ module.exports = async function onlineSmoke({
])
assert.equal(
await evaluate(
`Array.from(document.querySelectorAll('button')).some(b => b.textContent.trim() === ${JSON.stringify(label)})`,
`Array.from(document.querySelectorAll('button')).some(b => (b.getAttribute('aria-label') ?? b.textContent.trim()) === ${JSON.stringify(label)})`,
),
false,
'removed button: ' + label,
@@ -375,12 +377,11 @@ module.exports = async function onlineSmoke({
`Array.from(document.querySelectorAll('.n-base-select-option')).find(e => e.textContent.includes('HTTP smoke · Завершена')).click()`,
)
const selectedBeforeDownload = (await state()).catalog.name
await poll(
() =>
evaluate(
`document.querySelector('[data-testid="control-game"]')?.textContent.includes(${JSON.stringify(selectedBeforeDownload)})`,
),
'control target stays on local package despite server game selection',
assert.equal((await state()).catalog.key, null, 'server selection does not prepare a game')
assert.equal(
await evaluate(`!!document.querySelector('[data-testid="control-game"]')`),
false,
'current game stays empty until connection',
)
assert.notEqual(selectedBeforeDownload, 'HTTP smoke')
invalidStory = true
@@ -405,6 +406,24 @@ module.exports = async function onlineSmoke({
'anywhere',
)
invalidStory = false
await poll(
() => evaluate(`(() => {
const buttons = Array.from(document.querySelectorAll('button'))
const select = buttons.find(b => b.textContent.trim() === 'Выбрать игру')
const connect = buttons.find(b => b.textContent.trim() === 'Подключиться')
if (!select || select.disabled || !connect?.disabled) return false
select.click(); return true
})()`),
'confirm selected game before screen connection',
)
await poll(
async () => {
const online = await evaluate('window.screenBridge.onlineState()')
return !online.busy && online.currentGameId === 6 && online.screenId === null
&& online.materials.every(m => m.status === 'ready')
},
'game prepared without screen connection',
)
await poll(
() =>
evaluate(`(() => {
@@ -434,8 +453,15 @@ module.exports = async function onlineSmoke({
)
await checkBadges(true, true)
await poll(
() => evaluate(`document.querySelector('.connection-content .n-base-selection')?.textContent.includes('HTTP smoke')`),
'current game automatically selected',
() => evaluate(`(() => {
const content = document.querySelector('.connection-content')
const buttons = Array.from(document.querySelector('[data-testid="game-connection-status"]')?.closest('.n-card')?.querySelectorAll('button') ?? [])
return !content?.querySelector('.game-selection')
&& !buttons.some(b => b.textContent.trim() === 'Подключиться')
&& buttons.some(b => b.textContent.trim() === 'Отключиться'
&& b.closest('.n-space')?.textContent.includes('Экран №'))
})()`),
'selected game hides selector and connect button, disconnect follows screen name',
)
assert.equal((await state()).outputOpen, false)
await evaluate(`window.screenBridge.show(${displayId})`)
@@ -447,12 +473,12 @@ module.exports = async function onlineSmoke({
await evaluate(`(() => {
const assignment = document.querySelector('[data-testid="sound-assignment"]')
const card = assignment?.closest('.n-card')
return card?.querySelector('.n-card-header__main')?.textContent.trim() === 'Игра'
&& ['Назначить звук этому экрану', 'Отключить управление'].every(label =>
return card?.querySelector('.n-card-header__main')?.textContent.trim() === 'Экран игры'
&& ['Назначить звук этому экрану', 'Отключиться'].every(label =>
!Array.from(document.querySelectorAll('.n-card')).find(c => c.querySelector('.n-card-header__main')?.textContent.trim() === 'Экран')?.textContent.includes(label))
})()`),
true,
'server screen controls belong to game card',
'server screen controls belong to game screen card',
)
await poll(
() =>
@@ -602,7 +628,7 @@ module.exports = async function onlineSmoke({
() =>
evaluate(`(() => {
const button = Array.from(document.querySelectorAll('[data-testid="screen-plan"] button'))
.find(b => b.textContent.trim() === ${JSON.stringify(label)})
.find(b => (b.getAttribute('aria-label') ?? b.textContent.trim()) === ${JSON.stringify(label)})
if (!button || button.disabled) return false
button.click(); return true
})()`),
@@ -653,14 +679,14 @@ module.exports = async function onlineSmoke({
assert.equal((await state()).scene.revision, beforeSaveScene)
assert.equal(plan.steps[1].text, 'Текст из редактора')
assert.equal(plan.steps[2].timerDurationSeconds, 60)
await evaluate(`document.querySelector('[data-step-index="1"] button').click()`)
await evaluate(`document.querySelector('[data-step-index="1"] [data-testid="show-step"]').click()`)
await poll(
async () =>
(await state()).scene.text === 'Текст из редактора' &&
(await state()).scene.stepIndex === 1,
'show text step',
)
await evaluate(`document.querySelector('[data-step-index="2"] button').click()`)
await evaluate(`document.querySelector('[data-step-index="2"] [data-testid="show-step"]').click()`)
await poll(async () => (await state()).scene.stepIndex === 2, 'show timer step')
assert.equal((await state()).timer.status, 'stopped')
assert.equal((await state()).channels.main.desired, 'stopped')
@@ -704,7 +730,7 @@ module.exports = async function onlineSmoke({
poll(
() =>
evaluate(`(() => {
const button = Array.from(document.querySelectorAll('[data-testid="music-plan-editor"] button')).find(b => b.textContent.trim() === ${JSON.stringify(label)})
const button = Array.from(document.querySelectorAll('[data-testid="music-plan-editor"] button')).find(b => (b.getAttribute('aria-label') ?? b.textContent.trim()) === ${JSON.stringify(label)})
if (!button || button.disabled) return false
button.click(); return true
})()`),
@@ -823,25 +849,17 @@ module.exports = async function onlineSmoke({
assert.equal(afterOrder.desired, 'playing')
assert.ok(afterOrder.position >= beforeOrder.position)
console.log('SCREEN_MUSIC_PLAN_SMOKE_PASS')
await act({ action: 'disconnect' })
await evaluate(`Array.from(document.querySelectorAll('button'))
.find(b => b.textContent.trim() === 'Отключиться').click()`)
await poll(
() =>
evaluate(`(() => {
const select = document.querySelector('.connection-content .n-base-selection')
select?.dispatchEvent(new MouseEvent('mouseenter'))
const clear = select?.querySelector('.n-base-clear__clear')
if (!clear) return false
clear.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }))
clear.click(); return true
})()`),
'clear game selection',
)
await poll(
() =>
evaluate(
`document.querySelector('.connection-content .n-base-selection')?.textContent.includes('Выберите игру')`,
),
'server selection cleared',
() => evaluate(`(() => {
const card = document.querySelector('[data-testid="game-connection-status"]')?.closest('.n-card')
return card?.textContent.includes('Не подключено')
&& card.textContent.includes('Подключиться')
&& !card.textContent.includes('Отключиться')
&& !document.querySelector('.game-selection')
})()`),
'disconnect keeps selected game and restores connect in game screen card',
)
await poll(
() =>