Revert "CEC-2977 Filter portal access based on auth provider (#231)"
This reverts commit f2f046968e.
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`RoleWrap RoleWrap with access, child renders 1`] = `
|
||||
<div>
|
||||
<div
|
||||
data-testid="test-role-wrap-child"
|
||||
>
|
||||
Test
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`RoleWrap RoleWrap without access, child does not render 1`] = `<div />`;
|
||||
|
||||
exports[`RoleWrap RoleWrap without access, eitherComponent renders 1`] = `
|
||||
<div>
|
||||
<div
|
||||
data-testid="test-role-wrap-child"
|
||||
>
|
||||
Either
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@@ -1,19 +0,0 @@
|
||||
import {hasRole} from "../../../utils/roles";
|
||||
import React from "react";
|
||||
|
||||
export const RoleWrap = (props) => {
|
||||
const {groups, rolesPerProvider, providers} = props;
|
||||
|
||||
const eitherComponent = props["eitherComponent"] || null;
|
||||
|
||||
if (!hasRole(groups, rolesPerProvider, providers)) {
|
||||
return eitherComponent != null ? eitherComponent : <></>;
|
||||
}
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
{props.children}
|
||||
</React.Fragment>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { Permissions, Providers, Roles } from "../../../utils/roles";
|
||||
import addSnapshotSerializer from "../../../utils/snapshot";
|
||||
import { RoleWrap } from "./index";
|
||||
|
||||
const selector = "test-role-wrap-child";
|
||||
|
||||
const renderRoleWrap = async (
|
||||
groups,
|
||||
providers,
|
||||
rolesPerProvider,
|
||||
eitherComponent
|
||||
) => {
|
||||
const { container } = render(
|
||||
<RoleWrap
|
||||
groups={groups}
|
||||
providers={providers}
|
||||
rolesPerProvider={rolesPerProvider}
|
||||
eitherComponent={eitherComponent}
|
||||
>
|
||||
<div data-testid={selector}>Test</div>
|
||||
</RoleWrap>
|
||||
);
|
||||
return container;
|
||||
};
|
||||
|
||||
describe("RoleWrap", () => {
|
||||
beforeAll(() => {
|
||||
addSnapshotSerializer(expect);
|
||||
});
|
||||
|
||||
it("RoleWrap with access, child renders", async () => {
|
||||
const view = await renderRoleWrap(
|
||||
[Roles.READ],
|
||||
[Providers.FISKER],
|
||||
Permissions.FiskerRead,
|
||||
null
|
||||
);
|
||||
const childComponent = screen.getByTestId(selector);
|
||||
expect(childComponent).toHaveTextContent("Test");
|
||||
|
||||
expect(view).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("RoleWrap without access, child does not render", async () => {
|
||||
const view = await renderRoleWrap(
|
||||
[Roles.READ],
|
||||
[Providers.FISKER],
|
||||
Permissions.FiskerCreate,
|
||||
null
|
||||
);
|
||||
const childComponent = screen.queryByTestId(selector);
|
||||
expect(childComponent).toBeNull();
|
||||
|
||||
expect(view).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("RoleWrap without access, eitherComponent renders", async () => {
|
||||
const view = await renderRoleWrap(
|
||||
[Roles.READ],
|
||||
[Providers.FISKER],
|
||||
Permissions.FiskerCreate,
|
||||
<div data-testid={selector}>Either</div>
|
||||
);
|
||||
const childComponent = screen.getByTestId(selector);
|
||||
expect(childComponent).toHaveTextContent("Either");
|
||||
|
||||
expect(view).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user