Skip to content

Commit

Permalink
tweak: Detour notifications behind test group (#2855)
Browse files Browse the repository at this point in the history
Co-authored-by: Kayla Firestack <[email protected]>
  • Loading branch information
hannahpurcell and firestack authored Oct 15, 2024
1 parent 52b5eee commit 08dc1eb
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
7 changes: 5 additions & 2 deletions assets/src/components/notificationBellIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ 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
Expand Down
5 changes: 4 additions & 1 deletion assets/src/components/notificationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export const NotificationCard = ({

if (
notification.content.$type === NotificationType.Detour &&
!inTestGroup(TestGroups.DetoursList)
!(
inTestGroup(TestGroups.DetoursList) &&
inTestGroup(TestGroups.DetoursNotifications)
)
) {
return null
}
Expand Down
1 change: 1 addition & 0 deletions assets/src/userInTestGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion assets/tests/components/notificationBellIcon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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])
jest
.mocked(getTestGroups)
.mockReturnValue([
TestGroups.DetoursList,
TestGroups.DetoursNotifications,
])

const { baseElement } = render(
<StateDispatchProvider
Expand Down
6 changes: 5 additions & 1 deletion assets/tests/components/notificationCard.openDetour.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ describe("NotificationCard", () => {
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
Expand Down
4 changes: 3 additions & 1 deletion assets/tests/components/notificationCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ 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)
Expand Down

0 comments on commit 08dc1eb

Please sign in to comment.