Skip to content

Commit

Permalink
fix(hub-common): re-adds the discussion permissions to validPermissio…
Browse files Browse the repository at this point in the history
…ns array (#1223)

affects: @esri/hub-common
  • Loading branch information
rweber-esri authored Sep 20, 2023
1 parent ec37133 commit 9db7245
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/common/src/permissions/types/Permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const validPermissions = [
...PagePermissions,
...PlatformPermissions,
...TempPermissions,
...DiscussionPermissions,
] as const;

/**
Expand All @@ -37,7 +38,8 @@ export type Permission =
| (typeof GroupPermissions)[number]
| (typeof PagePermissions)[number]
| (typeof PlatformPermissions)[number]
| (typeof TempPermissions)[number];
| (typeof TempPermissions)[number]
| (typeof DiscussionPermissions)[number];

/**
* Validate a Permission
Expand Down
26 changes: 24 additions & 2 deletions packages/common/test/permissions/types/isPermission.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
import { isPermission } from "../../../src";
import { ProjectPermissions } from "../../../src/projects/_internal/ProjectBusinessRules";
import { SitePermissions } from "../../../src/sites/_internal/SiteBusinessRules";
import { InitiativePermissions } from "../../../src/initiatives/_internal/InitiativeBusinessRules";
import { DiscussionPermissions } from "../../../src/discussions/_internal/DiscussionBusinessRules";
import { ContentPermissions } from "../../../src/content/_internal/ContentBusinessRules";
import { GroupPermissions } from "../../../src/groups/_internal/GroupBusinessRules";
import { PagePermissions } from "../../../src/pages/_internal/PageBusinessRules";
import { PlatformPermissions } from "../../../src/permissions/PlatformPermissionPolicies";

describe("isPermission:", () => {
it("returns true for valid permission", () => {
expect(isPermission("hub:site:create")).toBe(true);
const allPermissions = [
...SitePermissions,
...ProjectPermissions,
...InitiativePermissions,
...ContentPermissions,
...GroupPermissions,
...PagePermissions,
...PlatformPermissions,
...DiscussionPermissions,
"temp:workspace:released",
];

allPermissions.forEach((permission) => {
it(`returns true for ${permission} permission`, () => {
expect(isPermission(permission)).toBe(true);
});
});

it("returns fails for invalid permission", () => {
Expand Down

0 comments on commit 9db7245

Please sign in to comment.