Skip to content

Commit

Permalink
added iconography module to SingleEvent integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchadwick committed Oct 21, 2024
1 parent f8a27fe commit 57a5d8f
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const definition = {
scope: '[data-test-header]',
hasLink: isPresent('a'),
title: text('[data-test-header-title]'),
isScheduled: isPresent('[data-test-scheduled-icon]'),
isDraft: isPresent('[data-test-draft-icon]'),
wasRecentlyUpdated: isPresent('[data-test-recently-updated-icon]'),
},
offeredAt: text('[data-test-offered-at]'),
offeredAtLink: attribute('href', '[data-test-offered-at] a'),
Expand Down
4 changes: 2 additions & 2 deletions packages/ilios-common/addon/components/single-event.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
data-test-recently-updated-icon
/>
{{/if}}
{{#if (not this.isPublished)}}
{{#if (not @event.isPublished)}}
<FaIcon
@icon="file-signature"
@title={{t "general.notPublished"}}
data-test-draft-icon
/>
{{else if this.isScheduled}}
{{else if @event.isScheduled}}
<FaIcon
@icon="clock"
@title={{t "general.scheduled" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,92 @@ module('Integration | Component | ilios calendar single event', function (hooks)
assert.ok(component.summary.header.hasLink);
});

module('iconography', function () {
test('recently updated', async function (assert) {
const now = DateTime.fromObject({ hour: 0, minute: 0, second: 0 });
this.server.create('userevent', {
name: 'Learn to Learn',
courseTitle: 'course',
startDate: now.toJSDate(),
endDate: now.plus({ hour: 1 }).toJSDate(),
isBlanked: false,
isPublished: true,
isScheduled: false,
offering: 1,
lastModified: now.plus({ hour: 1 }),
sessionTypeTitle: 'test type',
});

this.set('event', this.server.db.userevents[0]);
await render(hbs`<SingleEvent @event={{this.event}} />`);

assert.ok(component.summary.header.wasRecentlyUpdated, 'event has NewUpdates icon');
});

test('not recently updated', async function (assert) {
const now = DateTime.fromObject({ hour: 0, minute: 0, second: 0 });
this.server.create('userevent', {
name: 'Learn to Learn',
courseTitle: 'course',
startDate: now.toJSDate(),
endDate: now.plus({ days: 7 }).toJSDate(),
isBlanked: false,
isPublished: true,
isScheduled: false,
offering: 1,
lastModified: null,
sessionTypeTitle: 'test type',
});

this.set('event', this.server.db.userevents[0]);
await render(hbs`<SingleEvent @event={{this.event}} />`);
assert.notOk(
component.summary.header.wasRecentlyUpdated,
'event does not have NewUpdates icon',
);
});

test('scheduled', async function (assert) {
const now = DateTime.fromObject({ hour: 0, minute: 0, second: 0 });
this.server.create('userevent', {
name: 'Learn to Learn',
courseTitle: 'course',
startDate: now.toJSDate(),
endDate: now.plus({ hour: 1 }).toJSDate(),
isBlanked: false,
isPublished: true,
isScheduled: true,
offering: 1,
lastModified: null,
sessionTypeTitle: 'test type',
});

this.set('event', this.server.db.userevents[0]);
await render(hbs`<SingleEvent @event={{this.event}} />`);
assert.ok(component.summary.header.isScheduled, 'event has Scheduled icon');
});

test('draft', async function (assert) {
const now = DateTime.fromObject({ hour: 0, minute: 0, second: 0 });
this.server.create('userevent', {
name: 'Learn to Learn',
courseTitle: 'course',
startDate: now.toJSDate(),
endDate: now.plus({ hour: 1 }).toJSDate(),
isBlanked: false,
isPublished: false,
isScheduled: false,
offering: 1,
lastModified: null,
sessionTypeTitle: 'test type',
});

this.set('event', this.server.db.userevents[0]);
await render(hbs`<SingleEvent @event={{this.event}} />`);
assert.ok(component.summary.header.isDraft, 'event has NotPublished icon');
});
});

todo(
"non learners don't get link to session if session route doesn't exists",
async function (assert) {
Expand Down

0 comments on commit 57a5d8f

Please sign in to comment.