-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: added ui unit tests chore: added ui unit tests Signed-off-by: Darshan Simha <[email protected]>
- Loading branch information
Darshan Simha
committed
Nov 6, 2023
1 parent
d0ae148
commit 9ce354d
Showing
9 changed files
with
262 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import "@testing-library/jest-dom"; | ||
|
||
import { StatusBar } from "./index"; | ||
|
||
describe("StatusBar", () => { | ||
it("Renders", () => { | ||
render(<StatusBar healthy={1} warning={2} critical={3} />); | ||
expect(screen.getByText("Healthy")).toBeInTheDocument(); | ||
expect(screen.getByText("Warning")).toBeInTheDocument(); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
ui/src/components/common/StatusCounts/StatusCounts.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import "@testing-library/jest-dom"; | ||
|
||
import { StatusCounts } from "./StatusCounts"; | ||
|
||
describe("StatusCounts", () => { | ||
it("Renders", () => { | ||
render(<StatusCounts counts={{ healthy: 1, warning: 2, critical: 3 }} />); | ||
expect(screen.getByText("healthy")).toBeInTheDocument(); | ||
expect(screen.getByText(": 1")).toBeInTheDocument(); | ||
expect(screen.getByText("warning")).toBeInTheDocument(); | ||
expect(screen.getByText(": 2")).toBeInTheDocument(); | ||
expect(screen.getByText("critical")).toBeInTheDocument(); | ||
expect(screen.getByText(": 3")).toBeInTheDocument(); | ||
}); | ||
|
||
it("Renders when counts are zero", () => { | ||
render(<StatusCounts counts={{ healthy: 0, warning: 0, critical: 0 }} />); | ||
expect(screen.getByText("healthy")).toBeInTheDocument(); | ||
expect(screen.getAllByText(": 0").length).toBe(3); | ||
expect(screen.getByText("warning")).toBeInTheDocument(); | ||
expect(screen.getByText("critical")).toBeInTheDocument(); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
ui/src/components/common/StatusIndicator/StatusIndicator.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import "@testing-library/jest-dom"; | ||
|
||
import { IndicatorStatus, StatusIndicator } from "./StatusIndicator"; | ||
|
||
describe("StatusIndicator", () => { | ||
it("Renders", () => { | ||
render(<StatusIndicator status={IndicatorStatus.HEALTHY} />); | ||
expect(screen.getByTestId("HEALTHY")).toBeInTheDocument(); | ||
}); | ||
|
||
it("Renders when status is warning", () => { | ||
render(<StatusIndicator status={IndicatorStatus.WARNING} />); | ||
expect(screen.getByTestId("WARNING")).toBeInTheDocument(); | ||
}); | ||
|
||
it("Renders when status is critical", () => { | ||
render(<StatusIndicator status={IndicatorStatus.CRITICAL} />); | ||
expect(screen.getByTestId("CRITICAL")).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
198 changes: 198 additions & 0 deletions
198
ui/src/components/common/SummaryPageLayout/index.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import "@testing-library/jest-dom"; | ||
|
||
import { SummaryPageLayout } from "./index"; | ||
import { NamespacePipelineListing } from "../../pages/Namespace/partials/NamespacePipelineListing"; | ||
|
||
window.ResizeObserver = class ResizeObserver { | ||
observe() { | ||
// do nothing | ||
} | ||
unobserve() { | ||
// do nothing | ||
} | ||
disconnect() { | ||
// do nothing | ||
} | ||
}; | ||
|
||
const mockSummarySections = [ | ||
{ | ||
type: 3, | ||
collectionSections: [ | ||
{ type: 0, titledValueProps: { title: "PIPELINES", value: 4 } }, | ||
{ | ||
type: 1, | ||
statusesProps: { | ||
title: "PIPELINES STATUS", | ||
active: 3, | ||
inActive: 1, | ||
healthy: 3, | ||
warning: 0, | ||
critical: 0, | ||
tooltip: | ||
"Running pipeline health is determined by backpressure. Non-Running pipelines are failed, pausing, paused, or deleting.", | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
type: 3, | ||
collectionSections: [ | ||
{ | ||
type: 0, | ||
titledValueProps: { | ||
title: "ISB SERVICES", | ||
value: 5, | ||
tooltip: | ||
"Inter State Buffer Services are used to transfer data between vertices in a pipeline.", | ||
}, | ||
}, | ||
{ | ||
type: 1, | ||
statusesProps: { | ||
title: "ISB SERVICES STATUS", | ||
active: 5, | ||
inActive: 0, | ||
healthy: 5, | ||
warning: 0, | ||
critical: 0, | ||
tooltip: { | ||
key: null, | ||
ref: null, | ||
props: { | ||
children: { | ||
key: null, | ||
ref: null, | ||
props: { | ||
children: [ | ||
{ | ||
type: "b", | ||
key: null, | ||
ref: null, | ||
props: { children: "Healthy:" }, | ||
_owner: null, | ||
_store: {}, | ||
}, | ||
" The ISB service is operating optimally. No issues or anomalies detected.", | ||
{ | ||
type: "hr", | ||
key: null, | ||
ref: null, | ||
props: {}, | ||
_owner: null, | ||
_store: {}, | ||
}, | ||
{ | ||
type: "b", | ||
key: null, | ||
ref: null, | ||
props: { children: "Warning:" }, | ||
_owner: null, | ||
_store: {}, | ||
}, | ||
" The ISB service is experiencing minor issues or degradation within the data processing pipeline. Consider monitoring and further investigation.", | ||
{ | ||
type: "hr", | ||
key: null, | ||
ref: null, | ||
props: {}, | ||
_owner: null, | ||
_store: {}, | ||
}, | ||
{ | ||
type: "b", | ||
key: null, | ||
ref: null, | ||
props: { children: "Critical:" }, | ||
_owner: null, | ||
_store: {}, | ||
}, | ||
" The ISB service is in a critical state. Immediate attention required.", | ||
], | ||
}, | ||
_owner: null, | ||
_store: {}, | ||
}, | ||
}, | ||
_owner: null, | ||
_store: {}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
]; | ||
const mockComponentData = { | ||
pipelinesCount: 4, | ||
pipelinesActiveCount: 3, | ||
pipelinesInactiveCount: 1, | ||
pipelinesHealthyCount: 3, | ||
pipelinesWarningCount: 0, | ||
pipelinesCriticalCount: 0, | ||
isbsCount: 5, | ||
isbsActiveCount: 5, | ||
isbsInactiveCount: 0, | ||
isbsHealthyCount: 5, | ||
isbsWarningCount: 0, | ||
isbsCriticalCount: 0, | ||
pipelineSummaries: [ | ||
{ | ||
name: "simple-pipeline", | ||
status: "healthy", | ||
}, | ||
{ | ||
name: "simple-pipeline-25", | ||
status: "inactive", | ||
}, | ||
{ | ||
name: "simple-pipeline-3", | ||
status: "healthy", | ||
}, | ||
{ | ||
name: "simple-pipeline-6", | ||
status: "healthy", | ||
}, | ||
], | ||
}; | ||
|
||
describe("SummaryPageLayout", () => { | ||
it("Renders", () => { | ||
render( | ||
<SummaryPageLayout | ||
summarySections={[]} | ||
contentComponent={ | ||
<NamespacePipelineListing | ||
namespace={""} | ||
data={mockComponentData} | ||
refresh={() => {}} | ||
/> | ||
} | ||
/> | ||
); | ||
expect(screen.getByTestId("summary-page-layout")).toBeInTheDocument(); | ||
}); | ||
|
||
it("Renders with summary sections", () => { | ||
render( | ||
<SummaryPageLayout | ||
summarySections={mockSummarySections} | ||
contentComponent={undefined} | ||
/> | ||
); | ||
expect(screen.getByTestId("summary-page-layout")).toBeInTheDocument(); | ||
}); | ||
|
||
it("Renders when collapsible and collapsed is true", () => { | ||
render( | ||
<SummaryPageLayout | ||
summarySections={mockSummarySections} | ||
contentComponent={undefined} | ||
collapsable={true} | ||
defaultCollapsed={true} | ||
/> | ||
); | ||
expect(screen.getByTestId("summary-page-layout")).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters