import { expect, test } from '@playwright/test'; test.beforeEach(async ({ page }) => { await page.addInitScript(() => localStorage.setItem('pipu.locale', 'ru')); }); test('1. bootstrap admin changes credentials and lands on home', async ({ page }) => { await page.goto('/login'); await expect(page.getByText(/Первый запуск/)).toBeVisible(); await page.getByLabel('Логин').fill('admin'); await page.getByRole('textbox', { name: 'Пароль' }).fill('admin-password'); await page.getByRole('button', { name: 'Войти' }).click(); await expect(page.getByRole('heading', { name: 'Смените логин и пароль' })).toBeVisible(); await page.getByLabel('Новый логин').fill('owner'); await page.getByRole('textbox', { name: 'Новый пароль' }).fill('a-strong-owner-pass'); await page.getByRole('textbox', { name: 'Повторите пароль' }).fill('a-strong-owner-pass'); await page.getByRole('button', { name: 'Сохранить и продолжить' }).click(); await expect(page.getByRole('button', { name: 'Бегаю' })).toBeVisible(); }); test('4. search suggest opens the artist and Enter opens search', async ({ page }) => { await page.goto('/login'); await page.getByLabel('Логин').fill('alice'); await page.getByRole('textbox', { name: 'Пароль' }).fill('alice-password'); await page.getByRole('button', { name: 'Войти' }).click(); const box = page.getByRole('combobox', { name: 'Поиск' }); await box.fill('кино'); await page.getByRole('option', { name: /Кино/ }).first().click(); await expect(page.getByRole('heading', { name: 'Кино' })).toBeVisible(); await box.fill('кино'); // A suggestion under the pointer must not become a keyboard selection. const suggestion = page.getByRole('option', { name: /Кино/ }).first(); await suggestion.hover(); await expect(suggestion).toHaveAttribute('aria-selected', 'false'); await box.press('Enter'); await expect(page).toHaveURL(/\/search\?q=/); }); test('settings expose crossfade and loudness normalization', async ({ page }) => { await page.goto('/login'); await page.getByLabel('Логин').fill('alice'); await page.getByRole('textbox', { name: 'Пароль' }).fill('alice-password'); await page.getByRole('button', { name: 'Войти' }).click(); await page.getByRole('button', { name: 'Меню профиля' }).click(); await page.getByRole('menuitem', { name: 'Настройки' }).click(); await expect(page.getByText('Выравнивание громкости')).toBeVisible(); const slider = page.getByRole('slider', { name: /Кроссфейд/ }); await slider.fill('4'); await expect(page.getByText('Кроссфейд, 4 с')).toBeVisible(); }); test('9. login page switches between Russian and English', async ({ page }) => { await page.goto('/login'); await page.getByRole('button', { name: 'EN' }).click(); await expect(page.getByRole('heading', { name: 'Sign in' })).toBeVisible(); await page.getByRole('button', { name: 'RU' }).click(); await expect(page.getByRole('heading', { name: 'Вход' })).toBeVisible(); });