Skip to content

Commit

Permalink
Merge pull request #184 from amosproj/feat/#33search-container-by-name
Browse files Browse the repository at this point in the history
Feat/#33search container by name
  • Loading branch information
smnws authored Jun 28, 2023
2 parents b18c2c8 + 5cec9af commit a4ef470
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion Explorer/src/app/page.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from "@testing-library/react";
import { render, fireEvent } from "@testing-library/react";
import Index from "./page";
//eslint-disable-next-line @typescript-eslint/no-unused-vars
import { toBeInTheDocument } from "@testing-library/jest-dom";
Expand All @@ -15,6 +15,16 @@ jest.mock("../lib/db", () => ({
status: "Running",
ports: 1,
},
{
container_event_id: 2,
container_id: 2,
timestamp: "2021-08-01 00:00:00",
pod_id: 2,
name: "Container 2",
image: "Image 2",
status: "Pending",
ports: 2,
},
]),
}));

Expand All @@ -24,4 +34,23 @@ describe("Index", () => {

expect(getByText("Container 1")).toBeInTheDocument();
});

it("filters containers based on search term", async () => {
const { getByPlaceholderText, getAllByRole, getByText } = render(
await Index()
);

const searchInput = getByPlaceholderText("Search...");
fireEvent.change(searchInput, { target: { value: "Container 1" } });
fireEvent.click(getByText("Search"));

const tableRows = getAllByRole("row");
expect(tableRows).toHaveLength(2); // Header row + 1 matching row

fireEvent.change(searchInput, { target: { value: "Image" } });
fireEvent.click(getByText("Search"));

const updatedTableRows = getAllByRole("row");
expect(updatedTableRows).toHaveLength(3); // All containers match the search term
});
});

0 comments on commit a4ef470

Please sign in to comment.