-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add social tests #8
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"username": "test_anton", | ||
"email": "test_anton@gmail.com", | ||
"username": "test_manual4", | ||
"email": "test_manual4@gmail.com", | ||
"password": "xyzXYZ123_" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
///<reference types='cypress' /> | ||
import { getRandomNumber } from '/cypress/support/utils.js'; | ||
import { login } from '/cypress/support/shared.js'; | ||
import meUser from '/cypress/fixtures/me-user.json'; | ||
import { setJwtToken } from '/cypress/support/utils'; | ||
|
||
function selectFirstArticle() { | ||
waitForArticlesList(); | ||
cy.get('@articleList') | ||
.find('.article-preview') | ||
// .should('have.length', 12) | ||
.should('have.length.greaterThan', 2) | ||
.eq(0) | ||
.as('firstArticle'); | ||
} | ||
function waitForArticlesList() { | ||
cy.get('@articleList') | ||
.contains('.article-preview', 'Loading') | ||
.should('not.be.visible'); | ||
} | ||
|
||
function openGlobalFeed() { | ||
cy.get('.feed-toggle a.nav-link[ng-class*=all]').click(); | ||
} | ||
|
||
function checkActiveYourFeed() { | ||
cy.get('@yourFeed').should('have.class', 'active'); | ||
} | ||
|
||
function subscribeFromUser() { | ||
// meUser.username | ||
cy.get('@firstArticle').find('.author').as('describedAuthor').click(); | ||
cy.get('@describedAuthor') | ||
.invoke('text') | ||
.invoke('trim') | ||
.as('subscribedAuthorName'); | ||
cy.get('follow-btn button') | ||
.should('contain', 'Follow') | ||
.click() | ||
.as('followButton'); | ||
// TODO: improve selector | ||
cy.get('@followButton').should('contain', 'Unfollow'); | ||
} | ||
|
||
function unsubscribeFromUser() { | ||
checkActiveYourFeed(); | ||
selectFirstArticle(); | ||
cy.get('@firstArticle').find('.author').as('undescribedAuthor').click(); | ||
cy.get('@undescribedAuthor') | ||
.invoke('text') | ||
.invoke('trim') | ||
.as('unsubscribedAuthorName'); | ||
cy.get('follow-btn button') | ||
.should('contain', 'Unfollow') | ||
.click() | ||
.as('UnfollowButton'); | ||
// TODO: improve selector | ||
cy.get('@UnfollowButton').should('contain', 'Follow'); | ||
|
||
} | ||
|
||
function unsubscribeFromAll() { | ||
cy.get('@buttonHome').click(); | ||
waitForArticlesList(); | ||
cy.get('@articleList').find('.article-preview') | ||
.then(articles => { | ||
cy.log(articles.length); | ||
if (articles.length > 2) { | ||
cy.wrap(articles).eq(0).click(); | ||
unsubscribeFromUser(); | ||
unsubscribeFromAll(); | ||
} | ||
}); | ||
} | ||
|
||
function goToHomePage() { | ||
cy.get('@appHeader') | ||
.find('[show-authed=true] [ui-sref="app.home"]').as('buttonHome') | ||
.click(); | ||
} | ||
|
||
function deleteAllMyArticles() { | ||
cy.get('@appHeader').find('[ui-sref*=username]').click(); | ||
debugger; | ||
cy.wait(5000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment why do you need it here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what is wrong! But without cy.location('hash').should('eq', '#/@test_manual4'); or cy.url().should("include", "#/@test_manual4"); but it doesn't work too https://www.awesomescreenshot.com/video/14393554?key=918860b78fd72922afa44bb567f51de3 Help me, please |
||
// waitForArticlesList(); | ||
|
||
cy.get('.articles-toggle .nav-link[ui-sref*=main]').should('have.class', 'active'); | ||
cy.get('@articleList').find('.article-preview') | ||
.then(articles => { | ||
cy.log(articles.length); | ||
if (articles.length > 2) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have two |
||
deleteMyArticle(); | ||
deleteAllMyArticles(); | ||
} | ||
}); | ||
} | ||
|
||
function deleteMyArticle() { | ||
|
||
cy.get('@articleList').find('.article-preview').eq(0).click(); | ||
cy.get('.article-actions button[ng-click*=delete]').click(); | ||
checkActiveYourFeed(); | ||
} | ||
|
||
describe('Social', () => { | ||
|
||
beforeEach(() => { | ||
cy.visit('/'); | ||
cy.get('.navbar').should('be.visible').as('appHeader'); | ||
|
||
// cy.get('@token') | ||
cy.readFile('token.txt') | ||
.should('not.be.empty') | ||
.then(token => { | ||
cy.visit('/', { | ||
onBeforeLoad: (window) => setJwtToken(window, token) | ||
}); | ||
}); | ||
|
||
cy.get('.navbar').should('be.visible') | ||
.should('contain.text', meUser.username); | ||
|
||
cy.get('article-list').as('articleList'); | ||
cy.get('@appHeader').find('[show-authed=true] [ui-sref="app.home"]').as('buttonHome'); | ||
cy.get('.feed-toggle a.nav-link[ng-class*=feed]').as('yourFeed'); | ||
cy.location('hash').should('eq', '#/'); | ||
}); | ||
|
||
it('should do subscribe to user', () => { | ||
|
||
deleteAllMyArticles(); | ||
unsubscribeFromAll(); | ||
openGlobalFeed(); | ||
selectFirstArticle(); | ||
subscribeFromUser(); | ||
|
||
cy.get('@subscribedAuthorName').then((authorName) => { | ||
cy.log(authorName); | ||
console.log(authorName); | ||
|
||
goToHomePage(); | ||
|
||
cy.get('.home-page').should('contain', authorName); | ||
}); | ||
|
||
}); | ||
|
||
it('should do unsubscribe from user', () => { | ||
|
||
deleteAllMyArticles(); | ||
|
||
cy.get('@buttonHome').click(); | ||
|
||
checkActiveYourFeed(); | ||
waitForArticlesList(); | ||
|
||
cy.get('@articleList').find('.article-preview') | ||
.then(articles => { | ||
cy.log(articles.length); | ||
if (articles.length === 2) { | ||
|
||
openGlobalFeed(); | ||
selectFirstArticle(); | ||
subscribeFromUser(); | ||
|
||
cy.get('@subscribedAuthorName').then((authorName) => { | ||
cy.log(authorName); | ||
console.log(authorName); | ||
|
||
goToHomePage(); | ||
|
||
cy.get('.home-page').should('contain', authorName); | ||
}); | ||
} | ||
}); | ||
|
||
unsubscribeFromUser(); | ||
|
||
cy.get('@unsubscribedAuthorName').then((authorName) => { | ||
cy.log(authorName); | ||
console.log(authorName); | ||
|
||
goToHomePage(); | ||
|
||
cy.get('.home-page').should('not.contain', authorName); | ||
}); | ||
|
||
}); | ||
|
||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
export function getRandomNumber(min, max) { | ||
return Math.round(Math.random() * (max - min)) + min; | ||
} | ||
|
||
export function setJwtToken(window, token) { | ||
window.localStorage.setItem('jwtToken', token); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
Subscribe to user test case | ||
|
||
# It should do subscribe to user: | ||
|
||
## Before | ||
|
||
1. Open https://demo.realworld.io/ | ||
2. Repeat 2-9 from [login user](/test_cases/login_user.md) | ||
3. Url should be `/#/` — main page | ||
|
||
## Delete all my articles | ||
|
||
4. Click on button that contain username | ||
5. If articles is list not empty then | ||
* click button **Delete** | ||
* go to step 4 | ||
|
||
## Delete all subscriptions | ||
|
||
6. In feed toggle menu should be active **Your Feed** | ||
7. Your Feed contains text "No articles are here... yet"? | ||
* No, continue. | ||
* Yes, go to step 11. | ||
8. Select first article | ||
9. Click button **Unfollow** | ||
10. Confirm that the button text changes to **Follow** | ||
11. Click **Home** | ||
12. Back to step 4 | ||
|
||
## Select first article | ||
|
||
13. Click **Global Feed** in feed toggle menu | ||
14. List should have 10 article cards | ||
15. Select first article | ||
|
||
## Subscribe to user by following him | ||
|
||
16. Click button **Follow** | ||
17. Confirm that the button text changes to **Unfollow** | ||
|
||
## Check user in your subscription list | ||
|
||
18. Click **Home** | ||
17. In feed toggle menu should be active **Your Feed** | ||
19. Check `{author}` should be visible | ||
|
||
## Where: | ||
|
||
- `{author}` — subscribed author |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Unsubscribe to user test case | ||
|
||
# It should do unsubscribe from user: | ||
|
||
## Before | ||
|
||
1. Open https://demo.realworld.io/ | ||
2. Repeat steps 2-9 from [login user](/test_cases/login_user.md) | ||
3. Url should be `/#/` — main page | ||
|
||
## Delete all my articles | ||
|
||
4. Click on button that contain username | ||
5. If articles is list not empty then | ||
* click button **Delete** | ||
* go to step 4 | ||
|
||
## Checking for a subscribtion | ||
|
||
6. In feed toggle menu should be active **Your Feed** | ||
7. Your Feed contains text "No articles are here... yet"? | ||
* No, go to step 14. | ||
* Yes, continue. | ||
|
||
## Subscribe to user by following him | ||
|
||
8. Click **Global Feed** in feed toggle menu | ||
9. List should have 10 article cards | ||
10. Select first article | ||
11. Click buttun **Follow** | ||
12. Confirm that the button text changes to **Unfollow** | ||
|
||
## Check user in your subscription list | ||
|
||
13. Click **Home** | ||
14. In feed toggle menu should be active **Your Feed** | ||
15. Check `{authorFollowed}` should be visible | ||
|
||
## Unsubscribe from user by unfollowing him | ||
|
||
16. Select first article | ||
17. Click button **Unfollow** | ||
16. Confirm that the button text changes to **Follow** | ||
18. Click **Home** | ||
19. In feed toggle menu should be active **Your Feed** | ||
20. Check that your subscription list does not contain `{authorUnfollowed}` | ||
|
||
## Where: | ||
|
||
- `{authorFollow}` — subscribed author | ||
- `{authorUnfollow}` - unsubscribed author |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we find better selector? Is it
<a>
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if use
<a>
then find two elementshttps://disk.yandex.com/i/qKPV5o6XviIHlg