first commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect } from "@playwright/test";
|
||||
|
||||
import { getOrgFullOrigin } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||
|
||||
export async function gotoPathAndExpectRedirectToOrgDomain({
|
||||
page,
|
||||
org,
|
||||
path,
|
||||
expectedPath,
|
||||
}: {
|
||||
page: Page;
|
||||
org: { slug: string | null };
|
||||
path: string;
|
||||
expectedPath: string;
|
||||
}) {
|
||||
if (!org.slug) {
|
||||
throw new Error("Org slug is not defined");
|
||||
}
|
||||
page.goto(path).catch((e) => {
|
||||
console.log("Expected navigation error to happen");
|
||||
});
|
||||
|
||||
const orgSlug = org.slug;
|
||||
|
||||
const orgRedirectUrl = await new Promise(async (resolve) => {
|
||||
page.on("request", (request) => {
|
||||
if (request.isNavigationRequest()) {
|
||||
const requestedUrl = request.url();
|
||||
console.log("Requested navigation to", requestedUrl);
|
||||
// Resolve on redirection to org domain
|
||||
if (requestedUrl.includes(orgSlug)) {
|
||||
resolve(requestedUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
expect(orgRedirectUrl).toContain(`${getOrgFullOrigin(org.slug)}${expectedPath}`);
|
||||
}
|
||||
57
calcom/apps/web/playwright/organization/lib/inviteUser.ts
Normal file
57
calcom/apps/web/playwright/organization/lib/inviteUser.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import type { createUsersFixture } from "playwright/fixtures/users";
|
||||
|
||||
export const inviteUserToOrganization = async ({
|
||||
page,
|
||||
organizationId,
|
||||
email,
|
||||
usersFixture,
|
||||
}: {
|
||||
page: Page;
|
||||
organizationId: number;
|
||||
email: string;
|
||||
usersFixture: ReturnType<typeof createUsersFixture>;
|
||||
}) => {
|
||||
await page.goto("/settings/organizations/members");
|
||||
await page.waitForLoadState("networkidle");
|
||||
const invitedUserEmail = usersFixture.trackEmail({
|
||||
username: email.split("@")[0],
|
||||
domain: email.split("@")[1],
|
||||
});
|
||||
await inviteAnEmail(page, invitedUserEmail);
|
||||
return { invitedUserEmail };
|
||||
};
|
||||
|
||||
export const inviteExistingUserToOrganization = async ({
|
||||
page,
|
||||
organizationId,
|
||||
user,
|
||||
usersFixture,
|
||||
}: {
|
||||
page: Page;
|
||||
organizationId: number;
|
||||
user: {
|
||||
email: string;
|
||||
};
|
||||
usersFixture: ReturnType<typeof createUsersFixture>;
|
||||
}) => {
|
||||
await page.goto("/settings/organizations/members");
|
||||
await page.waitForLoadState("networkidle");
|
||||
|
||||
await inviteAnEmail(page, user.email);
|
||||
await page.waitForSelector('[data-testid="toast-success"]');
|
||||
return { invitedUserEmail: user.email };
|
||||
};
|
||||
|
||||
export async function acceptTeamOrOrgInvite(page: Page) {
|
||||
await page.goto("/settings/teams");
|
||||
await page.click('[data-testid^="accept-invitation"]');
|
||||
await page.waitForLoadState("networkidle");
|
||||
}
|
||||
|
||||
async function inviteAnEmail(page: Page, invitedUserEmail: string) {
|
||||
await page.locator('button:text("Add")').click();
|
||||
await page.locator('input[name="inviteUser"]').fill(invitedUserEmail);
|
||||
await page.locator('button:text("Send invite")').click();
|
||||
await page.waitForLoadState("networkidle");
|
||||
}
|
||||
Reference in New Issue
Block a user