Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

normalize date display format for course overview and materials #7881

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions packages/frontend/tests/acceptance/course/overview-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,23 @@ module('Acceptance | Course - Overview', function (hooks) {
await percySnapshot(assert);
assert.strictEqual(
page.details.overview.startDate.text,
'Start: ' + this.intl.formatDate(courseModel.startDate),
'Start: ' +
this.intl.formatDate(courseModel.startDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
);
assert.strictEqual(page.details.overview.externalId.text, 'Course ID: 123');
assert.strictEqual(page.details.overview.level.text, 'Level: 3');
assert.strictEqual(
page.details.overview.endDate.text,
'End: ' + this.intl.formatDate(courseModel.endDate),
'End: ' +
this.intl.formatDate(courseModel.endDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
);
assert.strictEqual(page.details.overview.universalLocator, 'ILIOS' + courseModel.id);
assert.strictEqual(
Expand All @@ -72,13 +82,23 @@ module('Acceptance | Course - Overview', function (hooks) {
await percySnapshot(assert);
assert.strictEqual(
page.details.overview.startDate.text,
'Start: ' + this.intl.formatDate(courseModel.startDate),
'Start: ' +
this.intl.formatDate(courseModel.startDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
);
assert.strictEqual(page.details.overview.externalId.text, 'Course ID: 123');
assert.strictEqual(page.details.overview.level.text, 'Level: 3');
assert.strictEqual(
page.details.overview.endDate.text,
'End: ' + this.intl.formatDate(courseModel.endDate),
'End: ' +
this.intl.formatDate(courseModel.endDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
);
assert.strictEqual(page.details.overview.universalLocator, 'ILIOS' + courseModel.id);
assert.strictEqual(
Expand Down Expand Up @@ -177,12 +197,12 @@ module('Acceptance | Course - Overview', function (hooks) {
});
const courseModel = await this.owner.lookup('service:store').findRecord('course', course.id);
await page.visit({ courseId: courseModel.id, details: true });
assert.strictEqual(page.details.overview.startDate.text, 'Start: 3/23/2013');
assert.strictEqual(page.details.overview.startDate.text, 'Start: 03/23/2013');
await page.details.overview.startDate.edit();
assert.strictEqual(page.details.overview.startDate.datePicker.value, '3/23/2013');
await page.details.overview.startDate.datePicker.set('2013-04-23');
await page.details.overview.startDate.save();
assert.strictEqual(page.details.overview.startDate.text, 'Start: 4/23/2013');
assert.strictEqual(page.details.overview.startDate.text, 'Start: 04/23/2013');
});

test('start date validation', async function (assert) {
Expand All @@ -195,7 +215,7 @@ module('Acceptance | Course - Overview', function (hooks) {
});
const courseModel = await this.owner.lookup('service:store').findRecord('course', course.id);
await page.visit({ courseId: courseModel.id, details: true });
assert.strictEqual(page.details.overview.startDate.text, `Start: 3/23/2013`);
assert.strictEqual(page.details.overview.startDate.text, `Start: 03/23/2013`);
assert.notOk(page.details.overview.startDate.hasError);
await page.details.overview.startDate.edit();
assert.strictEqual(page.details.overview.startDate.datePicker.value, '3/23/2013');
Expand All @@ -214,12 +234,12 @@ module('Acceptance | Course - Overview', function (hooks) {
});
const courseModel = await this.owner.lookup('service:store').findRecord('course', course.id);
await page.visit({ courseId: courseModel.id, details: true });
assert.strictEqual(page.details.overview.endDate.text, `End: 4/22/2015`);
assert.strictEqual(page.details.overview.endDate.text, `End: 04/22/2015`);
await page.details.overview.endDate.edit();
assert.strictEqual(page.details.overview.endDate.datePicker.value, '4/22/2015');
await page.details.overview.endDate.datePicker.set('2016-05-22');
await page.details.overview.endDate.save();
assert.strictEqual(page.details.overview.endDate.text, 'End: 5/22/2016');
assert.strictEqual(page.details.overview.endDate.text, 'End: 05/22/2016');
});

test('end date validation', async function (assert) {
Expand All @@ -232,7 +252,7 @@ module('Acceptance | Course - Overview', function (hooks) {
});
const courseModel = await this.owner.lookup('service:store').findRecord('course', course.id);
await page.visit({ courseId: courseModel.id, details: true });
assert.strictEqual(page.details.overview.endDate.text, 'End: 4/22/2013');
assert.strictEqual(page.details.overview.endDate.text, 'End: 04/22/2013');
assert.notOk(page.details.overview.endDate.hasError);
await page.details.overview.endDate.edit();
assert.strictEqual(page.details.overview.endDate.datePicker.value, '4/22/2013');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
</td>
<td>
{{#if lmObject.session.firstOfferingDate}}
{{format-date lmObject.session.firstOfferingDate}}
{{format-date lmObject.session.firstOfferingDate day="2-digit" month="2-digit" year="numeric"}}
{{else}}
{{t "general.none"}}
{{/if}}
Expand Down
8 changes: 4 additions & 4 deletions packages/ilios-common/addon/components/course-overview.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<span>
{{#if @editable}}
<EditableField
@value={{format-date @course.startDate}}
@value={{format-date @course.startDate day="2-digit" month="2-digit" year="numeric"}}
@save={{perform this.changeStartDate}}
@close={{this.revertStartDateChanges}}
>
Expand All @@ -129,7 +129,7 @@
</EditableField>
<ValidationError @errors={{get-errors-for this.startDate}} />
{{else}}
{{format-date @course.startDate}}&nbsp;
{{format-date @course.startDate day="2-digit" month="2-digit" year="numeric"}}&nbsp;
{{/if}}
</span>
</div>
Expand All @@ -138,7 +138,7 @@
<span>
{{#if @editable}}
<EditableField
@value={{format-date @course.endDate}}
@value={{format-date @course.endDate day="2-digit" month="2-digit" year="numeric"}}
@save={{perform this.changeEndDate}}
@close={{this.revertEndDateChanges}}
>
Expand All @@ -149,7 +149,7 @@
</EditableField>
<ValidationError @errors={{get-errors-for this.endDate}} />
{{else}}
{{format-date @course.endDate}}&nbsp;
{{format-date @course.endDate day="2-digit" month="2-digit" year="numeric"}}&nbsp;
{{/if}}
</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{{t "general.startDate"}}:
</label>
<span>
{{format-date @course.startDate}}
{{format-date @course.startDate day="2-digit" month="2-digit" year="numeric"}}
</span>
</div>
<div class="block">
Expand All @@ -53,7 +53,7 @@
{{t "general.endDate"}}:
</label>
<span>
{{format-date @course.endDate}}
{{format-date @course.endDate day="2-digit" month="2-digit" year="numeric"}}
</span>
</div>
<div class="block">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ module('Integration | Component | course materials', function (hooks) {
assert.strictEqual(component.sessions[0].type, 'Link');
assert.strictEqual(component.sessions[0].author, 'author1');
assert.strictEqual(component.sessions[0].sessionTitle, 'session1title');
assert.strictEqual(component.sessions[0].firstOffering, '2/2/2020');
assert.strictEqual(component.sessions[0].firstOffering, '02/02/2020');

assert.strictEqual(component.sessions.length, 3);
assert.strictEqual(component.sessions[1].title, 'title2');
Expand All @@ -140,15 +140,15 @@ module('Integration | Component | course materials', function (hooks) {
assert.strictEqual(component.sessions[1].type, 'File');
assert.strictEqual(component.sessions[1].author, 'author2');
assert.strictEqual(component.sessions[1].sessionTitle, 'session1title');
assert.strictEqual(component.sessions[1].firstOffering, '2/2/2020');
assert.strictEqual(component.sessions[1].firstOffering, '02/02/2020');

assert.strictEqual(component.sessions.length, 3);
assert.strictEqual(component.sessions[2].title, 'title3 citationtext');
assert.notOk(component.sessions[2].hasLink);
assert.strictEqual(component.sessions[2].type, 'Citation');
assert.strictEqual(component.sessions[2].author, 'author3');
assert.strictEqual(component.sessions[2].sessionTitle, 'session1title');
assert.strictEqual(component.sessions[2].firstOffering, '2/2/2020');
assert.strictEqual(component.sessions[2].firstOffering, '02/02/2020');
});

test('clicking sort fires action', async function (assert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ module('Integration | Component | course summary header', function (hooks) {
assert.dom(title).hasText('course 0');
assert.dom(printIcon).hasClass('fa-print');
assert.dom(rolloverIcon).hasClass('fa-shuffle');
assert.dom(start).hasText('6/24/2005');
assert.dom(start).hasText('06/24/2005');
assert.dom(externalId).hasText('abc');
assert.dom(end).hasText('8/12/2005');
assert.dom(end).hasText('08/12/2005');
assert.dom(level).hasText('3');
assert.dom(status).hasText('Published');
});
Expand Down