diff --git a/src/routes/projects/list.spec.js b/src/routes/projects/list.spec.js index 9ebb3e13..e570e225 100644 --- a/src/routes/projects/list.spec.js +++ b/src/routes/projects/list.spec.js @@ -160,7 +160,7 @@ const data = [ role: 'manager', firstName: 'first', lastName: 'last', - handle: 'manager_handle', + handle: 'MANAGER_HANDLE', isPrimary: true, createdBy: 1, updatedBy: 1, @@ -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({ @@ -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({ @@ -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*') diff --git a/src/utils/es-config.js b/src/utils/es-config.js index 657add4b..c8e1be8a 100644 --- a/src/utils/es-config.js +++ b/src/utils/es-config.js @@ -241,7 +241,6 @@ MAPPINGS[ES_PROJECT_INDEX] = { }, handle: { type: 'string', - index: 'not_analyzed', }, id: { type: 'long',