Skip to content

Commit 0f3f61b

Browse files
committed
fix: put support admin behind feature flag
1 parent 28a8785 commit 0f3f61b

5 files changed

Lines changed: 106 additions & 4 deletions

File tree

api/prisma/seed-staging.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const stagingSeed = async (
6363
FeatureFlagEnum.enablePartnerSettings,
6464
FeatureFlagEnum.enableSection8Question,
6565
FeatureFlagEnum.enableSingleUseCode,
66+
FeatureFlagEnum.enableSupportAdmin,
6667
FeatureFlagEnum.enableUtilitiesIncluded,
6768
FeatureFlagEnum.enableWaitlistLottery,
6869
FeatureFlagEnum.enableWhatToExpectAdditionalField,

shared-helpers/src/auth/AuthContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,12 @@ export const AuthProvider: FunctionComponent<React.PropsWithChildren> = ({ child
404404
// Return true only if all jurisdictions have the flag turned on
405405
if (onlyIfAllJurisdictionsHaveItEnabled) {
406406
return jurisdictions.every(
407-
(j) => j.featureFlags.find((flag) => flag.name === featureFlag)?.active || false
407+
(j) => j.featureFlags?.find((flag) => flag.name === featureFlag)?.active || false
408408
)
409409
}
410410
// Otherwise return true if at least one jurisdiction has the flag turned on
411411
return jurisdictions.some(
412-
(j) => j.featureFlags.find((flag) => flag.name === featureFlag)?.active || false
412+
(j) => j.featureFlags?.find((flag) => flag.name === featureFlag)?.active || false
413413
)
414414
},
415415
getJurisdictionLanguages: (jurisdictionId: string) => {

sites/partners/__tests__/components/users/FormUserManage.test.tsx

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,103 @@ describe("<FormUserManage>", () => {
439439
).not.toBeInTheDocument()
440440
})
441441
})
442+
443+
describe("enableSupportAdmin", () => {
444+
it("should not show support admin role when feature flag not enabled", async () => {
445+
const adminUserWithJurisdictionsAndAllDisabled = {
446+
...adminUser,
447+
jurisdictions: [
448+
{
449+
id: "jurisdiction1",
450+
name: "jurisdictionWithoutSupportAdmin",
451+
},
452+
{
453+
id: "jurisdiction2",
454+
name: "jurisdictionWithoutSupportAdmin2",
455+
},
456+
],
457+
}
458+
server.use(
459+
rest.get("http://localhost/api/adapter/user", (_req, res, ctx) => {
460+
return res(ctx.json(adminUserWithJurisdictionsAndAllDisabled))
461+
}),
462+
rest.post("http://localhost/api/adapter/user/invite", (_req, res, ctx) => {
463+
return res(ctx.json({ success: true }))
464+
})
465+
)
466+
const onCancel = jest.fn()
467+
const onDrawerClose = jest.fn()
468+
document.cookie = "access-token-available=True"
469+
470+
render(
471+
<FormUserManage
472+
isOpen={true}
473+
title={t("users.addUser")}
474+
mode={"add"}
475+
listings={[]}
476+
onCancel={onCancel}
477+
onDrawerClose={onDrawerClose}
478+
/>
479+
)
480+
481+
await waitFor(() => screen.getByText("Administrator"))
482+
expect(screen.getByText("Add user")).toBeInTheDocument()
483+
expect(screen.getByText("User details")).toBeInTheDocument()
484+
// "Role" select should not have Support Admin
485+
expect(screen.getByRole("combobox", { name: "Role" })).toBeInTheDocument()
486+
expect(screen.getByRole("option", { name: "Administrator" })).toBeInTheDocument()
487+
expect(screen.getByRole("option", { name: "Partner" })).toBeInTheDocument()
488+
expect(screen.queryByRole("option", { name: "Admin (support)" })).not.toBeInTheDocument()
489+
})
490+
491+
it("should show support admin role when feature flag enabled", async () => {
492+
const adminUserWithJurisdictionsAndOneEnabled = {
493+
...adminUser,
494+
jurisdictions: [
495+
{
496+
id: "jurisdiction1",
497+
name: "jurisdictionWithSupportAdmin",
498+
},
499+
{
500+
id: "jurisdiction2",
501+
name: "jurisdictionWithSupportAdmin2",
502+
featureFlags: [{ name: FeatureFlagEnum.enableSupportAdmin, active: true }],
503+
},
504+
],
505+
}
506+
server.use(
507+
rest.get("http://localhost/api/adapter/user", (_req, res, ctx) => {
508+
return res(ctx.json(adminUserWithJurisdictionsAndOneEnabled))
509+
}),
510+
rest.post("http://localhost/api/adapter/user/invite", (_req, res, ctx) => {
511+
return res(ctx.json({ success: true }))
512+
})
513+
)
514+
const onCancel = jest.fn()
515+
const onDrawerClose = jest.fn()
516+
document.cookie = "access-token-available=True"
517+
518+
render(
519+
<FormUserManage
520+
isOpen={true}
521+
title={t("users.addUser")}
522+
mode={"add"}
523+
listings={[]}
524+
onCancel={onCancel}
525+
onDrawerClose={onDrawerClose}
526+
/>
527+
)
528+
529+
await waitFor(() => screen.getByText("Administrator"))
530+
expect(screen.getByText("Add user")).toBeInTheDocument()
531+
expect(screen.getByText("User details")).toBeInTheDocument()
532+
// "Role" select should not Support Admin
533+
expect(screen.getByRole("combobox", { name: "Role" })).toBeInTheDocument()
534+
expect(screen.queryByRole("option", { name: "Admin (support)" })).toBeInTheDocument()
535+
expect(screen.getByRole("option", { name: "Administrator" })).toBeInTheDocument()
536+
expect(screen.getByRole("option", { name: "Partner" })).toBeInTheDocument()
537+
})
538+
})
442539
})
443540

444541
describe("Edit User", () => {

sites/partners/src/components/applications/PaperApplicationDetails/sections/DetailsMultiselectQuestions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const DetailsMultiselectQuestions = ({
5959
<Grid.Row columns={2}>
6060
{listingQuestions?.map((listingQuestion) => {
6161
return (
62-
<Grid.Cell>
62+
<Grid.Cell key={listingQuestion?.multiselectQuestions.text}>
6363
<FieldValue
6464
key={listingQuestion?.multiselectQuestions.text}
6565
label={listingQuestion?.multiselectQuestions.text}

sites/partners/src/components/users/FormUserManage.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ const FormUserManage = ({
7070
}
7171
if (profile?.userRoles?.isAdmin) {
7272
possibleUserRoles.push(RoleOption.Administrator)
73-
possibleUserRoles.push(RoleOption.AdminSupport)
73+
// If any jurisdiction has enableSupportAdmin than admins can add an "Admin (support)" user
74+
// This means that there can be a scenario where jurisdictions get access to this role when they don't have it enabled
75+
if (doJurisdictionsHaveFeatureFlagOn(FeatureFlagEnum.enableSupportAdmin)) {
76+
possibleUserRoles.push(RoleOption.AdminSupport)
77+
}
7478
}
7579

7680
let defaultValues: FormUserManageValues = {}

0 commit comments

Comments
 (0)