Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

Cypress test #177

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"language": "node_js",

"dist": "xenial",
"node_js": [
"stable"
]

script:
#run E2E tests
$(npm bin)/cypress run
}
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
6 changes: 6 additions & 0 deletions cypress/fixtures/profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"AppUrl" : "https://react-redux.realworld.io/",
"userName": "nchaubey",
"email": "[email protected]",
"Password" :"Conduit@123"
}
38 changes: 38 additions & 0 deletions cypress/integration/Conduit_Integration/AddComment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
describe('Cypress test for editing blog successfully', function() {

before(function () {
cy.fixture('profile').then(function (data) {
this.data = data;
})

})
it('Login to application and edit the blog', function() {
//Visit the Conduit - RealWorld Page
cy.OpenApplication(this.data.AppUrl);

// Login to application
cy.login(this.data.email, this.data.Password);

// Verify username after login
cy.get(':nth-child(4) > .nav-link').should('have.text',this.data.userName);

//click on Global Feed
cy.get('.feed-toggle > .nav > :nth-child(2) > .nav-link').click();

//Open a blogg to add comment
cy.get(':nth-child(1) > .preview-link > h1').click()

//Add a comment in a blog
cy.get('.form-control').type('Comment added');

cy.get('.btn').click();

// Verify comment added successfully
cy.get(':nth-child(1) > .card-block > .card-text').should('have.text','Comment added');

//Verify username for comment added
cy.get(':nth-child(1) > .card-footer > :nth-child(2)').should('have.text',this.data.userName);

})

})
34 changes: 34 additions & 0 deletions cypress/integration/Conduit_Integration/CreateBlog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
describe('Cypress test for creating blog successfully', function() {

before(function () {
cy.fixture('profile').then(function (data) {
this.data = data;
})
})


it('Login to application and create a blog', function() {
//Visit the Conduit - RealWorld Page
cy.OpenApplication(this.data.AppUrl);


// Login to application
cy.login(this.data.email, this.data.Password);

// Verify username after login
cy.get(':nth-child(4) > .nav-link').should('have.text',this.data.userName);


// CLick on New Post tab
cy.get('.container > .nav > :nth-child(2) > .nav-link').click();

// Enter new article details
cy.get(':nth-child(1) > .form-control').type("Test Article"+ Math.floor(Math.random() * 100));
cy.get(':nth-child(2) > .form-control').type('This is test article');
cy.get(':nth-child(3) > .form-control').type('jncoihfpimncknoifheklfnnvdkjnvwojnwlk');
cy.get(':nth-child(4) > .form-control').type('test, Test, TEST');

cy.get('.btn').click();

})
})
29 changes: 29 additions & 0 deletions cypress/integration/Conduit_Integration/DeleteBLog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
describe('Cypress test for editing blog successfully', function() {

before(function () {
cy.fixture('profile').then(function (data) {
this.data = data;
})
})

it('Login to application and edit the blog', function() {
//Visit the Conduit - RealWorld Page
cy.OpenApplication(this.data.AppUrl);

// Login to application
cy.login(this.data.email, this.data.Password);

// Verify username after login
cy.get(':nth-child(4) > .nav-link').should('have.text',this.data.userName).click();

cy.reload();
//click on latest blog
cy.get(':nth-child(1) > .preview-link > h1').click();

//Click on delete blog button
cy.get('.btn-outline-danger').click()

})

})

41 changes: 41 additions & 0 deletions cypress/integration/Conduit_Integration/EditBlog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
describe('Cypress test for editing blog successfully', function() {

before(function () {
cy.fixture('profile').then(function (data) {
this.data = data;
})
})

it('Login to application and edit the blog', function() {
//Visit the Conduit - RealWorld Page
cy.OpenApplication(this.data.AppUrl);

// Login to application
cy.login(this.data.email, this.data.Password);

// Verify username after login
cy.get(':nth-child(4) > .nav-link').should('have.text',this.data.userName).click();

cy.reload();
//click on latest blog
cy.get(':nth-child(1) > .preview-link > h1').click();

//click on edit blog
cy.get('.btn-outline-secondary').click();

var EditedDesc = "This is edited";
// Edit the article description
cy.get(':nth-child(2) > .form-control').click().focused().clear().type('This is edited');

//Publish the blog
cy.get('.btn').click();
cy.get(':nth-child(1) > .nav-link').click();
cy.get(':nth-child(4) > .nav-link').click();

cy.reload();

//Verify edited blog description
cy.contains('edited').should('contain','edited');

})
})
41 changes: 41 additions & 0 deletions cypress/integration/Conduit_Integration/Register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

describe('Cypress test for page open and registration', function() {
before(function () {
cy.fixture('profile').then(function (data) {
this.data = data;
})
})

it('CLick on SignUp and and verify registartion', function() {

//Visit the Conduit - RealWorld Page
cy.OpenApplication(this.data.AppUrl);
//CLick on sign Up button
cy.get(':nth-child(3) > .nav-link').click();

// Enter registration details and signup
cy.get(':nth-child(1) > .form-control').type(this.data.userName);

cy.get(':nth-child(2) > .form-control').type(this.data.email);

cy.get(':nth-child(3) > .form-control').type(this.data.Password);

cy.get('.btn').click();

// If user already exists show error
if(this.data.userName.includes('nchaubey')) {

cy.get('.error-messages > :nth-child(1)').should('contain','email has already been taken');

cy.get('.error-messages > :nth-child(2)').should('contain','username has already been taken');
}

// If user in new, verify success
else{
cy.get(':nth-child(4) > .nav-link').should('have.text',this.data.userName);

}

// cy.get(':nth-child(4) > .element-list > .menu-list > li').should('have.length',9);
})
})
21 changes: 21 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// <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}
*/
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
44 changes: 44 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ***********************************************
// 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("OpenApplication", (appURL) => {

//Visit the Conduit - RealWorld Page
cy.visit(appURL);

//Verify the page title
cy.get('.logo-font').should('have.text','conduit');
})

Cypress.Commands.add("login", (email, password) => {

cy.get(':nth-child(2) > .nav-link').click();

cy.get(':nth-child(1) > .form-control').type(email);
cy.get(':nth-child(2) > .form-control').type(password);

cy.get('.btn').click();


})
//
//
// -- 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) => { ... })
20 changes: 20 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// 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')
7 changes: 7 additions & 0 deletions debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[1214/121317.884:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1214/142224.934:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1214/152415.685:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1214/163927.757:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1214/170402.728:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1214/172936.393:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1214/174918.140:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
Loading