From fec24aed43ae4d4a2b6b66b89dbafa791b735791 Mon Sep 17 00:00:00 2001 From: Liana Harris <46411498+LianaHarris360@users.noreply.github.com> Date: Fri, 9 Aug 2024 09:42:53 -0500 Subject: [PATCH 1/4] Update KDateCalendar view to automatically display month of the last allowed date --- lib/KDateRange/KDateCalendar.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/KDateRange/KDateCalendar.vue b/lib/KDateRange/KDateCalendar.vue index f9c1869d2..5fca08778 100644 --- a/lib/KDateRange/KDateCalendar.vue +++ b/lib/KDateRange/KDateCalendar.vue @@ -157,8 +157,9 @@ }, numOfDays: 7, isFirstChoice: this.selectedStartDate == null ? true : false, - activeMonth: new Date().getMonth() - 1 == -1 ? 11 : new Date().getMonth() - 1, - activeYearStart: new Date().getFullYear(), + activeMonth: + this.lastAllowedDate.getMonth() - 1 == -1 ? 11 : this.lastAllowedDate.getMonth() - 1, + activeYearStart: this.lastAllowedDate.getFullYear(), }; }, computed: { From 3be1a5f0a7ce25775cdb4db78b4837ab1d12a409 Mon Sep 17 00:00:00 2001 From: Liana Harris <46411498+LianaHarris360@users.noreply.github.com> Date: Fri, 9 Aug 2024 09:46:17 -0500 Subject: [PATCH 2/4] Update KDATECALENDAR_PROPS within KDateRange test to use set dates --- lib/KDateRange/__tests__/KDateRange.spec.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/KDateRange/__tests__/KDateRange.spec.js b/lib/KDateRange/__tests__/KDateRange.spec.js index bcf51c83b..9b3157e9c 100644 --- a/lib/KDateRange/__tests__/KDateRange.spec.js +++ b/lib/KDateRange/__tests__/KDateRange.spec.js @@ -90,9 +90,9 @@ describe('KDateRange component', () => { const KDATECALENDAR_PROPS = { firstAllowedDate: new Date(2022, 0, 1), - lastAllowedDate: new Date(), + lastAllowedDate: new Date(2022, 10, 1), selectedStartDate: new Date(2022, 8, 1), - selectedEndDate: new Date(), + selectedEndDate: new Date(2022, 10, 1), previousMonthText: 'Previous Month', nextMonthText: 'Next Month', }; @@ -120,16 +120,18 @@ describe('KDateCalendar component', () => { expect(wrapper.exists()).toBe(true); }); - it('the month and year display on the left-side calendar view should contain the previous month', async () => { + it('the month and year display on the left-side calendar view should display the previous month of the lastAllowedDate', async () => { const previousMonthDisplay = getKDateCalendarElements(wrapper).previousMonthDisplay(); - const previousMonth = new Date().setDate(0); + const lastAllowedDate = wrapper.props().lastAllowedDate; + const previousMonth = new Date(lastAllowedDate) - 1; const date = Vue.prototype.$formatDate(previousMonth, { month: 'long', year: 'numeric' }); expect(previousMonthDisplay.text()).toBe(date); }); - it('the month and year display on the right-side calendar view should contain the current month', async () => { + it('the month and year display on the right-side calendar view should display the current month of the lastAllowedDate', async () => { const currentMonthDisplay = getKDateCalendarElements(wrapper).currentMonthDisplay(); - const date = Vue.prototype.$formatDate(new Date(), { month: 'long', year: 'numeric' }); + const lastAllowedDate = wrapper.props().lastAllowedDate; + const date = Vue.prototype.$formatDate(lastAllowedDate, { month: 'long', year: 'numeric' }); expect(currentMonthDisplay.text()).toBe(date); }); }); From 13b4365315ca186768767a6876afde5c711fb621 Mon Sep 17 00:00:00 2001 From: Liana Harris <46411498+LianaHarris360@users.noreply.github.com> Date: Fri, 9 Aug 2024 14:03:50 -0500 Subject: [PATCH 3/4] Update lib/KDateRange/__tests__/KDateRange.spec.js Update how KDatecalendar test case prop previousMonth is set Co-authored-by: Alex Velez <51239030+AlexVelezLl@users.noreply.github.com> --- lib/KDateRange/__tests__/KDateRange.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/KDateRange/__tests__/KDateRange.spec.js b/lib/KDateRange/__tests__/KDateRange.spec.js index 9b3157e9c..ae7d3d0ae 100644 --- a/lib/KDateRange/__tests__/KDateRange.spec.js +++ b/lib/KDateRange/__tests__/KDateRange.spec.js @@ -123,7 +123,8 @@ describe('KDateCalendar component', () => { it('the month and year display on the left-side calendar view should display the previous month of the lastAllowedDate', async () => { const previousMonthDisplay = getKDateCalendarElements(wrapper).previousMonthDisplay(); const lastAllowedDate = wrapper.props().lastAllowedDate; - const previousMonth = new Date(lastAllowedDate) - 1; + const previousMonth = new Date(lastAllowedDate); + previousMonth.setMonth(lastAllowedDate.getMonth() - 1); const date = Vue.prototype.$formatDate(previousMonth, { month: 'long', year: 'numeric' }); expect(previousMonthDisplay.text()).toBe(date); }); From 8e78417054537e8aa76e87917aec3187c32a3acb Mon Sep 17 00:00:00 2001 From: Liana Harris <46411498+LianaHarris360@users.noreply.github.com> Date: Tue, 13 Aug 2024 09:49:55 -0500 Subject: [PATCH 4/4] Update changelog --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94fb8fb6b..83e30d268 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ Changelog is rather internal in nature. See release notes for the public overvie ## Upcoming version 5.x.x (`develop` branch) +- [#718] + - **Description:** This pull request resolves failing `KDateCalendar` component tests that occurred on the last day of the month in open pull requests by setting dates manually in the tests. Additionally, the `KDateCalendar` is updated to show the month of the `lastAllowedDate` property. + - **Products impact:** none + - **Addresses:** https://github.com/learningequality/kolibri-design-system/issues/713 + - **Components:** - + - **Breaking:** no + - **Impacts a11y:** - + - **Guidance:** - + +[#718]: https://github.com/learningequality/kolibri-design-system/pull/718 + - [#687] - **Description:** Adds logic that inserts ARIA live assertive and polite regions to an application's document body during KDS initialization and documents this on the new "Installation" page. Relatedly adds `useKLiveRegion` composable with public methods for updating the live regions with assertive and polite messages. - **Products impact:** new API