Files
Benny JooandDevin AI ab21c7f805 refactor: Cal.diy (#28903)
* feat: Cal.diy — community-driven MIT-licensed fork of Cal.com

This squashed commit contains all Cal.diy changes applied on top of calcom/cal.com main:

- Rebrand Cal.com to Cal.diy across the entire codebase
- Remove Enterprise Edition (EE) features, license checks, and AGPL restrictions
- Switch license from AGPL-3.0 to MIT
- Remove docs/ directory (migrated to Nextra at cal.diy)
- Remove dead code: org tests, EE tips, platform nav, premium username, SAML/SSO, etc.
- Clean up .env.example for self-hosted Cal.diy
- Update Docker image references to calcom/cal.diy
- Update README, CONTRIBUTING.md, and issue templates for Cal.diy community fork
- Add PR welcome bot for Cal.diy contributors
- Fix API v2 breaking changes oasdiff ignore entries
- Replace Blacksmith CI runners with default GitHub Actions

3893 files changed, 20789 insertions(+), 411020 deletions(-)

Co-Authored-By: benny@cal.com <sldisek783@gmail.com>

* refactor: remove org-specific /organizations/:orgId endpoints from API v2 atoms controllers (#1701)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix: revert Cal.diy Inc to Cal.com, Inc. in license files, copyright notices, and package metadata (#1702)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* rip out org related comments in api v2

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-04-15 09:52:36 -03:00

389 lines
8.7 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from "vitest";
import {
shouldHideBrandingForEventUsingProfile,
shouldHideBrandingForTeamEvent,
shouldHideBrandingForUserEvent,
} from "./hideBranding";
// Mock the dependencies
vi.mock("@calcom/features/users/repositories/UserRepository", () => {
return {
UserRepository: class MockUserRepository {
findUserWithHideBranding = vi.fn();
},
};
});
vi.mock("@calcom/features/profile/repositories/ProfileRepository", () => ({
ProfileRepository: {
findByUserIdAndOrgSlug: vi.fn(),
},
}));
vi.mock("@calcom/lib/logger", () => ({
default: {
getSubLogger: () => ({
error: vi.fn(),
}),
},
}));
vi.mock("@calcom/prisma", () => ({
prisma: {},
}));
describe("hideBranding", () => {
beforeEach(() => {
vi.clearAllMocks();
});
describe("shouldHideBrandingForEventUsingProfile", () => {
describe("team events", () => {
it("should return true when team has hideBranding enabled", () => {
const team = {
hideBranding: true,
parent: null,
};
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner: null,
team,
});
expect(result).toBe(true);
});
it("should return true when parent organization has hideBranding enabled", () => {
const team = {
hideBranding: false,
parent: {
hideBranding: true,
},
};
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner: null,
team,
});
expect(result).toBe(true);
});
it("should return true when both team and parent have hideBranding enabled", () => {
const team = {
hideBranding: true,
parent: {
hideBranding: true,
},
};
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner: null,
team,
});
expect(result).toBe(true);
});
it("should return false when neither team nor parent has hideBranding enabled", () => {
const team = {
hideBranding: false,
parent: {
hideBranding: false,
},
};
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner: null,
team,
});
expect(result).toBe(false);
});
it("should return false when team has hideBranding disabled and no parent", () => {
const team = {
hideBranding: false,
parent: null,
};
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner: null,
team,
});
expect(result).toBe(false);
});
it("should handle null hideBranding values", () => {
const team = {
hideBranding: null,
parent: {
hideBranding: null,
},
};
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner: null,
team,
});
expect(result).toBe(false);
});
});
describe("user events", () => {
it("should return true when user has hideBranding enabled", () => {
const owner = {
id: 1,
hideBranding: true,
profile: null,
};
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner,
team: null,
});
expect(result).toBe(true);
});
it("should return true when user's organization has hideBranding enabled", () => {
const owner = {
id: 1,
hideBranding: false,
profile: {
organization: {
hideBranding: true,
},
},
};
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner,
team: null,
});
expect(result).toBe(true);
});
it("should return true when both user and organization have hideBranding enabled", () => {
const owner = {
id: 1,
hideBranding: true,
profile: {
organization: {
hideBranding: true,
},
},
};
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner,
team: null,
});
expect(result).toBe(true);
});
it("should return false when neither user nor organization has hideBranding enabled", () => {
const owner = {
id: 1,
hideBranding: false,
profile: {
organization: {
hideBranding: false,
},
},
};
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner,
team: null,
});
expect(result).toBe(false);
});
it("should return false when user has hideBranding disabled and no organization", () => {
const owner = {
id: 1,
hideBranding: false,
profile: {
organization: null,
},
};
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner,
team: null,
});
expect(result).toBe(false);
});
it("should handle null profile", () => {
const owner = {
id: 1,
hideBranding: false,
profile: null,
};
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner,
team: null,
});
expect(result).toBe(false);
});
it("should handle null hideBranding values", () => {
const owner = {
id: 1,
hideBranding: null,
profile: {
organization: {
hideBranding: null,
},
},
};
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner,
team: null,
});
expect(result).toBe(false);
});
});
describe("no owner or team", () => {
it("should return false when neither owner nor team is provided", () => {
const result = shouldHideBrandingForEventUsingProfile({
eventTypeId: 1,
owner: null,
team: null,
});
expect(result).toBe(false);
});
});
});
describe("shouldHideBrandingForTeamEvent", () => {
it("should return true when team has hideBranding enabled", () => {
const team = {
hideBranding: true,
parent: null,
};
const result = shouldHideBrandingForTeamEvent({
eventTypeId: 1,
team,
});
expect(result).toBe(true);
});
it("should return true when parent organization has hideBranding enabled", () => {
const team = {
hideBranding: false,
parent: {
hideBranding: true,
},
};
const result = shouldHideBrandingForTeamEvent({
eventTypeId: 1,
team,
});
expect(result).toBe(true);
});
it("should return false when neither team nor parent has hideBranding enabled", () => {
const team = {
hideBranding: false,
parent: {
hideBranding: false,
},
};
const result = shouldHideBrandingForTeamEvent({
eventTypeId: 1,
team,
});
expect(result).toBe(false);
});
});
describe("shouldHideBrandingForUserEvent", () => {
it("should return true when user has hideBranding enabled", () => {
const owner = {
id: 1,
hideBranding: true,
profile: null,
};
const result = shouldHideBrandingForUserEvent({
eventTypeId: 1,
owner,
});
expect(result).toBe(true);
});
it("should return true when user's organization has hideBranding enabled", () => {
const owner = {
id: 1,
hideBranding: false,
profile: {
organization: {
hideBranding: true,
},
},
};
const result = shouldHideBrandingForUserEvent({
eventTypeId: 1,
owner,
});
expect(result).toBe(true);
});
it("should return false when neither user nor organization has hideBranding enabled", () => {
const owner = {
id: 1,
hideBranding: false,
profile: {
organization: {
hideBranding: false,
},
},
};
const result = shouldHideBrandingForUserEvent({
eventTypeId: 1,
owner,
});
expect(result).toBe(false);
});
});
});