test: add multiple guests e2e test (#7774)

pull/7799/head
Nafees Nazik 2023-03-17 12:33:54 +05:30 committed by GitHub
parent 5cbd334a42
commit e001c0b88f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View File

@ -529,7 +529,9 @@ export default function Success(props: SuccessProps) {
{bookingInfo?.attendees.map((attendee) => (
<div key={attendee.name} className="mb-3 last:mb-0">
{attendee.name && <p>{attendee.name}</p>}
<p className="text-bookinglight">{attendee.email}</p>
<p data-testid={`attendee-${attendee.email}`} className="text-bookinglight">
{attendee.email}
</p>
</div>
))}
</div>

View File

@ -132,4 +132,26 @@ test.describe("pro user", () => {
// This is the only booking in there that needed confirmation and now it should be empty screen
await expect(page.locator('[data-testid="empty-screen"]')).toBeVisible();
});
test("can book with multiple guests", async ({ page, users }) => {
const additionalGuests = ["test@gmail.com", "test2@gmail.com"];
await page.click('[data-testid="event-type-link"]');
await selectFirstAvailableTimeSlotNextMonth(page);
await page.fill('[name="name"]', "test1234");
await page.fill('[name="email"]', "test1234@example.com");
await page.locator('[data-testid="add-guests"]').click();
await page.locator('input[type="email"]').nth(1).fill(additionalGuests[0]);
await page.locator('[data-testid="add-another-guest"]').click();
await page.locator('input[type="email"]').nth(2).fill(additionalGuests[1]);
await page.locator('[data-testid="confirm-book-button"]').click();
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
additionalGuests.forEach(async (email) => {
await expect(page.locator(`[data-testid="attendee-${email}"]`)).toHaveText(email);
});
});
});

View File

@ -172,6 +172,7 @@ export const Components: Record<BookingFieldType, Component> = {
</ul>
{!readOnly && (
<Button
data-testid="add-another-guest"
type="button"
color="minimal"
StartIcon={FiUserPlus}
@ -190,6 +191,7 @@ export const Components: Record<BookingFieldType, Component> = {
{!value.length && !readOnly && (
<Button
data-testid="add-guests"
color="minimal"
variant="button"
StartIcon={FiUserPlus}