diff --git a/ui-v2/src/components/concurrency/global-concurrency-view/data-table/data-table.test.tsx b/ui-v2/src/components/concurrency/global-concurrency-view/data-table/data-table.test.tsx
index 162194c5628e..16e35f843441 100644
--- a/ui-v2/src/components/concurrency/global-concurrency-view/data-table/data-table.test.tsx
+++ b/ui-v2/src/components/concurrency/global-concurrency-view/data-table/data-table.test.tsx
@@ -1,27 +1,26 @@
+import { Toaster } from "@/components/ui/toaster";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { createWrapper } from "@tests/utils";
import { describe, expect, it, vi } from "vitest";
import { Table } from "./data-table";
-const MOCK_DATA = [
- {
- id: "0",
- created: "2021-01-01T00:00:00Z",
- updated: "2021-01-01T00:00:00Z",
- active: true,
- name: "global concurrency limit 0",
- limit: 0,
- active_slots: 0,
- slot_decay_per_second: 0,
- },
-];
+const MOCK_ROW = {
+ id: "0",
+ created: "2021-01-01T00:00:00Z",
+ updated: "2021-01-01T00:00:00Z",
+ active: true,
+ name: "global concurrency limit 0",
+ limit: 0,
+ active_slots: 0,
+ slot_decay_per_second: 0,
+};
describe("GlobalConcurrencyLimitTable -- table", () => {
it("renders row data", () => {
render(
{
render(
{
screen.getByRole("button", { name: /open menu/i, hidden: true }),
);
await user.click(screen.getByRole("menuitem", { name: /delete/i }));
- expect(mockFn).toHaveBeenCalledOnce();
+ expect(mockFn).toBeCalledWith(MOCK_ROW);
});
it("calls onEdit upon clicking rest action menu item", async () => {
const user = userEvent.setup();
@@ -64,7 +63,7 @@ describe("GlobalConcurrencyLimitTable -- table", () => {
render(
{
screen.getByRole("button", { name: /open menu/i, hidden: true }),
);
await user.click(screen.getByRole("menuitem", { name: /edit/i }));
- expect(mockFn).toHaveBeenCalledOnce();
+ expect(mockFn).toHaveBeenCalledWith(MOCK_ROW);
+ });
+
+ it("toggles active switch", async () => {
+ const user = userEvent.setup();
+
+ const { rerender } = render(
+ <>
+
+
+ >,
+ { wrapper: createWrapper() },
+ );
+ expect(
+ screen.getByRole("switch", { name: /toggle active/i }),
+ ).toBeChecked();
+
+ await user.click(
+ screen.getByRole("switch", {
+ name: /toggle active/i,
+ }),
+ );
+ expect(screen.getByText("Concurrency limit updated")).toBeVisible();
+ rerender(
+ ,
+ );
+
+ expect(
+ screen.getByRole("switch", { name: /toggle active/i }),
+ ).not.toBeChecked();
});
});
diff --git a/ui-v2/src/components/concurrency/task-run-concurrenct-view/data-table/data-table.test.tsx b/ui-v2/src/components/concurrency/task-run-concurrenct-view/data-table/data-table.test.tsx
index b15331a57494..85961acb10e5 100644
--- a/ui-v2/src/components/concurrency/task-run-concurrenct-view/data-table/data-table.test.tsx
+++ b/ui-v2/src/components/concurrency/task-run-concurrenct-view/data-table/data-table.test.tsx
@@ -3,22 +3,20 @@ import userEvent from "@testing-library/user-event";
import { describe, expect, it, vi } from "vitest";
import { Table } from "./data-table";
-const MOCK_DATA = [
- {
- id: "0",
- created: "2021-01-01T00:00:00Z",
- updated: "2021-01-01T00:00:00Z",
- tag: "my tag 0",
- concurrency_limit: 1,
- active_slots: [] as Array,
- },
-];
+const MOCK_ROW = {
+ id: "0",
+ created: "2021-01-01T00:00:00Z",
+ updated: "2021-01-01T00:00:00Z",
+ tag: "my tag 0",
+ concurrency_limit: 1,
+ active_slots: [] as Array,
+};
describe("TaskRunDataTable -- table", () => {
it("renders row data", () => {
render(
{
render(
{
screen.getByRole("button", { name: /open menu/i, hidden: true }),
);
await user.click(screen.getByRole("menuitem", { name: /delete/i }));
- expect(mockFn).toHaveBeenCalledOnce();
+ expect(mockFn).toHaveBeenCalledWith(MOCK_ROW);
});
it("calls onReset upon clicking rest action menu item", async () => {
const user = userEvent.setup();
@@ -54,7 +52,7 @@ describe("TaskRunDataTable -- table", () => {
render(
{
screen.getByRole("button", { name: /open menu/i, hidden: true }),
);
await user.click(screen.getByRole("menuitem", { name: /reset/i }));
- expect(mockFn).toHaveBeenCalledOnce();
+ expect(mockFn).toHaveBeenCalledWith(MOCK_ROW);
});
});