Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak: Detour notifications behind test group #2855

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading