Skip to content

Commit

Permalink
Preload Test Data Into the Store
Browse files Browse the repository at this point in the history
Since we use a peek record in these components we need to pre-load all
of the tests data into the store before rendering them.
  • Loading branch information
jrjohnson committed Jul 17, 2024
1 parent 6cc4556 commit 05b2c93
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ module('Integration | Component | school session type form', function (hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);

hooks.beforeEach(async function () {
this.store = this.owner.lookup('service:store');
});

test('it renders', async function (assert) {
this.server.create('aamc-method', {
id: 'AM001',
Expand All @@ -34,6 +38,8 @@ module('Integration | Component | school session type form', function (hooks) {
this.set('assessmentOptionId', summative.id);
this.set('title', 'one');
this.set('calendarColor', '#ffffff');
await this.store.findAll('aamc-method');
await this.store.findAll('assessment-option');
await render(hbs`<SchoolSessionTypeForm
@canEditTitle={{true}}
@canEditAamcMethod={{true}}
Expand Down Expand Up @@ -89,7 +95,8 @@ module('Integration | Component | school session type form', function (hooks) {
this.server.create('assessment-option', {
name: 'summative',
});
const assessmentOptions = await this.owner.lookup('service:store').findAll('assessment-option');
const assessmentOptions = await this.store.findAll('assessment-option');
await this.store.findAll('aamc-method');

this.set('assessmentOption', assessmentOptions[1]);
this.set('assessmentOptions', assessmentOptions);
Expand Down Expand Up @@ -124,6 +131,8 @@ module('Integration | Component | school session type form', function (hooks) {
});

test('assessment option hidden when assessment is false', async function (assert) {
await this.store.findAll('aamc-method');
await this.store.findAll('assessment-option');
await render(hbs`<SchoolSessionTypeForm
@assessment={{false}}
@assessmentOption={{null}}
Expand Down Expand Up @@ -176,12 +185,8 @@ module('Integration | Component | school session type form', function (hooks) {
const formative = this.server.create('assessment-option', {
name: 'formative',
});
const aamcMethodModel = await this.owner
.lookup('service:store')
.findRecord('aamc-method', method.id);
const assessmentOptionModel = await this.owner
.lookup('service:store')
.findRecord('assessment-option', formative.id);
const aamcMethodModel = await this.store.findRecord('aamc-method', method.id);
const assessmentOptionModel = await this.store.findRecord('assessment-option', formative.id);

this.set('save', (title, calendarColor, assessment, assessmentOption, aamcMethod, isActive) => {
assert.strictEqual(title, 'new title', 'title is correct');
Expand Down Expand Up @@ -232,6 +237,8 @@ module('Integration | Component | school session type form', function (hooks) {
name: 'formative',
});

await this.store.findAll('aamc-method');
await this.store.findAll('assessment-option');
await render(hbs`<SchoolSessionTypeForm
@canEditTitle={{false}}
@canEditAamcMethod={{false}}
Expand Down Expand Up @@ -276,6 +283,8 @@ module('Integration | Component | school session type form', function (hooks) {
name: 'formative',
});

await this.store.findAll('aamc-method');
await this.store.findAll('assessment-option');
await render(hbs`<SchoolSessionTypeForm
@canEditAamcMethod={{true}}
@selectedAamcMethodId="AM001"
Expand All @@ -301,6 +310,8 @@ module('Integration | Component | school session type form', function (hooks) {
name: 'formative',
});

await this.store.findAll('aamc-method');
await this.store.findAll('assessment-option');
this.set('aamcMethodId', aamcMethodId);
await render(hbs`<SchoolSessionTypeForm
@canEditAamcMethod={{false}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ module('Integration | Component | school session type manager', function (hooks)
setupRenderingTest(hooks);
setupMirage(hooks);

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
this.server.create('assessment-option', {
name: 'formative',
});
this.summative = this.server.create('assessment-option', {
name: 'summative',
});
await this.owner.lookup('service:store').findAll('assessment-option');
});

test('it renders', async function (assert) {
Expand Down

0 comments on commit 05b2c93

Please sign in to comment.