Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/datasets/datasets.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,11 @@ export class DatasetsController {
});
if (dataset.length == 0)
throw new ForbiddenException("Unauthorized access");
if (
Array.isArray(filterObj?.fields) &&
!filterObj.fields.includes("history")
)
return dataset[0];
return {
...dataset[0],
history: await this.convertToObsoleteHistory(dataset[0].pid),
Expand Down
13 changes: 13 additions & 0 deletions test/jest-e2e-tests/datasetHistory.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,17 @@ describe("Test v3 history in datasetLifecycle", () => {
expect(typeof lifecycle.previousValue._id).toBe("string");
});
});

it("Should check v3 built history by ID with field not including history", async () => {
const filter = { fields: ["datasetName"] };
await request(app.getHttpServer())
.get(`/api/v3/datasets/${encodeURIComponent(dsId)}`)
.query({ filter: JSON.stringify(filter) })
.auth(token, { type: "bearer" })
.expect(TestData.SuccessfulGetStatusCode)
.then((res) => {
expect(res.body.datasetName).toBeDefined();
expect(res.body.history).toBeUndefined();
});
});
});