Skip to content

Commit 3e78949

Browse files
Normalize update settings route matching
1 parent 831a188 commit 3e78949

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

client/src/protoFleet/features/updates/useUpdateIndicator.test.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,19 @@ describe("useUpdateIndicator", () => {
4848
expect(vi.mocked(useAvailableUpdate)).toHaveBeenLastCalledWith({ enabled: false });
4949
});
5050

51-
it("does not poll or render on the authoritative settings page", () => {
52-
render(
53-
<MemoryRouter initialEntries={["/settings/updates"]}>
54-
<Harness />
55-
</MemoryRouter>,
56-
);
57-
58-
expect(screen.queryByRole("button", { name: /Update v/ })).not.toBeInTheDocument();
59-
expect(vi.mocked(useAvailableUpdate)).toHaveBeenCalledWith({ enabled: false });
60-
});
51+
it.each(["/settings/updates", "/settings/updates/"])(
52+
"does not poll or render on the authoritative settings page at %s",
53+
(pathname) => {
54+
render(
55+
<MemoryRouter initialEntries={[pathname]}>
56+
<Harness />
57+
</MemoryRouter>,
58+
);
59+
60+
expect(screen.queryByRole("button", { name: /Update v/ })).not.toBeInTheDocument();
61+
expect(vi.mocked(useAvailableUpdate)).toHaveBeenCalledWith({ enabled: false });
62+
},
63+
);
6164

6265
it("does not render when the shell disables the indicator", () => {
6366
render(

client/src/protoFleet/features/updates/useUpdateIndicator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ interface UseUpdateIndicatorOptions {
1818
export function useUpdateIndicator({ enabled = true }: UseUpdateIndicatorOptions = {}): UpdatePillData | null {
1919
const navigate = useNavigate();
2020
const { pathname } = useLocation();
21-
const availableVersion = useAvailableUpdate({ enabled: enabled && pathname !== UPDATE_SETTINGS_PATH });
21+
const isUpdateSettingsPath = pathname.replace(/\/+$/, "") === UPDATE_SETTINGS_PATH;
22+
const availableVersion = useAvailableUpdate({ enabled: enabled && !isUpdateSettingsPath });
2223

2324
const openUpdateSettings = useCallback(() => {
2425
void navigate(UPDATE_SETTINGS_PATH);

0 commit comments

Comments
 (0)