Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
add editing post test
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Jun 25, 2019
1 parent a064046 commit 22cfdc7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions client/src/components/Article/ArticleActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const ArticleActions = props => {
<Link
to={`/editor/${article.slug}`}
className='btn btn-outline-secondary btn-sm'
data-cy='edit-article'
>
<i className='ion-edit' /> Edit Article
</Link>
Expand Down
25 changes: 24 additions & 1 deletion cypress/integration/new-post-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,27 @@ describe('New post', () => {
cy.contains('[data-cy=comment]', 'great post 👍').should('be.visible')
})

it('can fav article', () => {
it('can edit an article', () => {
cy.contains('a.nav-link', 'New Post').click()

// I have added "data-cy" attributes to select input fields
cy.get('[data-cy=title]').type('my title')
cy.get('[data-cy=about]').type('about X')
cy.get('[data-cy=article]').type('this post is **important**.')
cy.get('[data-cy=tags]').type('test{enter}')
cy.get('[data-cy=publish]').click()
cy.location('pathname').should('equal', '/article/my-title')

cy.get('[data-cy=edit-article]').click()
cy.location('pathname').should('equal', '/editor/my-title')
cy.get('[data-cy=title]')
.clear()
.type('a brand new title')
cy.get('[data-cy=publish]').click()
cy.location('pathname').should('equal', '/article/a-brand-new-title')
})

it('can fav and unfav an article', () => {
cy.contains('a.nav-link', 'New Post').click()

// I have added "data-cy" attributes to select input fields
Expand All @@ -53,6 +73,9 @@ describe('New post', () => {
cy.get('[data-cy=profile]').click()
cy.location('pathname').should('equal', '/@testuser')
cy.contains('.article-preview', 'my title')
// now unfav article
.find('[data-cy=fav-article]')
.click()
})

it('deletes comment', () => {
Expand Down

0 comments on commit 22cfdc7

Please sign in to comment.