Skip to content

Commit

Permalink
👌 [#357] PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Feb 13, 2025
1 parent 1a3059e commit ec4d6bd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions frontend/src/lib/api/zaken.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import fetchMock from "jest-fetch-mock";

import { zakenFactory } from "../../fixtures/zaak";
import { listZaken } from "./zaken";
import { searchZaken } from "./zaken";

describe("listZaken", () => {
describe("searchZaken", () => {
beforeAll(() => {
fetchMock.enableMocks();
});
Expand All @@ -15,11 +15,11 @@ describe("listZaken", () => {
it("should return a list of users on success", async () => {
const zaken = zakenFactory();
fetchMock.mockResponseOnce(JSON.stringify(zaken));
await expect(listZaken()).resolves.toEqual(zaken);
await expect(searchZaken()).resolves.toEqual(zaken);
});

it("should throw an error on failure", async () => {
fetchMock.mockRejectOnce(new Error("Internal Server Error"));
await expect(listZaken()).rejects.toThrow("Internal Server Error");
await expect(searchZaken()).rejects.toThrow("Internal Server Error");
});
});
6 changes: 3 additions & 3 deletions frontend/src/lib/api/zaken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { request } from "./request";
export type PaginatedZaken = PaginatedResults<Zaak>;

/**
* Retrieve zaken using the configured ZRC service. For information over the query parameters accepted and the schema of
* the response, look at the '/zaken/api/v1/zaken' list endpoint of Open Zaak.
* Search zaken using the configured ZRC service. For information over the filters that can be passed in the
* request body, look at query params of the '/zaken/api/v1/zaken' list endpoint of Open Zaak.
*/
export async function listZaken(params?: Record<string, string>) {
export async function searchZaken(params?: Record<string, string>) {
const response = await request(
"POST",
"/zaken/search/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LoaderFunctionArgs } from "@remix-run/router/utils";

import { User } from "../../../lib/api/auth";
import { listReviewers } from "../../../lib/api/reviewers";
import { PaginatedZaken, listZaken } from "../../../lib/api/zaken";
import { PaginatedZaken, searchZaken } from "../../../lib/api/zaken";
import {
canStartDestructionListRequired,
loginRequired,
Expand Down Expand Up @@ -35,7 +35,7 @@ export const destructionListCreateLoader = loginRequired(

// Fetch reviewers, zaken, and choices concurrently
const [zaken, reviewers] = await Promise.all([
listZaken(searchParamsZakenEndpoint),
searchZaken(searchParamsZakenEndpoint),
listReviewers(),
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
ReviewResponse,
getLatestReviewResponse,
} from "../../../lib/api/reviewResponse";
import { PaginatedZaken, listZaken } from "../../../lib/api/zaken";
import { PaginatedZaken, searchZaken } from "../../../lib/api/zaken";
import {
canViewDestructionListRequired,
loginRequired,
Expand Down Expand Up @@ -95,7 +95,7 @@ export const destructionListDetailLoader = loginRequired(
async (): Promise<PaginatedDestructionListItems> => {
const params = searchParams;
if (isEditing) {
params["item-order_match_zaken"] = "true"; // Must be in sync with `listZaken()` ordering.
params["item-order_match_zaken"] = "true"; // Must be in sync with `searchZaken()` ordering.
}
return reviewItemsWithZaak
? {
Expand Down Expand Up @@ -158,7 +158,7 @@ export const destructionListDetailLoader = loginRequired(
previous: null,
results: [],
} as PaginatedZaken)
: listZaken({
: searchZaken({
...searchParams,
not_in_destruction_list_except: uuid,
});
Expand Down

0 comments on commit ec4d6bd

Please sign in to comment.