This commit is contained in:
2026-10-18 18:32:06 +07:00
parent a3317dbf7a
commit a35c09d0dc
5 changed files with 457 additions and 255 deletions
+27 -12
View File
@@ -42,8 +42,9 @@ module.exports = async function onlineSmoke({
{ ID: 92, name: 'Два', filename: 'music-b.wav', position: 1 },
],
},
{ ID: 10, name: 'Тестовый плейлист', tracks: [] },
]
let nextPlaylistId = 10
let nextPlaylistId = 11
const requests = []
const server = createServer(async (req, res) => {
const chunks = []
@@ -627,7 +628,7 @@ module.exports = async function onlineSmoke({
await poll(
() =>
evaluate(`(() => {
const button = Array.from(document.querySelectorAll('[data-testid="screen-plan"] button'))
const button = Array.from(document.querySelector('[data-testid="screen-plan"]').closest('.n-card').querySelectorAll('button'))
.find(b => (b.getAttribute('aria-label') ?? b.textContent.trim()) === ${JSON.stringify(label)})
if (!button || button.disabled) return false
button.click(); return true
@@ -730,7 +731,7 @@ module.exports = async function onlineSmoke({
poll(
() =>
evaluate(`(() => {
const button = Array.from(document.querySelectorAll('[data-testid="music-plan-editor"] button')).find(b => (b.getAttribute('aria-label') ?? b.textContent.trim()) === ${JSON.stringify(label)})
const button = Array.from(document.querySelector('[data-testid="music-plan"]').querySelectorAll('button')).find(b => (b.getAttribute('aria-label') ?? b.textContent.trim()) === ${JSON.stringify(label)})
if (!button || button.disabled) return false
button.click(); return true
})()`),
@@ -774,13 +775,15 @@ module.exports = async function onlineSmoke({
async () => (await evaluate('window.screenBridge.onlineState()')).playlists.length > 0,
'library loaded automatically',
)
await setInput('#new-playlist-name', 'Создан из приложения')
await clickMusic('Создать плейлист')
await poll(() => library.some((p) => p.name === 'Создан из приложения'), 'playlist created')
await poll(
() => evaluate(`document.querySelector('#playlist-name')?.value === 'Создан из приложения'`),
'new playlist selected',
await clickMusic('Редактировать')
assert.equal(
await evaluate(`!!document.querySelector('#new-playlist-name') ||
Array.from(document.querySelectorAll('[data-testid="music-plan"] button'))
.some(b => b.textContent.trim() === 'Создать плейлист')`),
false,
'playlist creation form is absent',
)
await choosePlaylist('Тестовый плейлист')
await setInput('#playlist-name', 'Переименован')
// Повторный snapshot не затирает ввод названия.
await new Promise((resolve) => setTimeout(resolve, 650))
@@ -797,7 +800,7 @@ module.exports = async function onlineSmoke({
await poll(
() =>
evaluate(
`document.querySelector('[data-testid="music-plan-editor"] ol')?.textContent.includes('native.mp3')`,
`document.querySelector('[data-testid="music-plan-editor"] .track-list')?.textContent.includes('native.mp3')`,
),
'native MP3 uploaded',
)
@@ -810,7 +813,7 @@ module.exports = async function onlineSmoke({
await poll(
() =>
evaluate(
`!document.querySelector('[data-testid="music-plan-editor"] ol')?.textContent.includes('native.mp3')`,
`!document.querySelector('[data-testid="music-plan-editor"] .track-list')?.textContent.includes('native.mp3')`,
),
'track removed',
)
@@ -835,7 +838,7 @@ module.exports = async function onlineSmoke({
[91, 92],
'draft not published',
)
await clickMusic('Отменить')
await clickMusic('Отменить порядок')
await evaluate(`document.querySelector('[aria-label="Опустить трек 1"]').click()`)
await clickMusic('Сохранить порядок')
await poll(
@@ -848,6 +851,18 @@ module.exports = async function onlineSmoke({
assert.equal(afterOrder.seekOperation, beforeOrder.seekOperation)
assert.equal(afterOrder.desired, 'playing')
assert.ok(afterOrder.position >= beforeOrder.position)
await clickMusic('Готово')
await poll(
() => evaluate(`(() => {
const view = document.querySelector('[data-testid="music-plan-view"]')
const rows = Array.from(view?.querySelectorAll('[data-track-index]') ?? [])
return rows.length === 2 && !document.querySelector('[data-testid="music-plan-editor"]')
&& rows.every(row => !row.querySelector('.track-preview') && row.querySelector('.n-progress'))
&& rows.filter(row => !row.classList.contains('track-current')).every(row =>
Array.from(row.querySelectorAll('button[aria-label]')).every(button => button.disabled))
})()`),
'music view shows tracks, progress and inactive controls',
)
console.log('SCREEN_MUSIC_PLAN_SMOKE_PASS')
await evaluate(`Array.from(document.querySelectorAll('button'))
.find(b => b.textContent.trim() === 'Отключиться').click()`)