Skip to content

Commit 1b91bf7

Browse files
committed
added more cypress coverage, updated test scenarios, updated selenium installation instructions
1 parent 729d6a6 commit 1b91bf7

File tree

7 files changed

+161
-53
lines changed

7 files changed

+161
-53
lines changed

INSTALLATION.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ Please run the test with caution and comment out the code that drops database af
8585
npm run start:test
8686
```
8787

88-
- Step 2: Run standalone selenium tests
88+
- Step 2: Run standalone selenium tests - These tests required to run sequentially due to possible browser conflicts.
8989
```
90-
npm run test:e2e
90+
npm run test:e2e -- --runInBand
9191
```
9292

9393
- If you want to run whole test suite:
@@ -97,9 +97,14 @@ Please run the test with caution and comment out the code that drops database af
9797
```
9898

9999

100-
Selenium tests written in Jest using selenium-webdriver and uses firefox browser.
100+
Selenium tests written in Jest using selenium-webdriver and uses firefox and chrome browser.
101101

102102
### **DEPENDENCIES:**
103+
- Chrome:
104+
```
105+
npm install chromedriver
106+
```
107+
103108
- Firefox:
104109
```
105110
npm install geckodriver --save-dev

betta_test_scenarios.md

Lines changed: 98 additions & 48 deletions
Large diffs are not rendered by default.

cypress/integration/user_can_logout.js renamed to cypress/integration/user_logout_tests.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,30 @@ describe("Logout", () => {
4242

4343
});
4444

45+
it("A user can logout from their new post page and cannot access the posts page", () => {
46+
47+
// sign in
48+
cy.signIn();
49+
50+
cy.url().should("include", "/posts");
51+
52+
//click new post and go to new post page
53+
cy.get('a.global-button.new-post-link[href="/posts/new"]').click();
54+
55+
//click logout
56+
cy.get('input[type="submit"][value="Log Out"].global-button.logout').click();
57+
58+
cy.url().should("not.include", "/posts");
59+
60+
//should be back on login screen
61+
cy.url().should("include", "/sessions/new");
62+
63+
//try and access posts page
64+
cy.visit("/posts");
65+
66+
cy.url().should("include", "/sessions/new");
67+
68+
});
69+
4570

4671
});

cypress/integration/user_can_see_and_create_post.js renamed to cypress/integration/user_post_comments_tests.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,38 @@ it("User can click on and add a comment to a post", () => {
113113
cy.get('input#comment.comment-box.input-box').first().as('commentInput');
114114

115115
// Type text into the input element
116-
cy.get('@commentInput').type(new_comment);
116+
cy.get('@commentInput').type(`${new_comment}{enter}`);
117+
118+
117119

118120
// Assert that any of the elements contains the entered text eventually
119-
cy.get('input#comment.comment-box.input-box').should('have.value', new_comment);
121+
cy.get('p.comment-content').should('contain', new_comment);
122+
123+
});
124+
125+
it("User cannot add a comment that is too long to a post", () => {
126+
127+
const new_post_4 = chance.paragraph({ sentences: 1 })
128+
const new_comment_2 = chance.paragraph({ sentences: 10 })
129+
// sign in
130+
cy.signIn();
131+
132+
//click new post
133+
cy.get('a.global-button.new-post-link[href="/posts/new"]').click();
134+
135+
cy.get('#message').type(new_post_4);
136+
cy.get('input[type="submit"][value="Submit"]').click();
137+
138+
// Grab any one of the input elements
139+
cy.get('input#comment.comment-box.input-box').first().as('commentInput');
140+
141+
// Type text into the input element
142+
cy.get('@commentInput').type(`${new_comment_2}{enter}`);
143+
144+
145+
// Assert that any of the elements does not contain the long comment
146+
cy.get('p.comment-content').should('not.have.value', new_comment_2);
147+
120148

121149
});
122150

0 commit comments

Comments
 (0)