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 = () => {

Todo

setInput(e.target.value)} className={style.input} type="text" placeholder="Add your todo..." /> -
diff --git a/Cypress/react_todo/src/components/Todo.jsx b/Cypress/react_todo/src/components/Todo.jsx index eb99a38..2d33614 100644 --- a/Cypress/react_todo/src/components/Todo.jsx +++ b/Cypress/react_todo/src/components/Todo.jsx @@ -26,7 +26,7 @@ const Todo = ({ todo, toggleComplete, deleteTodo }) => { {todo.text}

- + ); }; diff --git a/Mocha/mongodb/test/mongodb.test.mjs b/Mocha/mongodb/test/mongodb.test.mjs index 5ec9e3d..cac678c 100644 --- a/Mocha/mongodb/test/mongodb.test.mjs +++ b/Mocha/mongodb/test/mongodb.test.mjs @@ -10,11 +10,12 @@ describe('insert', function() { before(async function() { config(); - connection = new MongoClient(process.env.MONGO_URI, { + const remoteurl = "mongodb+srv://chester_the_tester:pfwcs@pfw-cs.ctovaum.mongodb.net/?retryWrites=true&w=majority&appName=pfw-cs"; + connection = new MongoClient(remoteurl, { useNewUrlParser: true, useUnifiedTopology: true, }); - db = connection.db(process.env.MOCHA_DB); + db = connection.db("mocha_test"); users = db.collection("users"); users.deleteMany({}); });