Skip to content

fix(agent/agentcontainers): improve testing of convertDockerInspect, return correct host port #16887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 18, 2025
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
Next Next commit
chore(site): add stories for AgentDevcontainerCard
  • Loading branch information
johnstcn committed Mar 13, 2025
commit 999469f6e90dc89a3c30661845ca5f5e33846a77
32 changes: 32 additions & 0 deletions site/src/modules/resources/AgentDevcontainerCard.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { Meta, StoryObj } from "@storybook/react";
import { AgentDevcontainerCard } from "./AgentDevcontainerCard";
import {
MockWorkspace,
MockWorkspaceAgentDevcontainer,
MockWorkspaceAgentDevcontainerPorts,
} from "testHelpers/entities";

const meta: Meta<typeof AgentDevcontainerCard> = {
title: "modules/resources/AgentDevcontainerCard",
component: AgentDevcontainerCard,
args: {
container: MockWorkspaceAgentDevcontainer,
workspace: MockWorkspace,
wildcardHostname: "*.wildcard.hostname",
agentName: "dev",
},
};

export default meta;
type Story = StoryObj<typeof AgentDevcontainerCard>;

export const NoPorts: Story = {};

export const WithPorts: Story = {
args: {
container: {
...MockWorkspaceAgentDevcontainer,
ports: MockWorkspaceAgentDevcontainerPorts,
},
},
};
43 changes: 43 additions & 0 deletions site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4272,3 +4272,46 @@ function mockTwoDaysAgo() {
date.setDate(date.getDate() - 2);
return date.toISOString();
}

export const MockWorkspaceAgentDevcontainerPorts: TypesGen.WorkspaceAgentDevcontainerPort[] = [
{
port: 1000,
network: "tcp",
host_port: 1000,
host_ip: "0.0.0.0"
},
{
port: 2001,
network: "tcp",
host_port: 2000,
host_ip: "::1"
},
{
port: 8888,
network: "tcp",
}
]

export const MockWorkspaceAgentDevcontainer : TypesGen.WorkspaceAgentDevcontainer = {
created_at: "2024-01-04T15:53:03.21563Z",
id: "abcd1234",
name: "container-1",
image: "ubuntu:latest",
labels: {
"foo": "bar"
},
ports: [],
running: true,
status: "running",
volumes: {
"/mnt/volume1": "/volume1",
}
}

export const MockWorkspaceAgentListContainersResponse: TypesGen.WorkspaceAgentListContainersResponse =
{
containers: [
MockWorkspaceAgentDevcontainer,
],
"warnings": ["This is a warning"],
}