medusa-test-utils 1.1.45 → 2.0.0-rc-20241003153304

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. package/dist/database.d.ts +2 -0
  2. package/dist/database.d.ts.map +1 -0
  3. package/dist/database.js +100 -146
  4. package/dist/database.js.map +1 -1
  5. package/dist/events.d.ts +3 -0
  6. package/dist/events.d.ts.map +1 -0
  7. package/dist/events.js +41 -0
  8. package/dist/events.js.map +1 -0
  9. package/dist/id-map.d.ts +3 -2
  10. package/dist/id-map.d.ts.map +1 -0
  11. package/dist/id-map.js +8 -11
  12. package/dist/id-map.js.map +1 -1
  13. package/dist/index.d.ts +5 -4
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +5 -7
  16. package/dist/index.js.map +1 -1
  17. package/dist/init-modules.d.ts +2 -1
  18. package/dist/init-modules.d.ts.map +1 -0
  19. package/dist/init-modules.js +39 -97
  20. package/dist/init-modules.js.map +1 -1
  21. package/dist/jest.d.ts +1 -0
  22. package/dist/jest.d.ts.map +1 -0
  23. package/dist/jest.js +15 -64
  24. package/dist/jest.js.map +1 -1
  25. package/dist/medusa-test-runner-utils/bootstrap-app.d.ts +10 -5
  26. package/dist/medusa-test-runner-utils/bootstrap-app.d.ts.map +1 -0
  27. package/dist/medusa-test-runner-utils/bootstrap-app.js +53 -147
  28. package/dist/medusa-test-runner-utils/bootstrap-app.js.map +1 -1
  29. package/dist/medusa-test-runner-utils/clear-instances.d.ts +8 -0
  30. package/dist/medusa-test-runner-utils/clear-instances.d.ts.map +1 -0
  31. package/dist/medusa-test-runner-utils/clear-instances.js +14 -0
  32. package/dist/medusa-test-runner-utils/clear-instances.js.map +1 -0
  33. package/dist/medusa-test-runner-utils/config.d.ts +5 -0
  34. package/dist/medusa-test-runner-utils/config.d.ts.map +1 -0
  35. package/dist/medusa-test-runner-utils/config.js +28 -0
  36. package/dist/medusa-test-runner-utils/config.js.map +1 -0
  37. package/dist/medusa-test-runner-utils/index.d.ts +6 -0
  38. package/dist/medusa-test-runner-utils/index.d.ts.map +1 -0
  39. package/dist/medusa-test-runner-utils/index.js +22 -0
  40. package/dist/medusa-test-runner-utils/index.js.map +1 -0
  41. package/dist/medusa-test-runner-utils/use-db.d.ts +15 -12
  42. package/dist/medusa-test-runner-utils/use-db.d.ts.map +1 -0
  43. package/dist/medusa-test-runner-utils/use-db.js +51 -143
  44. package/dist/medusa-test-runner-utils/use-db.js.map +1 -1
  45. package/dist/medusa-test-runner-utils/utils.d.ts +2 -0
  46. package/dist/medusa-test-runner-utils/utils.d.ts.map +1 -0
  47. package/dist/medusa-test-runner-utils/utils.js +10 -0
  48. package/dist/medusa-test-runner-utils/utils.js.map +1 -0
  49. package/dist/medusa-test-runner.d.ts +16 -6
  50. package/dist/medusa-test-runner.d.ts.map +1 -0
  51. package/dist/medusa-test-runner.js +123 -343
  52. package/dist/medusa-test-runner.js.map +1 -1
  53. package/dist/mock-event-bus-service.d.ts +5 -4
  54. package/dist/mock-event-bus-service.d.ts.map +1 -0
  55. package/dist/mock-event-bus-service.js +13 -51
  56. package/dist/mock-event-bus-service.js.map +1 -1
  57. package/dist/module-test-runner.d.ts +4 -2
  58. package/dist/module-test-runner.d.ts.map +1 -0
  59. package/dist/module-test-runner.js +117 -132
  60. package/dist/module-test-runner.js.map +1 -1
  61. package/dist/tsconfig.tsbuildinfo +1 -0
  62. package/package.json +28 -39
  63. package/dist/mock-manager.d.ts +0 -9
  64. package/dist/mock-manager.js +0 -30
  65. package/dist/mock-manager.js.map +0 -1
  66. package/dist/mock-repository.d.ts +0 -51
  67. package/dist/mock-repository.js +0 -193
  68. package/dist/mock-repository.js.map +0 -1
