Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Learner Groups now use same loading style as Instructor Groups #7857

32 changes: 32 additions & 0 deletions packages/frontend/app/components/learner-groups/loading.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<table class="learner-groups-loading" ...attributes>
<thead>
<tr>
<th class="text-left" colspan="2">
{{t "general.learnerGroupTitle"}}
</th>
<th class="text-center hide-from-small-screen">
{{t "general.members"}}
</th>
<th class="text-center hide-from-small-screen">
{{t "general.subgroups"}}
</th>
<th class="text-right">
{{t "general.actions"}}
</th>
</tr>
</thead>
<tbody>
{{! template-lint-disable no-unused-block-params }}
{{#each (repeat @count) as |empty|}}
<tr class="is-loading">
<td class="text-left" colspan="2">{{truncate
(repeat (random 3 10) "ilios rocks")
michaelchadwick marked this conversation as resolved.
Show resolved Hide resolved
100
}}</td>
<td class="text-center hide-from-small-screen">{{random 1 9}}</td>
<td class="text-center hide-from-small-screen">{{random 1 9}}</td>
<td class="text-right"></td>
</tr>
{{/each}}
</tbody>
</table>
2 changes: 1 addition & 1 deletion packages/frontend/app/components/learner-groups/root.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
@setSortBy={{@setSortBy}}
/>
{{else}}
<PulseLoader />
<LearnerGroups::Loading @count={{2}} />
{{/if}}
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/app/styles/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
@import "components/learner-group/members";

@import "components/learner-groups/root";
@import "components/learner-groups/loading";

@import "components/instructor-group/courses";
@import "components/instructor-group/header";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@use "../../mixins" as m;

.learner-groups-loading {
@include m.main-list-loading-table;
}
83 changes: 41 additions & 42 deletions packages/frontend/tests/acceptance/learnergroups-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,51 @@ module('Acceptance | Learner Groups', function (hooks) {
});

test('visiting /learnergroups', async function (assert) {
assert.expect(1);
await page.visit();
assert.strictEqual(currentRouteName(), 'learner-groups');
});

test('list groups', async function (assert) {
assert.expect(8);
this.server.createList('user', 11);
const program = this.server.create('program', { school: this.school });
const programYear = this.server.create('program-year', { program });
const cohort = this.server.create('cohort', { programYear });
const firstLearnerGroup = this.server.create('learner-group', {
cohort,
userIds: [2, 3, 4, 5, 6],
});
this.server.create('learner-group', {
cohort,
});
const firstChildGroup = this.server.create('learner-group', {
parent: firstLearnerGroup,
userIds: [7, 8],
});
this.server.create('learner-group', {
parent: firstLearnerGroup,
userIds: [9, 10],
});
this.server.create('learner-group', {
parent: firstChildGroup,
userIds: [11, 12],
});
this.server.createList('offering', 2, {
learnerGroups: [firstLearnerGroup],
});

await page.visit();
await percySnapshot(assert);
assert.strictEqual(page.headerTitle, 'Learner Groups (2)');
assert.strictEqual(page.list.items.length, 2);
assert.strictEqual(page.list.items[0].title, 'learner group 0');
assert.strictEqual(page.list.items[0].users, '5');
assert.strictEqual(page.list.items[0].children, '2');
assert.strictEqual(page.list.items[1].title, 'learner group 1');
assert.strictEqual(page.list.items[1].users, '0');
assert.strictEqual(page.list.items[1].children, '0');
});

test('single option filters', async function (assert) {
assert.expect(6);
const program = this.server.create('program', { school: this.school });
Expand Down Expand Up @@ -93,47 +133,6 @@ module('Acceptance | Learner Groups', function (hooks) {
assert.strictEqual(page.list.items[0].title, 'learner group 1');
});

test('list groups', async function (assert) {
assert.expect(8);
this.server.createList('user', 11);
const program = this.server.create('program', { school: this.school });
const programYear = this.server.create('program-year', { program });
const cohort = this.server.create('cohort', { programYear });
const firstLearnerGroup = this.server.create('learner-group', {
cohort,
userIds: [2, 3, 4, 5, 6],
});
this.server.create('learner-group', {
cohort,
});
const firstChildGroup = this.server.create('learner-group', {
parent: firstLearnerGroup,
userIds: [7, 8],
});
this.server.create('learner-group', {
parent: firstLearnerGroup,
userIds: [9, 10],
});
this.server.create('learner-group', {
parent: firstChildGroup,
userIds: [11, 12],
});
this.server.createList('offering', 2, {
learnerGroups: [firstLearnerGroup],
});

await page.visit();
await percySnapshot(assert);
assert.strictEqual(page.headerTitle, 'Learner Groups (2)');
assert.strictEqual(page.list.items.length, 2);
assert.strictEqual(page.list.items[0].title, 'learner group 0');
assert.strictEqual(page.list.items[0].users, '5');
assert.strictEqual(page.list.items[0].children, '2');
assert.strictEqual(page.list.items[1].title, 'learner group 1');
assert.strictEqual(page.list.items[1].users, '0');
assert.strictEqual(page.list.items[1].children, '0');
});

test('filters by title', async function (assert) {
const program = this.server.create('program', { school: this.school });
const programYear = this.server.create('program-year', { program });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { setupIntl } from 'ember-intl/test-support';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import a11yAudit from 'ember-a11y-testing/test-support/audit';

module('Integration | Component | learner-groups/loading', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks, 'en-us');

test('it renders', async function (assert) {
await render(hbs`<LearnerGroups::Loading @count={{2}} />`);
assert.dom('tbody tr').exists({ count: 2 });
await a11yAudit(this.element);
});
});