Skip to content

[TM-1923] Fix inclusion of index IDs in association index responses. #116

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
Apr 3, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ describe("AssociationProcessor", () => {

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

const dto = data.find(({ id }) => id === uuid)?.attributes as unknown as DemographicDto;
Expand All @@ -67,6 +68,13 @@ describe("AssociationProcessor", () => {
unknown
);
expect(dto.entries.find(({ type, subtype }) => type === "age" && subtype === "youth")).toMatchObject(youth);

expect(result.meta.indices.length).toBe(1);
expect(result.meta.indices[0]).toMatchObject({
resource: "demographics",
requestPath: `/entities/v3/projectReports/${projectReportUuid}/demographics`,
ids: [uuid]
});
});

it("should include tree species", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export abstract class AssociationProcessor<M extends UuidModel<M>, D extends Ass
const additionalProps = { entityType: this.entityType, entityUuid: this.entityUuid };
const indexIds: string[] = [];
for (const association of associations) {
indexIds.push(association.uuid);
document.addData(association.uuid, new this.DTO(association, additionalProps));
}

Expand Down
Loading