@@ -1,364 +1,144 @@
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
- };
49
2
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.medusaIntegrationTestRunner = void 0;
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 = {
61
- user: DB_USERNAME,
62
- password: DB_PASSWORD,
63
- host: DB_HOST,
64
- };
65
- var dbTestUtilFactory = function () { return ({
66
- db_: null,
67
- pgConnection_: null,
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
- });
76
- },
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
- });
142
- },
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
- });
162
- },
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,
3
+ exports.medusaIntegrationTestRunner = medusaIntegrationTestRunner;
4
+ const utils_1 = require("@medusajs/framework/utils");
5
+ const awilix_1 = require("awilix");
6
+ const database_1 = require("./database");
7
+ const medusa_test_runner_utils_1 = require("./medusa-test-runner-utils");
8
+ function medusaIntegrationTestRunner({ moduleName, dbName, medusaConfigFile, schema = "public", env = {}, debug = false, inApp = false, testSuite, }) {
9
+ const tempName = parseInt(process.env.JEST_WORKER_ID || "1");
10
+ moduleName = moduleName ?? Math.random().toString(36).substring(7);
11
+ dbName ??= `medusa-${moduleName.toLowerCase()}-integration-${tempName}`;
12
+ let dbConfig = {
13
+ dbName,
172
14
  clientUrl: (0, database_1.getDatabaseURL)(dbName),
173
- schema: schema,
174
- debug: debug,
15
+ schema,
16
+ debug,
175
17
  };
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
- };
186
- return config;
187
- };
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,
18
+ const cwd = medusaConfigFile ?? process.cwd();
19
+ let shutdown = async () => void 0;
20
+ const dbUtils = (0, database_1.dbTestUtilFactory)();
21
+ let globalContainer;
22
+ let apiUtils;
23
+ let loadedApplication;
24
+ let options = {
197
25
  api: new Proxy({}, {
198
- get: function (target, prop) {
26
+ get: (target, prop) => {
199
27
  return apiUtils[prop];
200
28
  },
201
29
  }),
202
30
  dbConnection: new Proxy({}, {
203
- get: function (target, prop) {
204
- return dbUtils.db_[prop];
31
+ get: (target, prop) => {
32
+ return dbUtils.pgConnection_[prop];
205
33
  },
206
34
  }),
207
- getContainer: function () { return container; },
35
+ getMedusaApp: () => loadedApplication,
36
+ getContainer: () => globalContainer,
37
+ dbConfig: {
38
+ dbName,
39
+ schema,
40
+ clientUrl: dbConfig.clientUrl,
41
+ },
42
+ dbUtils,
208
43
  };
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
- }
278
- });
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
- }
44
+ let isFirstTime = true;
45
+ const beforeAll_ = async () => {
46
+ await (0, medusa_test_runner_utils_1.configLoaderOverride)(cwd, dbConfig);
47
+ (0, medusa_test_runner_utils_1.applyEnvVarsToProcess)(env);
48
+ const { logger, container, MedusaAppLoader } = await import("@medusajs/framework");
49
+ const appLoader = new MedusaAppLoader();
50
+ container.register({
51
+ [utils_1.ContainerRegistrationKeys.LOGGER]: (0, awilix_1.asValue)(logger),
323
52
  });
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
- }
53
+ try {
54
+ console.log(`Creating database ${dbName}`);
55
+ await dbUtils.create(dbName);
56
+ dbUtils.pgConnection_ = await (0, medusa_test_runner_utils_1.initDb)();
57
+ }
58
+ catch (error) {
59
+ console.error("Error initializing database", error?.message);
60
+ throw error;
61
+ }
62
+ console.log(`Migrating database with core migrations and links ${dbName}`);
63
+ await (0, medusa_test_runner_utils_1.migrateDatabase)(appLoader);
64
+ await (0, medusa_test_runner_utils_1.syncLinks)(appLoader, cwd, container);
65
+ await (0, medusa_test_runner_utils_1.clearInstances)();
66
+ let containerRes = container;
67
+ let serverShutdownRes;
68
+ let portRes;
69
+ loadedApplication = await appLoader.load();
70
+ try {
71
+ const { shutdown = () => void 0, container: appContainer, port, } = await (0, medusa_test_runner_utils_1.startApp)({
72
+ cwd,
73
+ env,
74
+ });
75
+ containerRes = appContainer;
76
+ serverShutdownRes = shutdown;
77
+ portRes = port;
78
+ }
79
+ catch (error) {
80
+ console.error("Error starting the app", error?.message);
81
+ throw error;
82
+ }
83
+ /**
84
+ * Run application migrations and sync links when inside
85
+ * an application
86
+ */
87
+ if (inApp) {
88
+ console.log(`Migrating database with core migrations and links ${dbName}`);
89
+ await (0, medusa_test_runner_utils_1.migrateDatabase)(appLoader);
90
+ await (0, medusa_test_runner_utils_1.syncLinks)(appLoader, cwd, containerRes);
91
+ }
92
+ const { default: axios } = (await import("axios"));
93
+ const cancelTokenSource = axios.CancelToken.source();
94
+ globalContainer = containerRes;
95
+ shutdown = async () => {
96
+ await serverShutdownRes();
97
+ cancelTokenSource.cancel("Request canceled by shutdown");
98
+ };
99
+ apiUtils = axios.create({
100
+ baseURL: `http://localhost:${portRes}`,
101
+ cancelToken: cancelTokenSource.token,
341
102
  });
