Skip to content

Commit a2358bf

Browse files
committed
fix: fix storybook tests
1 parent adce52e commit a2358bf

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

site/src/modules/workspaces/ClassicParameterFlowDeprecationWarning/ClassicParameterFlowDeprecationWarning.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe("ClassicParameterFlowDeprecationWarning", () => {
1515
it("renders warning when enabled and user has template update permissions", () => {
1616
render(
1717
<ClassicParameterFlowDeprecationWarning
18+
templateSettingsLink={`/templates/${defaultProps.organizationName}/${defaultProps.templateName}/settings`}
1819
{...defaultProps}
1920
isEnabled={true}
2021
/>,
@@ -27,6 +28,7 @@ describe("ClassicParameterFlowDeprecationWarning", () => {
2728
it("does not render when enabled is false", () => {
2829
const { container } = render(
2930
<ClassicParameterFlowDeprecationWarning
31+
templateSettingsLink={`/templates/${defaultProps.organizationName}/${defaultProps.templateName}/settings`}
3032
{...defaultProps}
3133
isEnabled={false}
3234
/>,

site/src/modules/workspaces/ClassicParameterFlowDeprecationWarning/ClassicParameterFlowDeprecationWarning.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
import { Alert } from "components/Alert/Alert";
22
import { Link } from "components/Link/Link";
3-
import { linkToTemplate, useLinks } from "modules/navigation";
43
import type { FC } from "react";
54
import { docs } from "utils/docs";
65

76
interface ClassicParameterFlowDeprecationWarningProps {
8-
organizationName: string;
9-
templateName: string;
7+
templateSettingsLink: string;
108
isEnabled: boolean;
119
}
1210

1311
export const ClassicParameterFlowDeprecationWarning: FC<
1412
ClassicParameterFlowDeprecationWarningProps
15-
> = ({ organizationName, templateName, isEnabled }) => {
16-
const getLink = useLinks();
17-
13+
> = ({ templateSettingsLink, isEnabled }) => {
1814
if (!isEnabled) {
1915
return null;
2016
}
2117

22-
const templateSettingsLink = `${getLink(
23-
linkToTemplate(organizationName, templateName),
24-
)}/settings`;
25-
2618
return (
2719
<Alert severity="warning" className="mb-2">
2820
<div>

site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Meta, StoryObj } from "@storybook/react";
33
import { within } from "@testing-library/react";
44
import userEvent from "@testing-library/user-event";
55
import { chromatic } from "testHelpers/chromatic";
6+
import { withDashboardProvider } from "testHelpers/storybook";
67
import {
78
MockTemplate,
89
MockTemplateVersionParameter1,
@@ -33,6 +34,7 @@ const meta: Meta<typeof CreateWorkspacePageView> = {
3334
onCancel: action("onCancel"),
3435
templatePermissions: { canUpdateTemplate: true },
3536
},
37+
decorators: [withDashboardProvider],
3638
};
3739

3840
export default meta;

site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { UserAutocomplete } from "components/UserAutocomplete/UserAutocomplete";
2828
import { type FormikContextType, useFormik } from "formik";
2929
import type { ExternalAuthPollingState } from "hooks/useExternalAuth";
3030
import { ExternalLinkIcon } from "lucide-react";
31+
import { linkToTemplate, useLinks } from "modules/navigation";
3132
import { ClassicParameterFlowDeprecationWarning } from "modules/workspaces/ClassicParameterFlowDeprecationWarning/ClassicParameterFlowDeprecationWarning";
3233
import { generateWorkspaceName } from "modules/workspaces/generateWorkspaceName";
3334
import { type FC, useCallback, useEffect, useMemo, useState } from "react";
@@ -102,6 +103,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
102103
onSubmit,
103104
onCancel,
104105
}) => {
106+
const getLink = useLinks();
105107
const [owner, setOwner] = useState(defaultOwner);
106108
const [suggestedName, setSuggestedName] = useState(() =>
107109
generateWorkspaceName(),
@@ -265,8 +267,9 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
265267
</PageHeader>
266268

267269
<ClassicParameterFlowDeprecationWarning
268-
organizationName={template.organization_name}
269-
templateName={template.name}
270+
templateSettingsLink={`${getLink(
271+
linkToTemplate(template.organization_name, template.name),
272+
)}/settings`}
270273
isEnabled={templatePermissions.canUpdateTemplate}
271274
/>
272275

site/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersForm.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ export const WorkspaceParametersForm: FC<WorkspaceParameterFormProps> = ({
9090
</Alert>
9191
)}
9292
<ClassicParameterFlowDeprecationWarning
93-
organizationName={workspace.organization_name}
94-
templateName={workspace.template_name}
93+
templateSettingsLink={`/templates/${workspace.organization_name}/${workspace.template_name}/settings`}
9594
isEnabled={templatePermissions?.canUpdateTemplate ?? false}
9695
/>
9796
<HorizontalForm onSubmit={form.handleSubmit} data-testid="form">

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy