ci / api / api (push) Canceled after 0s
ci / module boundaries / boundaries (push) Canceled after 0s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Canceled after 11m29s
ci / db / db (push) Canceled after 11m22s
ci / mobile / mobile (Metro-бандл Android) (push) Canceled after 6m43s
ci / recommender / recommender (push) Canceled after 6m47s
ci / ts / ts (packages + web) (push) Canceled after 1s
54 lines
4.3 KiB
TypeScript
54 lines
4.3 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
|
|
for (const width of [320, 800, 1280]) {
|
|
test(`friends, messages and sharing at ${width}px`, async ({ page }, info) => {
|
|
await page.setViewportSize({ width, height: 900 });
|
|
await page.emulateMedia({ reducedMotion: 'reduce' });
|
|
await page.addInitScript(() => localStorage.setItem('pipu.locale', 'ru'));
|
|
if (width === 800) await page.addInitScript(() => Object.defineProperty(navigator, 'share', { configurable: true, value: async (data: ShareData) => { sessionStorage.setItem('shared-url', data.url ?? ''); } }));
|
|
await page.goto('/login');
|
|
await page.getByLabel('Логин', { exact: true }).fill('alice');
|
|
await page.getByRole('textbox', { name: 'Пароль', exact: true }).fill('alice-password');
|
|
await page.getByRole('button', { name: 'Войти', exact: true }).click();
|
|
const openFriends = async () => {
|
|
if (width < 768) await page.getByRole('button', { name: 'Ещё', exact: true }).click();
|
|
await page.getByRole('link', { name: 'Друзья и общение', exact: true }).click();
|
|
};
|
|
await openFriends();
|
|
if (width === 800) await page.evaluate(() => { document.documentElement.dataset.theme = 'light'; });
|
|
await page.getByRole('button', { name: 'Написать', exact: true }).click();
|
|
if (width === 800) expect((await page.getByRole('textbox', { name: 'Сообщение', exact: true }).boundingBox())!.width).toBeGreaterThan(180);
|
|
await page.getByRole('textbox', { name: 'Сообщение', exact: true }).fill('Привет! Нашёл музыку для нашей поездки 🎵');
|
|
await page.getByRole('button', { name: 'Отправить', exact: true }).click();
|
|
await expect(page.getByText('Привет! Нашёл музыку для нашей поездки 🎵', { exact: true })).toBeVisible();
|
|
await expect(page.getByRole('textbox', { name: 'Сообщение', exact: true })).toBeEmpty();
|
|
await page.getByRole('button', { name: 'Действия с сообщением', exact: true }).click();
|
|
await expect(page.getByRole('menuitem', { name: 'Удалить для всех', exact: true })).toBeVisible();
|
|
await page.getByRole('menuitem', { name: '❤️', exact: true }).click();
|
|
await expect(page.getByRole('button', { name: '❤️ 1', exact: true })).toBeVisible();
|
|
await page.screenshot({ path: info.outputPath('conversation.png'), fullPage: true });
|
|
await page.getByRole('combobox', { name: 'Поиск', exact: true }).fill('кино');
|
|
await page.getByRole('combobox', { name: 'Поиск', exact: true }).press('Enter');
|
|
await page.getByRole('listitem').first().click();
|
|
await page.getByRole('contentinfo', { name: 'Плеер' }).getByRole('button', { name: 'Поделиться треком', exact: true }).click();
|
|
await expect(page.getByRole('dialog').getByRole('button', { name: 'Скопировать ссылку', exact: true })).toBeVisible();
|
|
if (width === 800) {
|
|
await page.getByRole('dialog').getByRole('button', { name: 'Отправить в приложение', exact: true }).click();
|
|
await expect.poll(() => page.evaluate(() => sessionStorage.getItem('shared-url'))).toContain('/track/');
|
|
}
|
|
await page.getByRole('dialog').getByRole('button', { name: 'moderator · Отправить', exact: true }).click();
|
|
await expect(page.getByRole('button', { name: 'moderator · Отправлено', exact: true })).toBeDisabled();
|
|
await page.screenshot({ path: info.outputPath('share-music.png') });
|
|
await page.getByRole('dialog').getByRole('button', { name: 'Закрыть', exact: true }).click();
|
|
await openFriends();
|
|
await page.getByRole('button', { name: 'Написать', exact: true }).click();
|
|
await expect(page.getByRole('link', { name: 'Открыть трек ↗', exact: true })).toBeVisible();
|
|
await expect.poll(() => page.evaluate(() => {
|
|
const main = document.querySelector('main')!;
|
|
return Math.max(document.documentElement.scrollWidth - innerWidth, main.scrollWidth - main.clientWidth);
|
|
})).toBeLessThanOrEqual(1);
|
|
await page.getByRole('link', { name: 'Открыть трек ↗', exact: true }).click();
|
|
await expect(page.getByRole('heading', { name: 'Группа крови', exact: true })).toBeVisible();
|
|
});
|
|
}
|