342
- }); };
343
- return describe("", function () {
103
+ };
104
+ const beforeEach_ = async () => {
105
+ // The beforeAll already run everything, so lets not re run the loaders for the first iteration
106
+ if (isFirstTime) {
107
+ isFirstTime = false;
108
+ return;
109
+ }
110
+ const container = options.getContainer();
111
+ const copiedContainer = (0, utils_1.createMedusaContainer)({}, container);
112
+ try {
113
+ const { MedusaAppLoader } = await import("@medusajs/framework");
114
+ const medusaAppLoader = new MedusaAppLoader({
115
+ container: copiedContainer,
116
+ });
117
+ await medusaAppLoader.runModulesLoader();
118
+ }
119
+ catch (error) {
120
+ console.error("Error runner modules loaders", error?.message);
121
+ throw error;
122
+ }
123
+ };
124
+ const afterEach_ = async () => {
125
+ try {
126
+ await dbUtils.teardown({ schema });
127
+ }
128
+ catch (error) {
129
+ console.error("Error tearing down database:", error?.message);
130
+ throw error;
131
+ }
132
+ };
133
+ return describe("", () => {
344
134
  beforeAll(beforeAll_);
345
135
  beforeEach(beforeEach_);
346
136
  afterEach(afterEach_);
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
- }); });
137
+ afterAll(async () => {
138
+ await dbUtils.shutdown(dbName);
139
+ await shutdown();
140
+ });
360
141
  testSuite(options);
361
142
  });
362
143
  }
