Merge pull request #3932 from bluewave-labs/fix/test-all-admin-guard
fix: add admin guard to test all button, fix tests
This commit is contained in:
2 files changed
+19
-17
No files matched your search
@@ -60,20 +60,22 @@ export const HeaderMonitorControls = ({
|
|||||||
direction={{ xs: "column", md: "row" }}
|
direction={{ xs: "column", md: "row" }}
|
||||||
gap={theme.spacing(2)}
|
gap={theme.spacing(2)}
|
||||||
>
|
>
|
||||||
<Button
|
{isAdmin && (
|
||||||
variant="contained"
|
<Button
|
||||||
color="secondary"
|
variant="contained"
|
||||||
loading={isPosting}
|
color="secondary"
|
||||||
startIcon={<Icon icon={Mail} />}
|
loading={isPosting}
|
||||||
onClick={async () => {
|
startIcon={<Icon icon={Mail} />}
|
||||||
await post(`/notifications/test/all`, { monitorId: monitor.id });
|
onClick={async () => {
|
||||||
}}
|
await post(`/notifications/test/all`, { monitorId: monitor.id });
|
||||||
sx={{
|
}}
|
||||||
whiteSpace: "nowrap",
|
sx={{
|
||||||
}}
|
whiteSpace: "nowrap",
|
||||||
>
|
}}
|
||||||
{t("common.buttons.testNotifications")}
|
>
|
||||||
</Button>
|
{t("common.buttons.testNotifications")}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ describe("isAllowed middleware", () => {
|
|||||||
const middleware = isAllowed(["admin", "superadmin"]);
|
const middleware = isAllowed(["admin", "superadmin"]);
|
||||||
const req = {
|
const req = {
|
||||||
user: {
|
user: {
|
||||||
userId: "user-1",
|
id: "user-1",
|
||||||
teamId: "team-1",
|
teamId: "team-1",
|
||||||
email: "admin@example.com",
|
email: "admin@example.com",
|
||||||
role: ["admin"],
|
role: ["admin"],
|
||||||
@@ -26,7 +26,7 @@ describe("isAllowed middleware", () => {
|
|||||||
const middleware = isAllowed(["admin", "superadmin"]);
|
const middleware = isAllowed(["admin", "superadmin"]);
|
||||||
const req = {
|
const req = {
|
||||||
user: {
|
user: {
|
||||||
userId: "user-2",
|
id: "user-2",
|
||||||
teamId: "team-1",
|
teamId: "team-1",
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
role: ["user"],
|
role: ["user"],
|
||||||
@@ -63,7 +63,7 @@ describe("isAllowed middleware", () => {
|
|||||||
const middleware = isAllowed(["admin", "superadmin"]);
|
const middleware = isAllowed(["admin", "superadmin"]);
|
||||||
const req = {
|
const req = {
|
||||||
user: {
|
user: {
|
||||||
userId: "user-3",
|
id: "user-3",
|
||||||
teamId: "team-1",
|
teamId: "team-1",
|
||||||
email: "multi@example.com",
|
email: "multi@example.com",
|
||||||
role: ["user", "admin"],
|
role: ["user", "admin"],
|
||||||
|
|||||||
Reference in new issue
Block a user