Skip to content

Fix for connect-app issue #3496 Support searching project by customer/manager handle #448

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

Merged
merged 1 commit into from
Jan 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/routes/projects/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,13 @@ const parseElasticSearchCriteria = (criteria, fields, order) => {
if (_.has(criteria, 'filters.customer')) {
mustQuery = _.concat(mustQuery, setFilter('customer',
criteria.filters.customer,
['members.firstName', 'members.lastName']));
['members.firstName', 'members.lastName', 'members.handle']));
}

if (_.has(criteria, 'filters.manager')) {
mustQuery = _.concat(mustQuery, setFilter('manager',
criteria.filters.manager,
['members.firstName', 'members.lastName']));
['members.firstName', 'members.lastName', 'members.handle']));
}

if (_.has(criteria, 'filters.userId') || _.has(criteria, 'filters.email')) {
Expand Down
46 changes: 46 additions & 0 deletions src/routes/projects/list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,52 @@ describe('LIST Project', () => {
});
});

it('should return all projects that match when filtering by customer handle', (done) => {
request(server)
.get('/v5/projects/?customer=*tourist*')
.set({
Authorization: `Bearer ${testUtil.jwts.admin}`,
})
.expect('Content-Type', /json/)
.expect(200)
.end((err, res) => {
if (err) {
done(err);
} else {
const resJson = res.body;
should.exist(resJson);
resJson.should.have.lengthOf(1);
resJson[0].name.should.equal('test1');
resJson[0].members.should.have.deep.property('[0].role', 'customer');
resJson[0].members[0].userId.should.equal(40051331);
done();
}
});
});

it('should return all projects that match when filtering by manager handle', (done) => {
request(server)
.get('/v5/projects/?manager=*_handle')
.set({
Authorization: `Bearer ${testUtil.jwts.admin}`,
})
.expect('Content-Type', /json/)
.expect(200)
.end((err, res) => {
if (err) {
done(err);
} else {
const resJson = res.body;
should.exist(resJson);
resJson.should.have.lengthOf(1);
resJson[0].name.should.equal('test3');
resJson[0].members.should.have.deep.property('[0].role', 'manager');
resJson[0].members[0].userId.should.equal(40051334);
done();
}
});
});

it('should return list of projects ordered ascending by lastActivityAt when sort column is "lastActivityAt"', (done) => {
request(server)
.get('/v5/projects/?sort=lastActivityAt')
Expand Down