feat(FN-3750): add test for selected roadmap update merge path
Adds test coverage for the selected roadmap update merge path in the roadmaps dashboard module. Fusion-Task-Id: FN-3750
This commit is contained in:
@@ -619,7 +619,7 @@ function MilestoneCard({
|
||||
data-testid={`milestone-card-${milestone.id}`}
|
||||
>
|
||||
<div className="roadmaps-view__milestone-header">
|
||||
{isEditingMilestone ? (
|
||||
{isEditingMilestone && milestoneEdit ? (
|
||||
<div className="roadmaps-view__inline-edit">
|
||||
<div className="roadmaps-view__inline-edit-row">
|
||||
<span
|
||||
@@ -833,7 +833,7 @@ function MilestoneCard({
|
||||
onDragLeave={onFeatureDragLeave}
|
||||
data-testid={`feature-item-${feature.id}`}
|
||||
>
|
||||
{isEditingFeature ? (
|
||||
{isEditingFeature && featureEdit ? (
|
||||
<div className="roadmaps-view__inline-edit roadmaps-view__inline-edit--compact">
|
||||
<div className="roadmaps-view__inline-edit-row">
|
||||
<span
|
||||
|
||||
@@ -230,6 +230,30 @@ describe("RoadmapsView", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("renders inline edit inputs with current values for milestone and feature", async () => {
|
||||
render(<RoadmapsView addToast={mockAddToast} />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Q2 Roadmap")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
fireEvent.click(screen.getByTestId("roadmap-item-RM-001"));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Milestone 1")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
fireEvent.click(screen.getByTestId("milestone-edit-RMS-001"));
|
||||
|
||||
const milestoneTitleInput = await screen.findByTestId("milestone-title-input-RMS-001");
|
||||
expect(milestoneTitleInput).toHaveValue("Milestone 1");
|
||||
|
||||
fireEvent.click(screen.getByTestId("feature-edit-RF-001"));
|
||||
|
||||
const featureTitleInput = await screen.findByTestId("feature-title-input-RF-001");
|
||||
expect(featureTitleInput).toHaveValue("Feature 1");
|
||||
});
|
||||
|
||||
it("edits a roadmap title inline", async () => {
|
||||
(api.updateRoadmap as ReturnType<typeof vi.fn>).mockResolvedValue({
|
||||
...mockRoadmaps[0],
|
||||
|
||||
@@ -208,6 +208,29 @@ describe("useRoadmaps", () => {
|
||||
expect(onSuccess).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("updates selectedRoadmap when updating the selected roadmap", async () => {
|
||||
const updatedRoadmap = { ...mockRoadmaps[0], title: "Updated Title" };
|
||||
(api.updateRoadmap as ReturnType<typeof vi.fn>).mockResolvedValue(updatedRoadmap);
|
||||
|
||||
const { result } = renderHook(() => useRoadmaps());
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.loading).toBe(false);
|
||||
});
|
||||
|
||||
result.current.selectRoadmap("RM-001");
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.selectedRoadmap?.title).toBe("Q2 Roadmap");
|
||||
});
|
||||
|
||||
await result.current.updateRoadmap("RM-001", { title: "Updated Title" });
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.selectedRoadmap?.title).toBe("Updated Title");
|
||||
});
|
||||
});
|
||||
|
||||
it("deletes a roadmap and removes it from the list", async () => {
|
||||
(api.deleteRoadmap as ReturnType<typeof vi.fn>).mockResolvedValue(undefined);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user