File size: 1,811 Bytes
1512e66 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
describe("Complete App", () => {
beforeEach(() => cy.visit("/"));
it("displays the title", () => {
cy.get("h1").should("have.text", "Todo List");
});
it("displays the create task form", () => {
cy.get("form").should("have.attr", {
"method": "POST",
"action": "/task/create",
});
cy.get("input[name=title]").should("be.visible");
cy.get("input[name=deadline]").should("be.visible");
cy.get("textarea[name=description]").should("be.visible");
cy.get("button[type=submit]").should("be.visible");
});
it("allows the user to create a new task", () => {
const newTask = {
title: "New task",
deadline: "2024-01-01",
description: "A new task"
};
cy.get("input[name=title]").type(newTask.title);
cy.get("input[name=deadline]").type(newTask.deadline);
cy.get("textarea[name=description]").type(newTask.description);
cy.get("button[type=submit]").click();
cy.get("h2").should("have.text", "Tasks");
cy.get("li").should("have.length", 1);
cy.get("li:first").should("contain.text", newTask.title);
cy.get("li:first").should("contain.text", newTask.deadline);
cy.get("li:first").should("contain.text", newTask.description);
});
it("allows the user to mark a task as complete", () => {
cy.get("input[type=checkbox]").should("be.visible");
cy.get("input[type=checkbox]").click();
cy.get("input[type=checkbox]").should("be.checked");
});
it("allows the user to delete a task", () => {
cy.get("li:first").should("contain.text", "New task");
cy.get("li:first").find("button.delete-task").click();
cy.get("li:first").find("button.delete-task").should("have.text", "Delete");
cy.get("li:first").should("contain.text", "Task deleted");
cy.get("li").should("have.length", 0);
});
}); |