|
|
@ -402,4 +402,105 @@ describe("QuestionDetailClient Validation", () => { |
|
|
expect(screen.getByRole("status")).toBeDefined(); |
|
|
expect(screen.getByRole("status")).toBeDefined(); |
|
|
expect(document.querySelector(".shimmer-bg")).toBeNull(); |
|
|
expect(document.querySelector(".shimmer-bg")).toBeNull(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("never renders TestIntroPage for normal profile sections", () => { |
|
|
|
|
|
const normalSectionItem = { |
|
|
|
|
|
slug: "personal_identity", |
|
|
|
|
|
title: "مشخصات فردی و هویتی", |
|
|
|
|
|
questions: [ |
|
|
|
|
|
{ |
|
|
|
|
|
id: "first_name", |
|
|
|
|
|
title: "نام", |
|
|
|
|
|
type: "text", |
|
|
|
|
|
order: 1, |
|
|
|
|
|
required: true, |
|
|
|
|
|
isVisible: true, |
|
|
|
|
|
private: false, |
|
|
|
|
|
description: "", |
|
|
|
|
|
tooltip: "", |
|
|
|
|
|
extras: {}, |
|
|
|
|
|
options: [], |
|
|
|
|
|
}, |
|
|
|
|
|
], |
|
|
|
|
|
}; |
|
|
|
|
|
(convertOverviewToFrontendItems as any).mockReturnValue([ |
|
|
|
|
|
{ |
|
|
|
|
|
slug: "personal_identity", |
|
|
|
|
|
title: "مشخصات فردی و هویتی", |
|
|
|
|
|
questions: [], |
|
|
|
|
|
}, |
|
|
|
|
|
]); |
|
|
|
|
|
(useFormSectionQuery as any).mockReturnValue({ |
|
|
|
|
|
data: { |
|
|
|
|
|
section: { cards: [] }, |
|
|
|
|
|
answers: {}, |
|
|
|
|
|
section_progress: { completion_percent: 0 }, |
|
|
|
|
|
}, |
|
|
|
|
|
isLoading: false, |
|
|
|
|
|
}); |
|
|
|
|
|
(mapBackendSectionToFrontend as any).mockReturnValue(normalSectionItem); |
|
|
|
|
|
|
|
|
|
|
|
const queryClient = new QueryClient({ |
|
|
|
|
|
defaultOptions: { queries: { retry: false } }, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
render( |
|
|
|
|
|
<QueryClientProvider client={queryClient}> |
|
|
|
|
|
<QuestionDetailClient |
|
|
|
|
|
closeLabel="Close" |
|
|
|
|
|
continueLabel="Continue" |
|
|
|
|
|
description="Desc" |
|
|
|
|
|
informationLabel="Info" |
|
|
|
|
|
itemSlug="personal_identity" |
|
|
|
|
|
questionsListHref="/questions-list" |
|
|
|
|
|
title="مشخصات فردی و هویتی" |
|
|
|
|
|
/> |
|
|
|
|
|
</QueryClientProvider>, |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Question input is rendered directly
|
|
|
|
|
|
expect(screen.getByText("نام")).toBeDefined(); |
|
|
|
|
|
// TestIntroPage elements (hero image, Start button) are NOT present
|
|
|
|
|
|
expect(document.querySelector("img[src*='test-intro-hero']")).toBeNull(); |
|
|
|
|
|
expect(screen.queryByRole("button", { name: "Start" })).toBeNull(); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("renders TestIntroPage for personality_test assessment", () => { |
|
|
|
|
|
(convertOverviewToFrontendItems as any).mockReturnValue([ |
|
|
|
|
|
{ |
|
|
|
|
|
slug: "personality_test", |
|
|
|
|
|
title: "آزمون کتل", |
|
|
|
|
|
estimate: "15 min", |
|
|
|
|
|
questions: [], |
|
|
|
|
|
}, |
|
|
|
|
|
]); |
|
|
|
|
|
(useCattellQuestionsQuery as any).mockReturnValue({ |
|
|
|
|
|
data: { questions: [{ id: 1, text: "Q1", options: ["A", "B", "C"] }] }, |
|
|
|
|
|
isLoading: false, |
|
|
|
|
|
isError: false, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const queryClient = new QueryClient({ |
|
|
|
|
|
defaultOptions: { queries: { retry: false } }, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
render( |
|
|
|
|
|
<QueryClientProvider client={queryClient}> |
|
|
|
|
|
<QuestionDetailClient |
|
|
|
|
|
closeLabel="Close" |
|
|
|
|
|
continueLabel="Continue" |
|
|
|
|
|
description="Desc" |
|
|
|
|
|
informationLabel="Info" |
|
|
|
|
|
itemSlug="personality_test" |
|
|
|
|
|
questionsListHref="/questions-list" |
|
|
|
|
|
title="آزمون کتل" |
|
|
|
|
|
/> |
|
|
|
|
|
</QueryClientProvider>, |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// TestIntroPage elements (Start button and title) are present
|
|
|
|
|
|
expect(screen.getAllByText("آزمون کتل").length).toBeGreaterThanOrEqual(1); |
|
|
|
|
|
expect(document.querySelector("img[src*='test-intro-hero']")).not.toBeNull(); |
|
|
|
|
|
expect(screen.getByRole("button", { name: "Start" })).toBeDefined(); |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |