-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(filter): add Cypress E2E tests for the Filter by Range grid
- refactored a few other Cypress tests to be a bit more consistent
- Loading branch information
Ghislain Beaulac
authored and
Ghislain Beaulac
committed
Aug 16, 2019
1 parent
308082f
commit 7da17f8
Showing
13 changed files
with
171 additions
and
17 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
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
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,149 @@ | ||
/// <reference types="cypress" /> | ||
import moment from 'moment-mini'; | ||
|
||
const presetMinComplete = 5; | ||
const presetMaxComplete = 88; | ||
const presetLowestDay = moment().add(-2, 'days').format('YYYY-MM-DD'); | ||
const presetHighestDay = moment().add(20, 'days').format('YYYY-MM-DD'); | ||
|
||
describe('Example 25 - Range Filters', () => { | ||
it('should display Example title', () => { | ||
cy.visit(`${Cypress.config('baseExampleUrl')}/range`); | ||
cy.get('h2').should('contain', 'Example 25: Filtering from Range of Search Values'); | ||
}); | ||
|
||
it('should have "% Complete" fields within the range (inclusive) of the filters presets', () => { | ||
cy.get('#grid25') | ||
.find('.slick-row') | ||
.each(($row) => { | ||
cy.wrap($row) | ||
.children('.slick-cell:nth(2)') | ||
.each(($cell) => { | ||
const value = parseInt($cell.text().trim(), 10); | ||
if (!isNaN(value)) { | ||
expect(value >= presetMinComplete).to.eq(true); | ||
expect(value <= presetMaxComplete).to.eq(true); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
it('should have Finish Dates within the range (inclusive) of the filters presets', () => { | ||
cy.get('#grid25') | ||
.find('.slick-row') | ||
.each(($row) => { | ||
cy.wrap($row) | ||
.children('.slick-cell:nth(4)') | ||
.each(($cell) => { | ||
const isDateBetween = moment($cell.text()).isBetween(presetLowestDay, presetHighestDay, null, '[]'); // [] is inclusive, () is exclusive | ||
expect(isDateBetween).to.eq(true); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should have "Duration" fields within the range (exclusive by default) of the filters presets', () => { | ||
cy.get('#grid25') | ||
.find('.slick-row') | ||
.each(($row) => { | ||
cy.wrap($row) | ||
.children('.slick-cell:nth(5)') | ||
.each(($cell) => { | ||
const value = parseInt($cell.text().trim(), 10); | ||
if (!isNaN(value)) { | ||
console.log('duration', value, presetMinComplete, presetMaxComplete, value > presetMinComplete, value < presetMaxComplete) | ||
expect(value > presetMinComplete).to.eq(true); | ||
expect(value < presetMaxComplete).to.eq(true); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
it('should change "% Complete" filter range by using the slider left handle (min value) to make it a higher min value and expect all rows to be within new range', () => { | ||
let newLowest = presetMinComplete; | ||
let newHighest = presetMaxComplete; | ||
|
||
cy.get('.ui-slider-range') | ||
.click('bottom', { force: true }); | ||
|
||
cy.get('.lowest-range-complete') | ||
.then(($lowest) => { | ||
newLowest = parseInt($lowest.text(), 10); | ||
}); | ||
|
||
cy.get('.highest-range-complete') | ||
.then(($highest) => { | ||
newHighest = parseInt($highest.text(), 10); | ||
}); | ||
|
||
cy.get('#grid25') | ||
.find('.slick-row') | ||
.each(($row) => { | ||
cy.wrap($row) | ||
.children('.slick-cell:nth(2)') | ||
.each(($cell) => { | ||
const value = parseInt($cell.text().trim(), 10); | ||
if (!isNaN(value)) { | ||
expect(value >= newLowest).to.eq(true); | ||
expect(value <= newHighest).to.eq(true); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
it('should change the "Duration" input filter and expect all rows to be within new range', () => { | ||
const newMin = 10; | ||
const newMax = 40; | ||
|
||
cy.contains('Clear Filters') | ||
.click({ force: true }); | ||
|
||
cy.get('.search-filter.filter-duration') | ||
.focus() | ||
.type(`${newMin}..${newMax}`); | ||
|
||
cy.get('#grid25') | ||
.find('.slick-row') | ||
.each(($row) => { | ||
cy.wrap($row) | ||
.children('.slick-cell:nth(5)') | ||
.each(($cell) => { | ||
const value = parseInt($cell.text().trim(), 10); | ||
if (!isNaN(value)) { | ||
expect(value > newMin).to.eq(true); | ||
expect(value < newMax).to.eq(true); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
xit('should change the "Finish" date in the picker and expect all rows to be within new dates range', () => { | ||
cy.contains('Clear Filters') | ||
.click({ force: true }); | ||
|
||
cy.get('.flatpickr.search-filter.filter-finish:nth(1)') | ||
.click('bottom', { force: true }); | ||
|
||
cy.get('.flatpickr-days') | ||
.find('[aria-label]') | ||
.contains(moment().format('MMMM')); | ||
|
||
cy.get('.flatpickr-day:nth(7)') | ||
.click({ force: true }); | ||
|
||
cy.get('.flatpickr-day') | ||
.should('contain', '28') | ||
.click({ force: true }); | ||
|
||
cy.get('#grid25') | ||
.find('.slick-row') | ||
.each(($row) => { | ||
cy.wrap($row) | ||
.children('.slick-cell:nth(4)') | ||
.each(($cell) => { | ||
const isDateBetween = moment($cell.text()).isBetween(presetLowestDay, presetHighestDay, null, '[]'); // [] is inclusive, () is exclusive | ||
expect(isDateBetween).to.eq(true); | ||
}); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
describe('Home Page', () => { | ||
it('should display Home Page', () => { | ||
cy.visit('http://localhost:4300/home'); | ||
|
||
cy.get('h2').should(($h2) => { | ||
expect($h2, 'text content').to.have.text('Angular-Slickgrid - Demo Site'); | ||
}); | ||
}); | ||
|
||
cy.get('.subtitle') | ||
.contains('This site is to demo multiple usage of Angular-Slickgrid'); | ||
}); | ||
}); |