Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
handling empty state
  • Loading branch information
Kira-Pilot committed Dec 5, 2023
commit 8b65aa8d85f53752ea974adf2cfc5fe7112abb0c
36 changes: 36 additions & 0 deletions site/src/components/Resources/AgentRowPreview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ const NoVSCode = {
] as DisplayApp[],
};

const NoModulesJustApps = {
...MockWorkspaceAgent,
apps: [],
};

const NoAppsJustModules = {
...MockWorkspaceAgent,
display_apps: [] as DisplayApp[],
};

const EmptyAppPreview = {
...MockWorkspaceAgent,
apps: [],
display_apps: [] as DisplayApp[],
};

describe("AgentRowPreviewApps", () => {
it.each<{
workspaceAgent: WorkspaceAgent;
Expand All @@ -55,6 +71,18 @@ describe("AgentRowPreviewApps", () => {
workspaceAgent: NoVSCode,
testName: "NoVSCode",
},
{
workspaceAgent: NoModulesJustApps,
testName: "NoModulesJustApps",
},
{
workspaceAgent: NoAppsJustModules,
testName: "NoAppsJustModules",
},
{
workspaceAgent: EmptyAppPreview,
testName: "EmptyAppPreview",
},
])(
`<AgentRowPreview agent={$testName} /> displays appropriately`,
({ workspaceAgent }) => {
Expand Down Expand Up @@ -92,6 +120,14 @@ describe("AgentRowPreviewApps", () => {
screen.queryByText(DisplayAppNameMap[app]),
).not.toBeInTheDocument();
});

// test empty state
if (
workspaceAgent.display_apps.length === 0 &&
workspaceAgent.apps.length === 0
) {
expect(screen.getByText("None")).toBeInTheDocument();
}
},
);
});
2 changes: 1 addition & 1 deletion site/src/components/Resources/AgentRowPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const AgentRowPreview: FC<AgentRowPreviewProps> = ({
</AppPreview>
)
)}
{agent.apps.length === 0 && (
{agent.apps.length === 0 && agent.display_apps.length === 0 && (
<span css={styles.agentDataValue}>None</span>
)}
</Stack>
Expand Down