forked from alan2207/bulletproof-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
964 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
|
||
# testing | ||
/coverage | ||
/cypress/videos | ||
/cypress/screenshots | ||
|
||
# production | ||
/build | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
root: true, | ||
plugins: ['eslint-plugin-cypress'], | ||
env: { 'cypress/globals': true }, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
const faker = require('faker'); | ||
|
||
describe('smoke', () => { | ||
it('should handle normal app flow', () => { | ||
const user = { | ||
firstName: faker.internet.userName(), | ||
lastName: faker.internet.userName(), | ||
email: faker.internet.email(), | ||
password: faker.internet.password(), | ||
teamName: faker.company.companyName(), | ||
}; | ||
|
||
const discussion = { | ||
title: faker.company.catchPhrase(), | ||
body: faker.lorem.sentence(), | ||
}; | ||
|
||
// registration: | ||
cy.visit('http://localhost:3000/auth/register'); | ||
|
||
cy.findByRole('textbox', { | ||
name: /first name/i, | ||
}).type(user.firstName); | ||
cy.findByRole('textbox', { | ||
name: /last name/i, | ||
}).type(user.lastName); | ||
cy.findByRole('textbox', { | ||
name: /email address/i, | ||
}).type(user.email); | ||
cy.findByLabelText(/password/i).type(user.password); | ||
|
||
cy.findByRole('textbox', { | ||
name: /team name/i, | ||
}).type(user.teamName); | ||
|
||
cy.findByRole('button', { | ||
name: /register/i, | ||
}).click(); | ||
|
||
cy.findByRole('heading', { | ||
name: `Welcome ${user.firstName} ${user.lastName}`, | ||
}).should('exist'); | ||
|
||
cy.findByRole('link', { | ||
name: /discussions/i, | ||
}).click(); | ||
|
||
// create discussion: | ||
cy.findByRole('button', { | ||
name: /create discussion/i, | ||
}).click(); | ||
|
||
cy.findByRole('dialog').within(() => { | ||
cy.findByRole('textbox', { | ||
name: /title/i, | ||
}).type(discussion.title); | ||
cy.findByRole('textbox', { | ||
name: /body/i, | ||
}).type(discussion.body); | ||
cy.findByRole('button', { | ||
name: /submit/i, | ||
}).click(); | ||
}); | ||
cy.findByRole('alert', { | ||
name: /discussion created/i, | ||
}).within(() => { | ||
cy.findByText(/discussion created/i).should('exist'); | ||
cy.findByRole('button').click(); | ||
}); | ||
cy.findByRole('dialog').should('not.exist'); | ||
|
||
cy.wait(200); | ||
|
||
// visit discussion page: | ||
cy.findByRole('row', { | ||
name: `${discussion.title} View Delete`, | ||
}).within(() => { | ||
cy.findByRole('link', { | ||
name: /view/i, | ||
}).click(); | ||
}); | ||
|
||
cy.findByRole('heading', { | ||
name: discussion.title, | ||
}).should('exist'); | ||
|
||
// update | ||
|
||
cy.findByRole('button', { | ||
name: /update discussion/i, | ||
}).click(); | ||
|
||
const updatedDiscussion = { | ||
title: faker.company.catchPhrase(), | ||
body: faker.lorem.sentence(), | ||
}; | ||
|
||
cy.findByRole('dialog').within(() => { | ||
cy.findByRole('textbox', { | ||
name: /title/i, | ||
}) | ||
.clear() | ||
.type(updatedDiscussion.title); | ||
cy.findByRole('textbox', { | ||
name: /body/i, | ||
}) | ||
.clear() | ||
.type(updatedDiscussion.body); | ||
cy.findByRole('button', { | ||
name: /submit/i, | ||
}).click(); | ||
}); | ||
cy.findByRole('alert', { | ||
name: /discussion updated/i, | ||
}).within(() => { | ||
cy.findByText(/discussion updated/i).should('exist'); | ||
cy.findByRole('button').click(); | ||
}); | ||
|
||
cy.findByRole('heading', { | ||
name: updatedDiscussion.title, | ||
}).should('exist'); | ||
|
||
// create comment | ||
|
||
const comment = { | ||
body: faker.lorem.sentence(), | ||
}; | ||
|
||
cy.findByRole('button', { | ||
name: /create comment/i, | ||
}).click(); | ||
|
||
cy.findByRole('dialog').within(() => { | ||
cy.findByRole('textbox', { | ||
name: /body/i, | ||
}).type(comment.body, { force: true }); // for some reason it requires force to be set to true | ||
|
||
cy.findByRole('button', { | ||
name: /submit/i, | ||
}).click(); | ||
}); | ||
cy.findByRole('alert', { | ||
name: /comment created/i, | ||
}).within(() => { | ||
cy.findByText(/comment created/i).should('exist'); | ||
cy.findByRole('button').click(); | ||
}); | ||
|
||
cy.findByRole('list', { | ||
name: 'comments', | ||
}).within(() => { | ||
cy.findByText(comment.body).should('exist'); | ||
}); | ||
|
||
cy.wait(200); | ||
|
||
// delete comment | ||
|
||
cy.findByRole('list', { | ||
name: 'comments', | ||
}).within(() => { | ||
cy.findByRole('listitem', { | ||
name: `comment-${comment.body}-0`, | ||
}).within(() => { | ||
cy.findByRole('button', { | ||
name: /delete comment/i, | ||
}).click(); | ||
}); | ||
}); | ||
|
||
cy.findByRole('dialog').within(() => { | ||
cy.findByRole('button', { | ||
name: /delete/i, | ||
}).click(); | ||
}); | ||
|
||
cy.findByRole('alert', { | ||
name: /comment deleted/i, | ||
}).within(() => { | ||
cy.findByText(/comment deleted/i).should('exist'); | ||
cy.findByRole('button').click(); | ||
}); | ||
|
||
cy.findByRole('list', { | ||
name: 'comments', | ||
}).within(() => { | ||
cy.findByText(comment.body).should('not.exist'); | ||
}); | ||
|
||
// go back to discussions list | ||
|
||
cy.findByRole('link', { | ||
name: /discussions/i, | ||
}).click(); | ||
|
||
cy.wait(200); | ||
|
||
// delete discussion: | ||
cy.findByRole('row', { | ||
name: `${updatedDiscussion.title} View Delete`, | ||
}).within(() => { | ||
cy.findByRole('button', { | ||
name: 'Delete', | ||
}).click(); | ||
}); | ||
|
||
cy.findByRole('dialog').within(() => { | ||
cy.findByRole('button', { | ||
name: /delete/i, | ||
}).click(); | ||
}); | ||
|
||
cy.findByRole('alert', { | ||
name: /discussion deleted/i, | ||
}).within(() => { | ||
cy.findByText(/discussion deleted/i).should('exist'); | ||
cy.findByRole('button').click(); | ||
}); | ||
|
||
cy.findByRole('row', { | ||
name: `${updatedDiscussion.title} View Delete`, | ||
}).should('not.exist'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
/** | ||
* @type {Cypress.PluginConfig} | ||
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
module.exports = (on, config) => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) | ||
import '@testing-library/cypress/add-commands'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// *********************************************************** | ||
// This example support/index.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands'; | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') | ||
|
||
cy.faker = require('faker'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["es5", "dom"], | ||
"types": ["cypress", "@testing-library/cypress"] | ||
}, | ||
"include": ["**/*.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.