Skip to content

Commit

Permalink
Adding changes to the entire project
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-badell committed Apr 25, 2024
1 parent 2029ee9 commit 3f60639
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 81 deletions.
108 changes: 47 additions & 61 deletions cypress/e2e/intercept.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,68 +94,54 @@ describe('Testing Orange HRM', () => {
});


// This step is to practice cy.request using POST methods.
// This step is to practice POST methods.
it('Deleting post of the Buzznewsfeed', () => {
const accessOrange = {
username: "Admin",
password: "admin123"
};

cy.request({
cy.intercept({
method: 'POST',
url: `${Cypress.env('baseUrl')}/web/index.php/auth/validate`,
body: accessOrange,
followRedirect: true,
}).then((response) => {
expect(response.status).to.equal(200);


cy.request({
method: 'POST',
url: `${Cypress.env('baseUrl')}/web/index.php/api/v2/buzz/posts`,
body: {
"type": "text",
"text": "Deleting this article with Cypress"
},
}).then((postResponse) => {
expect(postResponse.status).to.equal(200);

cy.get('.oxd-sidepanel-body');
cy.get('.oxd-main-menu-item')
.eq(11)
.should('contain', 'Buzz')
.click();

cy.get('div.oxd-layout-context')
.find('.oxd-text')
.should('contain', 'Deleting this article with Cypress');

cy.get(':nth-child(1) > .oxd-sheet')
.find('.orangehrm-buzz-post')
.find('.orangehrm-buzz-post-header')
.find('.orangehrm-buzz-post-header-config')
.find('li > .oxd-icon-button > .oxd-icon')
.first()
.click({ force: true });

cy.get('.oxd-dropdown-menu > :nth-child(1)')
.should('exist')
.contains('Delete Post')
.click();

cy.get('.oxd-button--label-danger').click();

cy.request({
url: `${Cypress.env('baseUrl')}/web/index.php/buzz/viewBuzz`,
method: 'GET'
}).then((buzzResponse) => {
expect(buzzResponse.status).to.equal(200);

if (buzzResponse.body && Array.isArray(buzzResponse.body.buzz) && buzzResponse.body.buzz.length > 0) {
expect(buzzResponse.body.buzz[0].title).not.to.equal('Deleting this article with Cypress');
}
});
});
});
});
}, {
statusCode: 200,
body: {
"username": "Admin",
"password": "admin123"
}
}).as('getValidation');

cy.intercept({
method: 'POST',
url: `${Cypress.env('baseUrl')}/web/index.php/api/v2/buzz/posts`,
}, {
statusCode: 200,
body: {
"type": "text",
"text": "Deleting this article with Cypress"
}
}).as('getPost');

cy.get('.oxd-sidepanel-body');
cy.get('.oxd-main-menu-item')
.eq(11)
.should('contain', 'Buzz')
.click();

cy.get(':nth-child(1) > .oxd-sheet')
.find('.orangehrm-buzz-post')
.find('.orangehrm-buzz-post-header')
.find('.orangehrm-buzz-post-header-config')
.find('li > .oxd-icon-button > .oxd-icon')
.first()
.click({ force: true });

cy.get('.oxd-dropdown-menu > :nth-child(1)')
.should('exist')
.contains('Delete Post')
.click();

cy.get('.oxd-button--label-danger').click();

cy.intercept({
url: `${Cypress.env('baseUrl')}/web/index.php/buzz/viewBuzz`,
method: 'GET'
}).as('getBuzz')
});
});
10 changes: 10 additions & 0 deletions cypress/e2e/intercept2.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
describe('Testing the entire PIM process on OrangeHRM', () => {
beforeEach('log in to the website', () => {
cy.logInToOrangeHRM("Succefully logged in");
});


it('Adding an employee on the system', () => {

})
})
23 changes: 18 additions & 5 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,26 @@



