From 21e5c5c5447a85377fc198b35cb580333456422c Mon Sep 17 00:00:00 2001 From: Michael Chadwick Date: Wed, 12 Jun 2024 15:37:16 -0700 Subject: [PATCH 1/2] changed date format to have leading zeros --- .../curriculum-inventory/report-list-item.hbs | 4 ++-- .../curriculum-inventory/report-overview.hbs | 8 ++++---- .../sequence-block-list-item.hbs | 4 ++-- .../curriculum-inventory/sequence-block-overview.hbs | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/frontend/app/components/curriculum-inventory/report-list-item.hbs b/packages/frontend/app/components/curriculum-inventory/report-list-item.hbs index 9de1fc58a5..405410b6a1 100644 --- a/packages/frontend/app/components/curriculum-inventory/report-list-item.hbs +++ b/packages/frontend/app/components/curriculum-inventory/report-list-item.hbs @@ -31,14 +31,14 @@ colspan="2" data-test-start-date > - {{format-date @report.startDate}} + {{format-date @report.startDate day="2-digit" month="2-digit" year="numeric"}} - {{format-date @report.endDate}} + {{format-date @report.endDate day="2-digit" month="2-digit" year="numeric"}} {{#if @canUpdate}} @@ -60,7 +60,7 @@ {{else}} - {{format-date @report.startDate}} + {{format-date @report.startDate day="2-digit" month="2-digit" year="numeric"}} {{/if}} @@ -71,7 +71,7 @@ {{#if @canUpdate}} @@ -83,7 +83,7 @@ {{else}} - {{format-date @report.endDate}} + {{format-date @report.endDate day="2-digit" month="2-digit" year="numeric"}} {{/if}} diff --git a/packages/frontend/app/components/curriculum-inventory/sequence-block-list-item.hbs b/packages/frontend/app/components/curriculum-inventory/sequence-block-list-item.hbs index 643ab02168..9c58d43926 100644 --- a/packages/frontend/app/components/curriculum-inventory/sequence-block-list-item.hbs +++ b/packages/frontend/app/components/curriculum-inventory/sequence-block-list-item.hbs @@ -25,14 +25,14 @@ {{#if @sequenceBlock.startDate}} - {{format-date @sequenceBlock.startDate}} + {{format-date @sequenceBlock.startDate day="2-digit" month="2-digit" year="numeric"}} {{else}} {{t "general.notApplicableAbbr"}} {{/if}} {{#if @sequenceBlock.endDate}} - {{format-date @sequenceBlock.endDate}} + {{format-date @sequenceBlock.endDate day="2-digit" month="2-digit" year="numeric"}} {{else}} {{t "general.notApplicableAbbr"}} {{/if}} diff --git a/packages/frontend/app/components/curriculum-inventory/sequence-block-overview.hbs b/packages/frontend/app/components/curriculum-inventory/sequence-block-overview.hbs index 7d45c94390..c7d7b2983d 100644 --- a/packages/frontend/app/components/curriculum-inventory/sequence-block-overview.hbs +++ b/packages/frontend/app/components/curriculum-inventory/sequence-block-overview.hbs @@ -39,8 +39,8 @@ {{#if this.course}} {{t "general.level"}}: {{this.course.level}}, - {{t "general.startDate"}}: {{format-date this.course.startDate}}, - {{t "general.endDate"}}: {{format-date this.course.endDate}} + {{t "general.startDate"}}: {{format-date this.course.startDate day="2-digit" month="2-digit" year="numeric"}}, + {{t "general.endDate"}}: {{format-date this.course.endDate day="2-digit" month="2-digit" year="numeric"}} {{#if this.course.clerkshipType}} - {{t "general.clerkship"}} ({{this.course.clerkshipType.title}}) {{/if}} @@ -176,7 +176,7 @@ {{on "click" (set this.isEditingDatesAndDuration true)}} > {{#if @sequenceBlock.startDate}} - {{format-date @sequenceBlock.startDate}} + {{format-date @sequenceBlock.startDate day="2-digit" month="2-digit" year="numeric"}} {{else}} {{t "general.clickToEdit"}} {{/if}} @@ -184,7 +184,7 @@ {{else}} {{#if @sequenceBlock.startDate}} - {{format-date @sequenceBlock.startDate}} + {{format-date @sequenceBlock.startDate day="2-digit" month="2-digit" year="numeric"}} {{else}} {{t "general.notApplicableAbbr"}} {{/if}} @@ -201,7 +201,7 @@ {{on "click" (set this.isEditingDatesAndDuration true)}} > {{#if @sequenceBlock.endDate}} - {{format-date @sequenceBlock.endDate}} + {{format-date @sequenceBlock.endDate day="2-digit" month="2-digit" year="numeric"}} {{else}} {{t "general.clickToEdit"}} {{/if}} @@ -209,7 +209,7 @@ {{else}} {{#if @sequenceBlock.endDate}} - {{format-date @sequenceBlock.endDate}} + {{format-date @sequenceBlock.endDate day="2-digit" month="2-digit" year="numeric"}} {{else}} {{t "general.notApplicableAbbr"}} {{/if}} From b66685d356c6f0b738247833a2cb0749342a6239 Mon Sep 17 00:00:00 2001 From: Michael Chadwick Date: Wed, 12 Jun 2024 16:13:43 -0700 Subject: [PATCH 2/2] fixed tests --- .../report-list-item-test.js | 18 ++++++++-- .../curriculum-inventory/report-list-test.js | 24 ++++++++++--- .../report-overview-test.js | 36 +++++++++++++++---- .../sequence-block-list-item-test.js | 12 +++++-- .../sequence-block-list-test.js | 24 ++++++++++--- .../sequence-block-overview-test.js | 32 ++++++++--------- 6 files changed, 112 insertions(+), 34 deletions(-) diff --git a/packages/frontend/tests/integration/components/curriculum-inventory/report-list-item-test.js b/packages/frontend/tests/integration/components/curriculum-inventory/report-list-item-test.js index 9d676596ac..25bd787a71 100644 --- a/packages/frontend/tests/integration/components/curriculum-inventory/report-list-item-test.js +++ b/packages/frontend/tests/integration/components/curriculum-inventory/report-list-item-test.js @@ -41,8 +41,22 @@ module('Integration | Component | curriculum-inventory/report-list-item', functi assert.strictEqual(component.name, 'CI Report'); assert.strictEqual(component.program, 'program 0'); assert.strictEqual(component.year, '2017'); - assert.strictEqual(component.startDate, this.intl.formatDate(this.report.startDate)); - assert.strictEqual(component.endDate, this.intl.formatDate(this.report.endDate)); + assert.strictEqual( + component.startDate, + this.intl.formatDate(this.report.startDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), + ); + assert.strictEqual( + component.endDate, + this.intl.formatDate(this.report.endDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), + ); assert.strictEqual(component.status, 'Draft'); assert.ok(component.isDeletable); assert.notOk(component.confirmRemoval.isVisible); diff --git a/packages/frontend/tests/integration/components/curriculum-inventory/report-list-test.js b/packages/frontend/tests/integration/components/curriculum-inventory/report-list-test.js index 86fda992d0..7e0f7a7e3d 100644 --- a/packages/frontend/tests/integration/components/curriculum-inventory/report-list-test.js +++ b/packages/frontend/tests/integration/components/curriculum-inventory/report-list-test.js @@ -96,12 +96,20 @@ module('Integration | Component | curriculum-inventory/report-list', function (h assert.strictEqual(component.reports[0].year, '2016', 'Academic year shows.'); assert.strictEqual( component.reports[0].startDate, - this.intl.formatDate(reportModel2.startDate), + this.intl.formatDate(reportModel2.startDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), 'Start date shows.', ); assert.strictEqual( component.reports[0].endDate, - this.intl.formatDate(reportModel2.endDate), + this.intl.formatDate(reportModel2.endDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), 'End date shows.', ); assert.strictEqual(component.reports[0].status, 'Finalized', 'Status shows.'); @@ -110,12 +118,20 @@ module('Integration | Component | curriculum-inventory/report-list', function (h assert.strictEqual(component.reports[1].year, '2017', 'Academic year shows.'); assert.strictEqual( component.reports[1].startDate, - this.intl.formatDate(reportModel1.startDate), + this.intl.formatDate(reportModel1.startDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), 'Start date shows.', ); assert.strictEqual( component.reports[1].endDate, - this.intl.formatDate(reportModel1.endDate), + this.intl.formatDate(reportModel1.endDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), 'End date shows.', ); assert.strictEqual(component.reports[1].status, 'Draft', 'Status shows.'); diff --git a/packages/frontend/tests/integration/components/curriculum-inventory/report-overview-test.js b/packages/frontend/tests/integration/components/curriculum-inventory/report-overview-test.js index b90efd9f33..ae154069ad 100644 --- a/packages/frontend/tests/integration/components/curriculum-inventory/report-overview-test.js +++ b/packages/frontend/tests/integration/components/curriculum-inventory/report-overview-test.js @@ -55,13 +55,21 @@ module('Integration | Component | curriculum-inventory/report-overview', functio assert.strictEqual(component.startDate.label, 'Start:', 'Start date label is correct.'); assert.strictEqual( component.startDate.text, - this.intl.formatDate(reportModel.startDate), + this.intl.formatDate(reportModel.startDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), 'Start date is visible.', ); assert.strictEqual(component.endDate.label, 'End:', 'End date label is correct.'); assert.strictEqual( component.endDate.text, - this.intl.formatDate(reportModel.endDate), + this.intl.formatDate(reportModel.endDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), 'End date is visible.', ); assert.strictEqual( @@ -101,12 +109,20 @@ module('Integration | Component | curriculum-inventory/report-overview', functio ); assert.strictEqual( component.startDate.readOnlyText, - this.intl.formatDate(reportModel.startDate), + this.intl.formatDate(reportModel.startDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), 'Start date is visible.', ); assert.strictEqual( component.endDate.readOnlyText, - this.intl.formatDate(reportModel.endDate), + this.intl.formatDate(reportModel.endDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), 'End date is visible.', ); assert.strictEqual( @@ -203,7 +219,11 @@ module('Integration | Component | curriculum-inventory/report-overview', functio await component.startDate.save(); assert.strictEqual( component.startDate.text, - this.intl.formatDate(newVal), + this.intl.formatDate(newVal, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), 'Edit link shown new start date post-update.', ); assert.strictEqual( @@ -248,7 +268,11 @@ module('Integration | Component | curriculum-inventory/report-overview', functio await component.endDate.save(); assert.strictEqual( component.endDate.text, - this.intl.formatDate(newVal), + this.intl.formatDate(newVal, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), 'Edit link shown new end date post-update.', ); assert.strictEqual( diff --git a/packages/frontend/tests/integration/components/curriculum-inventory/sequence-block-list-item-test.js b/packages/frontend/tests/integration/components/curriculum-inventory/sequence-block-list-item-test.js index 52e6370258..870d791352 100644 --- a/packages/frontend/tests/integration/components/curriculum-inventory/sequence-block-list-item-test.js +++ b/packages/frontend/tests/integration/components/curriculum-inventory/sequence-block-list-item-test.js @@ -60,11 +60,19 @@ module('Integration | Component | curriculum-inventory/sequence-block-list-item' assert.strictEqual(component.orderInSequence, '3'); assert.strictEqual( component.startDate, - this.intl.formatDate(DateTime.fromObject({ year: 2021, month: 3, day: 17 }).toJSDate()), + this.intl.formatDate(DateTime.fromObject({ year: 2021, month: 3, day: 17 }).toJSDate(), { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), ); assert.strictEqual( component.endDate, - this.intl.formatDate(DateTime.fromObject({ year: 2021, month: 5, day: 22 }).toJSDate()), + this.intl.formatDate(DateTime.fromObject({ year: 2021, month: 5, day: 22 }).toJSDate(), { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), ); assert.strictEqual(component.course, 'course 0'); assert.ok(component.isDeletable); diff --git a/packages/frontend/tests/integration/components/curriculum-inventory/sequence-block-list-test.js b/packages/frontend/tests/integration/components/curriculum-inventory/sequence-block-list-test.js index bc6b973426..f8fcd842ae 100644 --- a/packages/frontend/tests/integration/components/curriculum-inventory/sequence-block-list-test.js +++ b/packages/frontend/tests/integration/components/curriculum-inventory/sequence-block-list-test.js @@ -143,11 +143,19 @@ module('Integration | Component | curriculum-inventory/sequence-block-list', fun assert.strictEqual(component.list.items[1].orderInSequence, 'n/a'); assert.strictEqual( component.list.items[1].startDate, - this.intl.formatDate(this.sequenceBlock1.startDate), + this.intl.formatDate(this.sequenceBlock1.startDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), ); assert.strictEqual( component.list.items[1].endDate, - this.intl.formatDate(this.sequenceBlock1.endDate), + this.intl.formatDate(this.sequenceBlock1.endDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), ); assert.strictEqual(component.list.items[1].course, this.course.title); assert.ok(component.list.items[1].isDeletable); @@ -190,11 +198,19 @@ module('Integration | Component | curriculum-inventory/sequence-block-list', fun assert.strictEqual(component.list.items[1].orderInSequence, 'n/a'); assert.strictEqual( component.list.items[1].startDate, - this.intl.formatDate(this.sequenceBlock1.startDate), + this.intl.formatDate(this.sequenceBlock1.startDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), ); assert.strictEqual( component.list.items[1].endDate, - this.intl.formatDate(this.sequenceBlock1.endDate), + this.intl.formatDate(this.sequenceBlock1.endDate, { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }), ); assert.strictEqual(component.list.items[1].course, this.course.title); assert.ok(component.list.items[1].isDeletable); diff --git a/packages/frontend/tests/integration/components/curriculum-inventory/sequence-block-overview-test.js b/packages/frontend/tests/integration/components/curriculum-inventory/sequence-block-overview-test.js index e4fe619218..73543e59e3 100644 --- a/packages/frontend/tests/integration/components/curriculum-inventory/sequence-block-overview-test.js +++ b/packages/frontend/tests/integration/components/curriculum-inventory/sequence-block-overview-test.js @@ -114,7 +114,7 @@ module('Integration | Component | curriculum-inventory/sequence-block-overview', assert.ok(component.description.isEditable); assert.strictEqual( component.course.text, - `Course: Course A Level: 4, Start Date: 2/2/2015, End Date: 3/30/2015 - Clerkship (Block)`, + `Course: Course A Level: 4, Start Date: 02/02/2015, End Date: 03/30/2015 - Clerkship (Block)`, ); assert.ok(component.course.isEditable); const startLevel = await sequenceBlockModel.startingAcademicLevel; @@ -128,9 +128,9 @@ module('Integration | Component | curriculum-inventory/sequence-block-overview', assert.strictEqual(component.track.label, 'Is Track:'); assert.strictEqual(component.track.yesNoToggle.checked, 'true'); assert.ok(component.track.isEditable); - assert.strictEqual(component.startDate.text, 'Start: 1/2/2015'); + assert.strictEqual(component.startDate.text, 'Start: 01/02/2015'); assert.ok(component.startDate.isEditable); - assert.strictEqual(component.endDate.text, 'End: 4/30/2015'); + assert.strictEqual(component.endDate.text, 'End: 04/30/2015'); assert.ok(component.endDate.isEditable); assert.strictEqual( component.duration.text, @@ -295,7 +295,7 @@ module('Integration | Component | curriculum-inventory/sequence-block-overview', />`); assert.strictEqual( component.course.text, - `Course: Alpha Level: 1, Start Date: 1/1/2016, End Date: 1/2/2016 - Clerkship (clerkship type 0)`, + `Course: Alpha Level: 1, Start Date: 01/01/2016, End Date: 01/02/2016 - Clerkship (clerkship type 0)`, ); await component.course.edit(); assert.strictEqual(component.course.options.length, 4); @@ -303,7 +303,7 @@ module('Integration | Component | curriculum-inventory/sequence-block-overview', assert.strictEqual(component.course.options[1].text, 'Alpha'); assert.strictEqual( component.course.details, - 'Level: 1, Start Date: 1/1/2016, End Date: 1/2/2016 - Clerkship (clerkship type 0)', + 'Level: 1, Start Date: 01/01/2016, End Date: 01/02/2016 - Clerkship (clerkship type 0)', ); assert.strictEqual(component.course.options[1].value, courseModel.id); assert.ok(component.course.options[1].isSelected); @@ -312,12 +312,12 @@ module('Integration | Component | curriculum-inventory/sequence-block-overview', await component.course.select(newCourseModel.id); assert.strictEqual( component.course.details, - 'Level: 1, Start Date: 3/1/2016, End Date: 3/2/2016 - Clerkship (clerkship type 0)', + 'Level: 1, Start Date: 03/01/2016, End Date: 03/02/2016 - Clerkship (clerkship type 0)', ); await component.course.save(); assert.strictEqual( component.course.text, - 'Course: Gamma Level: 1, Start Date: 3/1/2016, End Date: 3/2/2016 - Clerkship (clerkship type 0)', + 'Course: Gamma Level: 1, Start Date: 03/01/2016, End Date: 03/02/2016 - Clerkship (clerkship type 0)', ); const blockCourse = await sequenceBlockModel.course; assert.strictEqual(blockCourse.id, newCourse.id); @@ -770,7 +770,7 @@ module('Integration | Component | curriculum-inventory/sequence-block-overview', assert.notOk(component.description.isEditable); assert.strictEqual( component.course.text, - `Course: Course A Level: 4, Start Date: 2/2/2015, End Date: 3/30/2015 - Clerkship (Block)`, + `Course: Course A Level: 4, Start Date: 02/02/2015, End Date: 03/30/2015 - Clerkship (Block)`, ); assert.notOk(component.course.isEditable); assert.strictEqual(component.startLevel.text, 'Start Level: Year 1'); @@ -781,9 +781,9 @@ module('Integration | Component | curriculum-inventory/sequence-block-overview', assert.notOk(component.required.isEditable); assert.strictEqual(component.track.text, 'Is Track: Yes'); assert.notOk(component.track.isEditable); - assert.strictEqual(component.startDate.text, 'Start: 1/2/2015'); + assert.strictEqual(component.startDate.text, 'Start: 01/02/2015'); assert.notOk(component.startDate.isEditable); - assert.strictEqual(component.endDate.text, 'End: 4/30/2015'); + assert.strictEqual(component.endDate.text, 'End: 04/30/2015'); assert.notOk(component.endDate.isEditable); assert.strictEqual( component.duration.text, @@ -1244,7 +1244,7 @@ module('Integration | Component | curriculum-inventory/sequence-block-overview', await component.durationEditor.save(); assert.strictEqual(component.startDate.text, 'Start: 10/30/2016'); assert.ok(component.startDate.isEditable); - assert.strictEqual(component.endDate.text, 'End: 11/2/2016'); + assert.strictEqual(component.endDate.text, 'End: 11/02/2016'); assert.ok(component.endDate.isEditable); assert.strictEqual( component.duration.text, @@ -1301,7 +1301,7 @@ module('Integration | Component | curriculum-inventory/sequence-block-overview', await component.durationEditor.save(); assert.strictEqual(component.startDate.text, 'Start: 10/30/2016'); assert.ok(component.startDate.isEditable); - assert.strictEqual(component.endDate.text, 'End: 11/2/2016'); + assert.strictEqual(component.endDate.text, 'End: 11/02/2016'); assert.strictEqual(component.duration.text, `Duration (in Days): Click to edit`); const { startDate, endDate, duration } = sequenceBlockModel; @@ -1396,9 +1396,9 @@ module('Integration | Component | curriculum-inventory/sequence-block-overview', @setSortBy={{(noop)}} />`); - assert.strictEqual(component.startDate.text, 'Start: 4/23/2016'); + assert.strictEqual(component.startDate.text, 'Start: 04/23/2016'); assert.ok(component.startDate.isEditable); - assert.strictEqual(component.endDate.text, 'End: 6/22/2016'); + assert.strictEqual(component.endDate.text, 'End: 06/22/2016'); assert.ok(component.endDate.isEditable); assert.strictEqual( component.duration.text, @@ -1409,9 +1409,9 @@ module('Integration | Component | curriculum-inventory/sequence-block-overview', await component.durationEditor.endDate.set('2016-11-02'); await component.durationEditor.duration.set(newDuration); await component.durationEditor.cancel(); - assert.strictEqual(component.startDate.text, 'Start: 4/23/2016'); + assert.strictEqual(component.startDate.text, 'Start: 04/23/2016'); assert.ok(component.startDate.isEditable); - assert.strictEqual(component.endDate.text, 'End: 6/22/2016'); + assert.strictEqual(component.endDate.text, 'End: 06/22/2016'); assert.strictEqual( component.duration.text, `Duration (in Days): ${sequenceBlockModel.duration}`,