-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UI v2] feat: Adds deployment parameter table
- Loading branch information
1 parent
26f354b
commit f892661
Showing
7 changed files
with
344 additions
and
70 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
ui-v2/src/components/deployments/deployment-description.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,15 @@ | ||
import { Deployment } from "@/api/deployments"; | ||
import Markdown from "react-markdown"; | ||
import remarkGfm from "remark-gfm"; | ||
|
||
type DeploymentDescriptionProps = { | ||
deployment: Deployment; | ||
}; | ||
|
||
export const DeploymentDescription = ({ | ||
deployment, | ||
}: DeploymentDescriptionProps) => ( | ||
<Markdown className="prose" remarkPlugins={[remarkGfm]}> | ||
{deployment.description} | ||
</Markdown> | ||
); |
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
41 changes: 41 additions & 0 deletions
41
...omponents/deployments/deployment-parameters-table/deployment-parameters-table.stories.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,41 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { createFakeDeployment } from "@/mocks"; | ||
import { DeploymentParametersTable } from "./deployment-parameters-table"; | ||
|
||
const meta = { | ||
title: "Components/Deployments/DeploymentParametersTable", | ||
component: DeploymentParametersTable, | ||
args: { | ||
deployment: createFakeDeployment({ | ||
parameter_openapi_schema: { | ||
title: "Parameters", | ||
type: "object", | ||
properties: { | ||
name: { | ||
default: "world", | ||
position: 0, | ||
title: "name", | ||
type: "string", | ||
}, | ||
goodbye: { | ||
default: false, | ||
position: 1, | ||
title: "goodbye", | ||
type: "boolean", | ||
}, | ||
}, | ||
}, | ||
parameters: { | ||
// @ts-expect-error TODO: Fix OpenAPI Schema | ||
goodbye: false, | ||
// @ts-expect-error TODO: Fix OpenAPI Schema | ||
name: "world", | ||
}, | ||
}), | ||
}, | ||
} satisfies Meta<typeof DeploymentParametersTable>; | ||
|
||
export default meta; | ||
|
||
export const story: StoryObj = { name: "DeploymentParametersTable" }; |
84 changes: 84 additions & 0 deletions
84
...c/components/deployments/deployment-parameters-table/deployment-parameters-table.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,84 @@ | ||
import { render, screen, waitFor } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
import { createFakeDeployment } from "@/mocks"; | ||
import { DeploymentParametersTable } from "./deployment-parameters-table"; | ||
|
||
const MOCK_DEPLOYMENT = createFakeDeployment({ | ||
parameter_openapi_schema: { | ||
title: "Parameters", | ||
type: "object", | ||
properties: { | ||
name: { | ||
default: "world", | ||
position: 0, | ||
title: "name", | ||
type: "string", | ||
}, | ||
goodbye: { | ||
default: false, | ||
position: 1, | ||
title: "goodbye", | ||
type: "boolean", | ||
}, | ||
}, | ||
}, | ||
parameters: { | ||
// @ts-expect-error TODO: Fix OpenAPI Schema | ||
goodbye: false, | ||
// @ts-expect-error TODO: Fix OpenAPI Schema | ||
name: "world", | ||
}, | ||
}); | ||
|
||
describe("DeploymentParametersTable", () => { | ||
it("renders table with rows", () => { | ||
// ------------ Setup | ||
render(<DeploymentParametersTable deployment={MOCK_DEPLOYMENT} />); | ||
|
||
// ------------ Assert | ||
expect(screen.getByRole("cell", { name: /name/i })).toBeVisible(); | ||
expect(screen.getByRole("cell", { name: /goodbye/i })).toBeVisible(); | ||
}); | ||
|
||
it("filters table rows", async () => { | ||
// ------------ Setup | ||
const user = userEvent.setup(); | ||
|
||
render(<DeploymentParametersTable deployment={MOCK_DEPLOYMENT} />); | ||
|
||
// ------------ Act | ||
await user.type(screen.getByRole("textbox"), "name"); | ||
|
||
// ------------ Assert | ||
await waitFor(() => | ||
expect( | ||
screen.queryByRole("cell", { name: /goodbye/i }), | ||
).not.toBeInTheDocument(), | ||
); | ||
expect(screen.getByRole("cell", { name: /name/i })).toBeVisible(); | ||
}); | ||
|
||
it("filters no results", async () => { | ||
// ------------ Setup | ||
const user = userEvent.setup(); | ||
|
||
render(<DeploymentParametersTable deployment={MOCK_DEPLOYMENT} />); | ||
|
||
// ------------ Act | ||
await user.type(screen.getByRole("textbox"), "no results found"); | ||
|
||
// ------------ Assert | ||
await waitFor(() => | ||
expect( | ||
screen.queryByRole("cell", { name: /goodbye/i }), | ||
).not.toBeInTheDocument(), | ||
); | ||
expect( | ||
screen.queryByRole("cell", { name: /name/i }), | ||
).not.toBeInTheDocument(); | ||
|
||
expect(screen.getByText("No results.")).toBeVisible(); | ||
}); | ||
}); |
Oops, something went wrong.