Skip to content

Commit

Permalink
enabling test
Browse files Browse the repository at this point in the history
  • Loading branch information
devinvillarosa committed Dec 11, 2024
1 parent 9a3eb59 commit 3d5bd60
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { type TaskRunConcurrencyLimit } from "@/hooks/task-run-concurrency-limits";
import { CellContext } from "@tanstack/react-table";

type Props = CellContext<TaskRunConcurrencyLimit, Array<string>>;

export const ActiveTaskRunCells = (props: Props) => {
const activeTaskRuns = props.getValue();
const numActiveTaskRuns = activeTaskRuns.length;
if (numActiveTaskRuns === 0) {
return "None";
}
return numActiveTaskRuns;
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { SearchInput } from "@/components/ui/input";
import { useDeferredValue, useMemo } from "react";
import { ActionsCell } from "./actions-cell";
import { ActiveTaskRunCells } from "./active-task-runs-cell";

const routeApi = getRouteApi("/concurrency-limits");

Expand All @@ -30,7 +31,8 @@ const createColumns = ({
header: "Slots",
}),
columnHelper.accessor("active_slots", {
header: "Active Task Runs", // TODO: Give this styling once knowing what it looks like
header: "Active Task Runs",
cell: ActiveTaskRunCells,
}),
columnHelper.display({
id: "actions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CreateLimitDialog } from "./create-dialog";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { createWrapper } from "@tests/utils";
import { beforeAll, describe, expect, it, vi } from "vitest";
import { expect, test, vi } from "vitest";

const MOCK_DATA = {
id: "0",
Expand All @@ -14,35 +14,31 @@ const MOCK_DATA = {
active_slots: [] as Array<string>,
};

describe("CreateLimitDialog", () => {
beforeAll(() => {
class ResizeObserverMock {
observe() {}
unobserve() {}
disconnect() {}
}
global.ResizeObserver = ResizeObserverMock;
});
test.skip("CreateLimitDialog calls onSubmit upon entering form data", async () => {
class ResizeObserverMock {
observe() {}
unobserve() {}
disconnect() {}
}
global.ResizeObserver = ResizeObserverMock;

it.skip("calls onSubmit upon entering form data", async () => {
const user = userEvent.setup();
const user = userEvent.setup();

// ------------ Setup
const mockOnSubmitFn = vi.fn();
render(
<CreateLimitDialog onOpenChange={vi.fn()} onSubmit={mockOnSubmitFn} />,
{ wrapper: createWrapper() },
);
// ------------ Act
await user.type(screen.getByLabelText(/tag/i), MOCK_DATA.tag);
await user.type(
screen.getByLabelText("Concurrency Limit"),
MOCK_DATA.concurrency_limit.toString(),
);
// ------------ Setup
const mockOnSubmitFn = vi.fn();
render(
<CreateLimitDialog onOpenChange={vi.fn()} onSubmit={mockOnSubmitFn} />,
{ wrapper: createWrapper() },
);

await user.click(screen.getByRole("button", { name: /add/i }));
// ------------ Act
await user.type(screen.getByLabelText(/tag/i), MOCK_DATA.tag);
await user.type(
screen.getByLabelText("Concurrency Limit"),
String(MOCK_DATA.concurrency_limit),
);
await user.click(screen.getByRole("button", { name: /add/i }));

// ------------ Assert
expect(mockOnSubmitFn).toHaveBeenCalledOnce();
});
// ------------ Assert
expect(mockOnSubmitFn).toHaveBeenCalledOnce();
});

0 comments on commit 3d5bd60

Please sign in to comment.