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

Blais5 4436 #382

Merged
merged 3 commits into from
Oct 22, 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
3 changes: 2 additions & 1 deletion server/role-to-serverparks-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"IPS Manager" : ["gusty", "cma"],
"IPS Field Interviewer" : ["gusty", "cma"],
"IPS Pilot Interviewer" : ["gusty", "cma"],
"IPS Researcher" : ["gusty", "cma"],
"Field Interviewer" : ["gusty", "cma"],
"SVT_Editor" : ["gusty", "cma"],
"SVT_Supervisor" : ["gusty", "cma"],
"DEFAULT" : ["gusty"]
}
}
14 changes: 0 additions & 14 deletions src/Interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,3 @@ export interface BreadcrumbItem {
export interface BreadcrumbProps {
BreadcrumbList: BreadcrumbItem[]
}

export enum ValidUserRoles {
DST = "DST",
BDSS = "BDSS",
IPSManager = "IPS Manager",
IPSFieldInterviewer = "IPS Field Interviewer",
Editor = "Editor",
EditorManager = "Editor Manager",
TOAppointments = "TO Appointments",
TOManager = "TO Manager",
TOInterviewer = "TO Interviewer",
SEL = "SEL",
WelshSpeaker = "Welsh Speaker",
}
26 changes: 13 additions & 13 deletions src/pages/users/UserProfileEdits/ChangeRole.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import "@testing-library/jest-dom";
import ChangeRole from "./ChangeRole";
import { MemoryRouter, useParams } from "react-router-dom";
import { getAllRoles, patchUserRolesAndPermissions } from "../../../api/http";
import { ValidUserRoles } from "../../../Interfaces";
import userEvent from "@testing-library/user-event";

jest.mock("react-router-dom", () => ({
Expand All @@ -27,17 +26,18 @@ jest.mock("../../../api/http", () => ({
}));

const mockRoles = [
{ name: ValidUserRoles.DST, description: "DST User" },
{ name: ValidUserRoles.BDSS, description: "BDSS User" },
{ name: ValidUserRoles.IPSFieldInterviewer, description: "IPS Field Interviewer User" },
{ name: ValidUserRoles.IPSManager, description: "IPS Manager User" },
{ name: ValidUserRoles.Editor, description: "Editor User" },
{ name: ValidUserRoles.EditorManager, description: "Editor Manager User" },
{ name: ValidUserRoles.TOAppointments, description: "TO Appointments User" },
{ name: ValidUserRoles.TOManager, description: "TO Manager User" },
{ name: ValidUserRoles.TOInterviewer, description: "TO Interviewer User" },
{ name: ValidUserRoles.SEL, description: "SEL User" },
{ name: ValidUserRoles.WelshSpeaker, description: "Welsh Speaker User" }
{ name: "DST", description: "DST User" },
{ name: "BDSS", description: "BDSS User" },
{ name: "IPS Manager", description: "IPS Field Interviewer User" },
{ name: "IPS Field Interviewer", description: "IPS Manager User" },
{ name: "IPS Researcher", description: "IPS Researcher User" },
{ name: "Editor", description: "Editor User" },
{ name: "Editor Manager", description: "Editor Manager User" },
{ name: "TO Appointments", description: "TO Appointments User" },
{ name: "TO Manager", description: "TO Manager User" },
{ name: "TO Interviewer", description: "TO Interviewer User" },
{ name: "SEL", description: "SEL User" },
{ name: "Welsh Speaker", description: "Welsh Speaker User" }
];

const mockUserDetails = {
Expand Down Expand Up @@ -136,4 +136,4 @@ describe("ChangeRole Component (with state management)", () => {

expect(await findByText(/Failed to fetch roles list, please try again/i)).toBeVisible();
});
});
});
6 changes: 3 additions & 3 deletions src/pages/users/UserProfileEdits/ChangeRole.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ONSButton, ONSErrorPanel, ONSLoadingPanel, ONSPanel } from "blaise-desi
import { ChangeEvent, ReactElement, useEffect, useState } from "react";
import { Navigate, useLocation, useParams } from "react-router-dom";
import Breadcrumbs from "../../../Components/Breadcrumbs";
import { BreadcrumbItem, ValidUserRoles } from "../../../Interfaces";
import { BreadcrumbItem } from "../../../Interfaces";
import { RedirectWithData, UserRouteParams } from "../../../Interfaces/usersPage";
import { getAllRoles, patchUserRolesAndPermissions } from "../../../api/http";
import { UserRole } from "blaise-api-node-client";
Expand Down Expand Up @@ -47,7 +47,7 @@ export default function ChangeRole(): ReactElement {
return;
}

if (Object.values(ValidUserRoles).includes(role as ValidUserRoles)) {
if (roleList.some((userRole) => userRole.name === role)) {
const res = await patchUserRolesAndPermissions(viewedUsername, role);
setRedirectWithData({ redirect: true, visible: true, message: res?.message || "", statusType: res?.status === 500 ? "error" : "success" });
} else {
Expand Down Expand Up @@ -117,4 +117,4 @@ export default function ChangeRole(): ReactElement {
}
</>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,20 @@ exports[`ChangeRole Component (with state management) matches the snapshot 1`] =
>
BDSS
</option>
<option
value="IPS Manager"
>
IPS Manager
</option>
<option
value="IPS Field Interviewer"
>
IPS Field Interviewer
</option>
<option
value="IPS Manager"
value="IPS Researcher"
>
IPS Manager
IPS Researcher
</option>
<option
value="Editor"
Expand Down
3 changes: 2 additions & 1 deletion src/role-to-serverparks-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"IPS Manager" : ["gusty", "cma"],
"IPS Field Interviewer" : ["gusty", "cma"],
"IPS Pilot Interviewer" : ["gusty", "cma"],
"IPS Researcher" : ["gusty", "cma"],
"Field Interviewer" : ["gusty", "cma"],
"SVT_Editor" : ["gusty", "cma"],
"SVT_Supervisor" : ["gusty", "cma"],
"DEFAULT" : ["gusty"]
}
}
Loading