-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task is done and waiting for review #253
Open
objelov
wants to merge
4
commits into
mate-academy:main
Choose a base branch
from
objelov:testing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+819
−4
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,7 +1,170 @@ | ||
/// <reference types='cypress' /> | ||
|
||
import WebTables from '../support/pageObjects/pages/webTables'; | ||
import RegistrationForm from | ||
'../support/pageObjects/components/registrationForm'; | ||
import Pagination from '../support/pageObjects/components/pagination'; | ||
import generateWorker from '../support/generateData'; | ||
import workersData from '../support/fixtures/workersData.json'; | ||
import titles from '../support/fixtures/titles.json'; | ||
|
||
const webTables = new WebTables(); | ||
const registrationForm = new RegistrationForm(); | ||
const pagination = new Pagination(); | ||
|
||
describe('Web Tables page', () => { | ||
it('', () => { | ||
beforeEach(() => { | ||
cy.wrap(generateWorker()).as('workerData'); | ||
|
||
cy.wrap(generateWorker()).as('newWorker'); | ||
|
||
cy.visit(''); | ||
}); | ||
|
||
it('should allow to add a new worker', () => { | ||
webTables.assertAddBtnExists(titles.addBtn) | ||
.clickOnAddBtn(); | ||
|
||
cy.get('@workerData').then((workerData) => { | ||
registrationForm | ||
.assertFormExists(titles.registrationForm, titles.submitDataBtn) | ||
.fillFormAndSubmit(workerData); | ||
|
||
webTables.assertWorkerDataInTable(workerData); | ||
}); | ||
}); | ||
|
||
it('should allow to delete a worker', () => { | ||
cy.get('@workerData').then((workerData) => { | ||
webTables.addWorker(workerData) | ||
.assertWorkerDataInTable(workerData) | ||
.deleteWorker(workerData) | ||
.assertWorkerIsDeleted(workerData); | ||
}); | ||
}); | ||
|
||
it('should allow to delete all workers', () => { | ||
webTables.deleteAllWorkers() | ||
.assertTableIsClear(titles.emptyTable); | ||
}); | ||
|
||
it('should allow to find a worker by first name', () => { | ||
cy.get('@workerData').then((workerData) => { | ||
const { firstName } = workerData; | ||
|
||
webTables.addWorker(workerData) | ||
.assertSearchFieldExists() | ||
.searchForWorker(firstName) | ||
.assertWorkerDataInTable(workerData); | ||
}); | ||
}); | ||
|
||
it('should allow to find a worker by last name', () => { | ||
cy.get('@workerData').then((workerData) => { | ||
const { lastName } = workerData; | ||
|
||
webTables.addWorker(workerData) | ||
.searchForWorker(lastName) | ||
.assertWorkerDataInTable(workerData); | ||
}); | ||
}); | ||
|
||
it('should allow to find a worker by age', () => { | ||
cy.get('@workerData').then((workerData) => { | ||
const { age } = workerData; | ||
|
||
webTables.addWorker(workerData) | ||
.searchForWorker(age) | ||
.assertWorkerDataInTable(workerData); | ||
}); | ||
}); | ||
|
||
it('should allow to find a worker by email', () => { | ||
cy.get('@workerData').then((workerData) => { | ||
const { email } = workerData; | ||
|
||
webTables.addWorker(workerData) | ||
.searchForWorker(email) | ||
.assertWorkerDataInTable(workerData); | ||
}); | ||
}); | ||
|
||
it('should allow to find a worker by salary', () => { | ||
cy.get('@workerData').then((workerData) => { | ||
const { salary } = workerData; | ||
|
||
webTables.addWorker(workerData) | ||
.searchForWorker(salary) | ||
.assertWorkerDataInTable(workerData); | ||
}); | ||
}); | ||
|
||
it('should allow to find a worker by department', () => { | ||
cy.get('@workerData').then((workerData) => { | ||
const { department } = workerData; | ||
|
||
webTables.addWorker(workerData) | ||
.searchForWorker(department) | ||
.assertWorkerDataInTable(workerData); | ||
}); | ||
}); | ||
|
||
it('should allow to edit the found worker', () => { | ||
cy.get('@workerData').then((workerData) => { | ||
const { email } = workerData; | ||
|
||
webTables.addWorker(workerData) | ||
.searchForWorker(email) | ||
.clickOnEditBtnOfParticularWorker(email); | ||
|
||
registrationForm.assertFormContainsWorkerData(workerData); | ||
|
||
const updatedFirstName = workerData.firstName + ' edited'; | ||
const updatedLastName = workerData.lastName + ' edited'; | ||
|
||
cy.get('@newWorker').then((newWorkerData) => { | ||
registrationForm.editFormAndSubmit(newWorkerData); | ||
|
||
webTables.clearSearchField() | ||
.assertWorkerDataIsEdited( | ||
updatedFirstName, updatedLastName, newWorkerData | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
it(`should allow to change the rows count selection of the table data`, () => { | ||
const rowsCount = ['5', '10', '20', '25', '50', '100']; | ||
|
||
webTables.assertRowsSelection(rowsCount); | ||
}); | ||
|
||
it(`should allow to navigate to the next table pages by entering page number into the "Page input" field`, () => { | ||
webTables.addMultipleWorkers(workersData); | ||
|
||
pagination.selectRowsCount() | ||
.navigateUntilLastPageByPageNumber(); | ||
}); | ||
|
||
it(`should allow to navigate to the previous table pages by entering page number into the "Page input" field`, () => { | ||
webTables.addMultipleWorkers(workersData); | ||
|
||
pagination.selectRowsCount() | ||
.navigateUntilFirstPageByPageNumber(); | ||
}); | ||
|
||
it(`should allow to navigate to the next table pages by clicking on [Next]`, () => { | ||
webTables.addMultipleWorkers(workersData); | ||
|
||
pagination.selectRowsCount() | ||
.navigateUntilLastPageByClickingOnNextBtn(); | ||
}); | ||
|
||
it(`should allow to navigate to the previous table pages by clicking on [Previous]`, () => { | ||
webTables.addMultipleWorkers(workersData); | ||
|
||
pagination.selectRowsCount() | ||
.navigateToLastPage() | ||
.navigateUntilFirstPageByClickingOnPreviousBtn(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"addBtn": "Add", | ||
"registrationForm": "Registration Form", | ||
"submitDataBtn": "Submit", | ||
"emptyTable": "No rows found" | ||
} |
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 @@ | ||
[ | ||
{ | ||
"firstName": "Test1", | ||
"lastName": "Customer1", | ||
"email": "[email protected]", | ||
"age": 35, | ||
"salary": 2500, | ||
"department": "Sales" | ||
}, | ||
{ | ||
"firstName": "Test2", | ||
"lastName": "Customer2", | ||
"email": "[email protected]", | ||
"age": 39, | ||
"salary": 3500, | ||
"department": "Finance" | ||
}, | ||
{ | ||
"firstName": "Test3", | ||
"lastName": "Customer3", | ||
"email": "[email protected]", | ||
"age": 40, | ||
"salary": 5500, | ||
"department": "Marketing" | ||
} | ||
] |
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 @@ | ||
import { faker } from '@faker-js/faker'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. generateData - to general file name, please make it more specific |
||
|
||
function generateWorker() { | ||
const gender = faker.helpers.arrayElement(['male', 'female']); | ||
const firstName = faker.person.firstName(gender); | ||
const lastName = faker.person.lastName(gender); | ||
const email = faker.internet.email(); | ||
const age = faker.finance.amount({ min: 16, max: 60, dec: 0 }); | ||
const salary = faker.finance.amount({ min: 600, max: 100000, dec: 0 }); | ||
const department = faker.commerce.department(); | ||
|
||
return { | ||
firstName, | ||
lastName, | ||
email, | ||
age, | ||
salary, | ||
department | ||
}; | ||
} | ||
|
||
export default generateWorker; |
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,7 @@ | ||
/// <reference types="cypress" /> | ||
|
||
declare namespace Cypress { | ||
interface Chainable<Subject> { | ||
getById(selector: string): Chainable<any> | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.