forked from cypress-io/cypress-example-conduit-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile-spec.js
More file actions
67 lines (59 loc) · 2.01 KB
/
profile-spec.js
File metadata and controls
67 lines (59 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/// <reference types="Cypress" />
describe('Profile', () => {
beforeEach(() => {
cy.task('cleanDatabase')
cy.registerUserIfNeeded()
cy.login()
})
it('shows my profile', () => {
cy.get('[data-cy=profile]').click()
cy.location('pathname').should('equal', '/@testuser')
cy.get('[data-cy=edit-profile-settings]').click()
})
it('logs out via profile', () => {
cy.get('[data-cy=profile]').click()
cy.location('pathname').should('equal', '/@testuser')
cy.get('[data-cy=edit-profile-settings]').click()
cy.get('[data-cy=logout]').click()
cy.get('[data-cy=sign-in]').should('be.visible')
})
it('can update my profile', () => {
cy.get('[data-cy=profile]').click()
cy.location('pathname').should('equal', '/@testuser')
cy.get('[data-cy="edit-profile-settings"]').click()
cy.get('[data-cy=bio]')
.clear()
.type('my new bio')
cy.get('form').submit()
cy.location('pathname').should('equal', '/')
// saved bio should be displayed
cy.get('[data-cy=profile]').click()
cy.location('pathname').should('equal', '/@testuser')
cy.get('[data-cy=user-info]')
.should('be.visible')
.find('[data-cy=bio]')
.should('have.text', 'my new bio')
})
it('shows favorite articles', () => {
cy.article({
title: 'first post',
description: 'first description',
body: 'first article',
tagList: ['first', 'testing']
})
cy.location('pathname').should('equal', '/article/first-post')
cy.get('[data-cy=home]').click()
cy.get('[data-cy=global-feed]').click()
cy.get('.article-preview')
.should('have.length', 1)
.first()
.find('[data-cy=fav-article]')
.click()
// check if the click has registered and the favorite flag has been set
.should('not.have.class', 'btn-outline-primary')
// check favorited articles feed
cy.get('[data-cy=profile]').click()
cy.get('[data-cy=favorited-articles]').click()
cy.get('.article-preview').should('have.length', 1)
})
})