Cypress.Commands.add('logInToOrangeHRM', () => {
cy.visit(Cypress.env('baseUrl'))
cy.get('[placeholder="Username"]').type('Admin')
cy.get('[placeholder="Password"]').type('admin123')
cy.get('form').submit()
Cypress.Commands.add('logInToOrangeHRM', () => {
cy.visit(Cypress.env('baseUrl'))

// Access to username and password placeholders
cy.get('input[placeholder]').each(($el, index, $list) => {
const placeholder = $el.attr('placeholder');

if (/username/i.test(placeholder) || /nombre de usuario/i.test(placeholder)) {
cy.wrap($el).type('Admin');
} else if (/password/i.test(placeholder) || /contraseña/i.test(placeholder)) {
cy.wrap($el).type('admin123');
}
})

cy.get('form').submit()
})




Cypress.Commands.add('getByClass', (className) => {
return cy.get(`.${className}`)
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"cypress:open": "cypress open"
},
"devDependencies": {
"cypress": "^13.1.0"
"cypress": "^13.7.0"
}
}
22 changes: 8 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.5.7.tgz#4b8ecac87fbefbc92f431d09c30e176fc0a7c377"
integrity sha512-dP7f3LdZIysZnmvP3ANJYTSwg+wLLl8p7RqniVlV7j+oXSXAbt9h0WIBFmJy5inWZoX9wZN6eXx+YXd9Rh3RBA==

"@types/node@^16.18.39":
version "16.18.46"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.46.tgz#9f2102d0ba74a318fcbe170cbff5463f119eab59"
integrity sha512-Mnq3O9Xz52exs3mlxMcQuA7/9VFe/dXcrgAyfjLkABIqxXKOgBRjyazTxUbjsxDa4BP7hhPliyjVTP9RDP14xg==

"@types/[email protected]":
version "8.1.1"
resolved "https://registry.yarnpkg.com/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.1.tgz#b49c2c70150141a15e0fa7e79cf1f92a72934ce3"
Expand Down Expand Up @@ -185,7 +180,7 @@ buffer-crc32@~0.2.3:
resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242"
integrity sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==

buffer@^5.6.0:
buffer@^5.7.1:
version "5.7.1"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0"
integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==
Expand Down Expand Up @@ -311,20 +306,19 @@ cross-spawn@^7.0.0:
shebang-command "^2.0.0"
which "^2.0.1"

cypress@^13.1.0:
version "13.1.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.1.0.tgz#18f268e66662cd91b1766db18bd1f63a66592205"
integrity sha512-LUKxCYlB973QBFls1Up4FAE9QIYobT+2I8NvvAwMfQS2YwsWbr6yx7y9hmsk97iqbHkKwZW3MRjoK1RToBFVdQ==
cypress@^13.7.0:
version "13.7.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.7.0.tgz#19e53c0bd6eca5e3bde0d6ac9e98fbf1782e3a9e"
integrity sha512-UimjRSJJYdTlvkChcdcfywKJ6tUYuwYuk/n1uMMglrvi+ZthNhoRYcxnWgTqUtkl17fXrPAsD5XT2rcQYN1xKA==
dependencies:
"@cypress/request" "^3.0.0"
"@cypress/xvfb" "^1.2.4"
"@types/node" "^16.18.39"
"@types/sinonjs__fake-timers" "8.1.1"
"@types/sizzle" "^2.3.2"
arch "^2.2.0"
blob-util "^2.0.2"
bluebird "^3.7.2"
buffer "^5.6.0"
buffer "^5.7.1"
cachedir "^2.3.0"
chalk "^4.1.0"
check-more-types "^2.24.0"
Expand All @@ -342,7 +336,7 @@ cypress@^13.1.0:
figures "^3.2.0"
fs-extra "^9.1.0"
getos "^3.2.1"
is-ci "^3.0.0"
is-ci "^3.0.1"
is-installed-globally "~0.4.0"
lazy-ass "^1.6.0"
listr2 "^3.8.3"
Expand Down Expand Up @@ -644,7 +638,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/ini/-/ini-2.0.0.tgz#e5fd556ecdd5726be978fa1001862eacb0a94bc5"
integrity sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA==

is-ci@^3.0.0:
is-ci@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-3.0.1.tgz#db6ecbed1bd659c43dac0f45661e7674103d1867"
integrity sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==
Expand Down

0 comments on commit 3f60639

Please sign in to comment.