-
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
1 parent
6fbba74
commit 2741679
Showing
9 changed files
with
1,035 additions
and
802 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
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,4 @@ | ||
# for Api tests | ||
# https://dummyjson.com/docs/auth | ||
API_USERNAME=... | ||
API_PASSWORD=... |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,100 @@ | ||
import { getGreeting } from '../support/app.po'; | ||
|
||
describe('asdf-e2e', () => { | ||
beforeEach(() => cy.visit('/')); | ||
|
||
it('should display welcome message', () => { | ||
// Custom command example, see `../support/commands.ts` file | ||
cy.login('[email protected]', 'myPassword'); | ||
it('should verify sequential (paginated) loading of posts', () => { | ||
cy.visit('/'); | ||
|
||
cy.intercept('GET', 'https://dummyjson.com/posts?limit=50&skip=0').as( | ||
'getPosts1Till50' | ||
); | ||
cy.intercept('GET', 'https://dummyjson.com/posts?limit=50&skip=50').as( | ||
'getPosts51Till100' | ||
); | ||
cy.intercept('GET', 'https://dummyjson.com/posts?limit=50&skip=100').as( | ||
'getPosts101Till150' | ||
); | ||
cy.intercept('GET', 'https://dummyjson.com/posts?limit=50&skip=150').as( | ||
'getPosts151Till200' | ||
); | ||
|
||
cy.wait('@getPosts1Till50').its('response.statusCode').should('eq', 200); | ||
cy.get('[data-testid="posts-container"]').should('exist'); | ||
cy.get('[data-testid="posts-container"]') | ||
.children('article') | ||
.should('have.length', 50); | ||
|
||
cy.get('[data-testid="posts-container"]').children('button').click(); | ||
|
||
cy.wait('@getPosts51Till100').its('response.statusCode').should('eq', 200); | ||
cy.get('[data-testid="posts-container"]').should('exist'); | ||
cy.get('[data-testid="posts-container"]') | ||
.children('article') | ||
.should('have.length', 100); | ||
|
||
cy.get('[data-testid="posts-container"]').children('button').click(); | ||
|
||
cy.wait('@getPosts101Till150').its('response.statusCode').should('eq', 200); | ||
cy.get('[data-testid="posts-container"]').should('exist'); | ||
cy.get('[data-testid="posts-container"]') | ||
.children('article') | ||
.should('have.length', 150); | ||
|
||
cy.get('[data-testid="posts-container"]').children('button').click(); | ||
|
||
cy.wait('@getPosts151Till200').its('response.statusCode').should('eq', 200); | ||
cy.get('[data-testid="posts-container"]').should('exist'); | ||
cy.get('[data-testid="posts-container"]') | ||
.children('p') | ||
.should('have.text', 'All posts have been fetched.'); | ||
}); | ||
|
||
it('should login the user', () => { | ||
cy.login( | ||
Cypress.env('USERNAME') || "Cypress.env('USERNAME') is undefined", | ||
Cypress.env('PASSWORD') || "Cypress.env('PASSWORD') is undefined" | ||
); | ||
}); | ||
|
||
it('should verify user info after login', () => { | ||
cy.visit('/'); | ||
cy.login( | ||
Cypress.env('USERNAME') || "Cypress.env('USERNAME') is undefined", | ||
Cypress.env('PASSWORD') || "Cypress.env('PASSWORD') is undefined" | ||
); | ||
cy.visit('/user'); | ||
|
||
// Function helper example, see `../support/app.po.ts` file | ||
getGreeting().contains(/Welcome/); | ||
cy.get('[data-testid="user-info-container"]').should('exist'); | ||
cy.get('[data-testid="user-info-container"]').should( | ||
'include.text', | ||
'"id": 15' | ||
); | ||
cy.get('[data-testid="user-info-container"]').should( | ||
'include.text', | ||
'"username": "kminchelle"' | ||
); | ||
cy.get('[data-testid="user-info-container"]').should( | ||
'include.text', | ||
'"email": "[email protected]"' | ||
); | ||
cy.get('[data-testid="user-info-container"]').should( | ||
'include.text', | ||
'"firstName": "Jeanne"' | ||
); | ||
cy.get('[data-testid="user-info-container"]').should( | ||
'include.text', | ||
'"lastName": "Halvorson"' | ||
); | ||
cy.get('[data-testid="user-info-container"]').should( | ||
'include.text', | ||
'"gender": "female"' | ||
); | ||
cy.get('[data-testid="user-info-container"]').should( | ||
'include.text', | ||
'"image": "https://robohash.org/Jeanne.png?set=set4"' | ||
); | ||
cy.get('[data-testid="user-info-container"]').should( | ||
'include.text', | ||
'"token": "*****"' | ||
); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,6 @@ | |
"main": "./index.cjs", | ||
"module": "./index.js", | ||
"dependencies": { | ||
"dotenv": "16.3.1" | ||
"dotenv": "16.3.2" | ||
} | ||
} |
Oops, something went wrong.