fix: add public profiles tests

This commit is contained in:
David Nguyen
2025-02-19 16:07:04 +11:00
parent 5ce2bae39d
commit a319ea0f5e
26 changed files with 187 additions and 41 deletions

View File

@ -60,7 +60,7 @@ export default function PublicProfilePage({ loaderData }: Route.ComponentProps)
const { _ } = useLingui();
const { toast } = useToast();
const { user } = useSession();
const { user, refreshSession } = useSession();
const team = useOptionalCurrentTeam();
const [isPublicProfileVisible, setIsPublicProfileVisible] = useState(profile.enabled);
@ -96,6 +96,9 @@ export default function PublicProfilePage({ loaderData }: Route.ComponentProps)
});
} else {
await updateUserProfile(data);
// Need to refresh session because we're editing the user's profile.
await refreshSession();
}
if (data.enabled === undefined && !isPublicProfileVisible) {

View File

@ -7,7 +7,7 @@ import { ChevronLeft } from 'lucide-react';
import { Link, Outlet } from 'react-router';
import LogoIcon from '@documenso/assets/logo_icon.png';
import { useSession } from '@documenso/lib/client-only/providers/session';
import { useOptionalSession } from '@documenso/lib/client-only/providers/session';
import { cn } from '@documenso/ui/lib/utils';
import { Button } from '@documenso/ui/primitives/button';
@ -21,7 +21,7 @@ export function meta() {
}
export default function PublicProfileLayout() {
const session = useSession();
const { sessionData } = useOptionalSession();
const [scrollY, setScrollY] = useState(0);
@ -37,8 +37,8 @@ export default function PublicProfileLayout() {
return (
<div className="min-h-screen">
{session ? (
<AuthenticatedHeader user={session.user} teams={session.teams} />
{sessionData ? (
<AuthenticatedHeader user={sessionData.user} teams={sessionData.teams} />
) : (
<header
className={cn(

View File

@ -44,7 +44,6 @@ export async function loader({ params }: Route.LoaderArgs) {
profileUrl,
}).catch(() => null);
// Todo: Test
if (!publicProfile || !publicProfile.profile.enabled) {
throw new Response('Not Found', { status: 404 });
}

View File

@ -29,7 +29,7 @@ export default function RecipientLayout() {
);
}
// Todo: Use generic error boundary.
// Todo: (RR7) Use generic error boundary.
export function ErrorBoundary() {
return (
<div className="mx-auto flex min-h-[80vh] w-full items-center justify-center py-32">

View File

@ -1,4 +1,4 @@
// Todo: Test, used AI to migrate this component from NextJS to Remix.
// Todo: (RR7) Test, used AI to migrate this component from NextJS to Remix.
import satori from 'satori';
import sharp from 'sharp';
import { P, match } from 'ts-pattern';

View File

@ -4,7 +4,7 @@ import { NEXT_PUBLIC_MARKETING_URL, NEXT_PUBLIC_WEBAPP_URL } from '@documenso/li
import type { Route } from './+types/share.$slug';
// Todo: Test meta.
// Todo: (RR7) Test meta.
export function meta({ params: { slug } }: Route.MetaArgs) {
return [
{ title: 'Documenso - Share' },

View File

@ -6,7 +6,7 @@ export type ShareHandlerAPIResponse =
| Awaited<ReturnType<typeof getRecipientOrSenderByShareLinkSlug>>
| { error: string };
// Todo: Test
// Todo: (RR7) Test
export async function loader({ request }: Route.LoaderArgs) {
try {
const url = new URL(request.url);

View File

@ -1,6 +1,6 @@
import { stripeWebhookHandler } from '@documenso/ee/server-only/stripe/webhook/handler';
// Todo
// Todo: (RR7)
// export const config = {
// api: { bodyParser: false },
// };

View File

@ -2,7 +2,7 @@ import { handlerTriggerWebhooks } from '@documenso/lib/server-only/webhooks/trig
import type { Route } from './+types/webhook.trigger';
// Todo
// Todo: (RR7)
// export const config = {
// maxDuration: 300,
// api: {

View File

@ -6,7 +6,7 @@ import { EmbedPaywall } from '~/components/embed/embed-paywall';
import type { Route } from './+types/_layout';
// Todo: Test
// Todo: (RR7) Test
export function headers({ loaderHeaders }: Route.HeadersArgs) {
const origin = loaderHeaders.get('Origin') ?? '*';