fix: Use origin as provided in HeadSeo. origin would be different for Domain cases (#14935)
* fix: Use origin as provided in HeadSeo. origin would be different for Domain cases * Add a test * add more test * Add tests * Cleanup tests * Add an e2e as well * fix-test * Reset mocks
This commit is contained in:
1 parent
29ccc58806
commit
5f5cf92456
16 files changed
+730
-27
No files matched your search
@@ -1,10 +1,15 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { getOrgSlug, getOrgDomainConfigFromHostname } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||
import {
|
||||
getOrgSlug,
|
||||
getOrgDomainConfigFromHostname,
|
||||
getOrgFullOrigin,
|
||||
} from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||
import * as constants from "@calcom/lib/constants";
|
||||
|
||||
function setupEnvs({ WEBAPP_URL = "https://app.cal.com" } = {}) {
|
||||
function setupEnvs({ WEBAPP_URL = "https://app.cal.com", WEBSITE_URL } = {}) {
|
||||
Object.defineProperty(constants, "WEBAPP_URL", { value: WEBAPP_URL });
|
||||
Object.defineProperty(constants, "WEBSITE_URL", { value: WEBSITE_URL });
|
||||
Object.defineProperty(constants, "ALLOWED_HOSTNAMES", {
|
||||
value: ["cal.com", "cal.dev", "cal-staging.com", "cal.community", "cal.local:3000", "localhost:3000"],
|
||||
});
|
||||
@@ -82,4 +87,22 @@ describe("Org Domains Utils", () => {
|
||||
expect(getOrgSlug("acme.cal.com:3000")).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getOrgFullOrigin", () => {
|
||||
it("should return the regular(non-org) origin if slug is null", () => {
|
||||
setupEnvs({
|
||||
WEBAPP_URL: "https://app.cal.com",
|
||||
WEBSITE_URL: "https://abc.com",
|
||||
});
|
||||
expect(getOrgFullOrigin(null)).toEqual("https://abc.com");
|
||||
});
|
||||
it("should return the org origin if slug is set", () => {
|
||||
setupEnvs({
|
||||
WEBAPP_URL: "https://app.cal-app.com",
|
||||
WEBSITE_URL: "https://cal.com",
|
||||
});
|
||||
// We are supposed to use WEBAPP_URL to derive the origin from and not WEBSITE_URL
|
||||
expect(getOrgFullOrigin("org")).toEqual("https://org.cal-app.com");
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user