Skip to content
Open
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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@iconify-icon/react": "^2.3.0",
"@madie/cql-antlr-parser": "^1.0.14",
"@madie/madie-design-system": "^1.2.93",
"@madie/madie-models": "^1.4.73",
"@madie/madie-models": "^1.4.74",
"@mui/icons-material": "^6.1.0",
"@mui/material": "^6.1.0",
"@mui/system": "^6.1.0",
Expand Down
27 changes: 27 additions & 0 deletions src/api/useCqlLibraryServiceApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,33 @@ describe("useCqlLibraryServiceApi", () => {
).rejects.toThrow("canceled");
});

it("should fetch libraries in review", async () => {
const mockedResponse = { data: [{ id: "1", reviewStatus: "READY" }] };
mockedAxios.get.mockResolvedValueOnce(mockedResponse);
const result = await cqlLibraryServiceApi.fetchReviewLibraries(undefined);
expect(mockedAxios.get).toHaveBeenCalledWith(
`${mockBaseUrl}/cql-libraries/reviews`,
expect.objectContaining({
headers: { Authorization: `Bearer ${mockToken}` },
})
);
expect(result).toEqual(mockedResponse.data);
});

it("should rethrow a cancellation from fetchReviewLibraries", async () => {
mockedAxios.get.mockRejectedValueOnce(new Error("canceled"));
await expect(
cqlLibraryServiceApi.fetchReviewLibraries(undefined)
).rejects.toThrow("canceled");
});

it("should wrap non-cancellation errors from fetchReviewLibraries", async () => {
mockedAxios.get.mockRejectedValueOnce(new Error("boom"));
await expect(
cqlLibraryServiceApi.fetchReviewLibraries(undefined)
).rejects.toThrow("Unable to fetch libraries in review");
});

it("should search Cql Libraries for an admin-selected user", async () => {
const mockedResponse = { data: { content: [{ id: "1" }] } };
const searchCriteria = {
Expand Down
37 changes: 35 additions & 2 deletions src/api/useCqlLibraryServiceApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import axios from "./axios-instance";
import useServiceConfig from "./useServiceConfig";
import useOktaTokens from "../hooks/useOktaTokens";
import { AxiosResponse } from "axios";

import { CqlLibrary, OwnershipType } from "@madie/madie-models";
import { CqlLibrary, LibraryListDTO, OwnershipType } from "@madie/madie-models";

export type AuditRow = {
actionType: string;
Expand Down Expand Up @@ -54,6 +53,40 @@ export class CqlLibraryServiceApi {
}
}

/**
* Fetches every library instance currently in the review process
* (backend GET /cql-libraries/reviews). The endpoint returns the full,
* unpaginated list of LibraryListDTOs (each carrying a populated
* reviewStatus); sorting/pagination are handled client-side. Only reviewers
* (MADiE-Reviewer) are authorized to call this.
*
* @param signal optional AbortSignal so callers can cancel an in-flight request
* (e.g. when switching tabs).
*/
async fetchReviewLibraries(signal?): Promise<LibraryListDTO[]> {
try {
const response = await axios.get<any>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const response = await axios.get<any>(
const response = await axios.get<LibraryListDTO[]>(

`${this.baseUrl}/cql-libraries/reviews`,
{
headers: {
Authorization: `Bearer ${this.getAccessToken()}`,
},
signal,
}
);
return response.data;
} catch (err) {
if (err.message === "canceled") {
throw new Error(err.message);
}
const message = `Unable to fetch libraries in review`;
console.error(message);
console.error(err);

throw new Error(message);
}
}

async adminSearchCqlLibrariesForUser(
harpId: string,
ownershipType: OwnershipType,
Expand Down
Loading