Skip to content

Commit bfe665b

Browse files
committed
Fix tests, port forward button and fmt
1 parent 27e4658 commit bfe665b

File tree

8 files changed

+25
-57
lines changed

8 files changed

+25
-57
lines changed

site/src/components/PaginationWidget/PaginationWidgetBase.test.tsx

+4-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
type SampleProps = Omit<PaginationWidgetBaseProps, "onPageChange">;
1010

1111
describe(PaginationWidgetBase.name, () => {
12-
it("Should have its previous button be aria-disabled while on page 1", async () => {
12+
it("Should have its previous button be disabled while on page 1", async () => {
1313
const sampleProps: SampleProps[] = [
1414
{ currentPage: 1, pageSize: 5, totalRecords: 6 },
1515
{ currentPage: 1, pageSize: 50, totalRecords: 200 },
@@ -23,16 +23,15 @@ describe(PaginationWidgetBase.name, () => {
2323
);
2424

2525
const prevButton = await screen.findByLabelText("Previous page");
26-
expect(prevButton).not.toBeDisabled();
27-
expect(prevButton).toHaveAttribute("aria-disabled", "true");
26+
expect(prevButton).toBeDisabled();
2827

2928
await userEvent.click(prevButton);
3029
expect(onPageChange).not.toHaveBeenCalled();
3130
unmount();
3231
}
3332
});
3433

35-
it("Should have its next button be aria-disabled while on last page", async () => {
34+
it("Should have its next button be disabled while on last page", async () => {
3635
const sampleProps: SampleProps[] = [
3736
{ currentPage: 2, pageSize: 5, totalRecords: 6 },
3837
{ currentPage: 4, pageSize: 50, totalRecords: 200 },
@@ -46,8 +45,7 @@ describe(PaginationWidgetBase.name, () => {
4645
);
4746

4847
const button = await screen.findByLabelText("Next page");
49-
expect(button).not.toBeDisabled();
50-
expect(button).toHaveAttribute("aria-disabled", "true");
48+
expect(button).toBeDisabled();
5149

5250
await userEvent.click(button);
5351
expect(onPageChange).not.toHaveBeenCalled();
@@ -72,13 +70,11 @@ describe(PaginationWidgetBase.name, () => {
7270
const nextButton = await screen.findByLabelText("Next page");
7371

7472
expect(prevButton).not.toBeDisabled();
75-
expect(prevButton).toHaveAttribute("aria-disabled", "false");
7673

7774
await userEvent.click(prevButton);
7875
expect(onPageChange).toHaveBeenCalledTimes(1);
7976

8077
expect(nextButton).not.toBeDisabled();
81-
expect(nextButton).toHaveAttribute("aria-disabled", "false");
8278

8379
await userEvent.click(nextButton);
8480
expect(onPageChange).toHaveBeenCalledTimes(2);

site/src/modules/resources/DownloadAgentLogsButton.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import DownloadOutlined from "@mui/icons-material/DownloadOutlined";
2-
import { Button } from "components/Button/Button";
32
import { agentLogs } from "api/queries/workspaces";
43
import type { WorkspaceAgent, WorkspaceAgentLog } from "api/typesGenerated";
4+
import { Button } from "components/Button/Button";
55
import { displayError } from "components/GlobalSnackbar/utils";
66
import { saveAs } from "file-saver";
77
import { type FC, useState } from "react";
@@ -60,4 +60,4 @@ export const DownloadAgentLogsButton: FC<DownloadAgentLogsButtonProps> = ({
6060
{isDownloading ? "Downloading..." : "Download logs"}
6161
</Button>
6262
);
63-
};
63+
};

site/src/modules/resources/PortForwardButton.tsx

+4-16
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { type Interpolation, type Theme, useTheme } from "@emotion/react";
22
import LockIcon from "@mui/icons-material/Lock";
33
import LockOpenIcon from "@mui/icons-material/LockOpen";
44
import SensorsIcon from "@mui/icons-material/Sensors";
5-
import CircularProgress from "@mui/material/CircularProgress";
65
import FormControl from "@mui/material/FormControl";
76
import Link from "@mui/material/Link";
87
import MenuItem from "@mui/material/MenuItem";
@@ -76,21 +75,10 @@ export const PortForwardButton: FC<PortForwardButtonProps> = (props) => {
7675
return (
7776
<Popover>
7877
<PopoverTrigger>
79-
<Button
80-
disabled={!portsQuery.data}
81-
size="sm"
82-
variant="subtle"
83-
css={{ fontSize: 13, padding: "8px 12px" }}
84-
>
85-
{portsQuery.data ? (
86-
<div>
87-
<span css={styles.portCount}>
88-
{portsQuery.data.ports.length}
89-
</span>
90-
</div>
91-
) : (
92-
<CircularProgress size={10} />
93-
)}
78+
<Button disabled={!portsQuery.data} size="sm" variant="subtle">
79+
<Spinner loading={!portsQuery.data}>
80+
<span css={styles.portCount}>{portsQuery.data?.ports.length}</span>
81+
</Spinner>
9482
Open ports
9583
<ChevronDownIcon className="size-4" />
9684
</Button>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,4 @@ const styles = {
163163
codeExampleLabel: {
164164
fontSize: 12,
165165
},
166-
} satisfies Record<string, Interpolation<Theme>>;
166+
} satisfies Record<string, Interpolation<Theme>>;

site/src/modules/templates/TemplateExampleCard/TemplateExampleCard.tsx

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Interpolation, Theme } from "@emotion/react";
2-
import { Button } from "components/Button/Button";
32
import Link from "@mui/material/Link";
43
import type { TemplateExample } from "api/typesGenerated";
4+
import { Button } from "components/Button/Button";
55
import { ExternalImage } from "components/ExternalImage/ExternalImage";
66
import { Pill } from "components/Pill/Pill";
77
import type { FC, HTMLAttributes } from "react";
@@ -54,16 +54,13 @@ export const TemplateExampleCard: FC<TemplateExampleCardProps> = ({
5454
</span>
5555
</div>
5656

57-
<div css={styles.useButtonContainer}>
58-
<Button
59-
asChild
60-
className="w-full"
61-
>
62-
<RouterLink to={`/templates/new?exampleId=${example.id}`}>
63-
Use template
64-
</RouterLink>
65-
</Button>
66-
</div>
57+
<div css={styles.useButtonContainer}>
58+
<Button asChild className="w-full">
59+
<RouterLink to={`/templates/new?exampleId=${example.id}`}>
60+
Use template
61+
</RouterLink>
62+
</Button>
63+
</div>
6764
</div>
6865
);
6966
};

site/src/pages/ChatPage/ChatLanding.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { useTheme } from "@emotion/react";
2-
import { Button } from "components/Button/Button";
32
import IconButton from "@mui/material/IconButton";
43
import Paper from "@mui/material/Paper";
54
import Stack from "@mui/material/Stack";
65
import TextField from "@mui/material/TextField";
76
import { createChat } from "api/queries/chats";
87
import type { Chat } from "api/typesGenerated";
8+
import { Button } from "components/Button/Button";
99
import { Margins } from "components/Margins/Margins";
1010
import { useAuthenticated } from "hooks";
1111
import { SendIcon } from "lucide-react";

site/src/pages/ResetPasswordPage/RequestOTPPage.tsx

+3-12
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,8 @@ const RequestOTP: FC<RequestOTPProps> = ({
9797
<Spinner loading={isRequesting} />
9898
Reset password
9999
</Button>
100-
<Button
101-
asChild
102-
size="lg"
103-
variant="outline"
104-
className="w-full"
105-
>
106-
<RouterLink to="/login">
107-
Cancel
108-
</RouterLink>
100+
<Button asChild size="lg" variant="outline" className="w-full">
101+
<RouterLink to="/login">Cancel</RouterLink>
109102
</Button>
110103
</Stack>
111104
</Stack>
@@ -152,9 +145,7 @@ const RequestOTPSuccess: FC<{ email: string }> = ({ email }) => {
152145
</p>
153146

154147
<Button asChild variant="default">
155-
<RouterLink to="/login">
156-
Back to login
157-
</RouterLink>
148+
<RouterLink to="/login">Back to login</RouterLink>
158149
</Button>
159150
</div>
160151
</div>

site/src/pages/TemplatesPage/EmptyTemplates.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Interpolation, Theme } from "@emotion/react";
2-
import { Button } from "components/Button/Button";
32
import Link from "@mui/material/Link";
43
import type { TemplateExample } from "api/typesGenerated";
4+
import { Button } from "components/Button/Button";
55
import { CodeExample } from "components/CodeExample/CodeExample";
66
import { Stack } from "components/Stack/Stack";
77
import { TableEmpty } from "components/TableEmpty/TableEmpty";
@@ -78,11 +78,7 @@ export const EmptyTemplates: FC<EmptyTemplatesProps> = ({
7878
))}
7979
</div>
8080

81-
<Button
82-
size="sm"
83-
asChild
84-
css={{ borderRadius: 9999 }}
85-
>
81+
<Button size="sm" asChild css={{ borderRadius: 9999 }}>
8682
<RouterLink to="/starter-templates">
8783
View all starter templates
8884
</RouterLink>

0 commit comments

Comments
 (0)