Skip to content

Commit beea361

Browse files
jkuestersugat009
authored andcommitted
fix(#9389): update api/v1/person query param from personType to type (#9390)
1 parent a93dede commit beea361

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

api/src/controllers/person.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = {
3131
getAll: serverUtils.doOrError(async (req, res) => {
3232
await checkUserPermissions(req);
3333

34-
const personType = Qualifier.byContactType(req.query.personType);
34+
const personType = Qualifier.byContactType(req.query.type);
3535
const limit = req.query.limit ? Number(req.query.limit) : req.query.limit;
3636

3737
const docs = await getPageByType()( personType, req.query.cursor, limit );

api/tests/mocha/controllers/person.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ describe('Person Controller', () => {
169169
beforeEach(() => {
170170
req = {
171171
query: {
172-
personType,
172+
type: personType,
173173
cursor,
174174
limit,
175175
}
@@ -193,7 +193,7 @@ describe('Person Controller', () => {
193193
await controller.v1.getAll(req, res);
194194

195195
expect(hasAllPermissions.calledOnceWithExactly(userCtx, 'can_view_contacts')).to.be.true;
196-
expect(qualifierByContactType.calledOnceWithExactly(req.query.personType)).to.be.true;
196+
expect(qualifierByContactType.calledOnceWithExactly(req.query.type)).to.be.true;
197197
expect(dataContextBind.calledOnceWithExactly(Person.v1.getPage)).to.be.true;
198198
expect(personGetPageByType.calledOnceWithExactly(personTypeQualifier, cursor, limit)).to.be.true;
199199
expect(res.json.calledOnceWithExactly(people)).to.be.true;
@@ -238,7 +238,7 @@ describe('Person Controller', () => {
238238
await controller.v1.getAll(req, res);
239239

240240
expect(hasAllPermissions.calledOnceWithExactly(userCtx, 'can_view_contacts')).to.be.true;
241-
expect(qualifierByContactType.calledOnceWithExactly(req.query.personType)).to.be.true;
241+
expect(qualifierByContactType.calledOnceWithExactly(req.query.type)).to.be.true;
242242
expect(dataContextBind.calledOnceWithExactly(Person.v1.getPage)).to.be.true;
243243
expect(personGetPageByType.calledOnceWithExactly(personTypeQualifier, cursor, limit)).to.be.true;
244244
expect(res.json.notCalled).to.be.true;
@@ -254,7 +254,7 @@ describe('Person Controller', () => {
254254
await controller.v1.getAll(req, res);
255255

256256
expect(hasAllPermissions.calledOnceWithExactly(userCtx, 'can_view_contacts')).to.be.true;
257-
expect(qualifierByContactType.calledOnceWithExactly(req.query.personType)).to.be.true;
257+
expect(qualifierByContactType.calledOnceWithExactly(req.query.type)).to.be.true;
258258
expect(dataContextBind.calledOnceWithExactly(Person.v1.getPage)).to.be.true;
259259
expect(personGetPageByType.calledOnceWithExactly(personTypeQualifier, cursor, limit)).to.be.true;
260260
expect(res.json.notCalled).to.be.true;

shared-libs/cht-datasource/src/remote/person.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export namespace v1 {
3030
): Promise<Page<Person.v1.Person>> => {
3131
const queryParams = {
3232
'limit': limit.toString(),
33-
'personType': personType.contactType,
33+
'type': personType.contactType,
3434
...(cursor ? { cursor } : {})
3535
};
3636
return getPeople(remoteContext)(queryParams);

shared-libs/cht-datasource/test/remote/person.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('remote person', () => {
7676
const personTypeQualifier = {contactType: personType};
7777
const queryParam = {
7878
limit: limit.toString(),
79-
personType,
79+
type: personType,
8080
cursor,
8181
};
8282

tests/integration/api/controllers/person.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ describe('Person API', () => {
188188

189189
it('throws 400 error when personType is invalid', async () => {
190190
const queryParams = {
191-
'personType': invalidContactType
191+
type: invalidContactType
192192
};
193193
const queryString = new URLSearchParams(queryParams).toString();
194194
const opts = {
@@ -201,7 +201,7 @@ describe('Person API', () => {
201201

202202
it('throws 400 error when limit is invalid', async () => {
203203
const queryParams = {
204-
personType,
204+
type: personType,
205205
limit: -1
206206
};
207207
const queryString = new URLSearchParams(queryParams).toString();
@@ -215,7 +215,7 @@ describe('Person API', () => {
215215

216216
it('throws 400 error when cursor is invalid', async () => {
217217
const queryParams = {
218-
personType,
218+
type: personType,
219219
cursor: '-1'
220220
};
221221
const queryString = new URLSearchParams(queryParams).toString();

0 commit comments

Comments
 (0)