Skip to content

connect-app#3755 Fix searching projects by handle to be case insensitive. #501

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
Mar 12, 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
98 changes: 95 additions & 3 deletions src/routes/projects/list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const data = [
role: 'manager',
firstName: 'first',
lastName: 'last',
handle: 'manager_handle',
handle: 'MANAGER_HANDLE',
isPrimary: true,
createdBy: 1,
updatedBy: 1,
Expand Down Expand Up @@ -723,7 +723,7 @@ describe('LIST Project', () => {
});
});

it('should return all projects that match when filtering by customer handle', (done) => {
it('should return all projects that match when filtering by customer handle (lowercase)', (done) => {
request(server)
.get('/v5/projects/?customer=*tourist*')
.set({
Expand All @@ -746,7 +746,53 @@ describe('LIST Project', () => {
});
});

it('should return all projects that match when filtering by manager handle', (done) => {
it('should return all projects that match when filtering by customer handle (uppercase)', (done) => {
request(server)
.get('/v5/projects/?customer=*TOUR*')
.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 customer handle (mixed case)', (done) => {
request(server)
.get('/v5/projects/?customer=*tOURiS*')
.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 (lowercase)', (done) => {
request(server)
.get('/v5/projects/?manager=*_handle')
.set({
Expand All @@ -769,6 +815,52 @@ describe('LIST Project', () => {
});
});

it('should return all projects that match when filtering by manager handle (uppercase)', (done) => {
request(server)
.get('/v5/projects/?manager=MANAG*')
.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 all projects that match when filtering by manager handle (mixed case)', (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 all projects that match when filtering by manager, searching on any non-customer role', (done) => {
request(server)
.get('/v5/projects/?manager=copi*')
Expand Down
1 change: 0 additions & 1 deletion src/utils/es-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ MAPPINGS[ES_PROJECT_INDEX] = {
},
handle: {
type: 'string',
index: 'not_analyzed',
},
id: {
type: 'long',
Expand Down