Skip to content

Commit

Permalink
fix: uncaught types errors in invite members team handler (calcom#16109)
Browse files Browse the repository at this point in the history
  • Loading branch information
zomars authored Aug 19, 2024
1 parent bba7fc1 commit a091c60
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 9 deletions.
2 changes: 2 additions & 0 deletions packages/trpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "eslint . --ext .ts,.tsx --fix",
"build": "yarn trpc:generate || true",
"dev": "yarn build",
"dx": "yarn build",
"trpc:generate": "yarn tsc --project tsconfig.json"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { beforeEach, vi, expect } from "vitest";
import { mockReset, mockDeep } from "vitest-mock-extended";

import type { MembershipRole } from "@calcom/prisma/enums";

import type * as inviteMemberUtils from "../utils";

vi.mock("../utils", async () => {
Expand Down Expand Up @@ -70,16 +72,18 @@ export const inviteMemberutilsScenarios = {
team: any;
invitations: {
usernameOrEmail: string;
newRole?: MembershipRole;
}[];
}
) {
inviteMemberUtilsMock.findUsersWithInviteStatus.mockImplementation(({ invitations, team }) => {
const allInvitationsExist = invitations.every((invitation) =>
forInput.invitations.find((i) => i.usernameOrEmail === invitation.usernameOrEmail)
);
if (forInput.team.id == team.id && allInvitationsExist) return returnVal;
if (forInput.team.id == team.id && allInvitationsExist) return Promise.resolve(returnVal);
return Promise.resolve([]);
});
return returnVal;
return Promise.resolve(returnVal);
},
},
getOrgConnectionInfo: {
Expand All @@ -102,7 +106,7 @@ export const expects = {
teamId,
}: {
emails: string[];
team;
team: any[];
inviterName: string;
teamId: number;
isOrg: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ describe("inviteMemberHandler", () => {
];

const retValueOfFindUsersWithInviteStatus =
inviteMemberUtilsScenarios.findUsersWithInviteStatus.useAdvancedMock(
await inviteMemberUtilsScenarios.findUsersWithInviteStatus.useAdvancedMock(
[
{
...usersToBeInvited[0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ const mockedReturnSuccessCheckPerms = {
isPrivate: false,
logoUrl: "",
calVideoLogo: "",
isOrganization: false,
},
};

const mockedRegularTeam: TeamWithParent = {
id: 1,
name: "Team A",
slug: null,
logo: null,
appLogo: null,
appIconLogo: null,
bio: null,
Expand All @@ -93,6 +93,7 @@ const mockedRegularTeam: TeamWithParent = {
bannerUrl: "",
isPlatform: false,
smsLockState: "LOCKED",
createdByOAuthClientId: null,
};

const mockedSubTeam = {
Expand Down Expand Up @@ -254,6 +255,11 @@ describe("Invite Member Utils", () => {
isOrganizationConfigured: false,
isOrganizationVerified: true,
orgAutoAcceptEmail: "example.com",
organizationId: 1,
lockEventTypeCreationForUsers: false,
adminGetsNoSlotsNotification: false,
isAdminReviewed: false,
isAdminAPIEnabled: false,
},
slug: "abc",
parent: null,
Expand All @@ -279,6 +285,11 @@ describe("Invite Member Utils", () => {
isOrganizationConfigured: false,
isOrganizationVerified: false,
orgAutoAcceptEmail: "example.com",
organizationId: 1,
lockEventTypeCreationForUsers: false,
adminGetsNoSlotsNotification: false,
isAdminReviewed: false,
isAdminAPIEnabled: false,
},
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Team } from "@calcom/prisma/client";
import type { Team } from "@prisma/client";

import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";

import type { TInviteMemberInputSchema } from "./inviteMember.schema";
Expand Down
30 changes: 29 additions & 1 deletion packages/trpc/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
{
"extends": "@calcom/tsconfig/react-library.json",
"include": ["client", "next", "react", "server"],
"paths": {
"~/*": ["/*"],
"@calcom/app-store": ["../app-store"],
"@calcom/app-store/*": ["../app-store/*"],
"@calcom/dayjs": ["../dayjs"],
"@calcom/dayjs/*": ["../dayjs/*"],
"@calcom/features": ["../features"],
"@calcom/features/*": ["../features/*"],
"@calcom/lib": ["../lib"],
"@calcom/lib/*": ["../lib/*"],
"@calcom/platform-constants": ["../platform/constants/index.ts"],
"@calcom/platform-types": ["../platform/types/index.ts"],
"@calcom/platform-utils": ["../platform/utils/index.ts"],
"@calcom/prisma": ["../prisma"],
"@calcom/prisma/*": ["../prisma/*"]
},
"include": [
"../types/@wojtekmaj__react-daterange-picker.d.ts",
"../types/business-days-plugin.d.ts",
"../types/next-auth.d.ts",
"../types/next.d.ts",
"../types/window.d.ts",
"client",
"next",
"react",
"server"
],
"compilerOptions": {
"isolatedModules": false,
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
"experimentalDecorators": true,
"declarationMap": false,
"resolveJsonModule": true,
"outFile": "types/router.d.ts"
}
}
4 changes: 2 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@
"outputs": ["dist/**", "build/**"]
},
"dev": {
"dependsOn": ["//#env-check:common", "//#env-check:app-store"],
"dependsOn": ["//#env-check:common", "//#env-check:app-store", "^dev"],
"cache": false
},
"dx": {
"dependsOn": ["//#env-check:common", "//#env-check:app-store"],
"dependsOn": ["//#env-check:common", "//#env-check:app-store", "^dx"],
"cache": false
},
"lint": {
Expand Down

0 comments on commit a091c60

Please sign in to comment.