-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: date selection in filters (#140)
* fix: date selection in filters * fix: share default dates and add component tests * fix: correct date selection behaviour * chore: add comments
- Loading branch information
1 parent
6338583
commit 06a146f
Showing
5 changed files
with
151 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* eslint-disable */ | ||
import { mount } from 'cypress-react-unit-test'; | ||
import React from 'react'; | ||
import theme from './common/theme'; | ||
import { ThemeProvider } from '@material-ui/core/styles'; | ||
|
||
import Filter from './Filter'; | ||
import FilterModel from '../models/Filter'; | ||
|
||
describe('Filter', () => { | ||
const filterModel = new FilterModel(); | ||
beforeEach(() => { | ||
mount( | ||
<ThemeProvider theme={theme}> | ||
<Filter | ||
filter={filterModel} | ||
isOpen={true} | ||
/> | ||
</ThemeProvider>, | ||
); | ||
}); | ||
|
||
it('works', () => { | ||
cy.contains(/Filters/i); | ||
}); | ||
|
||
it('start date picker forward button should be enabled', () => { | ||
cy.get('#start-date-picker+* button').then(($buttons) => { | ||
$buttons[0].click(); | ||
// Check forward button is disabled | ||
cy.get('.MuiPickersCalendarHeader-iconButton.Mui-disabled').should('have.length', 1); | ||
cy.get('.MuiPickersCalendarHeader-iconButton').then(($headerButtons) => { | ||
$headerButtons[0].click(); | ||
// Check both buttons are enabled | ||
cy.get('.MuiPickersCalendarHeader-iconButton.Mui-disabled').should('have.length', 0); | ||
}); | ||
}); | ||
}); | ||
|
||
it('end date picker back button should be enabled', () => { | ||
cy.get('#end-date-picker+* button').then(($buttons) => { | ||
$buttons[0].click(); | ||
// Check forward button is disabled | ||
cy.get('.MuiPickersCalendarHeader-iconButton.Mui-disabled').should('have.length', 1); | ||
cy.get('.MuiPickersCalendarHeader-iconButton').then(($headerButtons) => { | ||
$headerButtons[0].click(); | ||
// Check both buttons are enabled | ||
cy.get('.MuiPickersCalendarHeader-iconButton.Mui-disabled').should('have.length', 0); | ||
}); | ||
}); | ||
}); | ||
}); |
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,79 @@ | ||
/* eslint-disable */ | ||
import { mount } from 'cypress-react-unit-test'; | ||
import React from 'react'; | ||
import theme from './common/theme'; | ||
import { ThemeProvider } from '@material-ui/core/styles'; | ||
import { Provider } from 'react-redux'; | ||
import { init } from '@rematch/core'; | ||
|
||
import FilterTop from './FilterTop'; | ||
import FilterModel from '../models/Filter'; | ||
|
||
describe('FilterTop', () => { | ||
const filterModel = new FilterModel(); | ||
beforeEach(() => { | ||
store = init({ | ||
models: { | ||
species: { | ||
state: { | ||
speciesList: [], | ||
}, | ||
effects: {}, | ||
}, | ||
tags: { | ||
state: { | ||
tagList: [], | ||
}, | ||
effects: { | ||
getTags(_payload, _state) {}, | ||
}, | ||
}, | ||
organizations: { | ||
state: { | ||
organizationList: [], | ||
}, | ||
effects: { | ||
loadOrganizations(_payload, _state) {}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
mount( | ||
<Provider store={store}> | ||
<ThemeProvider theme={theme}> | ||
<FilterTop | ||
filter={filterModel} | ||
isOpen={true} | ||
/> | ||
</ThemeProvider>, | ||
</Provider> | ||
); | ||
}); | ||
|
||
it('start date picker forward button should be enabled', () => { | ||
cy.get('#start-date-picker+* button').then(($buttons) => { | ||
$buttons[0].click(); | ||
// Check forward button is disabled | ||
cy.get('.MuiPickersCalendarHeader-iconButton.Mui-disabled').should('have.length', 1); | ||
cy.get('.MuiPickersCalendarHeader-iconButton').then(($headerButtons) => { | ||
$headerButtons[0].click(); | ||
// Check both buttons are enabled | ||
cy.get('.MuiPickersCalendarHeader-iconButton.Mui-disabled').should('have.length', 0); | ||
}); | ||
}); | ||
}); | ||
|
||
it('end date picker back button should be enabled', () => { | ||
cy.get('#end-date-picker+* button').then(($buttons) => { | ||
$buttons[0].click(); | ||
// Check forward button is disabled | ||
cy.get('.MuiPickersCalendarHeader-iconButton.Mui-disabled').should('have.length', 1); | ||
cy.get('.MuiPickersCalendarHeader-iconButton').then(($headerButtons) => { | ||
$headerButtons[0].click(); | ||
// Check both buttons are enabled | ||
cy.get('.MuiPickersCalendarHeader-iconButton.Mui-disabled').should('have.length', 0); | ||
}); | ||
}); | ||
}); | ||
}); |