Skip to content

Commit

Permalink
feat: add tabs to display pipelines and isb services (#1293)
Browse files Browse the repository at this point in the history
Signed-off-by: Darshan Simha <[email protected]>
Co-authored-by: Darshan Simha <[email protected]>
  • Loading branch information
darshansimha and Darshan Simha authored Oct 30, 2023
1 parent 0dccf96 commit 6efab64
Show file tree
Hide file tree
Showing 7 changed files with 949 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ export function DeleteModal({
}`}
/>
<Box sx={buttonContainerStyle}>
<Button onClick={handleDelete} variant="contained" color="secondary">
<Button
onClick={handleDelete}
variant="contained"
color="secondary"
data-testid="delete-confirmation-button"
>
Delete
</Button>
<Button onClick={onCancel} variant="outlined" color="primary">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
// Tests the ISBServiceCard component

import React from "react";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import userEvent from "@testing-library/user-event";
import { ISBServiceCard } from "./ISBServiceCard";
import { AppContext } from "../../../../../../App";
import { BrowserRouter } from "react-router-dom";
import { act } from "react-dom/test-utils";

const mockSetSidebarProps = jest.fn();

const mockNamespace = "numaflow-system";

const mockData = {
name: "default",
status: "healthy",
isbService: {
kind: "InterStepBufferService",
apiVersion: "numaflow.numaproj.io/v1alpha1",
metadata: {
name: "default",
namespace: "numaflow-system",
uid: "56a52b93-b9bf-481e-8556-2bad974805a4",
resourceVersion: "331851",
generation: 1,
creationTimestamp: "2023-10-12T14:35:53Z",
annotations: {
"kubectl.kubernetes.io/last-applied-configuration":
'{"apiVersion":"numaflow.numaproj.io/v1alpha1","kind":"InterStepBufferService","metadata":{"annotations":{},"name":"default","namespace":"numaflow-system"},"spec":{"jetstream":{"persistence":{"volumeSize":"3Gi"},"version":"latest"}}}\n',
},
finalizers: ["isbsvc-controller"],
managedFields: [
{
manager: "kubectl-client-side-apply",
operation: "Update",
apiVersion: "numaflow.numaproj.io/v1alpha1",
time: "2023-10-12T14:35:53Z",
fieldsType: "FieldsV1",
fieldsV1: {
"f:metadata": {
"f:annotations": {
".": {},
"f:kubectl.kubernetes.io/last-applied-configuration": {},
},
},
"f:spec": {
".": {},
"f:jetstream": {
".": {},
"f:persistence": {
".": {},
"f:volumeSize": {},
},
"f:replicas": {},
"f:version": {},
},
},
},
},
{
manager: "numaflow",
operation: "Update",
apiVersion: "numaflow.numaproj.io/v1alpha1",
time: "2023-10-12T14:35:54Z",
fieldsType: "FieldsV1",
fieldsV1: {
"f:metadata": {
"f:finalizers": {
".": {},
'v:"isbsvc-controller"': {},
},
},
},
},
{
manager: "numaflow",
operation: "Update",
apiVersion: "numaflow.numaproj.io/v1alpha1",
time: "2023-10-30T13:32:18Z",
fieldsType: "FieldsV1",
fieldsV1: {
"f:status": {
".": {},
"f:conditions": {},
"f:config": {
".": {},
"f:jetstream": {
".": {},
"f:auth": {
".": {},
"f:basic": {
".": {},
"f:password": {
".": {},
"f:key": {},
"f:name": {},
},
"f:user": {
".": {},
"f:key": {},
"f:name": {},
},
},
},
"f:streamConfig": {},
"f:url": {},
},
},
"f:phase": {},
"f:type": {},
},
},
subresource: "status",
},
],
},
spec: {
jetstream: {
version: "latest",
replicas: 3,
persistence: {
volumeSize: "3Gi",
},
},
},
status: {
conditions: [
{
type: "Configured",
status: "True",
lastTransitionTime: "2023-10-30T13:32:18Z",
reason: "Successful",
message: "Successful",
},
{
type: "Deployed",
status: "True",
lastTransitionTime: "2023-10-30T13:32:18Z",
reason: "Successful",
message: "Successful",
},
],
phase: "Running",
config: {
jetstream: {
url: "nats://isbsvc-default-js-svc.numaflow-system.svc:4222",
auth: {
basic: {
user: {
name: "isbsvc-default-js-client-auth",
key: "client-auth-user",
},
password: {
name: "isbsvc-default-js-client-auth",
key: "client-auth-password",
},
},
},
streamConfig:
"consumer:\n ackwait: 60s\n maxackpending: 25000\notbucket:\n history: 1\n maxbytes: 0\n maxvaluesize: 0\n replicas: 3\n storage: 0\n ttl: 3h\nprocbucket:\n history: 1\n maxbytes: 0\n maxvaluesize: 0\n replicas: 3\n storage: 0\n ttl: 72h\nstream:\n duplicates: 60s\n maxage: 72h\n maxbytes: -1\n maxmsgs: 100000\n replicas: 3\n retention: 0\n storage: 0\n",
},
},
type: "jetstream",
},
},
};

const mockRefresh = jest.fn();

describe("ISBServiceCard", () => {
beforeEach(() => {
jest.clearAllMocks();
});

it("should render ISBServiceCard with correct data", async () => {
render(
<BrowserRouter>
<AppContext.Provider
value={{
setSidebarProps: mockSetSidebarProps,
}}
>
<ISBServiceCard
namespace={mockNamespace}
data={mockData}
refresh={mockRefresh}
/>
</AppContext.Provider>
</BrowserRouter>
);
expect(screen.getByText("Active")).toBeInTheDocument();
expect(screen.getByText("Healthy")).toBeInTheDocument();
expect(screen.getByText("jetstream")).toBeInTheDocument();
expect(screen.getByText("3")).toBeInTheDocument();
});

it("Tests if Delete exists and is clickable", async () => {
render(
<BrowserRouter>
<AppContext.Provider
value={{
setSidebarProps: mockSetSidebarProps,
}}
>
<ISBServiceCard
namespace={mockNamespace}
data={mockData}
refresh={mockRefresh}
/>
</AppContext.Provider>
</BrowserRouter>
);

const deleteButton = screen.getByTestId("delete-isb");
expect(deleteButton).toBeInTheDocument();
userEvent.click(deleteButton);
expect(
screen.getByTestId("delete-confirmation-button")
).toBeInTheDocument();
await act(async () => {
userEvent.click(screen.getByTestId("delete-confirmation-button"));
});
});
it("Tests if Edit exists and is clickable", async () => {
render(
<BrowserRouter>
<AppContext.Provider
value={{
setSidebarProps: mockSetSidebarProps,
}}
>
<ISBServiceCard
namespace={mockNamespace}
data={mockData}
refresh={mockRefresh}
/>
</AppContext.Provider>
</BrowserRouter>
);

const editButton = screen.getByTestId("edit-isb");
expect(editButton).toBeInTheDocument();
userEvent.click(editButton);
});
});
Loading

0 comments on commit 6efab64

Please sign in to comment.