feat: Add Owner during organization creation (#13069)

* feat: Add Owner during organization creation

* chore: remove dead code

* fix: change route from onboard-admin to onboard-members

* fix: change button name to add_members from add_team_member

* fix: change MembershipRole badge colour

* fix: previous membership role bug

* update: "On-board administrators" tests

* fix: wrong import

* Reverted extra changes

* fix: current user cannot remove itself

* Reverted extra changes

* Reverted extra changes 2

* send isOrg to removeMember handler

* fix: removed prisma.user.delete cleanup as not needed

---------

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-01-22 10:24:09 -05:00
1 parent 2ae2c15083
commit 3c8c6d0574
11 files changed
+62 -130

No files matched your search

@@ -1,6 +1,6 @@
import LegacyPage, {
buildWrappedOnboardTeamMembersPage,
} from "@pages/settings/organizations/[id]/onboard-admins";
} from "@pages/settings/organizations/[id]/onboard-members";
import { type Params } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { headers } from "next/headers";
@@ -2,7 +2,7 @@
import { redirect, useRouter } from "next/navigation";
import { AddNewOrgAdminsForm } from "@calcom/features/ee/organizations/components";
import AddNewTeamMembers from "@calcom/features/ee/teams/components/AddNewTeamMembers";
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Meta, WizardLayout, WizardLayoutAppDir } from "@calcom/ui";
@@ -20,7 +20,7 @@ const OnboardTeamMembersPage = () => {
title={t("invite_organization_admins")}
description={t("invite_organization_admins_description")}
/>
<AddNewOrgAdminsForm />
<AddNewTeamMembers isOrg={true} />
</>
);
};
@@ -103,18 +103,20 @@ test.describe("Organization", () => {
await page.locator("button[type=submit]").click();
// Waiting to be in next step URL
await page.waitForURL("/settings/organizations/*/onboard-admins");
await page.waitForURL("/settings/organizations/*/onboard-members");
});
await test.step("On-board administrators", async () => {
// Required field
await page.locator("button[type=submit]").click();
await page.waitForSelector('[data-testid="pending-member-list"]');
expect(await page.getByTestId("pending-member-item").count()).toBe(1);
// Happy path
const adminEmail = users.trackEmail({ username: "rick", domain: `${orgDomain}.com` });
await page.locator('textarea[name="emails"]').fill(adminEmail);
await page.locator("button[type=submit]").click();
//can add members
await page.getByTestId("new-member-button").click();
await page.locator('[placeholder="email\\@example\\.com"]').fill(adminEmail);
await page.getByTestId("invite-new-member-button").click();
await expect(page.locator(`li:has-text("${adminEmail}")`)).toBeVisible();
// Check if invited admin received the invitation email
await expectInvitationEmailToBeReceived(
page,
@@ -122,7 +124,15 @@ test.describe("Organization", () => {
adminEmail,
`${orgName}'s admin invited you to join the organization ${orgName} on Cal.com`
);
await expect(page.getByTestId("pending-member-item")).toHaveCount(2);
// can remove members
await expect(page.getByTestId("pending-member-item")).toHaveCount(2);
const lastRemoveMemberButton = page.getByTestId("remove-member-button").last();
await lastRemoveMemberButton.click();
await page.waitForLoadState("networkidle");
await expect(page.getByTestId("pending-member-item")).toHaveCount(1);
await page.getByTestId("publish-button").click();
// Waiting to be in next step URL
await page.waitForURL("/settings/organizations/*/add-teams");
});
@@ -614,6 +614,7 @@
"new_member": "New Member",
"invite": "Invite",
"add_team_members": "Add team members",
"add_org_members": "Add members",
"add_team_members_description": "Invite others to join your team",
"add_team_member": "Add team member",
"invite_new_member": "Invite a new team member",
@@ -1998,8 +1999,8 @@
"about_your_organization_description": "Organizations are shared environments where you can create multiple teams with shared members, event types, apps, workflows and more.",
"create_your_teams": "Create your teams",
"create_your_teams_description": "Start scheduling together by adding your team members to your organization",
"invite_organization_admins": "Invite your organization admins",
"invite_organization_admins_description": "These admins will have access to all teams in your organization. You can add team admins and members later.",
"invite_organization_admins": "Invite organization members",
"invite_organization_admins_description": "Invite others to join your organization. You can add members later.",
"set_a_password": "Set a password",
"set_a_password_description": "This will create a new user account with your organization email and this password.",
"organization_logo": "Organization Logo",