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
@@ -0,0 +1,102 @@
|
||||
import { render } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { getOrgFullOrigin } from "@calcom/ee/organizations/lib/orgDomains";
|
||||
import { useRouterQuery } from "@calcom/lib/hooks/useRouterQuery";
|
||||
import { HeadSeo } from "@calcom/ui";
|
||||
|
||||
import UserPage from "./users-public-view";
|
||||
|
||||
function mockedUserPageComponentProps(props: Partial<React.ComponentProps<typeof UserPage>>) {
|
||||
return {
|
||||
trpcState: {
|
||||
mutations: [],
|
||||
queries: [],
|
||||
},
|
||||
themeBasis: "dark",
|
||||
safeBio: "My Bio",
|
||||
profile: {
|
||||
name: "John Doe",
|
||||
image: "john-profile-url",
|
||||
theme: "dark",
|
||||
brandColor: "red",
|
||||
darkBrandColor: "black",
|
||||
organization: { requestedSlug: "slug", slug: "slug", id: 1 },
|
||||
allowSEOIndexing: true,
|
||||
username: "john",
|
||||
},
|
||||
users: [
|
||||
{
|
||||
name: "John Doe",
|
||||
username: "john",
|
||||
avatarUrl: "john-user-url",
|
||||
bio: "",
|
||||
verified: false,
|
||||
profile: {
|
||||
upId: "1",
|
||||
id: 1,
|
||||
username: "john",
|
||||
organizationId: null,
|
||||
organization: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
markdownStrippedBio: "My Bio",
|
||||
entity: {
|
||||
considerUnpublished: false,
|
||||
...(props.entity ?? null),
|
||||
},
|
||||
eventTypes: [],
|
||||
} satisfies React.ComponentProps<typeof UserPage>;
|
||||
}
|
||||
|
||||
describe("UserPage Component", () => {
|
||||
it("should render HeadSeo with correct props", () => {
|
||||
const mockData = {
|
||||
props: mockedUserPageComponentProps({
|
||||
entity: {
|
||||
considerUnpublished: false,
|
||||
orgSlug: "org1",
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
vi.mocked(getOrgFullOrigin).mockImplementation((orgSlug: string | null) => {
|
||||
return `${orgSlug}.cal.local`;
|
||||
});
|
||||
|
||||
vi.mocked(useRouterQuery).mockReturnValue({
|
||||
uid: "uid",
|
||||
});
|
||||
|
||||
render(<UserPage {...mockData.props} />);
|
||||
|
||||
const expectedDescription = mockData.props.markdownStrippedBio;
|
||||
const expectedTitle = expectedDescription;
|
||||
expect(HeadSeo).toHaveBeenCalledWith(
|
||||
{
|
||||
origin: `${mockData.props.entity.orgSlug}.cal.local`,
|
||||
title: `${mockData.props.profile.name}`,
|
||||
description: expectedDescription,
|
||||
meeting: {
|
||||
profile: {
|
||||
name: mockData.props.profile.name,
|
||||
image: mockData.props.users[0].avatarUrl,
|
||||
},
|
||||
title: expectedTitle,
|
||||
users: [
|
||||
{
|
||||
name: mockData.props.users[0].name,
|
||||
username: mockData.props.users[0].username,
|
||||
},
|
||||
],
|
||||
},
|
||||
nextSeoProps: {
|
||||
nofollow: !mockData.props.profile.allowSEOIndexing,
|
||||
noindex: !mockData.props.profile.allowSEOIndexing,
|
||||
},
|
||||
},
|
||||
{}
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
useEmbedStyles,
|
||||
useIsEmbed,
|
||||
} from "@calcom/embed-core/embed-iframe";
|
||||
import { getOrgFullOrigin } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||
import { EventTypeDescriptionLazy as EventTypeDescription } from "@calcom/features/eventtypes/components";
|
||||
import EmptyPage from "@calcom/features/eventtypes/components/EmptyPage";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
@@ -59,10 +60,10 @@ export function UserPage(props: InferGetServerSidePropsType<typeof getServerSide
|
||||
|
||||
const isEventListEmpty = eventTypes.length === 0;
|
||||
const isOrg = !!user?.profile?.organization;
|
||||
|
||||
return (
|
||||
<>
|
||||
<HeadSeo
|
||||
origin={getOrgFullOrigin(entity.orgSlug ?? null)}
|
||||
title={profile.name}
|
||||
description={markdownStrippedBio}
|
||||
meeting={{
|
||||
|
||||
Reference in new issue
Block a user