8000 Fix stories · coder/coder@22a43fe · GitHub
[go: up one dir, main page]

Skip to content

Commit 22a43fe

Browse files
committed
Fix stories
1 parent 5f7a176 commit 22a43fe

File tree

6 files changed

+34
-49
lines changed

6 files changed

+34
-49
lines changed

site/src/modules/resources/AgentRow.stories.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
withWebSocket,
99
} from "testHelpers/storybook";
1010
import { AgentRow } from "./AgentRow";
11+
import { spyOn } from "@storybook/test";
12+
import { API } from "api/api";
1113

1214
const defaultAgentMetadata = [
1315
{
@@ -223,6 +225,13 @@ export const ShowingPortForward: Story = {
223225
};
224226

225227
export const Outdated: Story = {
228+
beforeEach: () => {
229+
spyOn(API, "getBuildInfo").mockResolvedValue({
230+
...M.MockBuildInfo,
231+
version: "v99.999.9999+c1cdf14",
232+
agent_api_version: "1.0",
233+
});
234+
},
226235
args: {
227236
agent: M.MockWorkspaceAgentOutdated,
228237
workspace: M.MockWorkspace,

site/src/modules/resources/PortForwardButton.stories.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from "@storybook/react";
22
import {
33
MockListeningPortsResponse,
44
MockSharedPortsResponse,
5+
MockTemplate,
56
MockWorkspace,
67
MockWorkspaceAgent,
78
} from "testHelpers/entities";
@@ -14,6 +15,8 @@ const meta: Meta<typeof PortForwardButton> = {
1415
decorators: [withDashboardProvider],
1516
args: {
1617
agent: MockWorkspaceAgent,
18+
workspace: MockWorkspace,
19+
template: MockTemplate,
1720
},
1821
};
1922

site/src/modules/resources/PortForwardButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export const PortForwardButton: FC<PortForwardButtonProps> = ({
9191
...workspacePortShares(workspace.id),
9292
enabled: agent.status === "connected",
9393
select: (res) => res.shares,
94-
initialData: { shares: [] },
9594
});
9695

9796
return (
@@ -111,7 +110,7 @@ export const PortForwardButton: FC<PortForwardButtonProps> = ({
111110
agent={agent}
112111
workspace={workspace}
113112
template={template}
114-
sharedPorts={sharedPorts}
113+
sharedPorts={sharedPorts ?? []}
115114
listeningPorts={listeningPorts ?? []}
116115
portSharingControlsEnabled={
117116
entitlements.features.control_shared_ports.enabled

site/src/modules/resources/PortForwardPopoverView.stories.tsx

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,7 @@ type Story = StoryObj<typeof PortForwardPopoverView>;
4040
export const WithPorts: Story = {
4141
args: {
4242
listeningPorts: MockListeningPortsResponse.ports,
43-
},
44-
parameters: {
45-
queries: [
46-
{
47-
key: ["sharedPorts", MockWorkspace.id],
48-
data: MockSharedPortsResponse,
49-
},
50-
],
43+
sharedPorts: MockSharedPortsResponse.shares,
5144
},
5245
};
5346

@@ -58,49 +51,29 @@ export const WithManyPorts: Story = {
5851
network: "",
5952
port: 3000 + i,
6053
})),
61-
},
62-
parameters: {
63-
queries: [
64-
{
65-
key: ["sharedPorts", MockWorkspace.id],
66-
data: MockSharedPortsResponse,
67-
},
68-
],
54+
sharedPorts: MockSharedPortsResponse.shares,
6955
},
7056
};
7157

7258
export const Empty: Story = {
7359
args: {
7460
listeningPorts: [],
75-
},
76-
parameters: {
77-
queries: [
78-
{
79-
key: ["sharedPorts", MockWorkspace.id],
80-
data: { shares: [] },
81-
},
82-
],
61+
sharedPorts: [],
8362
},
8463
};
8564

8665
export const AGPLPortSharing: Story = {
8766
args: {
8867
listeningPorts: MockListeningPortsResponse.ports,
8968
portSharingControlsEnabled: false,
90-
},
91-
parameters: {
92-
queries: [
93-
{
94-
key: ["sharedPorts", MockWorkspace.id],
95-
data: MockSharedPortsResponse,
96-
},
97-
],
69+
sharedPorts: MockSharedPortsResponse.shares,
9870
},
9971
};
10072

10173
export const EnterprisePortSharingControlsOwner: Story = {
10274
args: {
10375
listeningPorts: MockListeningPortsResponse.ports,
76+
sharedPorts: [],
10477
template: {
10578
...MockTemplate,
10679
max_port_share_level: "owner",
@@ -115,17 +88,8 @@ export const EnterprisePortSharingControlsAuthenticated: Story = {
11588
...MockTemplate,
11689
max_port_share_level: "authenticated",
11790
},
118-
},
119-
parameters: {
120-
queries: [
121-
{
122-
key: ["sharedPorts", MockWorkspace.id],
123-
data: {
124-
shares: MockSharedPortsResponse.shares.filter((share) => {
125-
return share.share_level === "authenticated";
126-
}),
127-
},
128-
},
129-
],
91+
sharedPorts: MockSharedPortsResponse.shares.filter((share) => {
92+
return share.share_level === "authenticated";
93+
}),
13094
},
13195
};

site/src/modules/resources/SSHButton/SSHButton.stories.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import type { Meta, StoryObj } from "@storybook/react";
2-
import { userEvent, within } from "@storybook/test";
3-
import { MockWorkspace, MockWorkspaceAgent } from "testHelpers/entities";
2+
import { spyOn, userEvent, within } from "@storybook/test";
3+
import {
4+
MockDeploymentConfig,
5+
MockDeploymentSSH,
6+
MockWorkspace,
7+
MockWorkspaceAgent,
8+
} from "testHelpers/entities";
49
import { withDesktopViewport } from "testHelpers/storybook";
510
import { AgentSSHButton } from "./SSHButton";
11+
import { API } from "api/api";
612

713
const meta: Meta<typeof AgentSSHButton> = {
814
title: "modules/resources/AgentSSHButton",
@@ -20,6 +26,9 @@ export const Closed: Story = {
2026
};
2127

2228
export const Opened: Story = {
29+
beforeEach: () => {
30+
spyOn(API, "getDeploymentSSHConfig").mockResolvedValue(MockDeploymentSSH);
31+
},
2332
args: {
2433
workspaceName: MockWorkspace.name,
2534
agentName: MockWorkspaceAgent.name,

site/src/pages/TaskPage/TaskPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ const TaskPage = () => {
246246
<div className="flex flex-col">
247247
<h1 className="m-0 text-sm font-medium">{task.prompt}</h1>
248248
<span className="text-xs text-content-secondary">
249-
Created by {task.workspace.owner_username}{" "}
249+
Created by{" "}
250+
{task.workspace.owner_name ?? task.workspace.owner_username}{" "}
250251
{timeFrom(new Date(task.workspace.created_at))}
251252
</span>
252253
</div>

0 commit comments

Comments
 (0)
10C5
0