Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ workflows:
- save-partial-coverage-report:
label: e2e

- cypress/run:
name: Firefox
executor: cypress/browsers-chrome73-ff68
post-install:
- run:
name: Install Cypress pre-release
environment:
CYPRESS_INSTALL_BINARY: https://cdn.cypress.io/beta/binary/3.6.1/linux-x64/circle-issue-1096-firefox-support-42fcf58b442cc6bdbc35f3d5e2c34682f910badc-184089/cypress.zip
command: npm install https://cdn.cypress.io/beta/npm/3.6.1/circle-issue-1096-firefox-support-42fcf58b442cc6bdbc35f3d5e2c34682f910badc-184085/cypress.tgz
record: true
start: npm start
wait-on: http://localhost:4100
group: firefox-tests
browser: firefox
no-workspace: true

- merge-coverage:
requires:
- cypress/run
44 changes: 24 additions & 20 deletions cypress/integration/new-post-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { title, about, article, tags } from '../fixtures/post'
import { stripIndent } from 'common-tags'
import { skipOn } from '@cypress/skip-test'

describe('New post', () => {
beforeEach(() => {
Expand Down Expand Up @@ -92,34 +93,37 @@ describe('New post', () => {

// check that each tag is displayed after post is shown
cy.url().should('match', /my-title$/)
tags.forEach(tag => cy.contains('.tag-default', tag))
tags.forEach((tag) => cy.contains('.tag-default', tag))
})

it('sets the post body at once', () => {
cy.contains('a.nav-link', 'New Post').click()
skipOn('firefox', () => {
// this test will run on every platform but Firefox
it('sets the post body at once', () => {
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')
// 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')

// to speed up creating the post, set the text as value
// and then trigger change event by typing "Enter"
const post = stripIndent`
// to speed up creating the post, set the text as value
// and then trigger change event by typing "Enter"
const post = stripIndent`
# Fast tests

> Speed up your tests using direct access to DOM elements

You can set long text all at once and then trigger \`onChange\` event.
`

cy.get('[data-cy=article]')
.invoke('val', post)
.type('{enter}')
cy.get('[data-cy=article]')
.invoke('val', post)
.type('{enter}')

cy.get('[data-cy=tags]').type('test{enter}')
cy.get('[data-cy=publish]').click()
cy.get('[data-cy=tags]').type('test{enter}')
cy.get('[data-cy=publish]').click()

cy.contains('h1', 'my title')
cy.contains('h1', 'my title')
})
})

it('adds a new post', () => {
Expand All @@ -142,7 +146,7 @@ describe('New post', () => {
.invoke('dispatch', {
type: 'UPDATE_FIELD_EDITOR',
key: 'body',
value: article
value: article,
})

// need to click "Enter" after each tag
Expand All @@ -157,14 +161,14 @@ describe('New post', () => {
// new article should be on the server
cy.request('http://localhost:3000/api/articles?limit=10&offset=0')
.its('body')
.should(body => {
.should((body) => {
expect(body).to.have.property('articlesCount', 1)
expect(body.articles).to.have.length(1)
const firstPost = body.articles[0]
expect(firstPost).to.contain({
title,
description: about,
body: article
body: article,
})
expect(firstPost.tagList).to.be.an('array')
const sortedTags = firstPost.tagList.sort()
Expand All @@ -186,7 +190,7 @@ describe('New post', () => {
.invoke('dispatch', {
type: 'UPDATE_FIELD_EDITOR',
key: 'body',
value: article
value: article,
})

// need to click "Enter" after each tag
Expand All @@ -209,7 +213,7 @@ describe('New post', () => {
title: 'first post',
description: 'first description',
body: 'first article',
tagList: ['first', 'testing']
tagList: ['first', 'testing'],
})
})
})
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,8 @@
},
"nyc": {
"exclude": "server/lib/migrations"
},
"dependencies": {
"@cypress/skip-test": "1.2.1"
}
}