@cedarjs/testing 7.0.0-rc.128 → 8.0.0-canary.3263
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/dist/api/mockContext.d.ts +1 -1
- package/dist/api/mockContext.d.ts.map +1 -1
- package/dist/api/vitest/teardown.d.ts +18 -0
- package/dist/api/vitest/teardown.d.ts.map +1 -0
- package/dist/api/vitest/teardown.js +43 -0
- package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.d.ts.map +1 -1
- package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.js +6 -1
- package/dist/api/vitest/vitest-api.setup.d.ts.map +1 -1
- package/dist/api/vitest/vitest-api.setup.js +9 -22
- package/dist/web/MockParamsProvider.d.ts.map +1 -1
- package/dist/web/MockParamsProvider.js +10 -1
- package/dist/web/MockRouter.d.ts.map +1 -1
- package/dist/web/mockRequests.d.ts +14 -0
- package/dist/web/mockRequests.d.ts.map +1 -1
- package/dist/web/mockRequests.js +8 -0
- package/package.json +22 -95
- package/config/jest/api/RedwoodApiJestEnv.d.ts +0 -11
- package/config/jest/api/RedwoodApiJestEnv.d.ts.map +0 -1
- package/config/jest/api/RedwoodApiJestEnv.js +0 -48
- package/config/jest/api/apiBabelConfig.d.ts +0 -5
- package/config/jest/api/apiBabelConfig.d.ts.map +0 -1
- package/config/jest/api/apiBabelConfig.js +0 -34
- package/config/jest/api/globalSetup.d.ts +0 -3
- package/config/jest/api/globalSetup.d.ts.map +0 -1
- package/config/jest/api/globalSetup.js +0 -63
- package/config/jest/api/index.d.ts +0 -3
- package/config/jest/api/index.d.ts.map +0 -1
- package/config/jest/api/index.js +0 -25
- package/config/jest/api/jest-preset.d.ts +0 -4
- package/config/jest/api/jest-preset.d.ts.map +0 -1
- package/config/jest/api/jest-preset.js +0 -140
- package/config/jest/api/jest.setup.d.ts +0 -2
- package/config/jest/api/jest.setup.d.ts.map +0 -1
- package/config/jest/api/jest.setup.js +0 -267
- package/config/jest/api/package.json +0 -8
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -11
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.js +0 -122
- package/config/jest/jest-serial-runner.d.ts +0 -8
- package/config/jest/jest-serial-runner.d.ts.map +0 -1
- package/config/jest/jest-serial-runner.js +0 -37
- package/config/jest/web/RedwoodWebJestEnv.d.ts +0 -6
- package/config/jest/web/RedwoodWebJestEnv.d.ts.map +0 -1
- package/config/jest/web/RedwoodWebJestEnv.js +0 -43
- package/config/jest/web/index.d.ts +0 -3
- package/config/jest/web/index.d.ts.map +0 -1
- package/config/jest/web/index.js +0 -25
- package/config/jest/web/jest-fixed-jsdom.d.js +0 -1
- package/config/jest/web/jest-preset.d.ts +0 -4
- package/config/jest/web/jest-preset.d.ts.map +0 -1
- package/config/jest/web/jest-preset.js +0 -224
- package/config/jest/web/jest.setup.d.ts +0 -7
- package/config/jest/web/jest.setup.d.ts.map +0 -1
- package/config/jest/web/jest.setup.js +0 -21
- package/config/jest/web/package.json +0 -8
- package/config/jest/web/resolver.d.ts +0 -4
- package/config/jest/web/resolver.d.ts.map +0 -1
- package/config/jest/web/resolver.js +0 -30
- package/config/jest/web/webBabelConfig.d.ts +0 -10
- package/config/jest/web/webBabelConfig.d.ts.map +0 -1
- package/config/jest/web/webBabelConfig.js +0 -48
- package/config/package.json +0 -1
- 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 -50
- package/dist/cjs/api/checkTestDatabase.d.ts.map +0 -1
- package/dist/cjs/api/checkTestDatabase.js +0 -182
- 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 -86
- 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/config/jest/api/RedwoodApiJestEnv.d.ts +0 -11
- package/dist/cjs/config/jest/api/RedwoodApiJestEnv.d.ts.map +0 -1
- package/dist/cjs/config/jest/api/RedwoodApiJestEnv.js +0 -48
- package/dist/cjs/config/jest/api/apiBabelConfig.d.ts +0 -5
- package/dist/cjs/config/jest/api/apiBabelConfig.d.ts.map +0 -1
- package/dist/cjs/config/jest/api/apiBabelConfig.js +0 -34
- package/dist/cjs/config/jest/api/globalSetup.d.ts +0 -3
- package/dist/cjs/config/jest/api/globalSetup.d.ts.map +0 -1
- package/dist/cjs/config/jest/api/globalSetup.js +0 -63
- package/dist/cjs/config/jest/api/index.d.ts +0 -3
- package/dist/cjs/config/jest/api/index.d.ts.map +0 -1
- package/dist/cjs/config/jest/api/index.js +0 -25
- package/dist/cjs/config/jest/api/jest-preset.d.ts +0 -4
- package/dist/cjs/config/jest/api/jest-preset.d.ts.map +0 -1
- package/dist/cjs/config/jest/api/jest-preset.js +0 -140
- package/dist/cjs/config/jest/api/jest.setup.d.ts +0 -2
- package/dist/cjs/config/jest/api/jest.setup.d.ts.map +0 -1
- package/dist/cjs/config/jest/api/jest.setup.js +0 -267
- package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -11
- package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
- package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.js +0 -122
- package/dist/cjs/config/jest/jest-serial-runner.d.ts +0 -8
- package/dist/cjs/config/jest/jest-serial-runner.d.ts.map +0 -1
- package/dist/cjs/config/jest/jest-serial-runner.js +0 -37
- package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts +0 -6
- package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts.map +0 -1
- package/dist/cjs/config/jest/web/RedwoodWebJestEnv.js +0 -43
- package/dist/cjs/config/jest/web/index.d.ts +0 -3
- package/dist/cjs/config/jest/web/index.d.ts.map +0 -1
- package/dist/cjs/config/jest/web/index.js +0 -25
- package/dist/cjs/config/jest/web/jest-fixed-jsdom.d.js +0 -1
- package/dist/cjs/config/jest/web/jest-preset.d.ts +0 -4
- package/dist/cjs/config/jest/web/jest-preset.d.ts.map +0 -1
- package/dist/cjs/config/jest/web/jest-preset.js +0 -224
- package/dist/cjs/config/jest/web/jest.setup.d.ts +0 -7
- package/dist/cjs/config/jest/web/jest.setup.d.ts.map +0 -1
- package/dist/cjs/config/jest/web/jest.setup.js +0 -21
- package/dist/cjs/config/jest/web/resolver.d.ts +0 -4
- package/dist/cjs/config/jest/web/resolver.d.ts.map +0 -1
- package/dist/cjs/config/jest/web/resolver.js +0 -30
- package/dist/cjs/config/jest/web/webBabelConfig.d.ts +0 -10
- package/dist/cjs/config/jest/web/webBabelConfig.d.ts.map +0 -1
- package/dist/cjs/config/jest/web/webBabelConfig.js +0 -48
- 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/fileMock.d.ts +0 -10
- package/dist/cjs/web/fileMock.d.ts.map +0 -1
- package/dist/cjs/web/fileMock.js +0 -24
- 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
- package/dist/config/jest/api/RedwoodApiJestEnv.d.ts +0 -11
- package/dist/config/jest/api/RedwoodApiJestEnv.d.ts.map +0 -1
- package/dist/config/jest/api/RedwoodApiJestEnv.js +0 -28
- package/dist/config/jest/api/apiBabelConfig.d.ts +0 -5
- package/dist/config/jest/api/apiBabelConfig.d.ts.map +0 -1
- package/dist/config/jest/api/apiBabelConfig.js +0 -18
- package/dist/config/jest/api/globalSetup.d.ts +0 -3
- package/dist/config/jest/api/globalSetup.d.ts.map +0 -1
- package/dist/config/jest/api/globalSetup.js +0 -36
- package/dist/config/jest/api/index.d.ts +0 -3
- package/dist/config/jest/api/index.d.ts.map +0 -1
- package/dist/config/jest/api/index.js +0 -15
- package/dist/config/jest/api/jest-preset.d.ts +0 -4
- package/dist/config/jest/api/jest-preset.d.ts.map +0 -1
- package/dist/config/jest/api/jest-preset.js +0 -110
- package/dist/config/jest/api/jest.setup.d.ts +0 -2
- package/dist/config/jest/api/jest.setup.d.ts.map +0 -1
- package/dist/config/jest/api/jest.setup.js +0 -244
- package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -11
- package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
- package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.js +0 -102
- package/dist/config/jest/jest-serial-runner.d.ts +0 -8
- package/dist/config/jest/jest-serial-runner.d.ts.map +0 -1
- package/dist/config/jest/jest-serial-runner.js +0 -27
- package/dist/config/jest/web/RedwoodWebJestEnv.d.ts +0 -6
- package/dist/config/jest/web/RedwoodWebJestEnv.d.ts.map +0 -1
- package/dist/config/jest/web/RedwoodWebJestEnv.js +0 -13
- package/dist/config/jest/web/index.d.ts +0 -3
- package/dist/config/jest/web/index.d.ts.map +0 -1
- package/dist/config/jest/web/index.js +0 -15
- package/dist/config/jest/web/jest-fixed-jsdom.d.js +0 -0
- package/dist/config/jest/web/jest-preset.d.ts +0 -4
- package/dist/config/jest/web/jest-preset.d.ts.map +0 -1
- package/dist/config/jest/web/jest-preset.js +0 -194
- package/dist/config/jest/web/jest.setup.d.ts +0 -7
- package/dist/config/jest/web/jest.setup.d.ts.map +0 -1
- package/dist/config/jest/web/jest.setup.js +0 -27
- package/dist/config/jest/web/resolver.d.ts +0 -4
- package/dist/config/jest/web/resolver.d.ts.map +0 -1
- package/dist/config/jest/web/resolver.js +0 -42
- package/dist/config/jest/web/webBabelConfig.d.ts +0 -10
- package/dist/config/jest/web/webBabelConfig.d.ts.map +0 -1
- package/dist/config/jest/web/webBabelConfig.js +0 -18
- package/dist/web/fileMock.d.ts +0 -10
- package/dist/web/fileMock.d.ts.map +0 -1
- package/dist/web/fileMock.js +0 -4
|
@@ -1,182 +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 checkTestDatabase_exports = {};
|
|
30
|
-
__export(checkTestDatabase_exports, {
|
|
31
|
-
checkTestDatabaseIdentity: () => checkTestDatabaseIdentity,
|
|
32
|
-
checkTestDatabaseUrlMatchesProvider: () => checkTestDatabaseUrlMatchesProvider,
|
|
33
|
-
redactDatabaseUrl: () => redactDatabaseUrl
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(checkTestDatabase_exports);
|
|
36
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
37
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
const PROVIDER_URL_SCHEMES = {
|
|
39
|
-
sqlite: ["file:"],
|
|
40
|
-
postgresql: ["postgres:", "postgresql:"],
|
|
41
|
-
postgres: ["postgres:", "postgresql:"],
|
|
42
|
-
cockroachdb: ["postgres:", "postgresql:"],
|
|
43
|
-
mysql: ["mysql:"],
|
|
44
|
-
sqlserver: ["sqlserver:"],
|
|
45
|
-
mongodb: ["mongodb:", "mongodb+srv:"]
|
|
46
|
-
};
|
|
47
|
-
function getUrlScheme(url) {
|
|
48
|
-
const match = url.match(/^([a-z][a-z0-9+.-]*:)/i);
|
|
49
|
-
return match?.[1]?.toLowerCase();
|
|
50
|
-
}
|
|
51
|
-
function redactDatabaseUrl(url) {
|
|
52
|
-
return url.replace(/:\/\/([^:/?#]+):([^@/?#]+)@/, "://$1:***@").replace(/((?:^|;)\s*password\s*=)[^;]*/gi, "$1***");
|
|
53
|
-
}
|
|
54
|
-
async function checkTestDatabaseUrlMatchesProvider(databaseUrl, usedFallback) {
|
|
55
|
-
let provider;
|
|
56
|
-
try {
|
|
57
|
-
provider = await (0, import_project_config.getPrismaDatasourceProvider)();
|
|
58
|
-
} catch {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const expectedSchemes = PROVIDER_URL_SCHEMES[provider];
|
|
62
|
-
if (!expectedSchemes) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const actualScheme = getUrlScheme(databaseUrl);
|
|
66
|
-
if (actualScheme && expectedSchemes.includes(actualScheme)) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const redactedUrl = redactDatabaseUrl(databaseUrl);
|
|
70
|
-
const reason = usedFallback ? `TEST_DATABASE_URL is not set, so the default sqlite test database was used (${redactedUrl}), but your schema.prisma is configured for "${provider}". Set TEST_DATABASE_URL to a "${provider}" connection string to run tests.` : `TEST_DATABASE_URL (${redactedUrl}) does not match the "${provider}" provider configured in schema.prisma. Update TEST_DATABASE_URL to a "${provider}" connection string.`;
|
|
71
|
-
throw new Error(
|
|
72
|
-
`Test database URL does not match your Prisma schema's provider.
|
|
73
|
-
|
|
74
|
-
${reason}`
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
const DEFAULT_PORTS = {
|
|
78
|
-
"postgresql:": "5432",
|
|
79
|
-
"mysql:": "3306",
|
|
80
|
-
"sqlserver:": "1433",
|
|
81
|
-
"mongodb:": "27017"
|
|
82
|
-
};
|
|
83
|
-
function normalizeScheme(scheme) {
|
|
84
|
-
return scheme === "postgres:" ? "postgresql:" : scheme;
|
|
85
|
-
}
|
|
86
|
-
function normalizeHost(host) {
|
|
87
|
-
return host.toLowerCase().replace(/\.$/, "");
|
|
88
|
-
}
|
|
89
|
-
function parseSqlServerIdentity(url) {
|
|
90
|
-
const [authority, ...params] = url.split(";");
|
|
91
|
-
const match = authority.match(
|
|
92
|
-
/^([a-z][a-z0-9+.-]*:)\/\/([^:/?#]+)(?::(\d+))?/i
|
|
93
|
-
);
|
|
94
|
-
if (!match) {
|
|
95
|
-
return void 0;
|
|
96
|
-
}
|
|
97
|
-
const [, scheme, host, port] = match;
|
|
98
|
-
const databaseParam = params.find(
|
|
99
|
-
(param) => /^\s*(?:database|initial\s+catalog)\s*=/i.test(param)
|
|
100
|
-
);
|
|
101
|
-
const database = databaseParam?.slice(databaseParam.indexOf("=") + 1).trim();
|
|
102
|
-
return {
|
|
103
|
-
scheme: scheme.toLowerCase(),
|
|
104
|
-
host: normalizeHost(host),
|
|
105
|
-
port,
|
|
106
|
-
database
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function parseUriIdentity(url) {
|
|
110
|
-
try {
|
|
111
|
-
const parsed = new URL(url);
|
|
112
|
-
const database = decodeURIComponent(parsed.pathname.replace(/^\//, "")).split("/")[0] || void 0;
|
|
113
|
-
return {
|
|
114
|
-
scheme: parsed.protocol.toLowerCase(),
|
|
115
|
-
host: parsed.hostname ? normalizeHost(parsed.hostname) : void 0,
|
|
116
|
-
port: parsed.port || void 0,
|
|
117
|
-
database
|
|
118
|
-
};
|
|
119
|
-
} catch {
|
|
120
|
-
return void 0;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function parseDatabaseIdentity(url) {
|
|
124
|
-
const scheme = getUrlScheme(url);
|
|
125
|
-
if (!scheme) {
|
|
126
|
-
return void 0;
|
|
127
|
-
}
|
|
128
|
-
if (scheme === "file:") {
|
|
129
|
-
return { scheme, database: import_node_path.default.resolve(url.slice("file:".length)) };
|
|
130
|
-
}
|
|
131
|
-
if (scheme === "sqlserver:") {
|
|
132
|
-
return parseSqlServerIdentity(url);
|
|
133
|
-
}
|
|
134
|
-
return parseUriIdentity(url);
|
|
135
|
-
}
|
|
136
|
-
function identitiesMatch(a, b) {
|
|
137
|
-
const schemeA = normalizeScheme(a.scheme);
|
|
138
|
-
const schemeB = normalizeScheme(b.scheme);
|
|
139
|
-
if (schemeA !== schemeB) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
if (schemeA === "file:") {
|
|
143
|
-
return !!a.database && a.database === b.database;
|
|
144
|
-
}
|
|
145
|
-
if (!a.database || !b.database || a.database !== b.database) {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
const portA = a.port || DEFAULT_PORTS[schemeA] || "";
|
|
149
|
-
const portB = b.port || DEFAULT_PORTS[schemeA] || "";
|
|
150
|
-
return (a.host ?? "") === (b.host ?? "") && portA === portB;
|
|
151
|
-
}
|
|
152
|
-
function checkTestDatabaseIdentity(testDatabaseUrl, mainDatabaseUrl, usedFallback) {
|
|
153
|
-
if (!mainDatabaseUrl) {
|
|
154
|
-
if (usedFallback) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const redactedTestUrl = redactDatabaseUrl(testDatabaseUrl);
|
|
158
|
-
throw new Error(
|
|
159
|
-
`TEST_DATABASE_URL (${redactedTestUrl}) is set, but there's no DATABASE_URL to confirm it isn't the same database your app actually uses. Refusing to run a destructive reset without that confirmation.
|
|
160
|
-
|
|
161
|
-
Set DATABASE_URL (even to a placeholder) so Cedar can verify TEST_DATABASE_URL points somewhere different.`
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
const sameRawUrl = mainDatabaseUrl === testDatabaseUrl;
|
|
165
|
-
const testIdentity = parseDatabaseIdentity(testDatabaseUrl);
|
|
166
|
-
const mainIdentity = parseDatabaseIdentity(mainDatabaseUrl);
|
|
167
|
-
const sameParsedIdentity = !!testIdentity && !!mainIdentity && identitiesMatch(testIdentity, mainIdentity);
|
|
168
|
-
if (sameRawUrl || sameParsedIdentity) {
|
|
169
|
-
const redactedTestUrl = redactDatabaseUrl(testDatabaseUrl);
|
|
170
|
-
throw new Error(
|
|
171
|
-
`TEST_DATABASE_URL (${redactedTestUrl}) points at the same database as DATABASE_URL. Refusing to run a destructive reset against your app's main database.
|
|
172
|
-
|
|
173
|
-
Set TEST_DATABASE_URL to a dedicated test database.`
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
178
|
-
0 && (module.exports = {
|
|
179
|
-
checkTestDatabaseIdentity,
|
|
180
|
-
checkTestDatabaseUrlMatchesProvider,
|
|
181
|
-
redactDatabaseUrl
|
|
182
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { A } from 'ts-toolbelt';
|
|
2
|
-
import type { DirectiveParams, ValidatorDirective, TransformerDirective } from '@cedarjs/graphql-server';
|
|
3
|
-
export { getDirectiveName } from '@cedarjs/graphql-server';
|
|
4
|
-
interface DirectiveMocker {
|
|
5
|
-
(directive: ValidatorDirective, executionMock: A.Compute<Omit<Partial<DirectiveParams>, 'resolvedValue'>>): any;
|
|
6
|
-
}
|
|
7
|
-
type TransformerMock = A.Compute<Omit<Partial<DirectiveParams>, 'resolvedValue'>> & {
|
|
8
|
-
mockedResolvedValue: any;
|
|
9
|
-
};
|
|
10
|
-
interface DirectiveMocker {
|
|
11
|
-
(directive: TransformerDirective, executionMock: TransformerMock): any;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @description
|
|
15
|
-
*
|
|
16
|
-
* Used for writing both synchronous and asynchronous directive tests e.g.
|
|
17
|
-
*
|
|
18
|
-
* - Transformer directives can be passed mockedResolvedValue
|
|
19
|
-
* - Validator directives should check for errors thrown in certain situations
|
|
20
|
-
* - Can provide args, directiveArgs and context to mock directive execution
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
*
|
|
24
|
-
* Synchronous transformer directive:
|
|
25
|
-
*
|
|
26
|
-
* ```ts
|
|
27
|
-
* const mockExecution = mockRedwoodDirective(myTransformer, {
|
|
28
|
-
* context: currentUser,
|
|
29
|
-
* mockedResolvedValue: 'Original Value',
|
|
30
|
-
* })
|
|
31
|
-
*
|
|
32
|
-
* expect(mockExecution).not.toThrow()
|
|
33
|
-
* expect(mockExecution()).toEqual('Transformed Value')
|
|
34
|
-
* ```ts
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
*
|
|
38
|
-
* Asynchronous transformer directive:
|
|
39
|
-
*
|
|
40
|
-
* ```ts
|
|
41
|
-
* const mockExecution = mockRedwoodDirective(myTransformer, {
|
|
42
|
-
* context: currentUser,
|
|
43
|
-
* mockedResolvedValue: 'Original Value',
|
|
44
|
-
* })
|
|
45
|
-
*
|
|
46
|
-
* await expect(mockExecution).resolves.not.toThrow()
|
|
47
|
-
* await expect(mockExecution()).resolves.toEqual('Transformed Value')
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export declare const mockRedwoodDirective: DirectiveMocker;
|
|
51
|
-
//# sourceMappingURL=directive.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directive.d.ts","sourceRoot":"","sources":["../../../src/api/directive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,aAAa,CAAA;AAGpC,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAG1D,UAAU,eAAe;IACvB,CACE,SAAS,EAAE,kBAAkB,EAC7B,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,CAAC,GACxE,GAAG,CAAA;CACP;AAED,KAAK,eAAe,GAAG,CAAC,CAAC,OAAO,CAC9B,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,CAChD,GAAG;IACF,mBAAmB,EAAE,GAAG,CAAA;CACzB,CAAA;AAGD,UAAU,eAAe;IACvB,CAAC,SAAS,EAAE,oBAAoB,EAAE,aAAa,EAAE,eAAe,GAAG,GAAG,CAAA;CACvE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,oBAAoB,EAAE,eAmDlC,CAAA"}
|
|
@@ -1,77 +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 directive_exports = {};
|
|
20
|
-
__export(directive_exports, {
|
|
21
|
-
getDirectiveName: () => import_graphql_server2.getDirectiveName,
|
|
22
|
-
mockRedwoodDirective: () => mockRedwoodDirective
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(directive_exports);
|
|
25
|
-
var import_context = require("@cedarjs/context");
|
|
26
|
-
var import_graphql_server = require("@cedarjs/graphql-server");
|
|
27
|
-
var import_graphql_server2 = require("@cedarjs/graphql-server");
|
|
28
|
-
const mockRedwoodDirective = (directive, executionMock) => {
|
|
29
|
-
const { directiveArgs, context, ...others } = executionMock;
|
|
30
|
-
if (directive.onResolvedValue.constructor.name === "AsyncFunction") {
|
|
31
|
-
return async () => {
|
|
32
|
-
if (context !== void 0) {
|
|
33
|
-
(0, import_context.setContext)(context);
|
|
34
|
-
}
|
|
35
|
-
if (directive.type === import_graphql_server.DirectiveType.TRANSFORMER) {
|
|
36
|
-
const { mockedResolvedValue } = others;
|
|
37
|
-
return directive.onResolvedValue({
|
|
38
|
-
resolvedValue: mockedResolvedValue,
|
|
39
|
-
directiveArgs: directiveArgs ?? {},
|
|
40
|
-
context: import_context.context,
|
|
41
|
-
...others
|
|
42
|
-
});
|
|
43
|
-
} else {
|
|
44
|
-
await directive.onResolvedValue({
|
|
45
|
-
directiveArgs: directiveArgs ?? {},
|
|
46
|
-
context: import_context.context,
|
|
47
|
-
...others
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return () => {
|
|
53
|
-
if (context !== void 0) {
|
|
54
|
-
(0, import_context.setContext)(context);
|
|
55
|
-
}
|
|
56
|
-
if (directive.type === import_graphql_server.DirectiveType.TRANSFORMER) {
|
|
57
|
-
const { mockedResolvedValue } = others;
|
|
58
|
-
return directive.onResolvedValue({
|
|
59
|
-
resolvedValue: mockedResolvedValue,
|
|
60
|
-
directiveArgs: directiveArgs ?? {},
|
|
61
|
-
context: import_context.context,
|
|
62
|
-
...others
|
|
63
|
-
});
|
|
64
|
-
} else {
|
|
65
|
-
directive.onResolvedValue({
|
|
66
|
-
directiveArgs: directiveArgs ?? {},
|
|
67
|
-
context: import_context.context,
|
|
68
|
-
...others
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
-
0 && (module.exports = {
|
|
75
|
-
getDirectiveName,
|
|
76
|
-
mockRedwoodDirective
|
|
77
|
-
});
|
package/dist/cjs/api/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA"}
|
package/dist/cjs/api/index.js
DELETED
|
@@ -1,26 +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 __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var api_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(api_exports);
|
|
18
|
-
__reExport(api_exports, require("./apiFunction.js"), module.exports);
|
|
19
|
-
__reExport(api_exports, require("./scenario.js"), module.exports);
|
|
20
|
-
__reExport(api_exports, require("./directive.js"), module.exports);
|
|
21
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
-
0 && (module.exports = {
|
|
23
|
-
...require("./apiFunction.js"),
|
|
24
|
-
...require("./scenario.js"),
|
|
25
|
-
...require("./directive.js")
|
|
26
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockContext.d.ts","sourceRoot":"","sources":["../../../src/api/mockContext.ts"],"names":[],"mappings":"AAoCA,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAAG;AAEjE,eAAO,MAAM,OAAO,IAAc,CAAA;AAElC,eAAO,MAAM,UAAU,GAAI,YAAY,aAAa,KAAG,aAKtD,CAAA"}
|
|
@@ -1,58 +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 mockContext_exports = {};
|
|
20
|
-
__export(mockContext_exports, {
|
|
21
|
-
context: () => context,
|
|
22
|
-
setContext: () => setContext
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(mockContext_exports);
|
|
25
|
-
const mockContextStore = /* @__PURE__ */ new Map();
|
|
26
|
-
const mockContext = new Proxy(
|
|
27
|
-
{},
|
|
28
|
-
{
|
|
29
|
-
get: (_target, prop) => {
|
|
30
|
-
if (prop === "toJSON") {
|
|
31
|
-
return () => mockContextStore.get("context");
|
|
32
|
-
}
|
|
33
|
-
const ctx = mockContextStore.get("context");
|
|
34
|
-
if (!ctx) {
|
|
35
|
-
return void 0;
|
|
36
|
-
}
|
|
37
|
-
return ctx[prop];
|
|
38
|
-
},
|
|
39
|
-
set: (_target, prop, value) => {
|
|
40
|
-
const ctx = mockContextStore.get("context");
|
|
41
|
-
if (!ctx) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
ctx[prop] = value;
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
const context = mockContext;
|
|
50
|
-
const setContext = (newContext) => {
|
|
51
|
-
mockContextStore.set("context", newContext);
|
|
52
|
-
return mockContext;
|
|
53
|
-
};
|
|
54
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
-
0 && (module.exports = {
|
|
56
|
-
context,
|
|
57
|
-
setContext
|
|
58
|
-
});
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import type { A } from 'ts-toolbelt';
|
|
2
|
-
/**
|
|
3
|
-
* Use this function to define your scenario.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* export const standard = defineScenario({
|
|
7
|
-
* user: {
|
|
8
|
-
* dom: {
|
|
9
|
-
* name: 'Dom Saadi',
|
|
10
|
-
* email: 'dom@cedarjs.com',
|
|
11
|
-
* },
|
|
12
|
-
* },
|
|
13
|
-
* })
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* export const standard = defineScenario<Prisma.CreateUserArgs>({
|
|
17
|
-
* user: {
|
|
18
|
-
* dom: {
|
|
19
|
-
* name: 'Dom Saadi',
|
|
20
|
-
* email: 'dom@cedarjs.com',
|
|
21
|
-
* },
|
|
22
|
-
* },
|
|
23
|
-
* })
|
|
24
|
-
*/
|
|
25
|
-
export declare const defineScenario: DefineScenario;
|
|
26
|
-
/**
|
|
27
|
-
* @example
|
|
28
|
-
* {
|
|
29
|
-
* dannyUser: {
|
|
30
|
-
* data: {
|
|
31
|
-
* id: 1,
|
|
32
|
-
* name: 'Danny',
|
|
33
|
-
* },
|
|
34
|
-
* },
|
|
35
|
-
* }
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* krisUser: (scenario) => {
|
|
39
|
-
* return {
|
|
40
|
-
* data: {
|
|
41
|
-
* id: 2,
|
|
42
|
-
* name: 'Kris',
|
|
43
|
-
* },
|
|
44
|
-
* }
|
|
45
|
-
* }
|
|
46
|
-
*/
|
|
47
|
-
type ScenarioDefinitionMap<PrismaCreateType extends {
|
|
48
|
-
data: any;
|
|
49
|
-
}, ModelName extends string | number | symbol = string | number | symbol, TKeys extends string | number | symbol = string | number | symbol> = Record<TKeys, A.Compute<PrismaCreateType> | ((scenario: Record<ModelName, Record<TKeys, any>>) => A.Compute<PrismaCreateType>)>;
|
|
50
|
-
export interface DefineScenario {
|
|
51
|
-
<PrismaCreateType extends {
|
|
52
|
-
data: any;
|
|
53
|
-
}, ModelName extends string | number | symbol = string | number | symbol, TKeys extends string | number | symbol = string | number | symbol>(scenarioMap: Record<ModelName, ScenarioDefinitionMap<PrismaCreateType, ModelName, TKeys>>): Record<ModelName, Record<TKeys, any>>;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Type of data seeded by the scenario. Use this type to get the 'strict' return type of defineScenario
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* import { Product } from '@prisma/client'
|
|
60
|
-
*
|
|
61
|
-
* // If you scenario looks like this:
|
|
62
|
-
* export const standard = defineScenario({
|
|
63
|
-
* product: {
|
|
64
|
-
* shirt: {
|
|
65
|
-
* id: 55,
|
|
66
|
-
* price: 10,
|
|
67
|
-
* },
|
|
68
|
-
* },
|
|
69
|
-
* })
|
|
70
|
-
*
|
|
71
|
-
* // Export the StandardScenario type as
|
|
72
|
-
* export StandardScenario = ScenarioData<Product, 'product'>
|
|
73
|
-
*
|
|
74
|
-
* // You can also define each of the keys in your scenario, so you get stricter type checking
|
|
75
|
-
* export StandardScenario = ScenarioData<Product, 'product', 'shirt'>
|
|
76
|
-
*/
|
|
77
|
-
export declare type ScenarioData<TModel, // the prisma model, imported from @prisma/client e.g. "Product"
|
|
78
|
-
TName extends string | number = string | number, // (optional) name of the prisma model e.g. "product"
|
|
79
|
-
TKeys extends string | number = string | number> = Record<TName, Record<TKeys, TModel>>;
|
|
80
|
-
interface TestFunctionWithScenario<TData> {
|
|
81
|
-
(scenario?: TData): Promise<void>;
|
|
82
|
-
}
|
|
83
|
-
interface DescribeBlockWithGetScenario<TData> {
|
|
84
|
-
(getScenario: () => TData): void;
|
|
85
|
-
}
|
|
86
|
-
export interface Scenario {
|
|
87
|
-
(title: string, testFunction: TestFunctionWithScenario<any>): void;
|
|
88
|
-
}
|
|
89
|
-
export interface Scenario {
|
|
90
|
-
(namedScenario: string, title: string, testFunction: TestFunctionWithScenario<any>): void;
|
|
91
|
-
}
|
|
92
|
-
export interface Scenario {
|
|
93
|
-
only: Scenario;
|
|
94
|
-
}
|
|
95
|
-
export interface DescribeScenario {
|
|
96
|
-
<TData = any>(title: string, describeBlock: DescribeBlockWithGetScenario<TData>): void;
|
|
97
|
-
}
|
|
98
|
-
export interface DescribeScenario {
|
|
99
|
-
<TData>(title: string, describeBlock: DescribeBlockWithGetScenario<TData>): void;
|
|
100
|
-
}
|
|
101
|
-
export interface DescribeScenario {
|
|
102
|
-
<TData>(namedScenario: string, title: string, describeBlock: DescribeBlockWithGetScenario<TData>): void;
|
|
103
|
-
}
|
|
104
|
-
export interface DescribeScenario {
|
|
105
|
-
only: DescribeScenario;
|
|
106
|
-
}
|
|
107
|
-
export {};
|
|
108
|
-
//# sourceMappingURL=scenario.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scenario.d.ts","sourceRoot":"","sources":["../../../src/api/scenario.ts"],"names":[],"mappings":"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"}
|
package/dist/cjs/api/scenario.js
DELETED
|
@@ -1,30 +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 scenario_exports = {};
|
|
20
|
-
__export(scenario_exports, {
|
|
21
|
-
defineScenario: () => defineScenario
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(scenario_exports);
|
|
24
|
-
const defineScenario = (data) => {
|
|
25
|
-
return data;
|
|
26
|
-
};
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
defineScenario
|
|
30
|
-
});
|
|
@@ -1,86 +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 CedarApiVitestEnv_exports = {};
|
|
30
|
-
__export(CedarApiVitestEnv_exports, {
|
|
31
|
-
default: () => CedarApiVitestEnv_default
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(CedarApiVitestEnv_exports);
|
|
34
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
-
var import_config = require("dotenv-defaults/config.js");
|
|
36
|
-
var import_execa = __toESM(require("execa"), 1);
|
|
37
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
var import_packageManager = require("@cedarjs/project-config/packageManager");
|
|
39
|
-
var import_checkTestDatabase = require("../checkTestDatabase.js");
|
|
40
|
-
const CedarApiVitestEnvironment = {
|
|
41
|
-
name: "cedar-api",
|
|
42
|
-
viteEnvironment: "ssr",
|
|
43
|
-
async setup() {
|
|
44
|
-
if (process.env.SKIP_DB_PUSH === "1") {
|
|
45
|
-
return {
|
|
46
|
-
teardown() {
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const cedarPaths = (0, import_project_config.getPaths)();
|
|
51
|
-
const mainDatabaseUrl = "CEDAR_APP_DATABASE_URL" in process.env ? process.env.CEDAR_APP_DATABASE_URL : process.env.DATABASE_URL;
|
|
52
|
-
const defaultDb = `file:${import_node_path.default.join(cedarPaths.generated.base, "test.db")}`;
|
|
53
|
-
const usedFallback = !process.env.TEST_DATABASE_URL;
|
|
54
|
-
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
55
|
-
await (0, import_checkTestDatabase.checkTestDatabaseUrlMatchesProvider)(
|
|
56
|
-
process.env.DATABASE_URL,
|
|
57
|
-
usedFallback
|
|
58
|
-
);
|
|
59
|
-
const testConfig = (0, import_project_config.getConfig)().test;
|
|
60
|
-
(0, import_checkTestDatabase.checkTestDatabaseIdentity)(
|
|
61
|
-
process.env.DATABASE_URL,
|
|
62
|
-
mainDatabaseUrl,
|
|
63
|
-
usedFallback
|
|
64
|
-
);
|
|
65
|
-
console.log(
|
|
66
|
-
`Setting up test database: ${(0, import_checkTestDatabase.redactDatabaseUrl)(process.env.DATABASE_URL)}`
|
|
67
|
-
);
|
|
68
|
-
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
69
|
-
const pm = (0, import_packageManager.getPackageManager)();
|
|
70
|
-
const pmExec = pm === "pnpm" ? pm : "npx";
|
|
71
|
-
const env = { ...process.env };
|
|
72
|
-
if (testConfig.autoConsentToDbReset && !("PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION" in env)) {
|
|
73
|
-
env.PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION = "Cedar auto-consent: cedar.toml's [test] autoConsentToDbReset is true, and the reset target passed Cedar's test-database identity guard.";
|
|
74
|
-
}
|
|
75
|
-
import_execa.default.sync(pmExec, ["cedar", ...command], {
|
|
76
|
-
cwd: cedarPaths.api.base,
|
|
77
|
-
stdio: "inherit",
|
|
78
|
-
env
|
|
79
|
-
});
|
|
80
|
-
return {
|
|
81
|
-
teardown() {
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
var CedarApiVitestEnv_default = CedarApiVitestEnvironment;
|