medusa-test-utils 1.1.45-snapshot-20240717160031 → 1.1.45-snapshot-20240718083016
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/database.d.ts +0 -1
- package/dist/database.js +142 -56
- package/dist/database.js.map +1 -1
- package/dist/id-map.d.ts +2 -3
- package/dist/id-map.js +13 -8
- package/dist/id-map.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/init-modules.d.ts +0 -1
- package/dist/init-modules.js +95 -38
- package/dist/init-modules.js.map +1 -1
- package/dist/jest.d.ts +0 -1
- package/dist/jest.js +62 -14
- package/dist/jest.js.map +1 -1
- package/dist/medusa-test-runner-utils/bootstrap-app.d.ts +5 -10
- package/dist/medusa-test-runner-utils/bootstrap-app.js +146 -54
- package/dist/medusa-test-runner-utils/bootstrap-app.js.map +1 -1
- package/dist/medusa-test-runner-utils/use-db.d.ts +12 -5
- package/dist/medusa-test-runner-utils/use-db.js +143 -29
- package/dist/medusa-test-runner-utils/use-db.js.map +1 -1
- package/dist/medusa-test-runner.d.ts +3 -9
- package/dist/medusa-test-runner.js +332 -144
- package/dist/medusa-test-runner.js.map +1 -1
- package/dist/mock-event-bus-service.d.ts +4 -5
- package/dist/mock-event-bus-service.js +51 -13
- package/dist/mock-event-bus-service.js.map +1 -1
- package/dist/mock-manager.d.ts +9 -0
- package/dist/mock-manager.js +30 -0
- package/dist/mock-manager.js.map +1 -0
- package/dist/mock-repository.d.ts +51 -0
- package/dist/mock-repository.js +193 -0
- package/dist/mock-repository.js.map +1 -0
- package/dist/module-test-runner.d.ts +2 -3
- package/dist/module-test-runner.js +129 -60
- package/dist/module-test-runner.js.map +1 -1
- package/package.json +12 -7
- package/dist/database.d.ts.map +0 -1
- package/dist/events.d.ts +0 -3
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js +0 -24
- package/dist/events.js.map +0 -1
- package/dist/id-map.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/init-modules.d.ts.map +0 -1
- package/dist/jest.d.ts.map +0 -1
- package/dist/medusa-test-runner-utils/bootstrap-app.d.ts.map +0 -1
- package/dist/medusa-test-runner-utils/use-db.d.ts.map +0 -1
- package/dist/medusa-test-runner.d.ts.map +0 -1
- package/dist/mock-event-bus-service.d.ts.map +0 -1
- package/dist/module-test-runner.d.ts.map +0 -1
@@ -1,174 +1,362 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
40
|
+
if (m) return m.call(o);
|
41
|
+
if (o && typeof o.length === "number") return {
|
42
|
+
next: function () {
|
43
|
+
if (o && i >= o.length) o = void 0;
|
44
|
+
return { value: o && o[i++], done: !o };
|
45
|
+
}
|
46
|
+
};
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
48
|
+
};
|
2
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
50
|
exports.medusaIntegrationTestRunner = void 0;
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
51
|
+
var database_1 = require("./database");
|
52
|
+
var use_db_1 = require("./medusa-test-runner-utils/use-db");
|
53
|
+
var bootstrap_app_1 = require("./medusa-test-runner-utils/bootstrap-app");
|
54
|
+
var pg_god_1 = require("pg-god");
|
55
|
+
var utils_1 = require("@medusajs/utils");
|
56
|
+
var axios = require("axios").default;
|
57
|
+
var DB_HOST = process.env.DB_HOST;
|
58
|
+
var DB_USERNAME = process.env.DB_USERNAME;
|
59
|
+
var DB_PASSWORD = process.env.DB_PASSWORD;
|
60
|
+
var pgGodCredentials = {
|
14
61
|
user: DB_USERNAME,
|
15
62
|
password: DB_PASSWORD,
|
16
63
|
host: DB_HOST,
|
17
64
|
};
|
18
|
-
|
65
|
+
var dbTestUtilFactory = function () { return ({
|
66
|
+
db_: null,
|
19
67
|
pgConnection_: null,
|
20
|
-
|
21
|
-
|
68
|
+
clear: function () {
|
69
|
+
var _a;
|
70
|
+
return __awaiter(this, void 0, void 0, function () {
|
71
|
+
return __generator(this, function (_b) {
|
72
|
+
(_a = this.db_) === null || _a === void 0 ? void 0 : _a.synchronize(true);
|
73
|
+
return [2 /*return*/];
|
74
|
+
});
|
75
|
+
});
|
22
76
|
},
|
23
|
-
|
24
|
-
|
25
|
-
return
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
}
|
37
|
-
|
77
|
+
create: function (dbName) {
|
78
|
+
return __awaiter(this, void 0, void 0, function () {
|
79
|
+
return __generator(this, function (_a) {
|
80
|
+
switch (_a.label) {
|
81
|
+
case 0: return [4 /*yield*/, (0, pg_god_1.createDatabase)({ databaseName: dbName }, pgGodCredentials)];
|
82
|
+
case 1:
|
83
|
+
_a.sent();
|
84
|
+
return [2 /*return*/];
|
85
|
+
}
|
86
|
+
});
|
87
|
+
});
|
88
|
+
},
|
89
|
+
teardown: function (_a) {
|
90
|
+
var _b = _a === void 0 ? {} : _a, forceDelete = _b.forceDelete, schema = _b.schema;
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
92
|
+
var manager, tableNames, tableNames_1, tableNames_1_1, table_name, e_1_1;
|
93
|
+
var e_1, _c;
|
94
|
+
return __generator(this, function (_d) {
|
95
|
+
switch (_d.label) {
|
96
|
+
case 0:
|
97
|
+
forceDelete !== null && forceDelete !== void 0 ? forceDelete : (forceDelete = []);
|
98
|
+
if (!this.db_) {
|
99
|
+
return [2 /*return*/];
|
100
|
+
}
|
101
|
+
manager = this.db_.manager;
|
102
|
+
schema !== null && schema !== void 0 ? schema : (schema = "public");
|
103
|
+
return [4 /*yield*/, manager.query("SET session_replication_role = 'replica';")];
|
104
|
+
case 1:
|
105
|
+
_d.sent();
|
106
|
+
return [4 /*yield*/, manager.query("SELECT table_name\n FROM information_schema.tables\n WHERE table_schema = '".concat(schema, "';"))];
|
107
|
+
case 2:
|
108
|
+
tableNames = _d.sent();
|
109
|
+
_d.label = 3;
|
110
|
+
case 3:
|
111
|
+
_d.trys.push([3, 8, 9, 10]);
|
112
|
+
tableNames_1 = __values(tableNames), tableNames_1_1 = tableNames_1.next();
|
113
|
+
_d.label = 4;
|
114
|
+
case 4:
|
115
|
+
if (!!tableNames_1_1.done) return [3 /*break*/, 7];
|
116
|
+
table_name = tableNames_1_1.value.table_name;
|
117
|
+
return [4 /*yield*/, manager.query("DELETE\n FROM ".concat(schema, ".\"").concat(table_name, "\";"))];
|
118
|
+
case 5:
|
119
|
+
_d.sent();
|
120
|
+
_d.label = 6;
|
121
|
+
case 6:
|
122
|
+
tableNames_1_1 = tableNames_1.next();
|
123
|
+
return [3 /*break*/, 4];
|
124
|
+
case 7: return [3 /*break*/, 10];
|
125
|
+
case 8:
|
126
|
+
e_1_1 = _d.sent();
|
127
|
+
e_1 = { error: e_1_1 };
|
128
|
+
return [3 /*break*/, 10];
|
129
|
+
case 9:
|
130
|
+
try {
|
131
|
+
if (tableNames_1_1 && !tableNames_1_1.done && (_c = tableNames_1.return)) _c.call(tableNames_1);
|
132
|
+
}
|
133
|
+
finally { if (e_1) throw e_1.error; }
|
134
|
+
return [7 /*endfinally*/];
|
135
|
+
case 10: return [4 /*yield*/, manager.query("SET session_replication_role = 'origin';")];
|
136
|
+
case 11:
|
137
|
+
_d.sent();
|
138
|
+
return [2 /*return*/];
|
139
|
+
}
|
140
|
+
});
|
141
|
+
});
|
38
142
|
},
|
39
|
-
shutdown:
|
40
|
-
|
41
|
-
|
42
|
-
|
143
|
+
shutdown: function (dbName) {
|
144
|
+
var _a, _b, _c, _d;
|
145
|
+
return __awaiter(this, void 0, void 0, function () {
|
146
|
+
return __generator(this, function (_e) {
|
147
|
+
switch (_e.label) {
|
148
|
+
case 0: return [4 /*yield*/, ((_a = this.db_) === null || _a === void 0 ? void 0 : _a.destroy())];
|
149
|
+
case 1:
|
150
|
+
_e.sent();
|
151
|
+
return [4 /*yield*/, ((_c = (_b = this.pgConnection_) === null || _b === void 0 ? void 0 : _b.context) === null || _c === void 0 ? void 0 : _c.destroy())];
|
152
|
+
case 2:
|
153
|
+
_e.sent();
|
154
|
+
return [4 /*yield*/, ((_d = this.pgConnection_) === null || _d === void 0 ? void 0 : _d.destroy())];
|
155
|
+
case 3:
|
156
|
+
_e.sent();
|
157
|
+
return [4 /*yield*/, (0, pg_god_1.dropDatabase)({ databaseName: dbName, errorIfNonExist: false }, pgGodCredentials)];
|
158
|
+
case 4: return [2 /*return*/, _e.sent()];
|
159
|
+
}
|
160
|
+
});
|
161
|
+
});
|
43
162
|
},
|
44
|
-
});
|
45
|
-
function medusaIntegrationTestRunner(
|
46
|
-
|
47
|
-
moduleName = moduleName
|
48
|
-
|
49
|
-
|
50
|
-
|
163
|
+
}); };
|
164
|
+
function medusaIntegrationTestRunner(_a) {
|
165
|
+
var _this = this;
|
166
|
+
var moduleName = _a.moduleName, dbName = _a.dbName, _b = _a.schema, schema = _b === void 0 ? "public" : _b, _c = _a.env, env = _c === void 0 ? {} : _c, _d = _a.force_modules_migration, force_modules_migration = _d === void 0 ? false : _d, _e = _a.debug, debug = _e === void 0 ? false : _e, testSuite = _a.testSuite;
|
167
|
+
var tempName = parseInt(process.env.JEST_WORKER_ID || "1");
|
168
|
+
moduleName = moduleName !== null && moduleName !== void 0 ? moduleName : Math.random().toString(36).substring(7);
|
169
|
+
dbName !== null && dbName !== void 0 ? dbName : (dbName = "medusa-".concat(moduleName.toLowerCase(), "-integration-").concat(tempName));
|
170
|
+
var dbConfig = {
|
171
|
+
dbName: dbName,
|
51
172
|
clientUrl: (0, database_1.getDatabaseURL)(dbName),
|
52
|
-
schema,
|
53
|
-
debug,
|
173
|
+
schema: schema,
|
174
|
+
debug: debug,
|
54
175
|
};
|
55
|
-
|
56
|
-
require("@medusajs/medusa/dist/loaders/config").default = (rootDirectory)
|
57
|
-
|
58
|
-
config.projectConfig.
|
59
|
-
config.projectConfig.
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
},
|
66
|
-
idle_in_transaction_session_timeout: 20000,
|
67
|
-
};
|
176
|
+
var originalConfigLoader = require("@medusajs/medusa/dist/loaders/config").default;
|
177
|
+
require("@medusajs/medusa/dist/loaders/config").default = function (rootDirectory) {
|
178
|
+
var config = originalConfigLoader(rootDirectory);
|
179
|
+
config.projectConfig.database_url = dbConfig.clientUrl;
|
180
|
+
config.projectConfig.database_driver_options = dbConfig.clientUrl.includes("localhost") ? {} : {
|
181
|
+
connection: {
|
182
|
+
ssl: { rejectUnauthorized: false },
|
183
|
+
},
|
184
|
+
idle_in_transaction_session_timeout: 20000,
|
185
|
+
};
|
68
186
|
return config;
|
69
187
|
};
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
188
|
+
var cwd = process.cwd();
|
189
|
+
var shutdown = function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
190
|
+
return [2 /*return*/, void 0];
|
191
|
+
}); }); };
|
192
|
+
var dbUtils = dbTestUtilFactory();
|
193
|
+
var container;
|
194
|
+
var apiUtils;
|
195
|
+
var options = {
|
196
|
+
dbUtils: dbUtils,
|
76
197
|
api: new Proxy({}, {
|
77
|
-
get: (target, prop)
|
198
|
+
get: function (target, prop) {
|
78
199
|
return apiUtils[prop];
|
79
200
|
},
|
80
201
|
}),
|
81
202
|
dbConnection: new Proxy({}, {
|
82
|
-
get: (target, prop)
|
83
|
-
return dbUtils.
|
203
|
+
get: function (target, prop) {
|
204
|
+
return dbUtils.db_[prop];
|
84
205
|
},
|
85
206
|
}),
|
86
|
-
getContainer: ()
|
87
|
-
dbConfig: {
|
88
|
-
dbName,
|
89
|
-
schema,
|
90
|
-
clientUrl: dbConfig.clientUrl,
|
91
|
-
},
|
92
|
-
dbUtils,
|
207
|
+
getContainer: function () { return container; },
|
93
208
|
};
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
209
|
+
var isFirstTime = true;
|
210
|
+
var beforeAll_ = function () { return __awaiter(_this, void 0, void 0, function () {
|
211
|
+
var dataSourceRes, pgConnectionRes, _a, dbDataSource, pgConnection, error_1, containerRes, serverShutdownRes, portRes, _b, _c, shutdown_1, container_1, port, error_2, cancelTokenSource;
|
212
|
+
var _this = this;
|
213
|
+
return __generator(this, function (_d) {
|
214
|
+
switch (_d.label) {
|
215
|
+
case 0: return [4 /*yield*/, dbUtils.create(dbName)];
|
216
|
+
case 1:
|
217
|
+
_d.sent();
|
218
|
+
_d.label = 2;
|
219
|
+
case 2:
|
220
|
+
_d.trys.push([2, 4, , 5]);
|
221
|
+
return [4 /*yield*/, (0, use_db_1.initDb)({
|
222
|
+
cwd: cwd,
|
223
|
+
env: env,
|
224
|
+
force_modules_migration: force_modules_migration,
|
225
|
+
database_extra: {},
|
226
|
+
dbUrl: dbConfig.clientUrl,
|
227
|
+
dbSchema: dbConfig.schema,
|
228
|
+
})];
|
229
|
+
case 3:
|
230
|
+
_a = _d.sent(), dbDataSource = _a.dbDataSource, pgConnection = _a.pgConnection;
|
231
|
+
dataSourceRes = dbDataSource;
|
232
|
+
pgConnectionRes = pgConnection;
|
233
|
+
return [3 /*break*/, 5];
|
234
|
+
case 4:
|
235
|
+
error_1 = _d.sent();
|
236
|
+
console.error("Error initializing database", error_1 === null || error_1 === void 0 ? void 0 : error_1.message);
|
237
|
+
throw error_1;
|
238
|
+
case 5:
|
239
|
+
dbUtils.db_ = dataSourceRes;
|
240
|
+
dbUtils.pgConnection_ = pgConnectionRes;
|
241
|
+
_d.label = 6;
|
242
|
+
case 6:
|
243
|
+
_d.trys.push([6, 8, , 9]);
|
244
|
+
return [4 /*yield*/, (0, bootstrap_app_1.startBootstrapApp)({
|
245
|
+
cwd: cwd,
|
246
|
+
env: env,
|
247
|
+
})];
|
248
|
+
case 7:
|
249
|
+
_b = _d.sent(), _c = _b.shutdown, shutdown_1 = _c === void 0 ? function () { return void 0; } : _c, container_1 = _b.container, port = _b.port;
|
250
|
+
containerRes = container_1;
|
251
|
+
serverShutdownRes = shutdown_1;
|
252
|
+
portRes = port;
|
253
|
+
return [3 /*break*/, 9];
|
254
|
+
case 8:
|
255
|
+
error_2 = _d.sent();
|
256
|
+
console.error("Error starting the app", error_2 === null || error_2 === void 0 ? void 0 : error_2.message);
|
257
|
+
throw error_2;
|
258
|
+
case 9:
|
259
|
+
cancelTokenSource = axios.CancelToken.source();
|
260
|
+
container = containerRes;
|
261
|
+
shutdown = function () { return __awaiter(_this, void 0, void 0, function () {
|
262
|
+
return __generator(this, function (_a) {
|
263
|
+
switch (_a.label) {
|
264
|
+
case 0: return [4 /*yield*/, serverShutdownRes()];
|
265
|
+
case 1:
|
266
|
+
_a.sent();
|
267
|
+
cancelTokenSource.cancel("Request canceled by shutdown");
|
268
|
+
return [2 /*return*/];
|
269
|
+
}
|
270
|
+
});
|
271
|
+
}); };
|
272
|
+
apiUtils = axios.create({
|
273
|
+
baseURL: "http://localhost:".concat(portRes),
|
274
|
+
cancelToken: cancelTokenSource.token,
|
275
|
+
});
|
276
|
+
return [2 /*return*/];
|
277
|
+
}
|
133
278
|
});
|
134
|
-
};
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
279
|
+
}); };
|
280
|
+
var beforeEach_ = function () { return __awaiter(_this, void 0, void 0, function () {
|
281
|
+
var container, copiedContainer, defaultLoader, error_3, medusaAppLoaderRunner, error_4;
|
282
|
+
return __generator(this, function (_a) {
|
283
|
+
switch (_a.label) {
|
284
|
+
case 0:
|
285
|
+
// The beforeAll already run everything, so lets not re run the loaders for the first iteration
|
286
|
+
if (isFirstTime) {
|
287
|
+
isFirstTime = false;
|
288
|
+
return [2 /*return*/];
|
289
|
+
}
|
290
|
+
container = options.getContainer();
|
291
|
+
copiedContainer = (0, utils_1.createMedusaContainer)({}, container);
|
292
|
+
if (!(process.env.MEDUSA_FF_MEDUSA_V2 != "true")) return [3 /*break*/, 4];
|
293
|
+
_a.label = 1;
|
294
|
+
case 1:
|
295
|
+
_a.trys.push([1, 3, , 4]);
|
296
|
+
defaultLoader = require("@medusajs/medusa/dist/loaders/defaults").default;
|
297
|
+
return [4 /*yield*/, defaultLoader({
|
298
|
+
container: copiedContainer,
|
299
|
+
})];
|
300
|
+
case 2:
|
301
|
+
_a.sent();
|
302
|
+
return [3 /*break*/, 4];
|
303
|
+
case 3:
|
304
|
+
error_3 = _a.sent();
|
305
|
+
console.error("Error runner medusa loaders", error_3 === null || error_3 === void 0 ? void 0 : error_3.message);
|
306
|
+
throw error_3;
|
307
|
+
case 4:
|
308
|
+
_a.trys.push([4, 6, , 7]);
|
309
|
+
medusaAppLoaderRunner = require("@medusajs/medusa/dist/loaders/medusa-app").runModulesLoader;
|
310
|
+
return [4 /*yield*/, medusaAppLoaderRunner({
|
311
|
+
container: copiedContainer,
|
312
|
+
configModule: container.resolve("configModule"),
|
313
|
+
})];
|
314
|
+
case 5:
|
315
|
+
_a.sent();
|
316
|
+
return [3 /*break*/, 7];
|
317
|
+
case 6:
|
318
|
+
error_4 = _a.sent();
|
319
|
+
console.error("Error runner modules loaders", error_4 === null || error_4 === void 0 ? void 0 : error_4.message);
|
320
|
+
throw error_4;
|
321
|
+
case 7: return [2 /*return*/];
|
322
|
+
}
|
323
|
+
});
|
324
|
+
}); };
|
325
|
+
var afterEach_ = function () { return __awaiter(_this, void 0, void 0, function () {
|
326
|
+
var error_5;
|
327
|
+
return __generator(this, function (_a) {
|
328
|
+
switch (_a.label) {
|
329
|
+
case 0:
|
330
|
+
_a.trys.push([0, 2, , 3]);
|
331
|
+
return [4 /*yield*/, dbUtils.teardown({ schema: schema })];
|
332
|
+
case 1:
|
333
|
+
_a.sent();
|
334
|
+
return [3 /*break*/, 3];
|
335
|
+
case 2:
|
336
|
+
error_5 = _a.sent();
|
337
|
+
console.error("Error tearing down database:", error_5 === null || error_5 === void 0 ? void 0 : error_5.message);
|
338
|
+
throw error_5;
|
339
|
+
case 3: return [2 /*return*/];
|
340
|
+
}
|
341
|
+
});
|
342
|
+
}); };
|
343
|
+
return describe("", function () {
|
165
344
|
beforeAll(beforeAll_);
|
166
345
|
beforeEach(beforeEach_);
|
167
346
|
afterEach(afterEach_);
|
168
|
-
afterAll(
|
169
|
-
|
170
|
-
|
171
|
-
|
347
|
+
afterAll(function () { return __awaiter(_this, void 0, void 0, function () {
|
348
|
+
return __generator(this, function (_a) {
|
349
|
+
switch (_a.label) {
|
350
|
+
case 0: return [4 /*yield*/, dbUtils.shutdown(dbName)];
|
351
|
+
case 1:
|
352
|
+
_a.sent();
|
353
|
+
return [4 /*yield*/, shutdown()];
|
354
|
+
case 2:
|
355
|
+
_a.sent();
|
356
|
+
return [2 /*return*/];
|
357
|
+
}
|
358
|
+
});
|
359
|
+
}); });
|
172
360
|
testSuite(options);
|
173
361
|
});
|
174
362
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"medusa-test-runner.js","sourceRoot":"","sources":["../src/medusa-test-runner.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"medusa-test-runner.js","sourceRoot":"","sources":["../src/medusa-test-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA2C;AAC3C,4DAA0D;AAC1D,0EAA4E;AAC5E,iCAAqD;AAErD,yCAAuD;AAEvD,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAA;AAEtC,IAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAA;AACnC,IAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;AAC3C,IAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;AAE3C,IAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,WAAW;IACrB,IAAI,EAAE,OAAO;CACd,CAAA;AAED,IAAM,iBAAiB,GAAG,cAAW,OAAA,CAAC;IACpC,GAAG,EAAE,IAAI;IACT,aAAa,EAAE,IAAI;IAEnB,KAAK,EAAE;;;;gBACL,MAAA,IAAI,CAAC,GAAG,0CAAE,WAAW,CAAC,IAAI,CAAC,CAAA;;;;KAC5B;IAED,MAAM,EAAE,UAAgB,MAAc;;;;4BACpC,qBAAM,IAAA,uBAAc,EAAC,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,gBAAgB,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AK,CAAA;;;;SAEd,CAAA;IAED,OAAO,QAAQ,CAAC,EAAE,EAAE;QAClB,SAAS,CAAC,UAAU,CAAC,CAAA;QACrB,UAAU,CAAC,WAAW,CAAC,CAAA;QACvB,SAAS,CAAC,UAAU,CAAC,CAAA;QACrB,QAAQ,CAAC;;;4BACP,qBAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAA;;wBAA9B,SAA8B,CAAA;wBAC9B,qBAAM,QAAQ,EAAE,EAAA;;wBAAhB,SAAgB,CAAA;;;;aACjB,CAAC,CAAA;QAEF,SAAS,CAAC,OAAQ,CAAC,CAAA;IACrB,CAAC,CAAC,CAAA;AACJ,CAAC;AA/LD,kEA+LC"}
|
@@ -1,9 +1,8 @@
|
|
1
|
-
import { EventBusTypes, IEventBusModuleService, Message, Subscriber } from "@medusajs/types";
|
1
|
+
import { EmitData, EventBusTypes, IEventBusModuleService, Message, Subscriber } from "@medusajs/types";
|
2
2
|
export default class EventBusService implements IEventBusModuleService {
|
3
|
-
emit<T>(
|
3
|
+
emit<T>(eventName: string, data: T, options?: Record<string, unknown>): Promise<void>;
|
4
|
+
emit<T>(data: EmitData<T>[]): Promise<void>;
|
5
|
+
emit<T>(data: Message<T>[]): Promise<void>;
|
4
6
|
subscribe(event: string | symbol, subscriber: Subscriber): this;
|
5
7
|
unsubscribe(event: string | symbol, subscriber: Subscriber, context?: EventBusTypes.SubscriberContext): this;
|
6
|
-
releaseGroupedEvents(eventGroupId: string): Promise<void>;
|
7
|
-
clearGroupedEvents(eventGroupId: string): Promise<void>;
|
8
8
|
}
|
9
|
-
//# sourceMappingURL=mock-event-bus-service.d.ts.map
|
@@ -1,19 +1,57 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
|
4
|
-
|
5
|
-
subscribe(event, subscriber) {
|
6
|
-
return this;
|
39
|
+
var EventBusService = /** @class */ (function () {
|
40
|
+
function EventBusService() {
|
7
41
|
}
|
8
|
-
|
42
|
+
EventBusService.prototype.emit = function (eventOrData, data, options) {
|
43
|
+
if (options === void 0) { options = {}; }
|
44
|
+
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
45
|
+
return [2 /*return*/];
|
46
|
+
}); });
|
47
|
+
};
|
48
|
+
EventBusService.prototype.subscribe = function (event, subscriber) {
|
9
49
|
return this;
|
10
|
-
}
|
11
|
-
|
12
|
-
return
|
13
|
-
}
|
14
|
-
|
15
|
-
|
16
|
-
}
|
17
|
-
}
|
50
|
+
};
|
51
|
+
EventBusService.prototype.unsubscribe = function (event, subscriber, context) {
|
52
|
+
return this;
|
53
|
+
};
|
54
|
+
return EventBusService;
|
55
|
+
}());
|
18
56
|
exports.default = EventBusService;
|
19
57
|
//# sourceMappingURL=mock-event-bus-service.js.map
|