Skip to content

Commit

Permalink
Merge pull request #61 from cearps/removing-description
Browse files Browse the repository at this point in the history
fixed the tests.
  • Loading branch information
maxjaszewski authored Sep 29, 2024
2 parents 04e0a00 + 262dffa commit 4fb7860
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 35 deletions.
16 changes: 8 additions & 8 deletions frontend/src/components/forms/add-board-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const AddBoardForm = ({
defaultValues,
}: {
onClose: () => void;
onSubmit: (name: string, dueDate: string, description: string) => void;
onSubmit: (name: string, dueDate: string) => void;
errors?: string;
defaultValues?: { name: string; dueDate: string; description: string };
defaultValues?: { name: string; dueDate: string };
}) => {
const [name, setName] = useState(defaultValues?.name || "");
const [dueDate, setDueDate] = useState(defaultValues?.dueDate || "");
const [description, setDescription] = useState(
defaultValues?.description || ""
);
// const [description, setDescription] = useState(
// defaultValues?.description || ""
// );

const cardRef = useRef<HTMLDivElement>(null);

Expand All @@ -36,7 +36,7 @@ const AddBoardForm = ({

const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
onSubmit(name, dueDate, description);
onSubmit(name, dueDate);
};

return (
Expand Down Expand Up @@ -96,7 +96,7 @@ const AddBoardForm = ({
required
/>
</div>
<div className="mb-4">
{/* <div className="mb-4">
<label className="block text-sm font-medium text-gray-700">
Description
</label>
Expand All @@ -107,7 +107,7 @@ const AddBoardForm = ({
className="block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-400"
required
/>
</div>
</div> */}
<div className="flex justify-end">
<Button type="submit">
{defaultValues ? "Update Board" : "Create Board"}
Expand Down
13 changes: 2 additions & 11 deletions frontend/src/components/kanbans/kanban-list-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,17 @@ export default function KanbanListView() {
};
}, []);

const handleAddBoard = async (
name: string,
dueDate: string,
description: string
) => {
const handleAddBoard = async (name: string, dueDate: string) => {
if (editingBoard) {
// If we're editing a board, update it
KanbanAPI.updateKanbanBoardObservable(editingBoard.id, {
name,
dueDate,
description,
}).subscribe({
next: () => {
setKanbanBoards((prevBoards) =>
prevBoards.map((board) =>
board.id === editingBoard.id
? { ...board, name, dueDate, description }
: board
board.id === editingBoard.id ? { ...board, name, dueDate } : board
)
);
setEditingBoard(null); // Reset after editing
Expand All @@ -63,7 +56,6 @@ export default function KanbanListView() {
KanbanAPI.createKanbanBoardWithDetailsObservable({
name,
dueDate,
description,
}).subscribe({
next: (board) => {
setKanbanBoards((prevBoards) => [...prevBoards, board]);
Expand Down Expand Up @@ -194,7 +186,6 @@ export default function KanbanListView() {
? {
name: editingBoard.name,
dueDate: editingBoard.dueDate,
description: editingBoard.description,
}
: undefined
} // Use undefined when editingBoard is null
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utilities/types.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type KanbanBoard = {
id: number;
name: string;
description: string;
description?: string;
startDate: string;
dueDate: string;
users: UserInfo[];
Expand Down
11 changes: 1 addition & 10 deletions frontend/test/components/forms/add-board-form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe("AddBoardForm Component", () => {
test("renders form with empty inputs by default", () => {
setup();
expect(screen.getByPlaceholderText(/enter board name/i)).toHaveValue("");
expect(screen.getByPlaceholderText(/enter description/i)).toHaveValue("");
expect(screen.getByLabelText(/due date/i)).toHaveValue("");
expect(
screen.getByRole("heading", { name: /create new board/i })
Expand All @@ -35,17 +34,13 @@ describe("AddBoardForm Component", () => {
const defaultValues = {
name: "Test Board",
dueDate: "2023-12-31",
description: "Test Description",
};
setup({ defaultValues });

expect(screen.getByPlaceholderText(/enter board name/i)).toHaveValue(
"Test Board"
);
expect(screen.getByLabelText(/due date/i)).toHaveValue("2023-12-31");
expect(screen.getByPlaceholderText(/enter description/i)).toHaveValue(
"Test Description"
);
expect(
screen.getByRole("heading", { name: /edit board/i })
).toBeInTheDocument();
Expand All @@ -60,16 +55,12 @@ describe("AddBoardForm Component", () => {
fireEvent.change(screen.getByLabelText(/due date/i), {
target: { value: "2023-11-20" },
});
fireEvent.change(screen.getByPlaceholderText(/enter description/i), {
target: { value: "A description" },
});

fireEvent.click(screen.getByRole("button", { name: /create board/i }));

expect(defaultProps.onSubmit).toHaveBeenCalledWith(
"New Board",
"2023-11-20",
"A description"
"2023-11-20"
);
});

Expand Down
5 changes: 0 additions & 5 deletions frontend/test/components/kanbans/kanban-list-view.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ describe("KanbanListView", () => {
id: 1,
name: "Test Board 1",
dueDate: "2024-09-30",
description: "Description 1",
users: [],
tasks: [],
startDate: "2024-09-01",
Expand All @@ -34,7 +33,6 @@ describe("KanbanListView", () => {
id: 2,
name: "Test Board 2",
dueDate: "2024-10-05",
description: "Description 2",
users: [],
tasks: [],
startDate: "2024-09-01",
Expand Down Expand Up @@ -81,9 +79,6 @@ describe("KanbanListView", () => {
fireEvent.change(screen.getByLabelText(/due date/i), {
target: { value: "2024-11-01" },
});
fireEvent.change(screen.getByPlaceholderText(/description/i), {
target: { value: "New Description" },
});
fireEvent.click(screen.getByRole("button", { name: /create board/i }));
// Wait for the new board to be rendered
expect(await screen.findByText("New Board")).toBeInTheDocument();
Expand Down

0 comments on commit 4fb7860

Please sign in to comment.