fix: team and org invite e2e tests (#12566)
This commit is contained in:
1 parent
d3ddbf418f
commit
c765ea9b31
9 files changed
+66
-84
No files matched your search
@@ -1,34 +0,0 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
E2E_CLIPBOARD_VALUE?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export type Window = typeof window;
|
||||
// creates the single server fixture
|
||||
export const createClipboardFixture = (page: Page) => {
|
||||
return {
|
||||
reset: async () => {
|
||||
await page.evaluate(() => {
|
||||
delete window.E2E_CLIPBOARD_VALUE;
|
||||
});
|
||||
},
|
||||
get: async () => {
|
||||
return getClipboardValue({ page });
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
function getClipboardValue({ page }: { page: Page }) {
|
||||
return page.evaluate(() => {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
setInterval(() => {
|
||||
if (!window.E2E_CLIPBOARD_VALUE) return;
|
||||
resolve(window.E2E_CLIPBOARD_VALUE);
|
||||
}, 500);
|
||||
setTimeout(() => reject(new Error("Timeout")), 1000);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import prisma from "@calcom/prisma";
|
||||
|
||||
import type { ExpectedUrlDetails } from "../../../../playwright.config";
|
||||
import { createBookingsFixture } from "../fixtures/bookings";
|
||||
import { createClipboardFixture } from "../fixtures/clipboard";
|
||||
import { createEmbedsFixture } from "../fixtures/embeds";
|
||||
import { createOrgsFixture } from "../fixtures/orgs";
|
||||
import { createPaymentsFixture } from "../fixtures/payments";
|
||||
@@ -30,7 +29,6 @@ export interface Fixtures {
|
||||
emails?: API;
|
||||
routingForms: ReturnType<typeof createRoutingFormsFixture>;
|
||||
bookingPage: ReturnType<typeof createBookingPageFixture>;
|
||||
clipboard: ReturnType<typeof createClipboardFixture>;
|
||||
}
|
||||
|
||||
declare global {
|
||||
@@ -97,8 +95,4 @@ export const test = base.extend<Fixtures>({
|
||||
const bookingPage = createBookingPageFixture(page);
|
||||
await use(bookingPage);
|
||||
},
|
||||
clipboard: async ({ page }, use) => {
|
||||
const clipboard = createClipboardFixture(page);
|
||||
await use(clipboard);
|
||||
},
|
||||
});
|
||||
@@ -203,6 +203,12 @@ export async function installAppleCalendar(page: Page) {
|
||||
await page.click('[data-testid="install-app-button"]');
|
||||
}
|
||||
|
||||
export async function getInviteLink(page: Page) {
|
||||
const response = await page.waitForResponse("**/api/trpc/teams/createInvite?batch=1");
|
||||
const json = await response.json();
|
||||
return json[0].result.data.json.inviteLink as string;
|
||||
}
|
||||
|
||||
export async function getEmailsReceivedByUser({
|
||||
emails,
|
||||
userEmail,
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { expect } from "@playwright/test";
|
||||
|
||||
import { test } from "../lib/fixtures";
|
||||
import { getInviteLink } from "../lib/testUtils";
|
||||
import { expectInvitationEmailToBeReceived } from "./expects";
|
||||
|
||||
test.describe.configure({ mode: "parallel" });
|
||||
|
||||
test.afterEach(async ({ users, emails, clipboard }) => {
|
||||
clipboard.reset();
|
||||
test.afterEach(async ({ users, emails }) => {
|
||||
await users.deleteAll();
|
||||
emails?.deleteAll();
|
||||
});
|
||||
|
||||
test.describe("Organization", () => {
|
||||
test("Invitation (non verified)", async ({ browser, page, users, emails, clipboard }) => {
|
||||
test("Invitation (non verified)", async ({ browser, page, users, emails }) => {
|
||||
const orgOwner = await users.create(undefined, { hasTeam: true, isOrg: true });
|
||||
const { team: org } = await orgOwner.getOrgMembership();
|
||||
await orgOwner.apiLogin();
|
||||
@@ -69,9 +69,8 @@ test.describe("Organization", () => {
|
||||
// Get the invite link
|
||||
await page.locator('button:text("Add")').click();
|
||||
await page.locator(`[data-testid="copy-invite-link-button"]`).click();
|
||||
const inviteLink = await clipboard.get();
|
||||
await page.waitForLoadState("networkidle");
|
||||
|
||||
const inviteLink = await getInviteLink(page);
|
||||
// Follow invite link in new window
|
||||
const context = await browser.newContext();
|
||||
const inviteLinkPage = await context.newPage();
|
||||
@@ -98,7 +97,7 @@ test.describe("Organization", () => {
|
||||
await page.waitForLoadState("networkidle");
|
||||
|
||||
await test.step("To the organization by email (internal user)", async () => {
|
||||
const invitedUserEmail = `rick@example.com`;
|
||||
const invitedUserEmail = `rick-${Date.now()}@example.com`;
|
||||
await page.locator('button:text("Add")').click();
|
||||
await page.locator('input[name="inviteUser"]').fill(invitedUserEmail);
|
||||
await page.locator('button:text("Send invite")').click();
|
||||
@@ -110,7 +109,7 @@ test.describe("Organization", () => {
|
||||
`${org.name}'s admin invited you to join the organization ${org.name} on Cal.com`
|
||||
);
|
||||
|
||||
// Check newly invited member exists and is pending
|
||||
// Check newly invited member exists and is not pending
|
||||
await expect(
|
||||
page.locator(`[data-testid="email-${invitedUserEmail.replace("@", "")}-pending"]`)
|
||||
).toHaveCount(0);
|
||||
|
||||
@@ -3,19 +3,18 @@ import { expect } from "@playwright/test";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
|
||||
import { test } from "../lib/fixtures";
|
||||
import { localize } from "../lib/testUtils";
|
||||
import { localize, getInviteLink } from "../lib/testUtils";
|
||||
import { expectInvitationEmailToBeReceived } from "./expects";
|
||||
|
||||
test.describe.configure({ mode: "parallel" });
|
||||
|
||||
test.afterEach(async ({ users, emails, clipboard }) => {
|
||||
clipboard.reset();
|
||||
test.afterEach(async ({ users, emails }) => {
|
||||
await users.deleteAll();
|
||||
emails?.deleteAll();
|
||||
});
|
||||
|
||||
test.describe("Team", () => {
|
||||
test("Invitation (non verified)", async ({ browser, page, users, emails, clipboard }) => {
|
||||
test("Invitation (non verified)", async ({ browser, page, users, emails }) => {
|
||||
const t = await localize("en");
|
||||
const teamOwner = await users.create(undefined, { hasTeam: true });
|
||||
const { team } = await teamOwner.getFirstTeam();
|
||||
@@ -76,8 +75,7 @@ test.describe("Team", () => {
|
||||
});
|
||||
await page.locator(`button:text("${t("add")}")`).click();
|
||||
await page.locator(`[data-testid="copy-invite-link-button"]`).click();
|
||||
const inviteLink = await clipboard.get();
|
||||
await page.waitForLoadState("networkidle");
|
||||
const inviteLink = await getInviteLink(page);
|
||||
|
||||
const context = await browser.newContext();
|
||||
const inviteLinkPage = await context.newPage();
|
||||
|
||||
Reference in new issue
Block a user