-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from bolitj01:GitHub-workflows
GitHub-workflows
- Loading branch information
Showing
8 changed files
with
41 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Node.JS CI/CD | ||
name: Mocha Tests | ||
|
||
on: | ||
push: | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); |
Binary file added
BIN
+279 KB
.../cypress/screenshots/todo.cy.js/Todo actions -- Delete a todo item (failed).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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({}); | ||
}); | ||
|