This commit is contained in:
2026-10-18 14:15:43 +07:00
parent 0cd736f682
commit 913b237cb8
14 changed files with 1042 additions and 100 deletions
+37 -20
View File
@@ -245,10 +245,22 @@ module.exports = async function onlineSmoke({
})
await session.defaultSession.closeAllConnections()
const act = (intent) => evaluate(`window.screenBridge.onlineAction(${JSON.stringify(intent)})`)
const checkBadges = (authenticated, connected) =>
poll(
() => evaluate(`(() => {
const auth = document.querySelectorAll('.n-card-header [data-testid="auth-status"]')
const game = document.querySelectorAll('.n-card-header [data-testid="game-connection-status"]')
return auth.length === 1 && game.length === 1
&& auth[0].textContent.trim() === '${authenticated ? 'Вход выполнен' : 'Не выполнен'}'
&& game[0].textContent.trim() === '${connected ? 'Подключено' : 'Не подключено'}'
})()`),
'auth and game badges reflect separate states',
)
try {
await evaluate('window.screenBridge.closeOutput()')
// Вход через настоящую форму пульта, загрузка через защищённый IPC.
await poll(() => evaluate('!!document.querySelector("#server")'), 'login form')
await checkBadges(false, false)
await evaluate(`(() => {
for (const [id, value] of Object.entries(${JSON.stringify({ server: url, email: 'organizer@example.test', password: 'test-password' })})) {
const element = document.querySelector('#' + id)
@@ -282,7 +294,7 @@ module.exports = async function onlineSmoke({
)
assert.deepEqual(
await evaluate(
`Array.from(document.querySelectorAll('.n-card-header__main')).map(e => e.textContent.trim())`,
`Array.from(document.querySelectorAll('.n-card-header__main')).map(e => (e.querySelector('.server-heading > span:first-child') ?? e).textContent.trim())`,
),
['Сервер', 'Игра', 'Экран', 'План экранов', 'План музыки'],
)
@@ -317,38 +329,25 @@ module.exports = async function onlineSmoke({
await poll(
() =>
evaluate(
`!Array.from(document.querySelectorAll('button')).find(b => b.textContent.trim() === 'Обновить список игр')?.disabled`,
`!document.querySelector('button[aria-label="Обновить список игр"]')?.disabled`,
),
'refresh games button ready',
)
const previousCalls = gamesCalls
await evaluate(
`Array.from(document.querySelectorAll('button')).find(b => b.textContent.trim() === 'Обновить список игр').click()`,
`document.querySelector('button[aria-label="Обновить список игр"]').click()`,
)
await poll(
async () =>
gamesCalls > previousCalls && !(await evaluate('window.screenBridge.onlineState()')).busy,
'refresh games complete',
)
await poll(
() =>
evaluate(
`document.querySelector('.connection-content')?.textContent.includes('Управление не подключено')`,
),
'connection status rendered',
)
assert.equal(
await evaluate(
`document.querySelector('.connection-content').textContent.split('Управление не подключено').length - 1`,
),
1,
'refresh does not duplicate status',
)
await checkBadges(true, false)
}
await poll(
() =>
evaluate(
`!Array.from(document.querySelectorAll('button')).find(b => b.textContent.trim() === 'Обновить список игр')?.disabled`,
`!document.querySelector('button[aria-label="Обновить список игр"]')?.disabled`,
),
'last refresh complete',
)
@@ -409,7 +408,7 @@ module.exports = async function onlineSmoke({
await poll(
() =>
evaluate(`(() => {
const button = Array.from(document.querySelectorAll('button')).find(b => b.textContent.trim() === 'Подключить')
const button = Array.from(document.querySelectorAll('button')).find(b => b.textContent.trim() === 'Подключиться')
if (!button || button.disabled) return false
button.click(); return true
})()`),
@@ -433,6 +432,11 @@ module.exports = async function onlineSmoke({
async () => (await evaluate('window.screenBridge.onlineState()')).connection === 'connected',
'connected with output closed',
)
await checkBadges(true, true)
await poll(
() => evaluate(`document.querySelector('.connection-content .n-base-selection')?.textContent.includes('HTTP smoke')`),
'current game automatically selected',
)
assert.equal((await state()).outputOpen, false)
await evaluate(`window.screenBridge.show(${displayId})`)
await poll(
@@ -469,6 +473,7 @@ module.exports = async function onlineSmoke({
async () => (await evaluate('window.screenBridge.onlineState()')).connection === 'offline',
'offline indication',
)
await checkBadges(true, false)
await command({ action: 'play', channel: 'main' })
offline = false
currentCommand = 'SCREEN_COMMAND_STOP'
@@ -830,7 +835,7 @@ module.exports = async function onlineSmoke({
await poll(
() =>
evaluate(`(() => {
const button = Array.from(document.querySelectorAll('button')).find(b => b.textContent.trim() === 'Подключить')
const button = Array.from(document.querySelectorAll('button')).find(b => b.textContent.trim() === 'Подключиться')
if (!button || button.disabled) return false
button.click(); return true
})()`),
@@ -843,6 +848,7 @@ module.exports = async function onlineSmoke({
assert.equal((await state()).catalog.name, 'HTTP smoke')
await act({ action: 'logout' })
await checkBadges(false, false)
assert.equal((await evaluate('window.screenBridge.onlineState()')).authenticated, false)
await poll(
() =>
@@ -851,6 +857,17 @@ module.exports = async function onlineSmoke({
),
'current local game stays visible after logout',
)
const packageKeys = (await evaluate('window.screenBridge.packages()')).map((pkg) => pkg.key)
await evaluate(`Array.from(document.querySelectorAll('button')).find(b => b.textContent.trim() === 'Сбросить').click()`)
await poll(
async () => (await state()).catalog.key === null,
'reset clears current game',
)
await poll(
() => evaluate(`!document.querySelector('[data-testid="control-game"]')`),
'reset hides current game row',
)
assert.deepEqual((await evaluate('window.screenBridge.packages()')).map((pkg) => pkg.key), packageKeys)
assert.ok(requests.includes('/api/auth/login'), 'login through proxy')
assert.ok(requests.includes('/api/files/cached-intro.wav'), 'redirected media through proxy')
console.log('SCREEN_PROXY_SMOKE_PASS')