Skip to content

Commit

Permalink
added e2e cypress testing for sprint 2 features
Browse files Browse the repository at this point in the history
  • Loading branch information
camybish committed Jun 14, 2023
1 parent e9432e4 commit 7dd3583
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
Empty file.
2 changes: 1 addition & 1 deletion frontend/cypress/e2e/signing_in.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe("Signing in", () => {

before(() => {
cy.signup("[email protected]", "12345678")
cy.signup("User", "[email protected]", "12345678")
})

it("with valid credentials, redirects to '/posts'", () => {
Expand Down
1 change: 1 addition & 0 deletions frontend/cypress/e2e/signing_up.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
describe("Signing up", () => {
it("with valid credentials, redirects to '/login'", () => {
cy.visit("/signup");
cy.get("#name").type("Someone")
cy.get("#email").type("[email protected]");
cy.get("#password").type("password");
cy.get("#submit").click();
Expand Down
33 changes: 33 additions & 0 deletions frontend/cypress/e2e/using_feed_page.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
describe("Signing in", () => {

before(() => {
cy.signup("User", "[email protected]", "12345678");
cy.login("[email protected]", "12345678");
});

it("creates a new post", () => {
cy.get("#newPost").type("Let's chat!");
cy.get("#submit").click();

cy.contains('div.message', "Let's chat!").should('be.visible');
});

it("throws an error if the user posts nothing", () => {
cy.get("#submit").click();

cy.contains('p.validation-error', "Please enter a post").should('be.visible');
})
it("displays your like when you like a post", () => {
cy.get("#newPost").type("Let's chat!");
cy.get("#submit").click();
cy.get(".like-button:first").click();

cy.contains('div.likes', "1").should('be.visible');
})

it("returns to login page after clicking logout", () => {
cy.get(".logout").click();

cy.url().should("include", "/login")
})
});
10 changes: 9 additions & 1 deletion frontend/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@
//
//
// -- This is a parent command --
Cypress.Commands.add('signup', (email, password) => {
Cypress.Commands.add('signup', (name, email, password) => {
cy.visit("/signup");
cy.get("#name").type(name);
cy.get("#email").type(email);
cy.get("#password").type(password);
cy.get("#submit").click();
})

Cypress.Commands.add('login', (email, password) => {
cy.visit("/login");
cy.get("#email").type(email);
cy.get("#password").type(password);
cy.get("#submit").click();
Expand Down

0 comments on commit 7dd3583

Please sign in to comment.