Skip to content

Commit

Permalink
reqresapi
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubaiyat-E-Mohammad committed Oct 10, 2023
0 parents commit e9e75e8
Show file tree
Hide file tree
Showing 6,463 changed files with 572,079 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added .DS_Store
Binary file not shown.
Binary file added ReqResApi/.DS_Store
Binary file not shown.
9 changes: 9 additions & 0 deletions ReqResApi/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
157 changes: 157 additions & 0 deletions ReqResApi/cypress/e2e/reqresapi.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@

describe('API Tests', () => {

it('List Users', () => {
cy.request('GET','https://reqres.in/api/users?page=2')
.then((response) => {

expect(response.status).to.eq(200);
expect(response.body.page).to.eq(2);
expect(response.body.per_page).to.eq(6);
expect(response.body.total).to.eq(12);
expect(response.body.total_pages).to.eq(2);
expect(response.body.data).to.have.length(6);

const user = response.body.data[0];
expect(user).to.have.property('id');
expect(user).to.have.property('email');
expect(user).to.have.property('first_name');
expect(user).to.have.property('last_name');
expect(user).to.have.property('avatar');
});
});

it('Signle User', () => {
cy.request('GET','https://reqres.in/api/users/2')
.then((response) => {
expect(response.status).to.eq(200);

const user = response.body.data;
expect(user).to.have.property('id');
expect(user).to.have.property('email');
expect(user).to.have.property('first_name');
expect(user).to.have.property('last_name');
expect(user).to.have.property('avatar');

const support = response.body.support;
expect(support).to.have.property('url');
expect(support).to.have.property('text');
});
});

it('Signle User not found', () => {
cy.request({
method: 'GET',
url: 'https://reqres.in/api/users/23',
failOnStatusCode: false
})
.then((response) => {
expect(response.status).to.eq(404);
});
});


it('List <resource>', () => {
cy.request('GET','https://reqres.in/api/unknown')
.then((response) => {

expect(response.status).to.eq(200);
expect(response.body.page).to.eq(1);
expect(response.body.per_page).to.eq(6);
expect(response.body.total).to.eq(12);
expect(response.body.total_pages).to.eq(2);
expect(response.body.data).to.have.length(6);

const user = response.body.data[0];
expect(user).to.have.property('id');
expect(user).to.have.property('name');
expect(user).to.have.property('year');
expect(user).to.have.property('color');
expect(user).to.have.property('pantone_value');
});
});

it('Single <resource>', () => {
cy.request('GET','https://reqres.in/api/unknown/2')
.then((response) => {

expect(response.status).to.eq(200);

const user = response.body.data;
expect(user).to.have.property('id');
expect(user).to.have.property('name');
expect(user).to.have.property('year');
expect(user).to.have.property('color');
expect(user).to.have.property('pantone_value');

const support = response.body.support;
expect(support).to.have.property('url');
expect(support).to.have.property('text');
});
});

it('Signle <resource> not found', () => {
cy.request({
method: 'GET',
url: 'https://reqres.in/api/users/23',
failOnStatusCode: false
})
.then((response) => {
expect(response.status).to.eq(404);
});
});

it('Create user', ()=>{
cy.request('POST', 'https://reqres.in/api/users', {
name: 'Rubaiyat E Mohammad',
job: 'Web Developer',
}).then((response)=>{
expect(response.status).to.eq(201);
})
})

it('Update user', ()=>{
cy.request('PUT', 'https://reqres.in/api/users/2', {
name: 'RubaiyatEM',
job: 'Software Developer',
}).then((response)=>{
expect(response.status).to.eq(200);
})
})

it('Patch user', ()=>{
cy.request('PATCH', 'https://reqres.in/api/users/2', {
name: 'Rubaiyat E M',
job: 'Dev Ops',
}).then((response)=>{
expect(response.status).to.eq(200);
})
})

it('Delete user', () => {
cy.request('DELETE', 'https://reqres.in/api/users/2')
.then((response) => {
expect(response.status).to.eq(204);
});
});

it('Delayed response', () => {
cy.request('GET','https://reqres.in/api/users?delay=3')
.then((response) => {

expect(response.status).to.eq(200);
expect(response.body.page).to.eq(1);
expect(response.body.per_page).to.eq(6);
expect(response.body.total).to.eq(12);
expect(response.body.total_pages).to.eq(2);
expect(response.body.data).to.have.length(6);

const user = response.body.data[0];
expect(user).to.have.property('id');
expect(user).to.have.property('email');
expect(user).to.have.property('first_name');
expect(user).to.have.property('last_name');
expect(user).to.have.property('avatar');
});
});
});
5 changes: 5 additions & 0 deletions ReqResApi/cypress/fixtures/example.json
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"
}
25 changes: 25 additions & 0 deletions ReqResApi/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// 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) => { ... })
20 changes: 20 additions & 0 deletions ReqResApi/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.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')
1 change: 1 addition & 0 deletions ReqResApi/node_modules/.bin/cypress

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

1 change: 1 addition & 0 deletions ReqResApi/node_modules/.bin/extract-zip

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

1 change: 1 addition & 0 deletions ReqResApi/node_modules/.bin/is-ci

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

1 change: 1 addition & 0 deletions ReqResApi/node_modules/.bin/node-which

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

1 change: 1 addition & 0 deletions ReqResApi/node_modules/.bin/rimraf

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

1 change: 1 addition & 0 deletions ReqResApi/node_modules/.bin/semver

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

1 change: 1 addition & 0 deletions ReqResApi/node_modules/.bin/sshpk-conv

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

1 change: 1 addition & 0 deletions ReqResApi/node_modules/.bin/sshpk-sign

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

1 change: 1 addition & 0 deletions ReqResApi/node_modules/.bin/sshpk-verify

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

1 change: 1 addition & 0 deletions ReqResApi/node_modules/.bin/uuid

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

Loading

0 comments on commit e9e75e8

Please sign in to comment.