From 56f10423d27a6c6d9ca690bfc641d0c95b2cfdc1 Mon Sep 17 00:00:00 2001 From: Michael Chadwick Date: Mon, 14 Oct 2024 16:18:32 -0700 Subject: [PATCH] added test for Terms in ProgramYear report --- .../tests/unit/services/reporting-test.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/packages/frontend/tests/unit/services/reporting-test.js b/packages/frontend/tests/unit/services/reporting-test.js index 7493b38492..c22dc8291e 100644 --- a/packages/frontend/tests/unit/services/reporting-test.js +++ b/packages/frontend/tests/unit/services/reporting-test.js @@ -2,6 +2,7 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; import { setupIntl } from 'ember-intl/test-support'; import { setupMirage } from 'frontend/tests/test-support/mirage'; +import { DateTime } from 'luxon'; module('Unit | Service | reporting', function (hooks) { setupTest(hooks); @@ -226,6 +227,45 @@ module('Unit | Service | reporting', function (hooks) { ); }); + test('buildReportDescription() - all terms for program year X in school Y', async function (assert) { + const school = this.server.create('school', { title: 'School of Schools' }); + const program = this.server.create('program', { school: school }); + const programYear = this.server.create('program-year', { + program, + startYear: DateTime.now().year, + }); + const vocabulary = this.server.create('vocabulary', { school }); + this.server.create('term', { + title: 'foo bar', + programYears: [programYear], + vocabulary, + }); + const report = this.server.create('report', { + subject: 'term', + prepositionalObject: 'program year', + prepositionalObjectTableRowId: programYear.id, + school, + }); + + const store = this.owner.lookup('service:store'); + const reportModel = await store.findRecord('report', report.id); + const programYearModel = await store.findRecord('program year', programYear.id); + const schoolModel = await store.findRecord('school', school.id); + const title = await this.service.buildReportDescription( + reportModel.subject, + reportModel.prepositionalObject, + reportModel.prepositionalObjectTableRowId, + school, + ); + const classOfYear = await programYearModel.getClassOfYear(); + const programYearTitle = `${classOfYear} ${program.title}`; + + assert.strictEqual( + title, + `This report shows all Terms associated with Program Year "${programYearTitle}" (${classOfYear}) in ${schoolModel.title}.`, + ); + }); + test('buildReportDescription() - broken report', async function (assert) { const school = this.server.create('school', { title: 'School of Schools' }); const report = this.server.create('report', {