From 22cfdc740db9890d8a14f7c05c48cb6dea27049d Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Tue, 25 Jun 2019 16:54:44 -0400 Subject: [PATCH] add editing post test --- .../src/components/Article/ArticleActions.js | 1 + cypress/integration/new-post-spec.js | 25 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/client/src/components/Article/ArticleActions.js b/client/src/components/Article/ArticleActions.js index 996ce374..1fa39421 100755 --- a/client/src/components/Article/ArticleActions.js +++ b/client/src/components/Article/ArticleActions.js @@ -19,6 +19,7 @@ const ArticleActions = props => { Edit Article diff --git a/cypress/integration/new-post-spec.js b/cypress/integration/new-post-spec.js index 376d946a..f1b8bf94 100644 --- a/cypress/integration/new-post-spec.js +++ b/cypress/integration/new-post-spec.js @@ -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 @@ -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', () => {