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
@@ -6,7 +6,7 @@ import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import TeamInviteFromOrg from "@calcom/ee/organizations/components/TeamInviteFromOrg";
|
||||
import { classNames } from "@calcom/lib";
|
||||
import { IS_TEAM_BILLING_ENABLED, WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { IS_TEAM_BILLING_ENABLED } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
import type { RouterOutputs } from "@calcom/trpc";
|
||||
@@ -25,7 +25,6 @@ import {
|
||||
TextAreaField,
|
||||
} from "@calcom/ui";
|
||||
import { Link } from "@calcom/ui/components/icon";
|
||||
import type { Window as WindowWithClipboardValue } from "@calcom/web/playwright/fixtures/clipboard";
|
||||
|
||||
import type { PendingMember } from "../lib/types";
|
||||
import { GoogleWorkspaceInviteButton } from "./GoogleWorkspaceInviteButton";
|
||||
@@ -76,8 +75,8 @@ export default function MemberInvitationModal(props: MemberInvitationModalProps)
|
||||
);
|
||||
|
||||
const createInviteMutation = trpc.viewer.teams.createInvite.useMutation({
|
||||
onSuccess(token) {
|
||||
copyInviteLinkToClipboard(token);
|
||||
async onSuccess({ inviteLink }) {
|
||||
await copyInviteLinkToClipboard(inviteLink);
|
||||
trpcContext.viewer.teams.get.invalidate();
|
||||
trpcContext.viewer.teams.list.invalidate();
|
||||
},
|
||||
@@ -86,20 +85,11 @@ export default function MemberInvitationModal(props: MemberInvitationModalProps)
|
||||
},
|
||||
});
|
||||
|
||||
const copyInviteLinkToClipboard = async (token: string) => {
|
||||
const isOrgInvite = isOrg;
|
||||
const teamInviteLink = `${WEBAPP_URL}/teams?token=${token}`;
|
||||
const orgInviteLink = `${WEBAPP_URL}/signup?token=${token}&callbackUrl=/getting-started`;
|
||||
|
||||
const inviteLink =
|
||||
isOrgInvite || (props?.orgMembers && props.orgMembers?.length > 0) ? orgInviteLink : teamInviteLink;
|
||||
const copyInviteLinkToClipboard = async (inviteLink: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(inviteLink);
|
||||
showToast(t("invite_link_copied"), "success");
|
||||
} catch (e) {
|
||||
if (process.env.NEXT_PUBLIC_IS_E2E) {
|
||||
(window as WindowWithClipboardValue).E2E_CLIPBOARD_VALUE = inviteLink;
|
||||
}
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
@@ -373,11 +363,9 @@ export default function MemberInvitationModal(props: MemberInvitationModalProps)
|
||||
type="button"
|
||||
color="minimal"
|
||||
variant="icon"
|
||||
onClick={() =>
|
||||
props.token
|
||||
? copyInviteLinkToClipboard(props.token)
|
||||
: createInviteMutation.mutate({ teamId: props.teamId })
|
||||
}
|
||||
onClick={() => {
|
||||
createInviteMutation.mutate({ teamId: props.teamId, token: props.token });
|
||||
}}
|
||||
className={classNames("gap-2", props.token && "opacity-50")}
|
||||
data-testid="copy-invite-link-button">
|
||||
<Link className="text-default h-4 w-4" aria-hidden="true" />
|
||||
|
||||
Reference in new issue
Block a user