Skip to content

Commit eb13ef4

Browse files
authored
Merge pull request #116 from wri/fix/TM-1923-association-index
[TM-1923] Fix inclusion of index IDs in association index responses.
2 parents 4a8446d + 7678b42 commit eb13ef4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

apps/entity-service/src/entities/processors/association-processor.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ describe("AssociationProcessor", () => {
5656

5757
const document = buildJsonApi(DemographicDto, { forceDataArray: true });
5858
await service.createAssociationProcessor("projectReports", projectReportUuid, "demographics").addDtos(document);
59-
const data = document.serialize().data as Resource[];
59+
const result = document.serialize();
60+
const data = result.data as Resource[];
6061
expect(data.length).toEqual(1);
6162

6263
const dto = data.find(({ id }) => id === uuid)?.attributes as unknown as DemographicDto;
@@ -67,6 +68,13 @@ describe("AssociationProcessor", () => {
6768
unknown
6869
);
6970
expect(dto.entries.find(({ type, subtype }) => type === "age" && subtype === "youth")).toMatchObject(youth);
71+
72+
expect(result.meta.indices.length).toBe(1);
73+
expect(result.meta.indices[0]).toMatchObject({
74+
resource: "demographics",
75+
requestPath: `/entities/v3/projectReports/${projectReportUuid}/demographics`,
76+
ids: [uuid]
77+
});
7078
});
7179

7280
it("should include tree species", async () => {

apps/entity-service/src/entities/processors/association-processor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export abstract class AssociationProcessor<M extends UuidModel<M>, D extends Ass
5959
const additionalProps = { entityType: this.entityType, entityUuid: this.entityUuid };
6060
const indexIds: string[] = [];
6161
for (const association of associations) {
62+
indexIds.push(association.uuid);
6263
document.addData(association.uuid, new this.DTO(association, additionalProps));
6364
}
6465

0 commit comments

Comments
 (0)