From 3947c4311e1211ff0800604b6840c0a21aac45b2 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Mon, 30 Dec 2024 01:55:26 -0800 Subject: [PATCH 1/5] Fix Calendar Week at a Glance at Year Boundary At the start and end of the year we need to pay special attention to the week, otherwise we get bad results. --- .../addon/components/dashboard/week.js | 38 ++++-- .../components/dashboard/week-test.js | 122 ++++++++++-------- 2 files changed, 90 insertions(+), 70 deletions(-) diff --git a/packages/ilios-common/addon/components/dashboard/week.js b/packages/ilios-common/addon/components/dashboard/week.js index 049d6e29e6..6a4164c73a 100644 --- a/packages/ilios-common/addon/components/dashboard/week.js +++ b/packages/ilios-common/addon/components/dashboard/week.js @@ -1,25 +1,37 @@ import Component from '@glimmer/component'; import { DateTime } from 'luxon'; + export default class DashboardWeekComponent extends Component { get expanded() { - const now = DateTime.now(); - const lastSunday = now.set({ weekday: 1 }).minus({ week: 1 }).toFormat('W'); - const thisSunday = now.set({ weekday: 1 }).toFormat('W'); - const nextSunday = now.set({ weekday: 1 }).plus({ week: 1 }).toFormat('W'); + const lastSunday = this.thisThursday.minus({ week: 1 }).toFormat('W'); + const thisSunday = this.thisThursday.toFormat('W'); + const nextSunday = this.thisThursday.plus({ week: 1 }).toFormat('W'); return `${lastSunday}-${thisSunday}-${nextSunday}`; } + + get thisThursday() { + const thursday = DateTime.fromObject({ + weekday: 4, + hour: 0, + minute: 0, + second: 0, + }); + + // In this component the week always starts on Sunday, but luxon's starts on Monday + // If today is sunday, we need to add a week to get the correct Thursday + if (DateTime.now().weekday === 7) { + return thursday.plus({ weeks: 1 }); + } + + return thursday; + } + get year() { - return DateTime.now().year; + return this.thisThursday.weekYear; } + get week() { - const today = DateTime.now(); - // In this component the week always starts on Sunday, but luxon's starts on Monday - // so we need to adjust the week number to account for that. - if (today.weekday === 7) { - return today.weekNumber + 1; - } else { - return today.weekNumber; - } + return this.thisThursday.weekNumber; } } diff --git a/packages/test-app/tests/integration/components/dashboard/week-test.js b/packages/test-app/tests/integration/components/dashboard/week-test.js index e939222156..2dfc6bf7e6 100644 --- a/packages/test-app/tests/integration/components/dashboard/week-test.js +++ b/packages/test-app/tests/integration/components/dashboard/week-test.js @@ -34,6 +34,15 @@ module('Integration | Component | dashboard/week', function (hooks) { return expectedTitle; }; + + this.setupEmptyEvents = function () { + class UserEvents extends Service { + async getEvents() { + return []; + } + } + this.owner.register('service:user-events', UserEvents); + }; }); hooks.afterEach(() => { @@ -92,14 +101,7 @@ module('Integration | Component | dashboard/week', function (hooks) { }); test('it renders blank', async function (assert) { - class UserEvents extends Service { - async getEvents() { - return []; - } - } - this.owner.register('service:user-events', UserEvents); - this.userEvents = this.owner.lookup('service:user-events'); - + this.setupEmptyEvents(); await render(hbs``); const expectedTitle = this.getTitle(); assert.strictEqual(component.weeklyLink, 'All Weeks'); @@ -108,13 +110,7 @@ module('Integration | Component | dashboard/week', function (hooks) { }); test('right week on sunday #5308', async function (assert) { - class UserEvents extends Service { - async getEvents() { - return []; - } - } - this.owner.register('service:user-events', UserEvents); - this.userEvents = this.owner.lookup('service:user-events'); + this.setupEmptyEvents(); freezeDateAt(DateTime.fromObject({ year: 2024, month: 3, day: 10 }).toJSDate()); await render(hbs``); @@ -122,13 +118,7 @@ module('Integration | Component | dashboard/week', function (hooks) { }); test('right week on monday #5308', async function (assert) { - class UserEvents extends Service { - async getEvents() { - return []; - } - } - this.owner.register('service:user-events', UserEvents); - this.userEvents = this.owner.lookup('service:user-events'); + this.setupEmptyEvents(); freezeDateAt(DateTime.fromObject({ year: 2023, month: 8, day: 7 }).toJSDate()); await render(hbs``); @@ -136,67 +126,85 @@ module('Integration | Component | dashboard/week', function (hooks) { }); test('right week on tuesday #5308', async function (assert) { - class UserEvents extends Service { - async getEvents() { - return []; - } - } - this.owner.register('service:user-events', UserEvents); - this.userEvents = this.owner.lookup('service:user-events'); + this.setupEmptyEvents(); freezeDateAt(DateTime.fromObject({ year: 2022, month: 12, day: 6 }).toJSDate()); await render(hbs``); assert.strictEqual(component.weekGlance.title, 'December 4-10 Week at a Glance'); }); test('right week on wednesday #5308', async function (assert) { - class UserEvents extends Service { - async getEvents() { - return []; - } - } - this.owner.register('service:user-events', UserEvents); - this.userEvents = this.owner.lookup('service:user-events'); + this.setupEmptyEvents(); freezeDateAt(DateTime.fromObject({ year: 2022, month: 7, day: 13 }).toJSDate()); await render(hbs``); assert.strictEqual(component.weekGlance.title, 'July 10-16 Week at a Glance'); }); test('right week on thursday #5308', async function (assert) { - class UserEvents extends Service { - async getEvents() { - return []; - } - } - this.owner.register('service:user-events', UserEvents); - this.userEvents = this.owner.lookup('service:user-events'); + this.setupEmptyEvents(); freezeDateAt(DateTime.fromObject({ year: 2021, month: 5, day: 13 }).toJSDate()); await render(hbs``); assert.strictEqual(component.weekGlance.title, 'May 9-15 Week at a Glance'); }); test('right week on friday #5308', async function (assert) { - class UserEvents extends Service { - async getEvents() { - return []; - } - } - this.owner.register('service:user-events', UserEvents); - this.userEvents = this.owner.lookup('service:user-events'); + this.setupEmptyEvents(); freezeDateAt(DateTime.fromObject({ year: 2021, month: 9, day: 24 }).toJSDate()); await render(hbs``); assert.strictEqual(component.weekGlance.title, 'September 19-25 Week at a Glance'); }); test('right week on saturday #5308', async function (assert) { - class UserEvents extends Service { - async getEvents() { - return []; - } - } - this.owner.register('service:user-events', UserEvents); - this.userEvents = this.owner.lookup('service:user-events'); + this.setupEmptyEvents(); freezeDateAt(DateTime.fromObject({ year: 2022, month: 7, day: 30 }).toJSDate()); await render(hbs``); assert.strictEqual(component.weekGlance.title, 'July 24-30 Week at a Glance'); }); + + test('correct at the start of 2024 ilios/ilios#5908', async function (assert) { + this.setupEmptyEvents(); + freezeDateAt(DateTime.fromObject({ year: 2024, month: 1, day: 2 }).toJSDate()); + await render(hbs``); + + assert.strictEqual(component.weekGlance.title, 'December 31 - January 6 Week at a Glance'); + }); + + test('correct at the end of 2024 ilios/ilios#5908', async function (assert) { + this.setupEmptyEvents(); + freezeDateAt(DateTime.fromObject({ year: 2024, month: 12, day: 30 }).toJSDate()); + await render(hbs``); + + assert.strictEqual(component.weekGlance.title, 'December 29 - January 4 Week at a Glance'); + }); + + test('correct at the start of 2025 ilios/ilios#5908', async function (assert) { + this.setupEmptyEvents(); + freezeDateAt(DateTime.fromObject({ year: 2025, month: 1, day: 3 }).toJSDate()); + await render(hbs``); + + assert.strictEqual(component.weekGlance.title, 'December 29 - January 4 Week at a Glance'); + }); + + test('correct at the end of 2025 ilios/ilios#5908', async function (assert) { + this.setupEmptyEvents(); + freezeDateAt(DateTime.fromObject({ year: 2025, month: 12, day: 30 }).toJSDate()); + await render(hbs``); + + assert.strictEqual(component.weekGlance.title, 'December 28 - January 3 Week at a Glance'); + }); + + test('correct at the start of 2026 ilios/ilios#5908', async function (assert) { + this.setupEmptyEvents(); + freezeDateAt(DateTime.fromObject({ year: 2026, month: 1, day: 2 }).toJSDate()); + await render(hbs``); + + assert.strictEqual(component.weekGlance.title, 'December 28 - January 3 Week at a Glance'); + }); + + test('correct on some random day ilios/ilios#5908', async function (assert) { + this.setupEmptyEvents(); + freezeDateAt(DateTime.fromObject({ year: 2005, month: 6, day: 24 }).toJSDate()); + await render(hbs``); + + assert.strictEqual(component.weekGlance.title, 'June 19-25 Week at a Glance'); + }); }); From b149ea0ad18d96b41e67108043217096ce368f8b Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Mon, 30 Dec 2024 02:18:20 -0800 Subject: [PATCH 2/5] Add More Date Tests Tests every single day around the year change against the reality we expect. --- .../components/dashboard/week-test.js | 187 ++++++++++-------- 1 file changed, 103 insertions(+), 84 deletions(-) diff --git a/packages/test-app/tests/integration/components/dashboard/week-test.js b/packages/test-app/tests/integration/components/dashboard/week-test.js index 2dfc6bf7e6..0966f34795 100644 --- a/packages/test-app/tests/integration/components/dashboard/week-test.js +++ b/packages/test-app/tests/integration/components/dashboard/week-test.js @@ -35,14 +35,25 @@ module('Integration | Component | dashboard/week', function (hooks) { return expectedTitle; }; - this.setupEmptyEvents = function () { + this.setupEvents = function (events) { class UserEvents extends Service { async getEvents() { - return []; + return events; } } this.owner.register('service:user-events', UserEvents); }; + + this.testTitleOnDate = async function (assert, obj, expectedTitle) { + const dt = DateTime.fromObject(obj); + freezeDateAt(dt.toJSDate()); + await render(hbs``); + assert.strictEqual( + component.weekGlance.title, + expectedTitle, + `correct title on ${dt.toISODate()}`, + ); + }; }); hooks.afterEach(() => { @@ -84,12 +95,7 @@ module('Integration | Component | dashboard/week', function (hooks) { }); const { userevents } = this.server.db; - class UserEvents extends Service { - async getEvents() { - return userevents; - } - } - this.owner.register('service:user-events', UserEvents); + this.setupEvents(userevents); await render(hbs``); const expectedTitle = this.getTitle(); @@ -101,7 +107,7 @@ module('Integration | Component | dashboard/week', function (hooks) { }); test('it renders blank', async function (assert) { - this.setupEmptyEvents(); + this.setupEvents([]); await render(hbs``); const expectedTitle = this.getTitle(); assert.strictEqual(component.weeklyLink, 'All Weeks'); @@ -110,101 +116,114 @@ module('Integration | Component | dashboard/week', function (hooks) { }); test('right week on sunday #5308', async function (assert) { - this.setupEmptyEvents(); - freezeDateAt(DateTime.fromObject({ year: 2024, month: 3, day: 10 }).toJSDate()); - - await render(hbs``); - assert.strictEqual(component.weekGlance.title, 'March 10-16 Week at a Glance'); + assert.expect(1); + await this.testTitleOnDate( + assert, + { year: 2024, month: 3, day: 10 }, + 'March 10-16 Week at a Glance', + ); }); test('right week on monday #5308', async function (assert) { - this.setupEmptyEvents(); - freezeDateAt(DateTime.fromObject({ year: 2023, month: 8, day: 7 }).toJSDate()); - - await render(hbs``); - assert.strictEqual(component.weekGlance.title, 'August 6-12 Week at a Glance'); + assert.expect(1); + await this.testTitleOnDate( + assert, + { year: 2023, month: 8, day: 7 }, + 'August 6-12 Week at a Glance', + ); }); test('right week on tuesday #5308', async function (assert) { - this.setupEmptyEvents(); - freezeDateAt(DateTime.fromObject({ year: 2022, month: 12, day: 6 }).toJSDate()); - await render(hbs``); - assert.strictEqual(component.weekGlance.title, 'December 4-10 Week at a Glance'); + assert.expect(1); + await this.testTitleOnDate( + assert, + { year: 2022, month: 12, day: 6 }, + 'December 4-10 Week at a Glance', + ); }); test('right week on wednesday #5308', async function (assert) { - this.setupEmptyEvents(); - freezeDateAt(DateTime.fromObject({ year: 2022, month: 7, day: 13 }).toJSDate()); - await render(hbs``); - assert.strictEqual(component.weekGlance.title, 'July 10-16 Week at a Glance'); + assert.expect(1); + await this.testTitleOnDate( + assert, + { year: 2022, month: 7, day: 13 }, + 'July 10-16 Week at a Glance', + ); }); test('right week on thursday #5308', async function (assert) { - this.setupEmptyEvents(); - freezeDateAt(DateTime.fromObject({ year: 2021, month: 5, day: 13 }).toJSDate()); - await render(hbs``); - assert.strictEqual(component.weekGlance.title, 'May 9-15 Week at a Glance'); + assert.expect(1); + await this.testTitleOnDate( + assert, + { year: 2021, month: 5, day: 13 }, + 'May 9-15 Week at a Glance', + ); }); test('right week on friday #5308', async function (assert) { - this.setupEmptyEvents(); - freezeDateAt(DateTime.fromObject({ year: 2021, month: 9, day: 24 }).toJSDate()); - await render(hbs``); - assert.strictEqual(component.weekGlance.title, 'September 19-25 Week at a Glance'); + assert.expect(1); + await this.testTitleOnDate( + assert, + { year: 2021, month: 9, day: 24 }, + 'September 19-25 Week at a Glance', + ); }); test('right week on saturday #5308', async function (assert) { - this.setupEmptyEvents(); - freezeDateAt(DateTime.fromObject({ year: 2022, month: 7, day: 30 }).toJSDate()); - await render(hbs``); - assert.strictEqual(component.weekGlance.title, 'July 24-30 Week at a Glance'); - }); - - test('correct at the start of 2024 ilios/ilios#5908', async function (assert) { - this.setupEmptyEvents(); - freezeDateAt(DateTime.fromObject({ year: 2024, month: 1, day: 2 }).toJSDate()); - await render(hbs``); - - assert.strictEqual(component.weekGlance.title, 'December 31 - January 6 Week at a Glance'); - }); - - test('correct at the end of 2024 ilios/ilios#5908', async function (assert) { - this.setupEmptyEvents(); - freezeDateAt(DateTime.fromObject({ year: 2024, month: 12, day: 30 }).toJSDate()); - await render(hbs``); - - assert.strictEqual(component.weekGlance.title, 'December 29 - January 4 Week at a Glance'); - }); - - test('correct at the start of 2025 ilios/ilios#5908', async function (assert) { - this.setupEmptyEvents(); - freezeDateAt(DateTime.fromObject({ year: 2025, month: 1, day: 3 }).toJSDate()); - await render(hbs``); - - assert.strictEqual(component.weekGlance.title, 'December 29 - January 4 Week at a Glance'); - }); - - test('correct at the end of 2025 ilios/ilios#5908', async function (assert) { - this.setupEmptyEvents(); - freezeDateAt(DateTime.fromObject({ year: 2025, month: 12, day: 30 }).toJSDate()); - await render(hbs``); - - assert.strictEqual(component.weekGlance.title, 'December 28 - January 3 Week at a Glance'); - }); - - test('correct at the start of 2026 ilios/ilios#5908', async function (assert) { - this.setupEmptyEvents(); - freezeDateAt(DateTime.fromObject({ year: 2026, month: 1, day: 2 }).toJSDate()); - await render(hbs``); - - assert.strictEqual(component.weekGlance.title, 'December 28 - January 3 Week at a Glance'); + assert.expect(1); + await this.testTitleOnDate( + assert, + { year: 2022, month: 7, day: 30 }, + 'July 24-30 Week at a Glance', + ); + }); + + test('correct at the end of 2023 and the start of 2024 ilios/ilios#5908', async function (assert) { + assert.expect(7); + this.setupEvents([]); + const title = 'December 31 - January 6 Week at a Glance'; + await this.testTitleOnDate(assert, { year: 2023, month: 12, day: 31 }, title); + await this.testTitleOnDate(assert, { year: 2024, month: 1, day: 1 }, title); + await this.testTitleOnDate(assert, { year: 2024, month: 1, day: 2 }, title); + await this.testTitleOnDate(assert, { year: 2024, month: 1, day: 3 }, title); + await this.testTitleOnDate(assert, { year: 2024, month: 1, day: 4 }, title); + await this.testTitleOnDate(assert, { year: 2024, month: 1, day: 5 }, title); + await this.testTitleOnDate(assert, { year: 2024, month: 1, day: 6 }, title); + }); + + test('correct at the end of 2024 and start of 2025 ilios/ilios#5908', async function (assert) { + assert.expect(7); + this.setupEvents([]); + const title = 'December 29 - January 4 Week at a Glance'; + await this.testTitleOnDate(assert, { year: 2024, month: 12, day: 29 }, title); + await this.testTitleOnDate(assert, { year: 2024, month: 12, day: 30 }, title); + await this.testTitleOnDate(assert, { year: 2024, month: 12, day: 31 }, title); + await this.testTitleOnDate(assert, { year: 2025, month: 1, day: 1 }, title); + await this.testTitleOnDate(assert, { year: 2025, month: 1, day: 2 }, title); + await this.testTitleOnDate(assert, { year: 2025, month: 1, day: 3 }, title); + await this.testTitleOnDate(assert, { year: 2025, month: 1, day: 4 }, title); + }); + + test('correct at the end of 2025 and start of 2026 ilios/ilios#5908', async function (assert) { + assert.expect(7); + this.setupEvents([]); + const title = 'December 28 - January 3 Week at a Glance'; + await this.testTitleOnDate(assert, { year: 2025, month: 12, day: 28 }, title); + await this.testTitleOnDate(assert, { year: 2025, month: 12, day: 29 }, title); + await this.testTitleOnDate(assert, { year: 2025, month: 12, day: 30 }, title); + await this.testTitleOnDate(assert, { year: 2025, month: 12, day: 31 }, title); + await this.testTitleOnDate(assert, { year: 2026, month: 1, day: 1 }, title); + await this.testTitleOnDate(assert, { year: 2026, month: 1, day: 2 }, title); + await this.testTitleOnDate(assert, { year: 2026, month: 1, day: 3 }, title); }); test('correct on some random day ilios/ilios#5908', async function (assert) { - this.setupEmptyEvents(); - freezeDateAt(DateTime.fromObject({ year: 2005, month: 6, day: 24 }).toJSDate()); - await render(hbs``); - - assert.strictEqual(component.weekGlance.title, 'June 19-25 Week at a Glance'); + assert.expect(1); + this.setupEvents([]); + await this.testTitleOnDate( + assert, + { year: 2005, month: 6, day: 24 }, + 'June 19-25 Week at a Glance', + ); }); }); From c51fc6e8504c8f8a3903d5213878307d7b5ac9b4 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Mon, 30 Dec 2024 02:46:28 -0800 Subject: [PATCH 3/5] Gracefully Fail for Bad Dates If we pass invalid data to this component such as a week that cannot exist in a year we should die much less horribly than we do right now. Kick out an error, and then don't display a title. --- .../ilios-common/addon/components/week-glance.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/ilios-common/addon/components/week-glance.js b/packages/ilios-common/addon/components/week-glance.js index 9376576cef..7664848f5b 100644 --- a/packages/ilios-common/addon/components/week-glance.js +++ b/packages/ilios-common/addon/components/week-glance.js @@ -29,21 +29,33 @@ export default class WeeklyGlance extends Component { } get thursdayOfTheWeek() { - return DateTime.fromObject({ + const thursday = DateTime.fromObject({ weekYear: this.args.year, weekNumber: this.args.week, weekday: 4, hour: 0, minute: 0, second: 0, - }).toJSDate(); + }); + + if (!thursday.isValid) { + console.error('Invalid date', thursday.invalidReason, this.args.year, this.args.week); + return null; + } + return thursday.toJSDate(); } get midnightAtTheStartOfTheWeekDateTime() { + if (!this.thursdayOfTheWeek) { + return null; + } return DateTime.fromJSDate(this.localeDays.firstDayOfDateWeek(this.thursdayOfTheWeek)); } get midnightAtTheEndOfTheWeekDateTime() { + if (!this.thursdayOfTheWeek) { + return null; + } return DateTime.fromJSDate(this.localeDays.lastDayOfDateWeek(this.thursdayOfTheWeek)); } From 60dcd7d8d63fe36408b9a9e8996c24fb02105d3e Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Mon, 30 Dec 2024 02:48:36 -0800 Subject: [PATCH 4/5] Remove Issue from Test This test doesn't cover this issue. --- .../tests/integration/components/dashboard/week-test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/test-app/tests/integration/components/dashboard/week-test.js b/packages/test-app/tests/integration/components/dashboard/week-test.js index 0966f34795..76db3d1838 100644 --- a/packages/test-app/tests/integration/components/dashboard/week-test.js +++ b/packages/test-app/tests/integration/components/dashboard/week-test.js @@ -178,7 +178,7 @@ module('Integration | Component | dashboard/week', function (hooks) { ); }); - test('correct at the end of 2023 and the start of 2024 ilios/ilios#5908', async function (assert) { + test('correct at the end of 2023 and the start of 2024', async function (assert) { assert.expect(7); this.setupEvents([]); const title = 'December 31 - January 6 Week at a Glance'; @@ -191,7 +191,7 @@ module('Integration | Component | dashboard/week', function (hooks) { await this.testTitleOnDate(assert, { year: 2024, month: 1, day: 6 }, title); }); - test('correct at the end of 2024 and start of 2025 ilios/ilios#5908', async function (assert) { + test('correct at the end of 2024 and start of 2025', async function (assert) { assert.expect(7); this.setupEvents([]); const title = 'December 29 - January 4 Week at a Glance'; @@ -204,7 +204,7 @@ module('Integration | Component | dashboard/week', function (hooks) { await this.testTitleOnDate(assert, { year: 2025, month: 1, day: 4 }, title); }); - test('correct at the end of 2025 and start of 2026 ilios/ilios#5908', async function (assert) { + test('correct at the end of 2025 and start of 2026', async function (assert) { assert.expect(7); this.setupEvents([]); const title = 'December 28 - January 3 Week at a Glance'; @@ -217,7 +217,7 @@ module('Integration | Component | dashboard/week', function (hooks) { await this.testTitleOnDate(assert, { year: 2026, month: 1, day: 3 }, title); }); - test('correct on some random day ilios/ilios#5908', async function (assert) { + test('correct on some random day', async function (assert) { assert.expect(1); this.setupEvents([]); await this.testTitleOnDate( From 00bdbeb6c072adbf73a1c7de088cc341501b0546 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Mon, 30 Dec 2024 02:50:46 -0800 Subject: [PATCH 5/5] Fix weeksInWeekYear calculation Doing this by modifying the current year didn't work. I'm not 100% sure why, but the right way to run a single value into a Luxon DateTime is with fromObject so I switched to this. This prevents us from passing a bad combination of weeks in a year and the year and blowing up the page. --- .../addon/components/weekly-events.js | 4 +- .../components/weekly-events-test.js | 46 +++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/packages/ilios-common/addon/components/weekly-events.js b/packages/ilios-common/addon/components/weekly-events.js index 3013498d61..113477fa2f 100644 --- a/packages/ilios-common/addon/components/weekly-events.js +++ b/packages/ilios-common/addon/components/weekly-events.js @@ -4,9 +4,9 @@ import { DateTime } from 'luxon'; export default class WeeklyEvents extends Component { get weeksInYear() { - const weeksInTheYear = DateTime.now().set({ year: this.args.year }).weeksInWeekYear; + const { weeksInWeekYear } = DateTime.fromObject({ year: this.args.year }); const weeks = []; - for (let i = 1; i <= weeksInTheYear; i++) { + for (let i = 1; i <= weeksInWeekYear; i++) { weeks.push(`${i}`); } return weeks; diff --git a/packages/test-app/tests/integration/components/weekly-events-test.js b/packages/test-app/tests/integration/components/weekly-events-test.js index 3ae85bbcda..19d36056cb 100644 --- a/packages/test-app/tests/integration/components/weekly-events-test.js +++ b/packages/test-app/tests/integration/components/weekly-events-test.js @@ -114,4 +114,50 @@ module('Integration | Component | weekly events', function (hooks) { assert.strictEqual(component.topNavigation.title, '2016'); assert.strictEqual(component.bottomNavigation.title, '2016'); }); + + test('it renders 2024 ilios/ilios#5908', async function (assert) { + await render( + hbs``, + ); + assert.strictEqual(component.topNavigation.title, '2024'); + assert.strictEqual(component.weeks.length, 52); + assert.strictEqual(component.weeks[0].title, 'December 31 - January 6'); + assert.strictEqual(component.weeks[51].title, 'December 22-28'); + }); + + test('it renders 2025 ilios/ilios#5908', async function (assert) { + await render( + hbs``, + ); + assert.strictEqual(component.topNavigation.title, '2025'); + assert.strictEqual(component.weeks.length, 52); + assert.strictEqual(component.weeks[0].title, 'December 29 - January 4'); + assert.strictEqual(component.weeks[51].title, 'December 21-27'); + }); + + test('it renders 2026 ilios/ilios#5908', async function (assert) { + assert.expect(4); + await render( + hbs``, + ); + assert.strictEqual(component.topNavigation.title, '2026'); + assert.strictEqual(component.weeks.length, 53); + assert.strictEqual(component.weeks[0].title, 'December 28 - January 3'); + assert.strictEqual(component.weeks[52].title, 'December 27 - January 2'); + }); });