Skip to content

Commit

Permalink
Merge pull request #7364 from stopfstedt/user_search_in_pending_user_…
Browse files Browse the repository at this point in the history
…updates

fixes user filtering on pending-updates page.
  • Loading branch information
dartajax committed Sep 1, 2023
2 parents a05335a + 8c74797 commit c2caa04
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/controllers/pending-user-updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import { task } from 'ember-concurrency';
import { findById } from 'ilios-common/utils/array-helpers';
import { isEmpty } from '@ember/utils';

export default class PendingUserUpdatesController extends Controller {
@service flashMessages;
Expand Down Expand Up @@ -41,7 +42,7 @@ export default class PendingUserUpdatesController extends Controller {
return this.updatesInCurrentSchool.filter((update) => {
const user = this.store.peekRecord('user', update.belongsTo('user').id());
const isNotDeleted = !this.deletedUpdates.includes(update);
const noUpdateName = !!user.fullName;
const noUpdateName = isEmpty(user.fullName);
const filterMatch = update
.get('user.fullName')
.trim()
Expand Down
35 changes: 35 additions & 0 deletions tests/acceptance/pending-user-updates-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,39 @@ module('Acceptance | pending user updates', function (hooks) {
assert.strictEqual(page.updates.length, 0);
assert.notOk(userModel.enabled);
});

test('filter-search users', async function (assert) {
const school = this.server.create('school');
const user1 = this.server.create('user', {
school,
enabled: true,
firstName: 'lorem',
lastName: 'ipsum',
});
this.server.create('pending-user-update', {
user: user1,
type: 'missingFromDirectory',
});
const user2 = this.server.create('user', {
school,
enabled: true,
firstName: 'zig',
lastName: 'zag',
});
this.server.create('pending-user-update', {
user: user2,
type: 'missingFromDirectory',
});
await setupAuthentication({ school, administeredSchools: [school] });
await page.visit();

assert.strictEqual(page.updates.length, 2);
assert.strictEqual(page.updates[0].userNameInfo.fullName, 'lorem M. ipsum');
assert.strictEqual(page.updates[1].userNameInfo.fullName, 'zig M. zag');
await page.titleFilter.set('lorem');
assert.strictEqual(page.updates.length, 1);
assert.strictEqual(page.updates[0].userNameInfo.fullName, 'lorem M. ipsum');
await page.titleFilter.set('no match');
assert.strictEqual(page.updates.length, 0);
});
});
1 change: 1 addition & 0 deletions tests/pages/pending-user-updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default create({
},
titleFilter: {
scope: '[data-test-title-filter]',
set: fillable('input'),
},
updates: collection('[data-test-pending-update]', {
userNameInfo,
Expand Down

0 comments on commit c2caa04

Please sign in to comment.