Skip to content

Commit

Permalink
Merge pull request #2 from bolitj01:GitHub-workflows
Browse files Browse the repository at this point in the history
GitHub-workflows
  • Loading branch information
bolitj01 authored Nov 14, 2024
2 parents af16866 + d08b71e commit 061c087
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mocha.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Node.JS CI/CD
name: Mocha Tests

on:
push:
Expand Down
Binary file removed Cypress/react_todo/cypress/downloads/downloads.htm
Binary file not shown.
37 changes: 32 additions & 5 deletions Cypress/react_todo/cypress/e2e/todo.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
describe('Todo actions', () => {
it('adds todo item', () => {
cy.visit('http://localhost:5173/Todo-App/')
})
})
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');
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Cypress/react_todo/cypress/videos/todo.cy.js.mp4
Binary file not shown.
5 changes: 4 additions & 1 deletion Cypress/react_todo/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,16 @@ const App = () => {
<h3 className={style.heading}>Todo</h3>
<form onSubmit={createTodo} className={style.form}>
<input
data-testid="todo-text"
value={input}
onChange={(e) => setInput(e.target.value)}
className={style.input}
type="text"
placeholder="Add your todo..."
/>
<button className={style.button}>
<button
data-testid="todo-add"
className={style.button}>
<AiOutlinePlus size={30} />
</button>
</form>
Expand Down
2 changes: 1 addition & 1 deletion Cypress/react_todo/src/components/Todo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Todo = ({ todo, toggleComplete, deleteTodo }) => {
{todo.text}
</p>
</div>
<button onClick={() => deleteTodo(todo.id)}>{<FaRegTrashAlt />}</button>
<button data-testid="todo-delete" onClick={() => deleteTodo(todo.id)}>{<FaRegTrashAlt />}</button>
</li>
);
};
Expand Down
5 changes: 3 additions & 2 deletions Mocha/mongodb/test/mongodb.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]/?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({});
});
Expand Down

0 comments on commit 061c087

Please sign in to comment.