Skip to content

Commit 8b42f7a

Browse files
committed
add more review requests
1 parent 90d49fb commit 8b42f7a

8 files changed

Lines changed: 11 additions & 44 deletions

File tree

src/features/local-repositories/api/useGetPageLocalRepository.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Local } from "@canonical/landscape-openapi";
44

55
type GetPageLocalRepositoryReturnType =
66
| {
7-
repository: Local | undefined;
7+
repository: Local;
88
isGettingRepository: false;
99
}
1010
| {
@@ -29,6 +29,10 @@ export const useGetPageLocalRepository =
2929
};
3030
}
3131

32+
if (!repository) {
33+
throw new Error("Local repository not found");
34+
}
35+
3236
return {
3337
repository: repository,
3438
isGettingRepository: false,

src/features/local-repositories/components/EditLocalRepositorySidePanel/EditLocalRepositorySidePanel.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ const EditLocalRepositorySidePanel: FC = () => {
1010
return <SidePanel.LoadingState />;
1111
}
1212

13-
if (!repository) {
14-
throw new Error("Local repository not found");
15-
}
16-
1713
return (
1814
<>
1915
<SidePanel.Header>Edit {repository.displayName}</SidePanel.Header>

src/features/local-repositories/components/ImportRepositoryPackagesSidePanel/ImportRepositoryPackagesSidePanel.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ const ImportRepositoryPackagesSidePanel: FC = () => {
9292
return <SidePanel.LoadingState />;
9393
}
9494

95-
if (!repository) {
96-
throw new Error("Local repository not found");
97-
}
98-
9995
const handleValidate = async () => {
10096
try {
10197
setOperationName("");

src/features/local-repositories/components/PublishLocalRepositorySidePanel/PublishLocalRepositorySidePanel.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ const PublishLocalRepositorySidePanel: FC = () => {
2020
return <SidePanel.LoadingState />;
2121
}
2222

23-
if (!repository) {
24-
throw new Error("Local repository not found");
25-
}
26-
2723
return (
2824
<>
2925
<SidePanel.Header>Publish {repository.displayName}</SidePanel.Header>

src/features/local-repositories/components/ViewLocalRepositorySidePanel/ViewLocalRepositorySidePanel.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ const ViewLocalRepositorySidePanel: FC = () => {
1616
return <SidePanel.LoadingState />;
1717
}
1818

19-
if (!repository) {
20-
throw new Error("Local repository not found");
21-
}
22-
2319
const tabs: { label: string; id: "details" | "packages" }[] = [
2420
{
2521
label: "General details",

src/features/profiles/components/AddProfileButton/AddProfileButton.test.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { withProfilesContext } from "@/tests/mocks/profilesContext";
33
import { screen } from "@testing-library/react";
44
import userEvent from "@testing-library/user-event";
55
import { useLocation } from "react-router";
6-
import { beforeEach, describe, expect, it, vi } from "vitest";
6+
import { describe, expect, it } from "vitest";
77
import AddProfileButton from "./AddProfileButton";
88

99
const LocationDisplay = () => {
@@ -13,11 +13,6 @@ const LocationDisplay = () => {
1313
};
1414

1515
describe("AddProfileButton", () => {
16-
beforeEach(() => {
17-
vi.clearAllMocks();
18-
localStorage.clear();
19-
});
20-
2116
it("displays specific appearance for scripts header", () => {
2217
renderWithProviders(
2318
<AddProfileButton isInsideScriptHeader />,

src/features/repository-profiles/components/RepositoryProfileList/RepositoryProfileList.test.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ describe("RepositoryProfileList", () => {
3434
const accessGroup = accessGroups.find(
3535
(group) => group.name === profile.access_group,
3636
)?.title;
37+
assert(accessGroup);
3738

38-
expect(accessGroup).toBeDefined();
39-
expect(
40-
await within(row).findByText(accessGroup ?? ""),
41-
).toBeInTheDocument();
39+
expect(await within(row).findByText(accessGroup)).toBeInTheDocument();
4240
}
4341
});
4442

@@ -80,19 +78,15 @@ describe("RepositoryProfileList", () => {
8078
name: (name) =>
8179
name.toLowerCase().includes(firstProfile.title.toLowerCase()),
8280
});
81+
assert(accessGroup);
8382

84-
expect(accessGroup).toBeDefined();
85-
expect(await within(row).findByText(accessGroup ?? "")).toBeInTheDocument();
83+
expect(await within(row).findByText(accessGroup)).toBeInTheDocument();
8684

8785
const profileButton = within(row).getByRole("button", {
8886
name: firstProfile.title,
8987
});
9088
await user.click(profileButton);
9189

92-
expect(
93-
within(row).getByRole("button", { name: firstProfile.title }),
94-
).toBeInTheDocument();
95-
9690
expect(await screen.findByTestId("location")).toHaveTextContent(
9791
"sidePath=view",
9892
);

src/tests/controllers/controller.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ export const getEndpointStatus = (path?: string): EndpointStatus => {
4141
if (targetedStatus) {
4242
return targetedStatus;
4343
}
44-
45-
const globalStatus = endpointStatuses.find(
46-
(status) => !normalizeEndpointPath(status.path),
47-
);
48-
49-
if (globalStatus) {
50-
return globalStatus;
51-
}
52-
53-
return DEFAULT_ENDPOINT_STATUS;
5444
}
5545

5646
const globalStatus = endpointStatuses.find(
@@ -61,7 +51,7 @@ export const getEndpointStatus = (path?: string): EndpointStatus => {
6151
return globalStatus;
6252
}
6353

64-
if (hasOneItem(endpointStatuses)) {
54+
if (!path && hasOneItem(endpointStatuses)) {
6555
return endpointStatuses[0];
6656
}
6757

0 commit comments

Comments
 (0)