diff --git a/cypress/fixtures/article.json b/cypress/fixtures/article.json new file mode 100644 index 0000000..2f0c22f --- /dev/null +++ b/cypress/fixtures/article.json @@ -0,0 +1,19 @@ +{ + "article": { + "title": "статья", + "slug": "-45l18w", + "body": "уцауцауц", + "createdAt": "2020-11-01T14:59:39.404Z", + "updatedAt": "2020-11-01T14:59:39.404Z", + "tagList": [], + "description": "цуцуа", + "author": { + "username": "sdfsdfsadsdfsdf", + "bio": null, + "image": "https://static.productionready.io/images/smiley-cyrus.jpg", + "following": false + }, + "favorited": false, + "favoritesCount": 0 + } +} \ No newline at end of file diff --git a/cypress/integration/home.spec.js b/cypress/integration/home.spec.js index 5cff51c..ce62cd1 100644 --- a/cypress/integration/home.spec.js +++ b/cypress/integration/home.spec.js @@ -1,4 +1,4 @@ -describe('View the homepage by guest', () => { +describe('View the homepage', () => { beforeEach(() => { cy.server() cy.route2('GET', /articles\?tag=butt/, { fixture: 'article_of_tag' }).as('article_of_tag') diff --git a/cypress/integration/like-follow.spec.js b/cypress/integration/like-follow.spec.js new file mode 100644 index 0000000..f80e0a2 --- /dev/null +++ b/cypress/integration/like-follow.spec.js @@ -0,0 +1,42 @@ +describe('test for like-follow mode', () => { + beforeEach(() => { + cy.server() + cy.route2('GET', /articles\?tag=butt/, { fixture: 'article_of_tag' }).as('article_of_tag') + cy.route2('GET', /articles\?/, { fixture: 'articles.json' }).as('getArticles') + cy.route2('GET', /articles\//, { fixture: 'article.json' }).as('getArticle') + cy.route2('GET', /tags/, { fixture: 'tags.json' }).as('getTags') + + cy.visit('/') + }) + + it('no-login:like artiles', () => { + cy.get('i.ion-heart:first') + .click() + + cy.url() + .should('contain', 'login') + + cy.get('h1.text-xs-center') + .should('contain.text', ' Sign in ') + }) + + it.only('no-login:follow author', () => { + cy.get('.article-preview:first') + .click() + + cy.url() + .should('contain', 'article') + + cy.get('body') + .should('contain', ' to add comments on this article. ') + + cy.get('.article-meta button.space:first') + .should('contain.text', ' Follow') + + cy.get('.article-meta button.space:first') + .click() + + cy.url() + .should('contain', 'login') + }) +}) diff --git a/cypress/integration/tag.spec.js b/cypress/integration/tag.spec.js index 1b736b2..ce1fe64 100644 --- a/cypress/integration/tag.spec.js +++ b/cypress/integration/tag.spec.js @@ -1,4 +1,4 @@ -describe('View the homepage by guest', () => { +describe('test for tag mode', () => { beforeEach(() => { cy.server() cy.route2('GET', /articles\?tag=butt/, { fixture: 'article_of_tag' }).as('article_of_tag')