Restore execution of playwright tests #130

Open
bustikiller wants to merge 8 commits from restore-playwright into main
Showing only changes of commit 3748805377 - Show all commits

View File

@ -1,7 +1,9 @@
import { test, expect, Page } from '@playwright/test' import { test, expect, Page } from '@playwright/test'
import { mock } from 'node:test';
const mockGuestsAPI = ({ page }: { page: Page }) => { const mockGuestsAPI = ({ page }: { page: Page }) => {
page.route('*/**/api/default/guests', async route => { page.route('*/**/api/default/guests', async route => {
if (route.request().method() === 'GET') {
const json = [ const json = [
{ {
"id": "f4a09c28-40ea-4553-90a5-96935a59cac6", "id": "f4a09c28-40ea-4553-90a5-96935a59cac6",
@ -24,6 +26,11 @@ const mockGuestsAPI = ({ page }: { page: Page }) => {
]; ];
await route.fulfill({ json }) await route.fulfill({ json })
} else if (route.request().method() === 'POST') {
const json = {};
await route.fulfill({ json });
}
}) })
} }
@ -92,6 +99,28 @@ test('should display the list of guests', async ({ page }) => {
await expect(page.getByRole('row').nth(2).locator('svg')).toHaveCount(2); await expect(page.getByRole('row').nth(2).locator('svg')).toHaveCount(2);
}); });
test('should allow creating a new guest', async ({ page }) => {
await mockGuestsAPI({ page });
await mockGroupsAPI({ page });
await page.goto('/default/dashboard/guests');
await page.getByRole('button', { name: 'Add new' }).click();
await page.getByRole('dialog').getByLabel('Name').fill('John Snow');
await page.keyboard.press('Tab');
await page.keyboard.press('ArrowDown');
await page.keyboard.press('ArrowDown');
await page.keyboard.press('Enter');
await page.keyboard.press('Tab');
await page.keyboard.press('ArrowDown');
await page.keyboard.press('ArrowDown');
await page.keyboard.press('Enter');
await page.getByRole('dialog').getByRole('button', { name: 'Create' }).click();
});
test('should display the list of groups', async ({ page }) => { test('should display the list of groups', async ({ page }) => {
await mockGroupsAPI({ page }); await mockGroupsAPI({ page });