sf-b5f / cypress /integration /index.spec.js
Mikelue's picture
Add 12 files
1512e66
raw
history blame
1.81 kB
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);
});
});