Merge pull request 'Include playwright test for changing guest name' (#100) from playwright-guests-change-name into main
All checks were successful
Check usage of free licenses / build-static-assets (push) Successful in 1m1s
Playwright Tests / test (push) Successful in 2m48s
Build Nginx-based docker image / build-static-assets (push) Successful in 4m16s

Reviewed-on: #100
This commit is contained in:
bustikiller 2024-11-13 23:28:16 +00:00
commit be7aed8246

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 }) => { const mockGuestsAPI = ({ page }: { page: Page }) => {
await page.route('*/**/api/guests.json', async route => { page.route('*/**/api/guests.json', async route => {
const json = { const json = {
data: [ data: [
{ {
@ -29,10 +29,14 @@ test('should display the list of guests', async ({ page }) => {
] ]
}; };
await route.fulfill({json}) 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: 'Groups' })).toBeVisible();
await expect(page.getByRole('tab', { name: 'Guests' })).toBeVisible(); await expect(page.getByRole('tab', { name: 'Guests' })).toBeVisible();
@ -42,14 +46,29 @@ test('should display the list of guests', async ({ page }) => {
await expect(page.getByRole('row').nth(1).getByRole('cell', { name: 'Kristofer Rohan DVM' })).toBeVisible(); await expect(page.getByRole('row').nth(1).getByRole('cell', { name: 'Kristofer Rohan DVM' })).toBeVisible();
await expect(page.getByRole('row').nth(1).getByRole('cell', { name: 'Childhood friends' })).toBeVisible(); await expect(page.getByRole('row').nth(1).getByRole('cell', { name: 'Childhood friends' })).toBeVisible();
await expect(page.getByRole('row').nth(1).getByRole('cell', { name: 'Tentative' })).toBeVisible(); await expect(page.getByRole('row').nth(1).getByRole('cell', { name: 'Tentative' })).toBeVisible();
await expect(page.getByRole('row').nth(1).getByRole('button', {name: 'Confirm'})).toBeVisible(); await expect(page.getByRole('row').nth(1).getByRole('button', { name: 'Confirm' })).toBeVisible();
await expect(page.getByRole('row').nth(1).getByRole('button', {name: 'Decline'})).toBeVisible(); await expect(page.getByRole('row').nth(1).getByRole('button', { name: 'Decline' })).toBeVisible();
await expect(page.getByRole('row').nth(2).getByRole('cell', { name: 'Olevia Quigley Jr.' })).toBeVisible(); await expect(page.getByRole('row').nth(2).getByRole('cell', { name: 'Olevia Quigley Jr.' })).toBeVisible();
await expect(page.getByRole('row').nth(2).getByRole('cell', { name: 'Work' })).toBeVisible(); await expect(page.getByRole('row').nth(2).getByRole('cell', { name: 'Work' })).toBeVisible();
await expect(page.getByRole('row').nth(2).getByRole('cell', { name: 'Invited' })).toBeVisible(); await expect(page.getByRole('row').nth(2).getByRole('cell', { name: 'Invited' })).toBeVisible();
await expect(page.getByRole('row').nth(2).getByRole('button', {name: 'Confirm'})).toBeVisible(); 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: 'Tentative' })).toBeVisible();
await expect(page.getByRole('row').nth(2).getByRole('button', {name: 'Decline'})).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();
});