Compare commits

...

2 Commits

Author SHA1 Message Date
Cursor Agent
11f635c1ff test: add test case for survey not found in metadata generation 2026-03-16 15:00:10 +00:00
Cursor Agent
e5cd9e5117 fix: handle ResourceNotFoundError in generateMetadata for link surveys 2026-03-16 14:23:59 +00:00
2 changed files with 14 additions and 1 deletions

View File

@@ -168,6 +168,14 @@ describe("getMetadataForLinkSurvey", () => {
expect(notFound).toHaveBeenCalled();
});
test("calls notFound when survey is not found", async () => {
vi.mocked(getSurveyWithMetadata).mockResolvedValue(null as any);
await getMetadataForLinkSurvey(mockSurveyId);
expect(notFound).toHaveBeenCalled();
});
test("handles metadata without openGraph property", async () => {
const mockSurvey = {
id: mockSurveyId,

View File

@@ -36,7 +36,12 @@ export const generateMetadata = async (props: LinkSurveyPageProps): Promise<Meta
// Extract language code from URL params
const languageCode = typeof searchParams.lang === "string" ? searchParams.lang : undefined;
return getMetadataForLinkSurvey(params.surveyId, languageCode);
try {
return await getMetadataForLinkSurvey(params.surveyId, languageCode);
} catch (error) {
logger.error(error, "Error fetching metadata for link survey");
notFound();
}
};
export const LinkSurveyPage = async (props: LinkSurveyPageProps) => {