From 7c89360f29e0583029920c60a24c320aa7e26364 Mon Sep 17 00:00:00 2001 From: Kayla Firestack Date: Fri, 11 Oct 2024 09:32:17 -0400 Subject: [PATCH 1/2] wip! lock notificaitons behind test group --- assets/src/components/notificationBellIcon.tsx | 4 ++-- assets/src/components/notificationCard.tsx | 2 +- assets/src/userInTestGroup.ts | 1 + assets/tests/components/notificationBellIcon.test.tsx | 2 +- assets/tests/components/notificationCard.openDetour.test.tsx | 2 +- assets/tests/components/notificationCard.test.tsx | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/assets/src/components/notificationBellIcon.tsx b/assets/src/components/notificationBellIcon.tsx index 4dc2a1dc2..567714f95 100644 --- a/assets/src/components/notificationBellIcon.tsx +++ b/assets/src/components/notificationBellIcon.tsx @@ -17,12 +17,12 @@ const NotificationBellIcon = ({ } = usePanelStateFromStateDispatchContext() const { notifications } = useContext(NotificationsContext) - const inDetoursList = inTestGroup(TestGroups.DetoursList) + const inDetoursNotificationGroup = inTestGroup(TestGroups.DetoursList) && inTestGroup(TestGroups.DetoursNotifications) const unreadNotifications = (notifications || []).filter( (notification) => notification.state === "unread" && !( - notification.content.$type === NotificationType.Detour && !inDetoursList + notification.content.$type === NotificationType.Detour && !inDetoursNotificationGroup ) ) const unreadBadge: boolean = unreadNotifications.length > 0 diff --git a/assets/src/components/notificationCard.tsx b/assets/src/components/notificationCard.tsx index 3bd961496..555187972 100644 --- a/assets/src/components/notificationCard.tsx +++ b/assets/src/components/notificationCard.tsx @@ -53,7 +53,7 @@ export const NotificationCard = ({ if ( notification.content.$type === NotificationType.Detour && - !inTestGroup(TestGroups.DetoursList) + !(inTestGroup(TestGroups.DetoursList) && inTestGroup(TestGroups.DetoursNotifications)) ) { return null } diff --git a/assets/src/userInTestGroup.ts b/assets/src/userInTestGroup.ts index eeab87498..2228c89ff 100644 --- a/assets/src/userInTestGroup.ts +++ b/assets/src/userInTestGroup.ts @@ -4,6 +4,7 @@ export enum TestGroups { BackwardsDetourPrevention = "backwards-detour-prevention", DemoMode = "demo-mode", DetoursList = "detours-list", + DetoursNotifications = "detours-notifications", DetoursPilot = "detours-pilot", MinimalLadderPage = "minimal-ladder-page", LateView = "late-view", diff --git a/assets/tests/components/notificationBellIcon.test.tsx b/assets/tests/components/notificationBellIcon.test.tsx index 58aae50c0..4f4fac2d4 100644 --- a/assets/tests/components/notificationBellIcon.test.tsx +++ b/assets/tests/components/notificationBellIcon.test.tsx @@ -160,7 +160,7 @@ describe("NotificationBellIcon", () => { }, ])("$type detour notification", () => { test("renders when there are new detour notifications and user is part of DetoursList group", () => { - jest.mocked(getTestGroups).mockReturnValue([TestGroups.DetoursList]) + jest.mocked(getTestGroups).mockReturnValue([TestGroups.DetoursList, TestGroups.DetoursNotifications]) const { baseElement } = render( { test("renders detour details modal to match mocked fetchDetour", async () => { jest .mocked(getTestGroups) - .mockReturnValue([TestGroups.DetoursPilot, TestGroups.DetoursList]) + .mockReturnValue([TestGroups.DetoursPilot, TestGroups.DetoursList, TestGroups.DetoursNotifications]) jest.mocked(fetchDetours).mockResolvedValue(Ok(detourListFactory.build())) jest diff --git a/assets/tests/components/notificationCard.test.tsx b/assets/tests/components/notificationCard.test.tsx index c4b42dd9b..230f0336e 100644 --- a/assets/tests/components/notificationCard.test.tsx +++ b/assets/tests/components/notificationCard.test.tsx @@ -32,7 +32,7 @@ jest.mock("../../src/helpers/fullStory") jest.mock("../../src/userTestGroups") beforeEach(() => { - jest.mocked(getTestGroups).mockReturnValue([TestGroups.DetoursList]) + jest.mocked(getTestGroups).mockReturnValue([TestGroups.DetoursList, TestGroups.DetoursNotifications]) jest.mocked(fetchDetours).mockResolvedValue(Ok(detourListFactory.build())) jest .mocked(fetchDetour) From 447d15512d84e8c95fc0ae47bc578532905f88ca Mon Sep 17 00:00:00 2001 From: Hannah Purcell Date: Tue, 15 Oct 2024 11:12:46 -0400 Subject: [PATCH 2/2] tweak: formatting --- assets/src/components/notificationBellIcon.tsx | 7 +++++-- assets/src/components/notificationCard.tsx | 5 ++++- assets/tests/components/notificationBellIcon.test.tsx | 7 ++++++- .../tests/components/notificationCard.openDetour.test.tsx | 6 +++++- assets/tests/components/notificationCard.test.tsx | 4 +++- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/assets/src/components/notificationBellIcon.tsx b/assets/src/components/notificationBellIcon.tsx index 567714f95..eb83cd228 100644 --- a/assets/src/components/notificationBellIcon.tsx +++ b/assets/src/components/notificationBellIcon.tsx @@ -17,12 +17,15 @@ const NotificationBellIcon = ({ } = usePanelStateFromStateDispatchContext() const { notifications } = useContext(NotificationsContext) - const inDetoursNotificationGroup = inTestGroup(TestGroups.DetoursList) && inTestGroup(TestGroups.DetoursNotifications) + const inDetoursNotificationGroup = + inTestGroup(TestGroups.DetoursList) && + inTestGroup(TestGroups.DetoursNotifications) const unreadNotifications = (notifications || []).filter( (notification) => notification.state === "unread" && !( - notification.content.$type === NotificationType.Detour && !inDetoursNotificationGroup + notification.content.$type === NotificationType.Detour && + !inDetoursNotificationGroup ) ) const unreadBadge: boolean = unreadNotifications.length > 0 diff --git a/assets/src/components/notificationCard.tsx b/assets/src/components/notificationCard.tsx index 555187972..aef5de1ea 100644 --- a/assets/src/components/notificationCard.tsx +++ b/assets/src/components/notificationCard.tsx @@ -53,7 +53,10 @@ export const NotificationCard = ({ if ( notification.content.$type === NotificationType.Detour && - !(inTestGroup(TestGroups.DetoursList) && inTestGroup(TestGroups.DetoursNotifications)) + !( + inTestGroup(TestGroups.DetoursList) && + inTestGroup(TestGroups.DetoursNotifications) + ) ) { return null } diff --git a/assets/tests/components/notificationBellIcon.test.tsx b/assets/tests/components/notificationBellIcon.test.tsx index 4f4fac2d4..3032ce815 100644 --- a/assets/tests/components/notificationBellIcon.test.tsx +++ b/assets/tests/components/notificationBellIcon.test.tsx @@ -160,7 +160,12 @@ describe("NotificationBellIcon", () => { }, ])("$type detour notification", () => { test("renders when there are new detour notifications and user is part of DetoursList group", () => { - jest.mocked(getTestGroups).mockReturnValue([TestGroups.DetoursList, TestGroups.DetoursNotifications]) + jest + .mocked(getTestGroups) + .mockReturnValue([ + TestGroups.DetoursList, + TestGroups.DetoursNotifications, + ]) const { baseElement } = render( { test("renders detour details modal to match mocked fetchDetour", async () => { jest .mocked(getTestGroups) - .mockReturnValue([TestGroups.DetoursPilot, TestGroups.DetoursList, TestGroups.DetoursNotifications]) + .mockReturnValue([ + TestGroups.DetoursPilot, + TestGroups.DetoursList, + TestGroups.DetoursNotifications, + ]) jest.mocked(fetchDetours).mockResolvedValue(Ok(detourListFactory.build())) jest diff --git a/assets/tests/components/notificationCard.test.tsx b/assets/tests/components/notificationCard.test.tsx index 230f0336e..175f4040d 100644 --- a/assets/tests/components/notificationCard.test.tsx +++ b/assets/tests/components/notificationCard.test.tsx @@ -32,7 +32,9 @@ jest.mock("../../src/helpers/fullStory") jest.mock("../../src/userTestGroups") beforeEach(() => { - jest.mocked(getTestGroups).mockReturnValue([TestGroups.DetoursList, TestGroups.DetoursNotifications]) + jest + .mocked(getTestGroups) + .mockReturnValue([TestGroups.DetoursList, TestGroups.DetoursNotifications]) jest.mocked(fetchDetours).mockResolvedValue(Ok(detourListFactory.build())) jest .mocked(fetchDetour)