Skip to content

Commit

Permalink
Merge pull request #7309 from stopfstedt/todo-to-test
Browse files Browse the repository at this point in the history
fleshes out some unimplemented tests.
  • Loading branch information
dartajax authored Jul 17, 2023
2 parents 117d775 + c97059c commit 713df92
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions tests/integration/components/learner-group/calendar-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { module, test, todo } from 'qunit';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { setupIntl } from 'ember-intl/test-support';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
Expand All @@ -14,58 +14,69 @@ module('Integration | Component | learner-group/calendar', function (hooks) {

hooks.beforeEach(async function () {
const today = DateTime.fromObject({ hour: 8 });
const course = this.server.create('course', {
title: 'course title',
const course1 = this.server.create('course');
const course2 = this.server.create('course', {
publishedAsTbd: true,
published: true,
});
const session = this.server.create('session', {
title: 'session title',
course,
const session1 = this.server.create('session', { course: course1 });
const session2 = this.server.create('session', {
course: course2,
publishedAsTbd: true,
published: true,
});
const offering1 = this.server.create('offering', {
startDate: today.toJSON(),
endDate: today.plus({ hour: 1 }).toJSDate(),
location: '123',
session,
session: session1,
});
const offering2 = this.server.create('offering', {
startDate: today.toJSON(),
endDate: today.plus({ hour: 1 }).toJSDate(),
location: '123',
session,
session: session2,
});
const learnerGroup = this.server.create('learner-group', {
const learnerGroup1 = this.server.create('learner-group', {
offerings: [offering1],
});
this.server.create('learner-group', {
const learnerGroup2 = this.server.create('learner-group', {
offerings: [offering2],
parent: learnerGroup,
parent: learnerGroup1,
});
this.learnerGroup = await this.owner
this.learnerGroup1 = await this.owner
.lookup('service:store')
.findRecord('learner-group', learnerGroup.id);
.findRecord('learner-group', learnerGroup1.id);
this.learnerGroup2 = await this.owner
.lookup('service:store')
.findRecord('learner-group', learnerGroup2.id);
});

test('shows events', async function (assert) {
this.set('learnerGroup', this.learnerGroup);
this.set('learnerGroup', this.learnerGroup1);
await render(hbs`<LearnerGroup::Calendar @learnerGroup={{this.learnerGroup}} />`);
assert.strictEqual(component.calendar.events.length, 1);
});

test('shows subgroup events', async function (assert) {
this.set('learnerGroup', this.learnerGroup);
this.set('learnerGroup', this.learnerGroup1);
await render(hbs`<LearnerGroup::Calendar @learnerGroup={{this.learnerGroup}} />`);
assert.strictEqual(component.calendar.events.length, 1);
await component.showSubgroups.toggle.click();
assert.strictEqual(component.calendar.events.length, 2);
});

todo('in-draft event is indicated as such', function () {
// @todo implement this once our page object is up to the job [ST 2023/07/03].
// @see https://github.com/ilios/common/pull/3430
test('in-draft event is indicated as such', async function (assert) {
this.set('learnerGroup', this.learnerGroup1);
await render(hbs`<LearnerGroup::Calendar @learnerGroup={{this.learnerGroup}} />`);
assert.strictEqual(component.calendar.events.length, 1);
assert.ok(component.calendar.events[0].isDraft);
});

todo('scheduled event is indicated as such', function () {
// @todo implement this once our page object is up to the job [ST 2023/07/03].
// @see https://github.com/ilios/common/pull/3430
test('scheduled event is indicated as such', async function (assert) {
this.set('learnerGroup', this.learnerGroup2);
await render(hbs`<LearnerGroup::Calendar @learnerGroup={{this.learnerGroup}} />`);
assert.strictEqual(component.calendar.events.length, 1);
assert.ok(component.calendar.events[0].isScheduled);
});
});

0 comments on commit 713df92

Please sign in to comment.