2022-03-01 08:38:23 +00:00
|
|
|
import { UserContext } from "@saleor/auth";
|
|
|
|
import { adminUserPermissions } from "@saleor/fixtures";
|
2022-03-09 08:56:55 +00:00
|
|
|
import { UserFragment } from "@saleor/graphql";
|
2022-03-01 08:38:23 +00:00
|
|
|
import * as React from "react";
|
|
|
|
|
|
|
|
export const MockedUserProvider: React.FC<{
|
2022-03-09 08:56:55 +00:00
|
|
|
customPermissions?: UserFragment["userPermissions"];
|
2022-03-01 08:38:23 +00:00
|
|
|
}> = ({ customPermissions, children }) => (
|
|
|
|
<UserContext.Provider
|
|
|
|
value={{
|
|
|
|
login: undefined,
|
|
|
|
loginByExternalPlugin: undefined,
|
|
|
|
logout: undefined,
|
|
|
|
requestLoginByExternalPlugin: undefined,
|
|
|
|
authenticating: false,
|
|
|
|
authenticated: false,
|
|
|
|
user: {
|
|
|
|
id: "0",
|
|
|
|
email: "email@email.me",
|
|
|
|
firstName: "user",
|
|
|
|
lastName: "user",
|
|
|
|
isStaff: true,
|
|
|
|
userPermissions: customPermissions ?? adminUserPermissions,
|
|
|
|
avatar: null,
|
|
|
|
__typename: "User"
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</UserContext.Provider>
|
|
|
|
);
|