363
- exports.medusaIntegrationTestRunner = medusaIntegrationTestRunner;
364
144
  //# sourceMappingURL=medusa-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O,CAAC,CAAA;YAC7D,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC,CAAA;IAED,OAAO,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE;QACvB,SAAS,CAAC,UAAU,CAAC,CAAA;QACrB,UAAU,CAAC,WAAW,CAAC,CAAA;QACvB,SAAS,CAAC,UAAU,CAAC,CAAA;QACrB,QAAQ,CAAC,KAAK,IAAI,EAAE;YAClB,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;YAC9B,MAAM,QAAQ,EAAE,CAAA;QAClB,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,OAAQ,CAAC,CAAA;IACrB,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,8 +1,9 @@
1
- import { EmitData, EventBusTypes, IEventBusModuleService, Message, Subscriber } from "@medusajs/types";
1
+ import { EventBusTypes, IEventBusModuleService, Message, Subscriber } from "@medusajs/framework/types";
2
2
  export default class EventBusService implements IEventBusModuleService {
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>;
3
+ emit<T>(data: Message<T> | Message<T>[], options: Record<string, unknown>): Promise<void>;
6
4
  subscribe(event: string | symbol, subscriber: Subscriber): this;
7
5
  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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-event-bus-service.d.ts","sourceRoot":"","sources":["../src/mock-event-bus-service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,OAAO,EACP,UAAU,EACX,MAAM,2BAA2B,CAAA;AAElC,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,sBAAsB;IAC9D,IAAI,CAAC,CAAC,EACV,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,EAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,IAAI,CAAC;IAEhB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAI/D,WAAW,CACT,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,aAAa,CAAC,iBAAiB,GACxC,IAAI;IAIP,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxD"}
@@ -1,57 +1,19 @@
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
- var EventBusService = /** @class */ (function () {
40
- function EventBusService() {
41
- }
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) {
3
+ class EventBusService {
4
+ async emit(data, options) { }
5
+ subscribe(event, subscriber) {
49
6
  return this;
50
- };
51
- EventBusService.prototype.unsubscribe = function (event, subscriber, context) {
7
+ }
8
+ unsubscribe(event, subscriber, context) {
52
9
  return this;
53
- };
54
- return EventBusService;
55
- }());
10
+ }
11
+ releaseGroupedEvents(eventGroupId) {
12
+ return Promise.resolve();
13
+ }
14
+ clearGroupedEvents(eventGroupId) {
15
+ return Promise.resolve();
16
+ }
17
+ }
56
18
  exports.default = EventBusService;
57
19
  //# sourceMappingURL=mock-event-bus-service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mock-event-bus-service.js","sourceRoot":"","sources":["../src/mock-event-bus-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;IAAA;IAgCA,CAAC;IAvBO,8BAAI,GAAV,UAOE,WAAmB,EACnB,IAAQ,EACR,OAAqC;QAArC,wBAAA,EAAA,YAAqC;;;;KACpB;IAEnB,mCAAS,GAAT,UAAU,KAAsB,EAAE,UAAsB;QACtD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,qCAAW,GAAX,UACE,KAAsB,EACtB,UAAsB,EACtB,OAAyC;QAEzC,OAAO,IAAI,CAAA;IACb,CAAC;IACH,sBAAC;AAAD,CAAC,AAhCD,IAgCC"}
1
+ {"version":3,"file":"mock-event-bus-service.js","sourceRoot":"","sources":["../src/mock-event-bus-service.ts"],"names":[],"mappings":";;AAOA,MAAqB,eAAe;IAClC,KAAK,CAAC,IAAI,CACR,IAA+B,EAC/B,OAAgC,IAChB,CAAC;IAEnB,SAAS,CAAC,KAAsB,EAAE,UAAsB;QACtD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,WAAW,CACT,KAAsB,EACtB,UAAsB,EACtB,OAAyC;QAEzC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,oBAAoB,CAAC,YAAoB;QACvC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IAC1B,CAAC;IAED,kBAAkB,CAAC,YAAoB;QACrC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IAC1B,CAAC;CACF;AAzBD,kCAyBC"}