@cedarjs/testing 7.0.0-canary.2989 → 7.0.0-canary.2991
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +21 -52
- package/dist/cjs/api/apiFunction.d.ts +0 -37
- package/dist/cjs/api/apiFunction.d.ts.map +0 -1
- package/dist/cjs/api/apiFunction.js +0 -89
- package/dist/cjs/api/checkTestDatabase.d.ts +0 -23
- package/dist/cjs/api/checkTestDatabase.d.ts.map +0 -1
- package/dist/cjs/api/checkTestDatabase.js +0 -69
- package/dist/cjs/api/directive.d.ts +0 -51
- package/dist/cjs/api/directive.d.ts.map +0 -1
- package/dist/cjs/api/directive.js +0 -77
- package/dist/cjs/api/index.d.ts +0 -4
- package/dist/cjs/api/index.d.ts.map +0 -1
- package/dist/cjs/api/index.js +0 -26
- package/dist/cjs/api/mockContext.d.ts +0 -5
- package/dist/cjs/api/mockContext.d.ts.map +0 -1
- package/dist/cjs/api/mockContext.js +0 -58
- package/dist/cjs/api/scenario.d.ts +0 -108
- package/dist/cjs/api/scenario.d.ts.map +0 -1
- package/dist/cjs/api/scenario.js +0 -30
- package/dist/cjs/api/vitest/CedarApiVitestEnv.js +0 -75
- package/dist/cjs/api/vitest/index.js +0 -34
- package/dist/cjs/api/vitest/vite-plugin-auto-import.js +0 -71
- package/dist/cjs/api/vitest/vite-plugin-cedar-vitest-api-config.js +0 -69
- package/dist/cjs/api/vitest/vite-plugin-track-db-imports.js +0 -47
- package/dist/cjs/api/vitest/vitest-api.setup.js +0 -270
- package/dist/cjs/cache/index.d.ts +0 -50
- package/dist/cjs/cache/index.d.ts.map +0 -1
- package/dist/cjs/cache/index.js +0 -104
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/web/MockParamsProvider.d.ts +0 -7
- package/dist/cjs/web/MockParamsProvider.d.ts.map +0 -1
- package/dist/cjs/web/MockParamsProvider.js +0 -44
- package/dist/cjs/web/MockProviders.d.ts +0 -5
- package/dist/cjs/web/MockProviders.d.ts.map +0 -1
- package/dist/cjs/web/MockProviders.js +0 -66
- package/dist/cjs/web/MockRouter.d.ts +0 -11
- package/dist/cjs/web/MockRouter.d.ts.map +0 -1
- package/dist/cjs/web/MockRouter.js +0 -48
- package/dist/cjs/web/customRender.d.ts +0 -6
- package/dist/cjs/web/customRender.d.ts.map +0 -1
- package/dist/cjs/web/customRender.js +0 -54
- package/dist/cjs/web/findCellMocks.d.ts +0 -2
- package/dist/cjs/web/findCellMocks.d.ts.map +0 -1
- package/dist/cjs/web/findCellMocks.js +0 -45
- package/dist/cjs/web/globRoutesImporter.d.ts +0 -13
- package/dist/cjs/web/globRoutesImporter.d.ts.map +0 -1
- package/dist/cjs/web/globRoutesImporter.js +0 -46
- package/dist/cjs/web/global.d.ts +0 -6
- package/dist/cjs/web/global.d.ts.map +0 -1
- package/dist/cjs/web/global.js +0 -1
- package/dist/cjs/web/index.d.ts +0 -6
- package/dist/cjs/web/index.d.ts.map +0 -1
- package/dist/cjs/web/index.js +0 -41
- package/dist/cjs/web/mockAuth.d.ts +0 -29
- package/dist/cjs/web/mockAuth.d.ts.map +0 -1
- package/dist/cjs/web/mockAuth.js +0 -89
- package/dist/cjs/web/mockRequests.d.ts +0 -72
- package/dist/cjs/web/mockRequests.d.ts.map +0 -1
- package/dist/cjs/web/mockRequests.js +0 -210
- package/dist/cjs/web/vitest/index.js +0 -37
- package/dist/cjs/web/vitest/vite-plugin-auto-import.js +0 -60
- package/dist/cjs/web/vitest/vite-plugin-cedar-vitest-web-config.js +0 -51
- package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.js +0 -42
- package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.js +0 -43
- package/dist/cjs/web/vitest/vitest-web.setup.js +0 -19
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var customRender_exports = {};
|
|
30
|
-
__export(customRender_exports, {
|
|
31
|
-
customRender: () => customRender,
|
|
32
|
-
customRenderHook: () => customRenderHook
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(customRender_exports);
|
|
35
|
-
var import_react = __toESM(require("react"), 1);
|
|
36
|
-
var import_react2 = require("@testing-library/react");
|
|
37
|
-
var import_MockProviders = require("./MockProviders.js");
|
|
38
|
-
const customRender = (ui, options = {}) => {
|
|
39
|
-
return (0, import_react2.render)(ui, {
|
|
40
|
-
wrapper: (props) => /* @__PURE__ */ import_react.default.createElement(import_MockProviders.MockProviders, { ...props }),
|
|
41
|
-
...options
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
const customRenderHook = (render2, options) => {
|
|
45
|
-
return (0, import_react2.renderHook)(render2, {
|
|
46
|
-
wrapper: (props) => /* @__PURE__ */ import_react.default.createElement(import_MockProviders.MockProviders, { ...props }),
|
|
47
|
-
...options
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
-
0 && (module.exports = {
|
|
52
|
-
customRender,
|
|
53
|
-
customRenderHook
|
|
54
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findCellMocks.d.ts","sourceRoot":"","sources":["../../../src/web/findCellMocks.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,GAAI,aAAa,MAAM,aAOhD,CAAA"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var findCellMocks_exports = {};
|
|
30
|
-
__export(findCellMocks_exports, {
|
|
31
|
-
findCellMocks: () => findCellMocks
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(findCellMocks_exports);
|
|
34
|
-
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
35
|
-
const findCellMocks = (webBasePath) => {
|
|
36
|
-
return import_fast_glob.default.sync("**/*Cell/*.mock.{js,ts,jsx,tsx}", {
|
|
37
|
-
cwd: webBasePath,
|
|
38
|
-
ignore: ["node_modules"],
|
|
39
|
-
absolute: true
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
-
0 && (module.exports = {
|
|
44
|
-
findCellMocks
|
|
45
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* All the routes the user has defined
|
|
3
|
-
*
|
|
4
|
-
* We render this in the `<MockProviders>` component to populate the `routes`
|
|
5
|
-
* import from `@cedarjs/router` to make sure code like
|
|
6
|
-
* `<Link to={routes.home()}>Home</Link>` works in tests
|
|
7
|
-
*
|
|
8
|
-
* The final piece to this puzzle is to realize that the user's Routes file
|
|
9
|
-
* imports `@cedarjs/router`, which we replace to import from '@cedarjs/testing'
|
|
10
|
-
* instead using a vite plugin that we only run for vitest and storybook
|
|
11
|
-
*/
|
|
12
|
-
export declare const UserRoutes: React.FC;
|
|
13
|
-
//# sourceMappingURL=globRoutesImporter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"globRoutesImporter.d.ts","sourceRoot":"","sources":["../../../src/web/globRoutesImporter.ts"],"names":[],"mappings":"AAwCA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAqB,KAAK,CAAC,EAAE,CAAA"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var globRoutesImporter_exports = {};
|
|
20
|
-
__export(globRoutesImporter_exports, {
|
|
21
|
-
UserRoutes: () => UserRoutes
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(globRoutesImporter_exports);
|
|
24
|
-
const import_meta = { glob: () => ({ "routes.tsx": () => null }) };
|
|
25
|
-
const defaultExports = import_meta.glob(
|
|
26
|
-
["/src/Routes.{tsx,jsx}", "/Routes.{tsx,jsx}"],
|
|
27
|
-
{
|
|
28
|
-
import: "default",
|
|
29
|
-
eager: true
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
const routesFileName = Object.keys(defaultExports)[0];
|
|
33
|
-
if (!routesFileName) {
|
|
34
|
-
throw new Error("@cedarjs/testing: No routes found");
|
|
35
|
-
}
|
|
36
|
-
const routesFunction = defaultExports[routesFileName];
|
|
37
|
-
if (typeof routesFunction !== "function") {
|
|
38
|
-
throw new Error(
|
|
39
|
-
"@cedarjs/testing: Routes file does not export a React component"
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
const UserRoutes = routesFunction;
|
|
43
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
-
0 && (module.exports = {
|
|
45
|
-
UserRoutes
|
|
46
|
-
});
|
package/dist/cjs/web/global.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { mockGraphQLQuery as _mockGraphQLQuery, mockGraphQLMutation as _mockGraphQLMutation } from './mockRequests.js';
|
|
2
|
-
declare global {
|
|
3
|
-
var mockGraphQLQuery: typeof _mockGraphQLQuery;
|
|
4
|
-
var mockGraphQLMutation: typeof _mockGraphQLMutation;
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=global.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../src/web/global.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,IAAI,iBAAiB,EACrC,mBAAmB,IAAI,oBAAoB,EAC5C,MAAM,mBAAmB,CAAA;AAE1B,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,gBAAgB,EAAE,OAAO,iBAAiB,CAAA;IAE9C,IAAI,mBAAmB,EAAE,OAAO,oBAAoB,CAAA;CAGrD"}
|
package/dist/cjs/web/global.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/cjs/web/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from '@testing-library/react';
|
|
2
|
-
export { customRender as render, customRenderHook as renderHook, } from './customRender.js';
|
|
3
|
-
export { MockProviders } from './MockProviders.js';
|
|
4
|
-
export { useAuth } from './mockAuth.js';
|
|
5
|
-
export * from './mockRequests.js';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AAGtC,OAAO,EACL,YAAY,IAAI,MAAM,EACtB,gBAAgB,IAAI,UAAU,GAC/B,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,cAAc,mBAAmB,CAAA"}
|
package/dist/cjs/web/index.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var web_exports = {};
|
|
21
|
-
__export(web_exports, {
|
|
22
|
-
MockProviders: () => import_MockProviders.MockProviders,
|
|
23
|
-
render: () => import_customRender.customRender,
|
|
24
|
-
renderHook: () => import_customRender.customRenderHook,
|
|
25
|
-
useAuth: () => import_mockAuth.useAuth
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(web_exports);
|
|
28
|
-
__reExport(web_exports, require("@testing-library/react"), module.exports);
|
|
29
|
-
var import_customRender = require("./customRender.js");
|
|
30
|
-
var import_MockProviders = require("./MockProviders.js");
|
|
31
|
-
var import_mockAuth = require("./mockAuth.js");
|
|
32
|
-
__reExport(web_exports, require("./mockRequests.js"), module.exports);
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
MockProviders,
|
|
36
|
-
render,
|
|
37
|
-
renderHook,
|
|
38
|
-
useAuth,
|
|
39
|
-
...require("@testing-library/react"),
|
|
40
|
-
...require("./mockRequests.js")
|
|
41
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export * from '@cedarjs/auth';
|
|
3
|
-
interface Props {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
}
|
|
6
|
-
export declare function useAuth(): {
|
|
7
|
-
loading: boolean;
|
|
8
|
-
isAuthenticated: boolean;
|
|
9
|
-
logIn: () => Promise<void>;
|
|
10
|
-
logOut: () => Promise<void>;
|
|
11
|
-
signUp: () => Promise<void>;
|
|
12
|
-
currentUser: Record<string, unknown> | null;
|
|
13
|
-
userMetadata: Record<string, unknown> | null;
|
|
14
|
-
getToken: () => Promise<null>;
|
|
15
|
-
getCurrentUser: () => Promise<Record<string, unknown> | null>;
|
|
16
|
-
hasRole: (roles: string | string[]) => boolean;
|
|
17
|
-
reauthenticate: () => Promise<void>;
|
|
18
|
-
forgotPassword: () => Promise<void>;
|
|
19
|
-
resetPassword: () => Promise<void>;
|
|
20
|
-
validateResetToken: () => Promise<void>;
|
|
21
|
-
type: string;
|
|
22
|
-
client: undefined;
|
|
23
|
-
hasError: boolean;
|
|
24
|
-
};
|
|
25
|
-
export declare const createAuthentication: () => {
|
|
26
|
-
AuthProvider: React.FC<Props>;
|
|
27
|
-
useAuth: typeof useAuth;
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=mockAuth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockAuth.d.ts","sourceRoot":"","sources":["../../../src/web/mockAuth.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,cAAc,eAAe,CAAA;AAI7B,UAAU,KAAK;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAYD,wBAAgB,OAAO;;;;;;;;;;qBAWF,MAAM,GAAG,MAAM,EAAE;;;;;;;;EAmBrC;AAED,eAAO,MAAM,oBAAoB;;;CAEhC,CAAA"}
|
package/dist/cjs/web/mockAuth.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var mockAuth_exports = {};
|
|
31
|
-
__export(mockAuth_exports, {
|
|
32
|
-
createAuthentication: () => createAuthentication,
|
|
33
|
-
useAuth: () => useAuth
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(mockAuth_exports);
|
|
36
|
-
var import_react = __toESM(require("react"), 1);
|
|
37
|
-
__reExport(mockAuth_exports, require("@cedarjs/auth"), module.exports);
|
|
38
|
-
var import_mockRequests = require("./mockRequests.js");
|
|
39
|
-
const AuthProvider = ({ children }) => {
|
|
40
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, children);
|
|
41
|
-
};
|
|
42
|
-
function makeArray(input) {
|
|
43
|
-
return !input ? [] : Array.isArray(input) ? input : [input];
|
|
44
|
-
}
|
|
45
|
-
function useAuth() {
|
|
46
|
-
return {
|
|
47
|
-
loading: false,
|
|
48
|
-
isAuthenticated: !!import_mockRequests.mockedUserMeta.currentUser,
|
|
49
|
-
logIn: async () => {
|
|
50
|
-
},
|
|
51
|
-
logOut: async () => {
|
|
52
|
-
},
|
|
53
|
-
signUp: async () => {
|
|
54
|
-
},
|
|
55
|
-
currentUser: import_mockRequests.mockedUserMeta.currentUser,
|
|
56
|
-
userMetadata: import_mockRequests.mockedUserMeta.currentUser,
|
|
57
|
-
getToken: async () => null,
|
|
58
|
-
getCurrentUser: async () => import_mockRequests.mockedUserMeta.currentUser,
|
|
59
|
-
hasRole: (roles) => {
|
|
60
|
-
const currentUserRoles = makeArray(
|
|
61
|
-
import_mockRequests.mockedUserMeta.currentUser?.roles
|
|
62
|
-
);
|
|
63
|
-
if (currentUserRoles) {
|
|
64
|
-
return makeArray(roles).some((role) => currentUserRoles.includes(role));
|
|
65
|
-
}
|
|
66
|
-
return false;
|
|
67
|
-
},
|
|
68
|
-
reauthenticate: async () => {
|
|
69
|
-
},
|
|
70
|
-
forgotPassword: async () => {
|
|
71
|
-
},
|
|
72
|
-
resetPassword: async () => {
|
|
73
|
-
},
|
|
74
|
-
validateResetToken: async () => {
|
|
75
|
-
},
|
|
76
|
-
type: "default",
|
|
77
|
-
client: void 0,
|
|
78
|
-
hasError: false
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
const createAuthentication = () => {
|
|
82
|
-
return { AuthProvider, useAuth };
|
|
83
|
-
};
|
|
84
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
-
0 && (module.exports = {
|
|
86
|
-
createAuthentication,
|
|
87
|
-
useAuth,
|
|
88
|
-
...require("@cedarjs/auth")
|
|
89
|
-
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { RequestHandler, SharedOptions } from 'msw';
|
|
2
|
-
import type { StartOptions as StartMSWWorkerOptions } from 'msw/browser';
|
|
3
|
-
interface MockServerCommonApi {
|
|
4
|
-
use(...handlers: any[]): void;
|
|
5
|
-
resetHandlers(): void;
|
|
6
|
-
}
|
|
7
|
-
type MockWorkerInstance = MockServerCommonApi & {
|
|
8
|
-
stop(): void;
|
|
9
|
-
};
|
|
10
|
-
type MockServerInstance = MockServerCommonApi & {
|
|
11
|
-
listen(options?: Partial<SharedOptions>): void;
|
|
12
|
-
close(): void;
|
|
13
|
-
};
|
|
14
|
-
type StartOptions<Target> = Target extends 'browsers' ? StartMSWWorkerOptions : Partial<SharedOptions>;
|
|
15
|
-
export declare const startMSW: <Target extends "node" | "browsers">(target: Target, options?: StartOptions<Target>) => Promise<MockWorkerInstance | MockServerInstance>;
|
|
16
|
-
export declare const setupRequestHandlers: () => void;
|
|
17
|
-
export declare const closeServer: () => void;
|
|
18
|
-
export declare const registerHandler: (handler: RequestHandler) => void;
|
|
19
|
-
/**
|
|
20
|
-
* The `ctx` object passed to mock-data functions. It mirrors the API of MSW
|
|
21
|
-
* v1's GraphQL context so that existing Cedar mocks keep working with MSW v2,
|
|
22
|
-
* where the `(req, res, ctx)` resolver signature no longer exists.
|
|
23
|
-
*/
|
|
24
|
-
export interface MockGraphQLContext {
|
|
25
|
-
/** Set the http response status code (and optionally status text) */
|
|
26
|
-
status(code: number, text?: string): void;
|
|
27
|
-
/** Delay the response by the given number of milliseconds */
|
|
28
|
-
delay(durationMs: number): void;
|
|
29
|
-
/** Return GraphQL errors in the response */
|
|
30
|
-
errors(errorList: Record<string, unknown>[]): void;
|
|
31
|
-
/** Set a response header. Accepts a name/value pair or an object */
|
|
32
|
-
set(name: string | Record<string, string>, value?: string): void;
|
|
33
|
-
/** Set a response cookie */
|
|
34
|
-
cookie(name: string, value: string): void;
|
|
35
|
-
/** Set the `extensions` field of the GraphQL response */
|
|
36
|
-
extensions(extensions: Record<string, unknown>): void;
|
|
37
|
-
/** Set an arbitrary field on the GraphQL response body */
|
|
38
|
-
field(fieldName: string, value: unknown): void;
|
|
39
|
-
/** Set the `data` field of the response. Overrides the returned mock-data */
|
|
40
|
-
data(data: Record<string, unknown>): void;
|
|
41
|
-
/** Perform a request that bypasses any mock handlers */
|
|
42
|
-
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Information about the intercepted GraphQL request, passed to mock-data
|
|
46
|
-
* functions as `req`
|
|
47
|
-
*/
|
|
48
|
-
export interface MockGraphQLRequest {
|
|
49
|
-
/** The intercepted Fetch API `Request` */
|
|
50
|
-
request: Request;
|
|
51
|
-
/** The GraphQL query document string */
|
|
52
|
-
query: string;
|
|
53
|
-
operationName: string;
|
|
54
|
-
variables: Record<string, any>;
|
|
55
|
-
cookies: Record<string, string>;
|
|
56
|
-
url: URL;
|
|
57
|
-
headers: Headers;
|
|
58
|
-
method: string;
|
|
59
|
-
}
|
|
60
|
-
export type DataFunction<Query extends Record<string, unknown> = Record<string, unknown>, QueryVariables = Record<string, any>> = (variables: QueryVariables, { req, ctx, }: {
|
|
61
|
-
req: MockGraphQLRequest;
|
|
62
|
-
ctx: MockGraphQLContext;
|
|
63
|
-
}) => Query | void | Promise<Query | void>;
|
|
64
|
-
type ResponseEnhancer = 'once' | 'networkError';
|
|
65
|
-
export declare const mockGraphQLQuery: <Query extends Record<string, unknown> = Record<string, unknown>, QueryVariables = Record<string, any>>(operation: string, data: DataFunction<Query, QueryVariables> | Query, responseEnhancer?: ResponseEnhancer) => Record<string, any> | DataFunction<Record<string, unknown>, Record<string, any>>;
|
|
66
|
-
export declare const mockGraphQLMutation: <Query extends Record<string, unknown> = Record<string, unknown>, QueryVariables = Record<string, any>>(operation: string, data: DataFunction<Query, QueryVariables> | Query, responseEnhancer?: ResponseEnhancer) => Record<string, any> | DataFunction<Record<string, unknown>, Record<string, any>>;
|
|
67
|
-
export declare const mockedUserMeta: {
|
|
68
|
-
currentUser: Record<string, unknown> | null;
|
|
69
|
-
};
|
|
70
|
-
export declare const mockCurrentUser: (user: Record<string, unknown> | null) => void;
|
|
71
|
-
export {};
|
|
72
|
-
//# sourceMappingURL=mockRequests.d.ts.map
|
|
@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
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var mockRequests_exports = {};
|
|
30
|
-
__export(mockRequests_exports, {
|
|
31
|
-
closeServer: () => closeServer,
|
|
32
|
-
mockCurrentUser: () => mockCurrentUser,
|
|
33
|
-
mockGraphQLMutation: () => mockGraphQLMutation,
|
|
34
|
-
mockGraphQLQuery: () => mockGraphQLQuery,
|
|
35
|
-
mockedUserMeta: () => mockedUserMeta,
|
|
36
|
-
registerHandler: () => registerHandler,
|
|
37
|
-
setupRequestHandlers: () => setupRequestHandlers,
|
|
38
|
-
startMSW: () => startMSW
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(mockRequests_exports);
|
|
41
|
-
var import_msw = require("msw");
|
|
42
|
-
let REQUEST_HANDLER_QUEUE = [];
|
|
43
|
-
let SERVER_INSTANCE;
|
|
44
|
-
const MSW_NODE_SPECIFIER = "msw/node";
|
|
45
|
-
const startMSW = async (target, options) => {
|
|
46
|
-
if (SERVER_INSTANCE) {
|
|
47
|
-
return SERVER_INSTANCE;
|
|
48
|
-
}
|
|
49
|
-
if (target === "browsers") {
|
|
50
|
-
const { setupWorker } = await import("msw/browser");
|
|
51
|
-
const worker = setupWorker();
|
|
52
|
-
SERVER_INSTANCE = worker;
|
|
53
|
-
await worker.start(options);
|
|
54
|
-
} else {
|
|
55
|
-
const { setupServer } = await import(
|
|
56
|
-
/* @vite-ignore */
|
|
57
|
-
MSW_NODE_SPECIFIER
|
|
58
|
-
);
|
|
59
|
-
const server = setupServer();
|
|
60
|
-
SERVER_INSTANCE = server;
|
|
61
|
-
server.listen(options);
|
|
62
|
-
}
|
|
63
|
-
return SERVER_INSTANCE;
|
|
64
|
-
};
|
|
65
|
-
const setupRequestHandlers = () => {
|
|
66
|
-
SERVER_INSTANCE?.resetHandlers();
|
|
67
|
-
for (const handler of REQUEST_HANDLER_QUEUE) {
|
|
68
|
-
SERVER_INSTANCE?.use(handler);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const closeServer = () => {
|
|
72
|
-
if (!SERVER_INSTANCE) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if ("close" in SERVER_INSTANCE) {
|
|
76
|
-
SERVER_INSTANCE.close();
|
|
77
|
-
} else {
|
|
78
|
-
SERVER_INSTANCE.stop();
|
|
79
|
-
}
|
|
80
|
-
SERVER_INSTANCE = void 0;
|
|
81
|
-
};
|
|
82
|
-
const registerHandler = (handler) => {
|
|
83
|
-
if (!SERVER_INSTANCE) {
|
|
84
|
-
REQUEST_HANDLER_QUEUE = [...REQUEST_HANDLER_QUEUE, handler];
|
|
85
|
-
} else {
|
|
86
|
-
SERVER_INSTANCE.use(handler);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
const mockGraphQL = (type, operation, data, responseEnhancer) => {
|
|
90
|
-
const resolver = async ({
|
|
91
|
-
request,
|
|
92
|
-
query,
|
|
93
|
-
operationName,
|
|
94
|
-
variables,
|
|
95
|
-
cookies
|
|
96
|
-
}) => {
|
|
97
|
-
let d = void 0;
|
|
98
|
-
let status = 200;
|
|
99
|
-
let statusText;
|
|
100
|
-
let delayDurationMs;
|
|
101
|
-
let errorList;
|
|
102
|
-
let extensions;
|
|
103
|
-
let explicitData;
|
|
104
|
-
const extraFields = {};
|
|
105
|
-
const headers = new Headers();
|
|
106
|
-
if (typeof data === "function") {
|
|
107
|
-
const ctx = {
|
|
108
|
-
status: (code, text) => {
|
|
109
|
-
status = code;
|
|
110
|
-
statusText = text;
|
|
111
|
-
},
|
|
112
|
-
delay: (durationMs) => {
|
|
113
|
-
delayDurationMs = durationMs;
|
|
114
|
-
},
|
|
115
|
-
errors: (errors) => {
|
|
116
|
-
errorList = errors;
|
|
117
|
-
},
|
|
118
|
-
set: (name, value) => {
|
|
119
|
-
if (typeof name === "object") {
|
|
120
|
-
for (const [headerName, headerValue] of Object.entries(name)) {
|
|
121
|
-
headers.set(headerName, headerValue);
|
|
122
|
-
}
|
|
123
|
-
} else if (typeof value !== "undefined") {
|
|
124
|
-
headers.set(name, value);
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
cookie: (name, value) => {
|
|
128
|
-
headers.append("Set-Cookie", `${name}=${value}`);
|
|
129
|
-
},
|
|
130
|
-
extensions: (ext) => {
|
|
131
|
-
extensions = ext;
|
|
132
|
-
},
|
|
133
|
-
field: (fieldName, value) => {
|
|
134
|
-
extraFields[fieldName] = value;
|
|
135
|
-
},
|
|
136
|
-
data: (dataValue) => {
|
|
137
|
-
explicitData = dataValue;
|
|
138
|
-
},
|
|
139
|
-
fetch: (input, init) => fetch((0, import_msw.bypass)(input, init))
|
|
140
|
-
};
|
|
141
|
-
const req = {
|
|
142
|
-
request,
|
|
143
|
-
query,
|
|
144
|
-
operationName,
|
|
145
|
-
variables,
|
|
146
|
-
cookies,
|
|
147
|
-
url: new URL(request.url),
|
|
148
|
-
headers: request.headers,
|
|
149
|
-
method: request.method
|
|
150
|
-
};
|
|
151
|
-
d = await data(variables, { req, ctx });
|
|
152
|
-
} else {
|
|
153
|
-
d = data;
|
|
154
|
-
}
|
|
155
|
-
if (responseEnhancer === "networkError") {
|
|
156
|
-
return import_msw.HttpResponse.error();
|
|
157
|
-
}
|
|
158
|
-
if (typeof delayDurationMs !== "undefined") {
|
|
159
|
-
await (0, import_msw.delay)(delayDurationMs);
|
|
160
|
-
}
|
|
161
|
-
const body = { ...extraFields };
|
|
162
|
-
const bodyData = explicitData ?? d;
|
|
163
|
-
if (typeof bodyData !== "undefined") {
|
|
164
|
-
body.data = bodyData;
|
|
165
|
-
}
|
|
166
|
-
if (typeof errorList !== "undefined") {
|
|
167
|
-
body.errors = errorList;
|
|
168
|
-
}
|
|
169
|
-
if (typeof extensions !== "undefined") {
|
|
170
|
-
body.extensions = extensions;
|
|
171
|
-
}
|
|
172
|
-
return import_msw.HttpResponse.json(body, { status, statusText, headers });
|
|
173
|
-
};
|
|
174
|
-
registerHandler(
|
|
175
|
-
import_msw.graphql[type](operation, resolver, {
|
|
176
|
-
once: responseEnhancer === "once"
|
|
177
|
-
})
|
|
178
|
-
);
|
|
179
|
-
return data;
|
|
180
|
-
};
|
|
181
|
-
const mockGraphQLQuery = (operation, data, responseEnhancer) => {
|
|
182
|
-
return mockGraphQL("query", operation, data, responseEnhancer);
|
|
183
|
-
};
|
|
184
|
-
const mockGraphQLMutation = (operation, data, responseEnhancer) => {
|
|
185
|
-
return mockGraphQL("mutation", operation, data, responseEnhancer);
|
|
186
|
-
};
|
|
187
|
-
const mockedUserMeta = {
|
|
188
|
-
currentUser: null
|
|
189
|
-
};
|
|
190
|
-
const mockCurrentUser = (user) => {
|
|
191
|
-
mockedUserMeta.currentUser = user;
|
|
192
|
-
mockGraphQLQuery("__CEDAR__AUTH_GET_CURRENT_USER", () => {
|
|
193
|
-
return {
|
|
194
|
-
cedar: {
|
|
195
|
-
currentUser: user
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
});
|
|
199
|
-
};
|
|
200
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
201
|
-
0 && (module.exports = {
|
|
202
|
-
closeServer,
|
|
203
|
-
mockCurrentUser,
|
|
204
|
-
mockGraphQLMutation,
|
|
205
|
-
mockGraphQLQuery,
|
|
206
|
-
mockedUserMeta,
|
|
207
|
-
registerHandler,
|
|
208
|
-
setupRequestHandlers,
|
|
209
|
-
startMSW
|
|
210
|
-
});
|