Skip to content

Commit

Permalink
test: adding test for event ui language
Browse files Browse the repository at this point in the history
  • Loading branch information
MehulZR committed Jan 22, 2025
1 parent 4d8c4b5 commit fdfb754
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
45 changes: 45 additions & 0 deletions apps/web/playwright/event-types.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { test } from "./lib/fixtures";
import {
bookTimeSlot,
createNewEventType,
createUserWithEnforcedUILang,
gotoBookingPage,
gotoFirstEventType,
saveEventType,
Expand Down Expand Up @@ -379,6 +380,50 @@ test.describe("Event Types tests", () => {
});
});
});

test.describe("Enforcing event UI language", () => {
test.use({
locale: "de",
});

test("Browser default", async ({ page, users }) => {
const SLUG = "default";
const UILanguage = null;

const user = await createUserWithEnforcedUILang({
slug: SLUG,
UILanguage,
users,
});

await page.goto(`/${user.username}/${SLUG}`);

await selectFirstAvailableTimeSlotNextMonth(page);

const locator = page.getByTestId("confirm-book-button");

await expect(locator).toHaveText("Bestätigen");
});

test("Overridden", async ({ page, users }) => {
const SLUG = "ar-lng";
const UILanguage = "ar";

const user = await createUserWithEnforcedUILang({
slug: SLUG,
UILanguage,
users,
});

await page.goto(`/${user.username}/${SLUG}`);

await selectFirstAvailableTimeSlotNextMonth(page);

const locator = page.getByTestId("confirm-book-button");

await expect(locator).toHaveText("تأكيد");
});
});
});

const selectAttendeePhoneNumber = async (page: Page) => {
Expand Down
25 changes: 25 additions & 0 deletions apps/web/playwright/lib/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,31 @@ export const createUserWithLimits = ({
});
};

export const createUserWithEnforcedUILang = ({
users,
slug,
UILanguage,
title,
length,
}: {
users: Fixtures["users"];
slug: string;
UILanguage: string | null;
title?: string;
length?: number;
}) => {
return users.create({
eventTypes: [
{
title: title ?? slug,
length: length ?? 30,
slug,
userInterfaceLanguage: UILanguage,
},
],
});
};

// this method is not used anywhere else
// but I'm keeping it here in case we need in the future
async function createUserWithSeatedEvent(users: Fixtures["users"]) {
Expand Down

0 comments on commit fdfb754

Please sign in to comment.