Skip to content

Commit

Permalink
fix: setting date picker should always work (#1229)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Jun 29, 2024
1 parent fc43fa8 commit b1b763a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 9 deletions.
15 changes: 9 additions & 6 deletions packages/demo/src/examples/slickgrid/example6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ export class Example6 {
},
];

const presetLowestDay = tempoFormat(addDay(new Date(), -2), 'YYYY-MM-DD');
const presetHighestDay = tempoFormat(addDay(new Date(), 20), 'YYYY-MM-DD');
const currentYear = new Date().getFullYear();
const presetLowestDay = `${currentYear}-01-01`;
const presetHighestDay = `${currentYear}-02-15`;

this.gridOptions = {
enableFiltering: true,
Expand Down Expand Up @@ -325,8 +326,9 @@ export class Example6 {
}

setFiltersDynamically() {
const presetLowestDay = tempoFormat(addDay(new Date(), -2), 'YYYY-MM-DD');
const presetHighestDay = tempoFormat(addDay(new Date(), 20), 'YYYY-MM-DD');
const currentYear = new Date().getFullYear();
const presetLowestDay = `${currentYear}-01-01`;
const presetHighestDay = `${currentYear}-02-15`;

// we can Set Filters Dynamically (or different filters) afterward through the FilterService
this.aureliaGrid.filterService.updateFilters([
Expand All @@ -347,8 +349,9 @@ export class Example6 {
}

resetToOriginalPresets() {
const presetLowestDay = tempoFormat(addDay(new Date(), -2), 'YYYY-MM-DD');
const presetHighestDay = tempoFormat(addDay(new Date(), 20), 'YYYY-MM-DD');
const currentYear = new Date().getFullYear();
const presetLowestDay = `${currentYear}-01-01`;
const presetHighestDay = `${currentYear}-02-15`;

this.aureliaGrid.filterService.updateFilters([
// you can use OperatorType or type them as string, e.g.: operator: 'EQ'
Expand Down
52 changes: 49 additions & 3 deletions test/cypress/e2e/example06.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { addDay, format } from '@formkit/tempo';

import { removeWhitespaces } from '../plugins/utilities';

const presetLowestDay = format(addDay(new Date(), -2), 'YYYY-MM-DD');
const presetHighestDay = format(addDay(new Date(), 20), 'YYYY-MM-DD');
const currentYear = new Date().getFullYear();
const presetLowestDay = `${currentYear}-01-01`;
const presetHighestDay = `${currentYear}-02-15`;

function removeSpaces(textS) {
return `${textS}`.replace(/\s+/g, '');
}
Expand Down Expand Up @@ -398,6 +400,34 @@ describe('Example 6 - GraphQL Grid', () => {
});
});

it('should open Date picker and expect date range between 01-Jan to 15-Feb', () => {
cy.get('.search-filter.filter-finish.filled')
.click();

cy.get('.vanilla-calendar-column:nth(0) .vanilla-calendar-month')
.should('have.text', 'January');

cy.get('.vanilla-calendar-column:nth(1) .vanilla-calendar-month')
.should('have.text', 'February');

cy.get('.vanilla-calendar-year:nth(0)')
.should('have.text', currentYear);

cy.get('.vanilla-calendar:visible')
.find('.vanilla-calendar-day__btn_selected')
.should('have.length', 46);

cy.get('.vanilla-calendar:visible')
.find('.vanilla-calendar-day__btn_selected')
.first()
.should('have.text', '1');

cy.get('.vanilla-calendar:visible')
.find('.vanilla-calendar-day__btn_selected')
.last()
.should('have.text', '15');
});

describe('Set Dynamic Sorting', () => {
it('should use slower server wait delay to test loading widget', () => {
cy.get('[data-test="server-delay"]')
Expand Down Expand Up @@ -448,6 +478,19 @@ describe('Example 6 - GraphQL Grid', () => {
totalCount,nodes{id,name,gender,company,billing{address{street,zip}},finish}}}`));
});
});

it('should open Date picker and no longer expect date range selection in the picker', () => {
cy.get('.search-filter.filter-finish')
.should('not.have.class', 'filled')
.click();

cy.get('.vanilla-calendar-year:nth(0)')
.should('have.text', currentYear);

cy.get('.vanilla-calendar:visible')
.find('.vanilla-calendar-day__btn_selected')
.should('not.exist');
});
});

describe('Translate by Language', () => {
Expand Down Expand Up @@ -538,7 +581,10 @@ describe('Example 6 - GraphQL Grid', () => {
.click({ force: true });
});

it('should switch locale to French', () => {
it('should switch locale from English to French', () => {
cy.get('[data-test=selected-locale]')
.should('contain', 'en.json');

cy.get('[data-test=language-button]')
.click();

Expand Down

0 comments on commit b1b763a

Please sign in to comment.