diff --git a/.github/workflows/mocha.yml b/.github/workflows/mocha.yml index c6472ea..f8be97f 100644 --- a/.github/workflows/mocha.yml +++ b/.github/workflows/mocha.yml @@ -1,4 +1,4 @@ -name: Node.JS CI/CD +name: Mocha Tests on: push: diff --git a/Cypress/react_todo/cypress/downloads/downloads.htm b/Cypress/react_todo/cypress/downloads/downloads.htm deleted file mode 100644 index 53acb93..0000000 Binary files a/Cypress/react_todo/cypress/downloads/downloads.htm and /dev/null differ diff --git a/Cypress/react_todo/cypress/e2e/todo.cy.js b/Cypress/react_todo/cypress/e2e/todo.cy.js index c6ca5e7..23bfefb 100644 --- a/Cypress/react_todo/cypress/e2e/todo.cy.js +++ b/Cypress/react_todo/cypress/e2e/todo.cy.js @@ -1,5 +1,32 @@ -describe('Todo actions', () => { - it('adds todo item', () => { - cy.visit('http://localhost:5173/Todo-App/') - }) -}) \ No newline at end of file +import { db } from "../../src/firebase"; +import { collection, deleteDoc, doc, getDocs } from "firebase/firestore"; + +describe("Todo actions", () => { + beforeEach(async () => { + if (!db) { + throw new Error("Firestore not found"); + } + //Delete all todos from firestore + const q = collection(db, "todos"); + const snap = await getDocs(q); + snap.forEach(async (d) => { + console.log(d); + await deleteDoc(doc(db, "todos", d.id)); + }); + cy.visit("http://localhost:5173/"); + }); + it("Add a todo item", () => { + //Ensure no li present + cy.get('li').should('not.exist'); + cy.get('[data-testid="todo-text"]').type("New todo item"); + cy.get('[data-testid="todo-add"]').click(); + cy.get('li').should('have.length', 1); + }); + it ("Delete a todo item", () => { + cy.get('[data-testid="todo-text"]').type("New todo item"); + cy.get('[data-testid="todo-add"]').click(); + cy.get('li').should('have.length', 1); + cy.get('[data-testid="todo-delete"]').click(); + cy.get('li').should('not.exist'); + }); +}); diff --git a/Cypress/react_todo/cypress/screenshots/todo.cy.js/Todo actions -- Delete a todo item (failed).png b/Cypress/react_todo/cypress/screenshots/todo.cy.js/Todo actions -- Delete a todo item (failed).png new file mode 100644 index 0000000..7acd9bd Binary files /dev/null and b/Cypress/react_todo/cypress/screenshots/todo.cy.js/Todo actions -- Delete a todo item (failed).png differ diff --git a/Cypress/react_todo/cypress/videos/todo.cy.js.mp4 b/Cypress/react_todo/cypress/videos/todo.cy.js.mp4 new file mode 100644 index 0000000..cab31b5 Binary files /dev/null and b/Cypress/react_todo/cypress/videos/todo.cy.js.mp4 differ diff --git a/Cypress/react_todo/src/App.jsx b/Cypress/react_todo/src/App.jsx index 61b8043..02d5488 100644 --- a/Cypress/react_todo/src/App.jsx +++ b/Cypress/react_todo/src/App.jsx @@ -70,13 +70,16 @@ const App = () => {