WIP specs for guest creation
Some checks failed
Check usage of free licenses / build-static-assets (pull_request) Successful in 40s
Add copyright notice / copyright_notice (pull_request) Successful in 54s
Build Nginx-based docker image / build-static-assets (push) Successful in 5m28s
Playwright Tests / test (pull_request) Failing after 14m3s

This commit is contained in:
Manuel Bustillo 2025-06-01 23:46:25 +02:00
parent e8551dd877
commit 3748805377

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 });