From 64696004036ad97d00c746f17709ca2495b84b3e Mon Sep 17 00:00:00 2001 From: Darren Boss Date: Wed, 18 Mar 2026 09:42:26 -0700 Subject: [PATCH 1/2] Sort fire zones --- mobile/asa-go/src/components/settings/Settings.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mobile/asa-go/src/components/settings/Settings.tsx b/mobile/asa-go/src/components/settings/Settings.tsx index d6b7ac13f..40f8cb5c5 100644 --- a/mobile/asa-go/src/components/settings/Settings.tsx +++ b/mobile/asa-go/src/components/settings/Settings.tsx @@ -77,7 +77,16 @@ const Settings = ({ activeTab }: SettingsProps) => { } } - return sorted; + const finalSorted: FireCentreInfo[] = sorted.map((fc) => { + return { + fire_centre_name: fc.fire_centre_name, + fire_zone_units: fc.fire_zone_units.toSorted((a, b) => + a.name.localeCompare(b.name), + ), + }; + }); + + return finalSorted; }, [fireCentreInfos, pinnedFireCentre]); const renderNotificationMessage = () => { From e258e638f5abb1bad37605312542ca446a577f38 Mon Sep 17 00:00:00 2001 From: Darren Boss Date: Wed, 18 Mar 2026 11:21:02 -0700 Subject: [PATCH 2/2] sorting tests --- .../settings/SubscriptionAccordion.tsx | 3 + .../src/components/settings/settings.test.tsx | 71 +++++++++++++++++-- 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/mobile/asa-go/src/components/settings/SubscriptionAccordion.tsx b/mobile/asa-go/src/components/settings/SubscriptionAccordion.tsx index 2c6b4b8ec..ff95f7e4a 100644 --- a/mobile/asa-go/src/components/settings/SubscriptionAccordion.tsx +++ b/mobile/asa-go/src/components/settings/SubscriptionAccordion.tsx @@ -114,6 +114,7 @@ const SubscriptionAccordion = ({ aria-disabled={disabled ? true : undefined} > } sx={{ backgroundColor: "rgba(252, 186, 25, 0.30)", diff --git a/mobile/asa-go/src/components/settings/settings.test.tsx b/mobile/asa-go/src/components/settings/settings.test.tsx index e5e039d43..09c4cfbfa 100644 --- a/mobile/asa-go/src/components/settings/settings.test.tsx +++ b/mobile/asa-go/src/components/settings/settings.test.tsx @@ -1,5 +1,5 @@ import { describe, it, expect, vi, Mock } from "vitest"; -import { render, screen, waitFor } from "@testing-library/react"; +import { render, screen, waitFor, within } from "@testing-library/react"; import { Provider } from "react-redux"; import { configureStore } from "@reduxjs/toolkit"; import Settings from "./Settings"; @@ -42,17 +42,17 @@ vi.mock("@/utils/storage", async () => { // Mock data const mockFireCentreInfos: FireCentreInfo[] = [ { - fire_centre_name: "Kamloops", + fire_centre_name: "Prince George", fire_zone_units: [ - { id: 1, name: "Kamloops Zone 1" }, - { id: 2, name: "Kamloops Zone 2" }, + { id: 4, name: "Prince George Zone 2" }, + { id: 3, name: "Prince George Zone 1" }, ], }, { - fire_centre_name: "Prince George", + fire_centre_name: "Kamloops", fire_zone_units: [ - { id: 3, name: "Prince George Zone 1" }, - { id: 4, name: "Prince George Zone 2" }, + { id: 2, name: "Kamloops Zone 2" }, + { id: 1, name: "Kamloops Zone 1" }, ], }, ]; @@ -285,4 +285,61 @@ describe("Settings", () => { ), ).toBeInTheDocument(); }); + it("sorts fire centres alphabetically", async () => { + // Mock permission check to return granted immediately + const { FirebaseMessaging } = await import("@capacitor-firebase/messaging"); + (FirebaseMessaging.checkPermissions as Mock).mockResolvedValue({ + receive: "granted", + }); + const store = createTestStore({ + settings: { + ...settingsReducer(undefined, { type: "unknown" }), + fireCentreInfos: mockFireCentreInfos, + }, + networkStatus: { + networkStatus: { connected: true, connectionType: "wifi" }, + }, + }); + render( + + + , + ); + + await waitFor(async () => { + const fireCentreElements = await screen.findAllByRole("heading"); + expect(fireCentreElements[0]).toHaveTextContent(/KAMLOOPS/i); + expect(fireCentreElements[1]).toHaveTextContent(/PRINCE GEORGE/i); + }); + }); + it("sorts fire zone units alphabetically", async () => { + // Mock permission check to return granted immediately + const { FirebaseMessaging } = await import("@capacitor-firebase/messaging"); + (FirebaseMessaging.checkPermissions as Mock).mockResolvedValue({ + receive: "granted", + }); + const store = createTestStore({ + settings: { + ...settingsReducer(undefined, { type: "unknown" }), + fireCentreInfos: mockFireCentreInfos, + }, + networkStatus: { + networkStatus: { connected: true, connectionType: "wifi" }, + }, + }); + render( + + + , + ); + screen.debug(undefined, 30000); + await waitFor(async () => { + const panel = screen.getByRole("region", { name: /kamloops/i }); + const items = within(panel).getAllByRole("listitem"); + + expect(items).toHaveLength(2); + expect(items[0]).toHaveTextContent("Kamloops Zone 1"); + expect(items[1]).toHaveTextContent("Kamloops Zone 2"); + }); + }); });