Include playwright test for changing guest name
All checks were successful
Check usage of free licenses / build-static-assets (pull_request) Successful in 1m27s
Add copyright notice / copyright_notice (pull_request) Successful in 2m4s
Playwright Tests / test (pull_request) Successful in 3m3s

This commit is contained in:
Manuel Bustillo 2024-11-14 00:24:07 +01:00
parent 321294c97d
commit a4815c6f14

View File

@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test'
import { test, expect, Page } from '@playwright/test'
test('should display the list of guests', async ({ page }) => {
await page.route('*/**/api/guests.json', async route => {
const mockGuestsAPI = ({ page }: { page: Page }) => {
page.route('*/**/api/guests.json', async route => {
const json = {
data: [
{
@ -31,8 +31,12 @@ test('should display the list of guests', async ({ page }) => {
await route.fulfill({ json })
})
}
await page.goto('/dashboard/guests')
test('should display the list of guests', async ({ page }) => {
await mockGuestsAPI({ page });
await page.goto('/dashboard/guests');
await expect(page.getByRole('tab', { name: 'Groups' })).toBeVisible();
await expect(page.getByRole('tab', { name: 'Guests' })).toBeVisible();
@ -52,4 +56,19 @@ test('should display the list of guests', async ({ page }) => {
await expect(page.getByRole('row').nth(2).getByRole('button', { name: 'Confirm' })).toBeVisible();
await expect(page.getByRole('row').nth(2).getByRole('button', { name: 'Tentative' })).toBeVisible();
await expect(page.getByRole('row').nth(2).getByRole('button', { name: 'Decline' })).toBeVisible();
})
});
test('should allow changing the name of a guest', async ({ page }) => {
await mockGuestsAPI({ page });
await page.goto('/dashboard/guests');
await expect(page.getByRole('row').nth(1).getByRole('cell', { name: 'Kristofer Rohan DVM' })).toBeVisible();
await page.getByRole('row').nth(1).getByRole('cell', { name: 'Kristofer Rohan DVM' }).click();
await page.getByRole('textbox').clear();
await page.getByRole('textbox').pressSequentially('John Snow');
await page.getByRole('textbox').evaluate(e => e.blur());
await expect(page.getByRole('row').nth(1).getByRole('cell', { name: 'John Snow' })).toBeVisible();
});