Skip to content

Commit

Permalink
test(api): add test for boolean order
Browse files Browse the repository at this point in the history
  • Loading branch information
Mendes Hugo committed Sep 25, 2023
1 parent c730989 commit ed80657
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
35 changes: 35 additions & 0 deletions apps/backend-e2e/src/backend/http/v1/workflows.http.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { AxiosError, HttpStatusCode } from "axios";
import { Jsonify } from "type-fest";
import { DbE2eHelper } from "~/app/backend/e2e/db-e2e/db-e2e.helper";
import { WorkflowHttpClient } from "~/app/backend/e2e/http/clients/workflow.http-client";
import { WorkflowQueryDto } from "~/lib/common/app/workflow/dtos";
import { WORKFLOWS_ENDPOINT_PREFIX } from "~/lib/common/app/workflow/endpoints";
import { BASE_SEED } from "~/lib/common/seeds";

describe("Backend HTTP Graphs", () => {
const client = new WorkflowHttpClient();

const dbHelper = DbE2eHelper.getHelper("base");
const db = JSON.parse(JSON.stringify(dbHelper.db)) as Jsonify<typeof BASE_SEED>;

beforeAll(async () => {
const [{ email, password }] = db.users;

await dbHelper.refresh();
await client.setAuth(email, password);
});

describe(`GET ${WORKFLOWS_ENDPOINT_PREFIX}`, () => {
beforeAll(() => dbHelper.refresh());

it("should order by boolean properties", async () => {
const response = await client
.findManyResponse({
params: { order: [{ active: "desc" }] } satisfies WorkflowQueryDto
})
.catch(({ response }: AxiosError) => response!);

expect(response.status).toBe(HttpStatusCode.Ok);
});
});
});
10 changes: 10 additions & 0 deletions apps/backend-e2e/src/support/http/clients/workflow.http-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { WorkflowDto } from "~/lib/common/app/workflow/dtos";
import { WORKFLOWS_ENDPOINT_PREFIX } from "~/lib/common/app/workflow/endpoints";

import { EntityHttpClient } from "./_lib/entity.http-client";

export class WorkflowHttpClient extends EntityHttpClient<WorkflowDto> {
public override getEndpoint(): string {
return WORKFLOWS_ENDPOINT_PREFIX;
}
}

0 comments on commit ed80657

Please sign in to comment.