diff --git a/packages/demo/src/examples/slickgrid/example6.ts b/packages/demo/src/examples/slickgrid/example6.ts index fa2008efb..3ec7b6f75 100644 --- a/packages/demo/src/examples/slickgrid/example6.ts +++ b/packages/demo/src/examples/slickgrid/example6.ts @@ -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, @@ -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([ @@ -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' diff --git a/test/cypress/e2e/example06.cy.ts b/test/cypress/e2e/example06.cy.ts index 700fcf14c..a36a4cc7a 100644 --- a/test/cypress/e2e/example06.cy.ts +++ b/test/cypress/e2e/example06.cy.ts @@ -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, ''); } @@ -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"]') @@ -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', () => { @@ -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();