fix: Team and User Links (#15342)

* fix: Team and User Links

* Add tests
This commit is contained in:
Hariom Balhara authored and GitHub committed 2024-06-06 11:40:29 +00:00
1 parent 4153e5b2d5
commit def87ea84a
7 files changed
+55 -17

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
import { describe, it, vi, expect } from "vitest";
import { getTeamUrlSync } from "./client";
import * as getBookerBaseUrlSyncExport from "./getBookerBaseUrlSync";
vi.mock("./getBookerBaseUrlSync", async () => {
return {
getBookerBaseUrlSync: vi.fn(),
};
});
describe("getBookerUrl:client", () => {
describe("getTeamUrlSync", () => {
it("if orgSlug is null, it should return a URL with /team in it", () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
getBookerBaseUrlSyncExport.getBookerBaseUrlSync.mockReturnValueOnce("https://abc.com");
const url = getTeamUrlSync({ orgSlug: null, teamSlug: "myTeam" });
expect(url).toBe("https://abc.com/team/myTeam");
});
it("if orgSlug is set, it should return a URL without /team in it", () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
getBookerBaseUrlSyncExport.getBookerBaseUrlSync.mockReturnValueOnce("https://acme.com");
const url = getTeamUrlSync({ orgSlug: "acme", teamSlug: "myTeam" });
expect(url).toBe("https://acme.com/myTeam");
});
});
});
+2 -10
View File
@@ -1,14 +1,6 @@
import { getOrgFullOrigin } from "@calcom/ee/organizations/lib/orgDomains";
export const getBookerBaseUrlSync = (
orgSlug: string | null,
options?: {
protocol: boolean;
}
) => {
return getOrgFullOrigin(orgSlug ?? "", options);
};
import { getBookerBaseUrlSync } from "./getBookerBaseUrlSync";
export { getBookerBaseUrlSync } from "./getBookerBaseUrlSync";
export const getTeamUrlSync = (
{
orgSlug,
@@ -0,0 +1,10 @@
import { getOrgFullOrigin } from "@calcom/ee/organizations/lib/orgDomains";
export const getBookerBaseUrlSync = (
orgSlug: string | null,
options?: {
protocol: boolean;
}
) => {
return getOrgFullOrigin(orgSlug ?? "", options);
};