fix: Error in team members migration during org onboarding (#15349)
* fix: Error in team members migration during org onboarding * Add invitationMemberHandler tests * Add unit tests * Improve tests and refactor * Improve tests and refactor * Fix type issue * Fix createNewUsersConnectToOrgIfExists args
This commit is contained in:
1 parent
750676f91a
commit
6670bbc1d7
15 files changed
+1212
-453
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { beforeEach, vi } from "vitest";
|
||||
import { mockReset, mockDeep } from "vitest-mock-extended";
|
||||
|
||||
import type * as checkRateLimitAndThrowError from "@calcom/lib/checkRateLimitAndThrowError";
|
||||
|
||||
vi.mock("@calcom/lib/checkRateLimitAndThrowError", () => checkRateLimitAndThrowErrorMock);
|
||||
|
||||
beforeEach(() => {
|
||||
mockReset(checkRateLimitAndThrowErrorMock);
|
||||
});
|
||||
|
||||
const checkRateLimitAndThrowErrorMock = mockDeep<typeof checkRateLimitAndThrowError>();
|
||||
|
||||
export const scenarios = {
|
||||
fakeRateLimitPassed: () => {
|
||||
// It doesn't matter what the implementation is, as long as it resolves without error
|
||||
checkRateLimitAndThrowErrorMock.checkRateLimitAndThrowError.mockResolvedValue(undefined);
|
||||
},
|
||||
fakeRateLimitFailed: () => {
|
||||
const error = new Error("FAKE_RATE_LIMIT_ERROR");
|
||||
// It doesn't matter what the implementation is, as long as it resolves without error
|
||||
checkRateLimitAndThrowErrorMock.checkRateLimitAndThrowError.mockImplementation(() => {
|
||||
throw error;
|
||||
});
|
||||
return error.message;
|
||||
},
|
||||
};
|
||||
|
||||
export default checkRateLimitAndThrowErrorMock;
|
||||
@@ -0,0 +1,21 @@
|
||||
import { beforeEach, vi } from "vitest";
|
||||
import { mockReset, mockDeep } from "vitest-mock-extended";
|
||||
|
||||
import type * as getTranslation from "@calcom/lib/server/i18n";
|
||||
|
||||
vi.mock("@calcom/lib/server/i18n", () => getTranslationMock);
|
||||
|
||||
beforeEach(() => {
|
||||
mockReset(getTranslationMock);
|
||||
});
|
||||
|
||||
const getTranslationMock = mockDeep<typeof getTranslation>();
|
||||
|
||||
export const mock = {
|
||||
fakeIdentityFn: () =>
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore
|
||||
getTranslationMock.getTranslation.mockImplementation(async () => (key: string) => key),
|
||||
};
|
||||
|
||||
export default getTranslationMock;
|
||||
Reference in new issue
Block a user