Skip to content

Commit

Permalink
Merge pull request #8008 from stopfstedt/school-events-user-context-f…
Browse files Browse the repository at this point in the history
…ilter

prevent the application of user context filters on school events.
  • Loading branch information
dartajax authored Jul 25, 2024
2 parents cc7ee08 + 3886e2a commit a2425ad
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
36 changes: 36 additions & 0 deletions packages/frontend/tests/acceptance/dashboard/calendar-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,42 @@ module('Acceptance | Dashboard Calendar', function (hooks) {
assert.notOk(page.calendar.controls.userContextFilter.isPresent);
});

test('user context filters do not apply to school calendar', async function (assert) {
assert.expect(2);
this.user = await setupAuthentication({ school: this.school }, true);
const day = DateTime.fromObject({
month: 7,
day: 7,
year: 2007,
hour: 8,
minute: 8,
second: 8,
});
freezeDateAt(day.toJSDate());
this.server.create('schoolevent', {
school: 1,
startDate: day.toJSDate(),
endDate: day.plus({ hour: 1 }).toJSDate(),
offering: 1,
});
this.server.create('schoolevent', {
school: 1,
startDate: day.toJSDate(),
endDate: day.plus({ hour: 1 }).toJSDate(),
offering: 2,
});
await page.visit({ show: 'calendar' });
// switch to the school calendar and verify that events are present
await page.calendar.controls.mySchedule.toggle.secondLabel.click();
assert.strictEqual(page.calendar.calendar.weekly.events.length, 2);
// switch to the user calendar and apply a user context filter
await page.calendar.controls.mySchedule.toggle.firstLabel.click();
await page.calendar.controls.userContextFilter.learning.toggle();
// switch to the school calendar and verify that nothing has changed
await page.calendar.controls.mySchedule.toggle.secondLabel.click();
assert.strictEqual(page.calendar.calendar.weekly.events.length, 2);
});

test('test user context filters', async function (assert) {
assert.expect(11);
this.user = await setupAuthentication({ school: this.school }, true);
Expand Down
4 changes: 3 additions & 1 deletion packages/ilios-common/addon/components/dashboard/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ export default class DashboardCalendarComponent extends Component {
'eventsWithSelectedCohorts',
'eventsWithSelectedCourses',
'eventsWithSelectedTerms',
'eventsWithSelectedUserContext',
];
if (this.args.mySchedule) {
eventTypes.push('eventsWithSelectedUserContext');
}
const allFilteredEvents = eventTypes.map((name) => {
return this[name];
});
Expand Down

0 comments on commit a2425ad

Please sign in to comment.