@quenty/gameproductservice 14.74.3 → 14.75.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [14.75.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/gameproductservice@14.74.3...@quenty/gameproductservice@14.75.0) (2026-10-14)
7
+
8
+ ### Features
9
+
10
+ - BindToClose service has a public method tests can use, simplify tests ([be4ca98](https://github.com/Quenty/NevermoreEngine/commit/be4ca986671cfd9b0757acc4f9ab85e6bfb7f38e))
11
+
6
12
  ## [14.74.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/gameproductservice@14.74.2...@quenty/gameproductservice@14.74.3) (2026-10-09)
7
13
 
8
14
  **Note:** Version bump only for package @quenty/gameproductservice
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/gameproductservice",
3
- "version": "14.74.3",
3
+ "version": "14.75.0",
4
4
  "description": "Generalized monetization system for handling products and purchases correctly.",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -30,40 +30,40 @@
30
30
  "access": "public"
31
31
  },
32
32
  "dependencies": {
33
- "@quenty/attributeutils": "14.38.2",
34
- "@quenty/avatareditorutils": "7.54.2",
33
+ "@quenty/attributeutils": "14.39.0",
34
+ "@quenty/avatareditorutils": "7.55.0",
35
35
  "@quenty/baseobject": "10.16.2",
36
- "@quenty/binder": "14.47.2",
37
- "@quenty/brio": "14.37.2",
38
- "@quenty/cmdrservice": "13.63.3",
36
+ "@quenty/binder": "14.48.0",
37
+ "@quenty/brio": "14.38.0",
38
+ "@quenty/cmdrservice": "13.64.0",
39
39
  "@quenty/enumutils": "3.4.6",
40
- "@quenty/gameconfig": "12.70.3",
41
- "@quenty/instanceutils": "13.37.2",
40
+ "@quenty/gameconfig": "12.71.0",
41
+ "@quenty/instanceutils": "13.38.0",
42
42
  "@quenty/jestutils": "1.1.2",
43
43
  "@quenty/loader": "10.11.3",
44
44
  "@quenty/maid": "3.12.2",
45
- "@quenty/marketplaceutils": "11.34.2",
45
+ "@quenty/marketplaceutils": "11.35.0",
46
46
  "@quenty/nevermore-test-runner": "1.6.2",
47
- "@quenty/observablecollection": "12.53.2",
48
- "@quenty/permissionprovider": "14.53.2",
49
- "@quenty/playerbinder": "14.51.2",
50
- "@quenty/playermock": "1.10.2",
51
- "@quenty/playerutils": "8.45.2",
52
- "@quenty/promise": "10.24.2",
53
- "@quenty/promisemaid": "5.24.2",
54
- "@quenty/receiptprocessing": "7.46.2",
55
- "@quenty/remoting": "12.45.2",
56
- "@quenty/rx": "13.34.2",
57
- "@quenty/rxbinderutils": "14.47.2",
47
+ "@quenty/observablecollection": "12.54.0",
48
+ "@quenty/permissionprovider": "14.54.0",
49
+ "@quenty/playerbinder": "14.52.0",
50
+ "@quenty/playermock": "1.11.0",
51
+ "@quenty/playerutils": "8.46.0",
52
+ "@quenty/promise": "10.25.0",
53
+ "@quenty/promisemaid": "5.25.0",
54
+ "@quenty/receiptprocessing": "7.47.0",
55
+ "@quenty/remoting": "12.46.0",
56
+ "@quenty/rx": "13.35.0",
57
+ "@quenty/rxbinderutils": "14.48.0",
58
58
  "@quenty/servicebag": "11.21.2",
59
59
  "@quenty/signal": "7.13.4",
60
- "@quenty/statestack": "14.39.2",
60
+ "@quenty/statestack": "14.40.0",
61
61
  "@quenty/steputils": "3.9.2",
62
62
  "@quenty/string": "3.5.2",
63
63
  "@quenty/table": "3.9.2",
64
- "@quenty/tie": "10.51.3",
65
- "@quenty/valueobject": "13.38.2",
64
+ "@quenty/tie": "10.52.0",
65
+ "@quenty/valueobject": "13.39.0",
66
66
  "@quentystudios/jest-lua": "3.10.0-quenty.2"
67
67
  },
68
- "gitHead": "3286fd397c9c42e7f29c8a881ac7dde12887e783"
68
+ "gitHead": "6b26147a6b432f17270769342498b4f2f08f60b1"
69
69
  }
@@ -79,12 +79,6 @@ local function setup()
79
79
  gameProductServiceClient = gameProductServiceClient,
80
80
  gameConfigService = gameConfigService,
81
81
  playerMock = playerMock,
82
- awaitBool = function(promise: any): boolean
83
- expect(PromiseTestUtils.awaitSettled(promise, 10)).toEqual(true)
84
- local ok, value = promise:Yield()
85
- expect(ok).toEqual(true)
86
- return value
87
- end,
88
82
  Destroy = function(_self)
89
83
  clientBag:Destroy()
90
84
  serverBag:Destroy()
@@ -129,7 +123,7 @@ describe("GameProductService server ownership from an injected lookup", function
129
123
  PlayerMock.writeLookup(controller.playerMock, "MarketplaceService.UserOwnsGamePassAsync", true, GAME_PASS_ID)
130
124
 
131
125
  expect(
132
- controller.awaitBool(
126
+ PromiseTestUtils.awaitFulfilled(
133
127
  controller.gameProductService:PromisePlayerOwnership(
134
128
  controller.playerMock,
135
129
  GameConfigAssetTypes.PASS,
@@ -138,7 +132,7 @@ describe("GameProductService server ownership from an injected lookup", function
138
132
  )
139
133
  ).toEqual(false)
140
134
  expect(
141
- controller.awaitBool(
135
+ PromiseTestUtils.awaitFulfilled(
142
136
  controller.gameProductService:PromisePlayerOwnership(
143
137
  controller.playerMock,
144
138
  GameConfigAssetTypes.PASS,
@@ -156,7 +150,7 @@ describe("GameProductService server ownership from an injected lookup", function
156
150
  PlayerMock.writeLookup(controller.playerMock, "MarketplaceService.UserOwnsGamePassAsync", true, GAME_PASS_ID)
157
151
 
158
152
  expect(
159
- controller.awaitBool(
153
+ PromiseTestUtils.awaitFulfilled(
160
154
  controller.gameProductService:PromisePlayerOwnership(
161
155
  controller.playerMock,
162
156
  GameConfigAssetTypes.PASS,
@@ -190,7 +184,7 @@ describe("GameProductService ownership override", function()
190
184
  local controller = setup()
191
185
  PlayerMock.writeLookup(controller.playerMock, "MarketplaceService.UserOwnsGamePassAsync", true, GAME_PASS_ID)
192
186
 
193
- controller.awaitBool(
187
+ PromiseTestUtils.awaitFulfilled(
194
188
  controller.gameProductService:SetPlayerOwnershipOverride(
195
189
  controller.playerMock,
196
190
  GameConfigAssetTypes.PASS,
@@ -200,7 +194,7 @@ describe("GameProductService ownership override", function()
200
194
  )
201
195
 
202
196
  expect(
203
- controller.awaitBool(
197
+ PromiseTestUtils.awaitFulfilled(
204
198
  controller.gameProductService:PromisePlayerOwnership(
205
199
  controller.playerMock,
206
200
  GameConfigAssetTypes.PASS,
@@ -216,7 +210,7 @@ describe("GameProductService ownership override", function()
216
210
  local controller = setup()
217
211
  PlayerMock.writeLookup(controller.playerMock, "MarketplaceService.UserOwnsGamePassAsync", true, GAME_PASS_ID)
218
212
 
219
- controller.awaitBool(
213
+ PromiseTestUtils.awaitFulfilled(
220
214
  controller.gameProductService:SetPlayerOwnershipOverride(
221
215
  controller.playerMock,
222
216
  GameConfigAssetTypes.PASS,
@@ -224,7 +218,7 @@ describe("GameProductService ownership override", function()
224
218
  false
225
219
  ) :: any
226
220
  )
227
- controller.awaitBool(
221
+ PromiseTestUtils.awaitFulfilled(
228
222
  controller.gameProductService:ClearPlayerOwnershipOverride(
229
223
  controller.playerMock,
230
224
  GameConfigAssetTypes.PASS,
@@ -233,7 +227,7 @@ describe("GameProductService ownership override", function()
233
227
  )
234
228
 
235
229
  expect(
236
- controller.awaitBool(
230
+ PromiseTestUtils.awaitFulfilled(
237
231
  controller.gameProductService:PromisePlayerOwnership(
238
232
  controller.playerMock,
239
233
  GameConfigAssetTypes.PASS,
@@ -252,7 +246,7 @@ describe("GameProductServiceClient ownership for the designated mock", function(
252
246
  PlayerMock.writeLookup(controller.playerMock, "MarketplaceService.UserOwnsGamePassAsync", true, GAME_PASS_ID)
253
247
 
254
248
  expect(
255
- controller.awaitBool(
249
+ PromiseTestUtils.awaitFulfilled(
256
250
  controller.gameProductService:PromisePlayerOwnership(
257
251
  controller.playerMock,
258
252
  GameConfigAssetTypes.PASS,
@@ -261,7 +255,7 @@ describe("GameProductServiceClient ownership for the designated mock", function(
261
255
  )
262
256
  ).toEqual(true)
263
257
  expect(
264
- controller.awaitBool(
258
+ PromiseTestUtils.awaitFulfilled(
265
259
  controller.gameProductServiceClient:PromisePlayerOwnership(
266
260
  controller.playerMock,
267
261
  GameConfigAssetTypes.PASS,
@@ -320,7 +314,7 @@ describe("client-initiated gamepass prompt", function()
320
314
  end)
321
315
 
322
316
  expect(
323
- controller.awaitBool(
317
+ PromiseTestUtils.awaitFulfilled(
324
318
  controller.gameProductServiceClient:PromisePromptPurchase(
325
319
  controller.playerMock,
326
320
  GameConfigAssetTypes.PASS,
@@ -345,7 +339,7 @@ describe("client-initiated gamepass prompt", function()
345
339
  )
346
340
  ).toEqual(true)
347
341
  expect(
348
- controller.awaitBool(
342
+ PromiseTestUtils.awaitFulfilled(
349
343
  controller.gameProductService:PromisePlayerOwnership(
350
344
  controller.playerMock,
351
345
  GameConfigAssetTypes.PASS,
@@ -372,7 +366,7 @@ describe("client-initiated gamepass prompt", function()
372
366
  end)
373
367
 
374
368
  expect(
375
- controller.awaitBool(
369
+ PromiseTestUtils.awaitFulfilled(
376
370
  controller.gameProductServiceClient:PromisePromptPurchase(
377
371
  controller.playerMock,
378
372
  GameConfigAssetTypes.PASS,
@@ -406,7 +400,7 @@ describe("client-initiated gamepass prompt", function()
406
400
  end)
407
401
 
408
402
  expect(
409
- controller.awaitBool(
403
+ PromiseTestUtils.awaitFulfilled(
410
404
  controller.gameProductServiceClient:PromisePromptPurchase(
411
405
  controller.playerMock,
412
406
  GameConfigAssetTypes.PASS,
@@ -470,7 +464,7 @@ describe("gamepass purchase verification under server-only prompting", function(
470
464
 
471
465
  -- Awaiting the ownership query also lets the server's verification settle first.
472
466
  expect(
473
- controller.awaitBool(
467
+ PromiseTestUtils.awaitFulfilled(
474
468
  controller.gameProductService:PromisePlayerOwnership(
475
469
  controller.playerMock,
476
470
  GameConfigAssetTypes.PASS,
@@ -553,7 +547,7 @@ describe("server-initiated gamepass prompt", function()
553
547
  end)
554
548
 
555
549
  expect(
556
- controller.awaitBool(
550
+ PromiseTestUtils.awaitFulfilled(
557
551
  controller.gameProductService:PromisePlayerPromptPurchase(
558
552
  controller.playerMock,
559
553
  GameConfigAssetTypes.PASS,
@@ -576,7 +570,7 @@ describe("server-initiated gamepass prompt", function()
576
570
  )
577
571
  ).toEqual(true)
578
572
  expect(
579
- controller.awaitBool(
573
+ PromiseTestUtils.awaitFulfilled(
580
574
  controller.gameProductService:PromisePlayerOwnership(
581
575
  controller.playerMock,
582
576
  GameConfigAssetTypes.PASS,
@@ -592,7 +586,7 @@ describe("server-initiated gamepass prompt", function()
592
586
  local controller = setup()
593
587
 
594
588
  expect(
595
- controller.awaitBool(
589
+ PromiseTestUtils.awaitFulfilled(
596
590
  controller.gameProductService:PromisePlayerPromptPurchase(
597
591
  controller.playerMock,
598
592
  GameConfigAssetTypes.PASS,
@@ -609,7 +603,7 @@ describe("server-initiated gamepass prompt", function()
609
603
  )
610
604
  ).toEqual(false)
611
605
  expect(
612
- controller.awaitBool(
606
+ PromiseTestUtils.awaitFulfilled(
613
607
  controller.gameProductService:PromisePlayerOwnership(
614
608
  controller.playerMock,
615
609
  GameConfigAssetTypes.PASS,
@@ -24,7 +24,6 @@ local Promise = require("Promise")
24
24
  local PromiseTestUtils = require("PromiseTestUtils")
25
25
  local Signal = require("Signal")
26
26
 
27
- local afterEach = Jest.Globals.afterEach
28
27
  local describe = Jest.Globals.describe
29
28
  local expect = Jest.Globals.expect
30
29
  local it = Jest.Globals.it
@@ -122,10 +121,7 @@ describe("PlayerAssetOwnershipTracker:PromiseOwnsAsset()", function()
122
121
  return Promise.resolved(true)
123
122
  end)
124
123
 
125
- local promise = context.tracker:PromiseOwnsAsset("swordKey")
126
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
127
- local ok, owns = promise:Yield()
128
- expect(ok).toEqual(true)
124
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"), 5)
129
125
  expect(owns).toEqual(true)
130
126
  context:Destroy()
131
127
  end)
@@ -136,10 +132,7 @@ describe("PlayerAssetOwnershipTracker:PromiseOwnsAsset()", function()
136
132
  return Promise.resolved(false)
137
133
  end)
138
134
 
139
- local promise = context.tracker:PromiseOwnsAsset("swordKey")
140
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
141
- local ok, owns = promise:Yield()
142
- expect(ok).toEqual(true)
135
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"), 5)
143
136
  expect(owns).toEqual(false)
144
137
  context:Destroy()
145
138
  end)
@@ -171,9 +164,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnership()", function()
171
164
 
172
165
  context.tracker:SetOwnership(KEY_TO_ID.swordKey, true)
173
166
 
174
- local promise = context.tracker:PromiseOwnsAsset("swordKey")
175
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
176
- local _, owns = promise:Yield()
167
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"), 5)
177
168
  expect(owns).toEqual(true)
178
169
  context:Destroy()
179
170
  end)
@@ -191,9 +182,7 @@ describe("PlayerAssetOwnershipTracker market tracker integration", function()
191
182
 
192
183
  context.marketTracker.Purchased:Fire(KEY_TO_ID.swordKey)
193
184
 
194
- local promise = context.tracker:PromiseOwnsAsset("swordKey")
195
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
196
- local _, owns = promise:Yield()
185
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"), 5)
197
186
  expect(owns).toEqual(true)
198
187
  context:Destroy()
199
188
  end)
@@ -262,9 +251,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() ownership wins", fu
262
251
 
263
252
  context.tracker:SetOwnershipOverride("swordKey", true)
264
253
 
265
- local promise = context.tracker:PromiseOwnsAsset("swordKey")
266
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
267
- local _, owns = promise:Yield()
254
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"), 5)
268
255
  expect(owns).toEqual(true)
269
256
  context:Destroy()
270
257
  end)
@@ -277,9 +264,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() ownership wins", fu
277
264
 
278
265
  context.tracker:SetOwnershipOverride("swordKey", false)
279
266
 
280
- local promise = context.tracker:PromiseOwnsAsset("swordKey")
281
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
282
- local _, owns = promise:Yield()
267
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"), 5)
283
268
  expect(owns).toEqual(false)
284
269
  context:Destroy()
285
270
  end)
@@ -289,9 +274,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() ownership wins", fu
289
274
 
290
275
  context.tracker:SetOwnershipOverride("swordKey", true)
291
276
 
292
- local promise = context.tracker:PromiseOwnsAsset("swordKey")
293
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
294
- local _, owns = promise:Yield()
277
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"), 5)
295
278
  expect(owns).toEqual(true)
296
279
  context:Destroy()
297
280
  end)
@@ -302,9 +285,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() ownership wins", fu
302
285
 
303
286
  context.tracker:SetOwnershipOverride("swordKey", false)
304
287
 
305
- local promise = context.tracker:PromiseOwnsAsset("swordKey")
306
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
307
- local _, owns = promise:Yield()
288
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"), 5)
308
289
  expect(owns).toEqual(false)
309
290
  context:Destroy()
310
291
  end)
@@ -315,9 +296,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() ownership wins", fu
315
296
 
316
297
  context.tracker:SetOwnershipOverride(KEY_TO_ID.swordKey, false)
317
298
 
318
- local promise = context.tracker:PromiseOwnsAsset("swordKey")
319
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
320
- local _, owns = promise:Yield()
299
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"), 5)
321
300
  expect(owns).toEqual(false)
322
301
  context:Destroy()
323
302
  end)
@@ -348,15 +327,11 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() lifecycle", functio
348
327
  end)
349
328
 
350
329
  context.tracker:SetOwnershipOverride("swordKey", true)
351
- local owned = context.tracker:PromiseOwnsAsset("swordKey")
352
- expect(PromiseTestUtils.awaitSettled(owned, 5)).toEqual(true)
353
- local _, ownsWhileOverridden = owned:Yield()
330
+ local ownsWhileOverridden = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"), 5)
354
331
  expect(ownsWhileOverridden).toEqual(true)
355
332
 
356
333
  context.tracker:ClearOwnershipOverride("swordKey")
357
- local afterClear = context.tracker:PromiseOwnsAsset("swordKey")
358
- expect(PromiseTestUtils.awaitSettled(afterClear, 5)).toEqual(true)
359
- local _, ownsAfterClear = afterClear:Yield()
334
+ local ownsAfterClear = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"), 5)
360
335
  expect(ownsAfterClear).toEqual(false)
361
336
  context:Destroy()
362
337
  end)
@@ -370,9 +345,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() lifecycle", functio
370
345
  context.tracker:SetOwnershipOverride("swordKey", true)
371
346
  context.tracker:SetOwnershipOverride("swordKey", nil)
372
347
 
373
- local promise = context.tracker:PromiseOwnsAsset("swordKey")
374
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
375
- local _, owns = promise:Yield()
348
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"), 5)
376
349
  expect(owns).toEqual(false)
377
350
  context:Destroy()
378
351
  end)
@@ -401,9 +374,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() combined keys", fun
401
374
 
402
375
  context.tracker:SetOwnershipOverride("swordKey", true)
403
376
 
404
- local promise = context.tracker:PromiseOwnsAsset(KEY_TO_ID.swordKey)
405
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
406
- local _, owns = promise:Yield()
377
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset(KEY_TO_ID.swordKey), 5)
407
378
  expect(owns).toEqual(true)
408
379
  context:Destroy()
409
380
  end)
@@ -416,9 +387,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() combined keys", fun
416
387
 
417
388
  context.tracker:SetOwnershipOverride(KEY_TO_ID.swordKey, false)
418
389
 
419
- local promise = context.tracker:PromiseOwnsAsset("swordKey")
420
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
421
- local _, owns = promise:Yield()
390
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"), 5)
422
391
  expect(owns).toEqual(false)
423
392
  context:Destroy()
424
393
  end)
@@ -431,9 +400,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() combined keys", fun
431
400
 
432
401
  context.tracker:SetOwnershipOverride("swordKey", true)
433
402
 
434
- local promise = context.tracker:PromiseOwnsAsset("shieldKey")
435
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
436
- local _, owns = promise:Yield()
403
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("shieldKey"), 5)
437
404
  expect(owns).toEqual(false)
438
405
  context:Destroy()
439
406
  end)
@@ -455,8 +422,8 @@ describe("PlayerAssetOwnershipTracker query failures", function()
455
422
  test. So the claim is pinned structurally -- the failure is reported once at the query, and every
456
423
  subscriber's continuation is consumed -- which is exactly what deleting either handler undoes.
457
424
 
458
- Spied on the class, so an instance built inside `func` is already covered. Restored in afterEach
459
- as well: a test killed mid-yield would otherwise leave the recorder installed for the whole run.
425
+ Spied on the class, so an instance built inside `func` is already covered. Restored through
426
+ afterThis: a test killed mid-yield would otherwise leave the recorder installed for the whole run.
460
427
  ]]
461
428
  local trackerClass: any = PlayerAssetOwnershipTracker
462
429
  local realWarn = trackerClass._warnQueryFailed
@@ -475,12 +442,12 @@ describe("PlayerAssetOwnershipTracker query failures", function()
475
442
  trackerClass._consumeObservedQueryFailure = function(_self, err)
476
443
  table.insert(consumed, err)
477
444
  end
478
- end
479
445
 
480
- afterEach(function()
481
- trackerClass._warnQueryFailed = realWarn
482
- trackerClass._consumeObservedQueryFailure = realConsume
483
- end)
446
+ JestUtils.afterThis(function()
447
+ trackerClass._warnQueryFailed = realWarn
448
+ trackerClass._consumeObservedQueryFailure = realConsume
449
+ end)
450
+ end
484
451
 
485
452
  it("should report once at the query and consume every subscriber's copy", function()
486
453
  local context = setup()
@@ -565,9 +532,7 @@ describe("PlayerAssetOwnershipTracker query failures", function()
565
532
  -- Destroying the tracker rejects the query with nothing, which is teardown rather than a refusal.
566
533
  -- The real _warnQueryFailed drops it on the nil check; here we see it arrive and assert the shape.
567
534
  context:Destroy()
568
- expect(PromiseTestUtils.awaitSettled(asked, 5)).toEqual(true)
569
- local askedOk = asked:Yield()
570
- expect(askedOk).toEqual(false)
535
+ PromiseTestUtils.awaitRejected(asked, 5)
571
536
 
572
537
  for _, report in reports do
573
538
  expect(report.err).toEqual(nil)
@@ -656,9 +621,7 @@ describe("PlayerAssetOwnershipTracker override replication", function()
656
621
  serverTracker:SetOwnershipOverride("swordKey", true)
657
622
 
658
623
  local clientTracker, destroyClient = makeTracker(player)
659
- local promise = clientTracker:PromiseOwnsAsset("swordKey")
660
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
661
- local _, owns = promise:Yield()
624
+ local owns = PromiseTestUtils.awaitFulfilled(clientTracker:PromiseOwnsAsset("swordKey"), 5)
662
625
  expect(owns).toEqual(true)
663
626
 
664
627
  destroyClient()
@@ -676,9 +639,7 @@ describe("PlayerAssetOwnershipTracker override replication", function()
676
639
  clientTracker:SetQueryOwnershipCallback(function()
677
640
  return Promise.resolved(true)
678
641
  end)
679
- local promise = clientTracker:PromiseOwnsAsset("swordKey")
680
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
681
- local _, owns = promise:Yield()
642
+ local owns = PromiseTestUtils.awaitFulfilled(clientTracker:PromiseOwnsAsset("swordKey"), 5)
682
643
  expect(owns).toEqual(false)
683
644
 
684
645
  destroyClient()
@@ -252,9 +252,7 @@ describe("PlayerAssetMarketTracker:PromisePromptPurchase()", function()
252
252
  context.tracker:HandlePurchaseEvent(capturedId, true)
253
253
  context.tracker:HandlePromptClosedEvent(capturedId)
254
254
 
255
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
256
- local ok, purchased = promise:Yield()
257
- expect(ok).toEqual(true)
255
+ local purchased = PromiseTestUtils.awaitFulfilled(promise, 5)
258
256
  expect(purchased).toEqual(true)
259
257
  context:Destroy()
260
258
  end)
@@ -266,9 +264,7 @@ describe("PlayerAssetMarketTracker:PromisePromptPurchase()", function()
266
264
  context.tracker:HandlePurchaseEvent(capturedId, false)
267
265
  context.tracker:HandlePromptClosedEvent(capturedId)
268
266
 
269
- expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
270
- local ok, purchased = promise:Yield()
271
- expect(ok).toEqual(true)
267
+ local purchased = PromiseTestUtils.awaitFulfilled(promise, 5)
272
268
  expect(purchased).toEqual(false)
273
269
  context:Destroy()
274
270
  end)
@@ -16,11 +16,12 @@
16
16
  local require = require(script.Parent.loader).load(script)
17
17
 
18
18
  local Jest = require("Jest")
19
+ local JestUtils = require("JestUtils")
20
+ local Maid = require("Maid")
19
21
  local PlayerMock = require("PlayerMock")
20
22
  local PlayerProductManagerBase = require("PlayerProductManagerBase")
21
23
  local Workspace = game:GetService("Workspace")
22
24
 
23
- local afterEach = Jest.Globals.afterEach
24
25
  local describe = Jest.Globals.describe
25
26
  local expect = Jest.Globals.expect
26
27
  local it = Jest.Globals.it
@@ -32,87 +33,118 @@ local jest = Jest.Globals.jest
32
33
  local realIsClientProcess = (PlayerProductManagerBase :: any)._isClientProcess
33
34
  local isClientProcessSpy = jest.spyOn(PlayerProductManagerBase :: any, "_isClientProcess")
34
35
 
35
- local function pretendClientProcess(): ()
36
- isClientProcessSpy.mockReturnValue(true)
36
+ local function canQueryCloudOwnership(player: any): boolean
37
+ return (PlayerProductManagerBase :: any)._canQueryCloudOwnership({ _player = player })
37
38
  end
38
39
 
39
- local function pretendServerProcess(): ()
40
- isClientProcessSpy.mockReturnValue(false)
41
- end
40
+ local function setup()
41
+ local maid = Maid.new()
42
42
 
43
- local created: { any } = {}
43
+ maid:GiveTask(function()
44
+ isClientProcessSpy.mockImplementation(realIsClientProcess)
45
+ end)
44
46
 
45
- afterEach(function()
46
- isClientProcessSpy.mockImplementation(realIsClientProcess)
47
- PlayerMock.setMockedLocalPlayer(nil)
47
+ local function pretendClientProcess(): ()
48
+ isClientProcessSpy.mockReturnValue(true)
49
+ end
48
50
 
49
- for _, instance in created do
50
- instance:Destroy()
51
+ local function pretendServerProcess(): ()
52
+ isClientProcessSpy.mockReturnValue(false)
51
53
  end
52
- table.clear(created)
53
- end)
54
54
 
55
- local function canQueryCloudOwnership(player: any): boolean
56
- return (PlayerProductManagerBase :: any)._canQueryCloudOwnership({ _player = player })
57
- end
55
+ -- A Folder without the mock tag: PlayerMock.isMock requires both, so this fails it and stands in for a
56
+ -- real player, which a server-run spec cannot otherwise have.
57
+ local function newNonMockPlayer(): any
58
+ local player = Instance.new("Folder")
59
+ player.Name = "NotAPlayerMock"
60
+ maid:GiveTask(player)
61
+ return player
62
+ end
58
63
 
59
- -- A Folder without the mock tag: PlayerMock.isMock requires both, so this fails it and stands in for a
60
- -- real player, which a server-run spec cannot otherwise have.
61
- local function newNonMockPlayer(): any
62
- local player = Instance.new("Folder")
63
- player.Name = "NotAPlayerMock"
64
- table.insert(created, player)
65
- return player
66
- end
64
+ local function newMock(): any
65
+ local mock: any = PlayerMock.new()
66
+ maid:GiveTask(mock)
67
+ return mock
68
+ end
67
69
 
68
- local function newMock(): any
69
- local mock: any = PlayerMock.new()
70
- table.insert(created, mock)
71
- return mock
72
- end
70
+ -- Parented before designating: the designation is a CollectionService tag, and GetTagged only resolves
71
+ -- instances in the DataModel.
72
+ local function designateLocal(mock: any): ()
73
+ mock.Parent = Workspace
74
+ maid:Add(PlayerMock.setMockedLocalPlayer(mock))
75
+ end
76
+
77
+ local controller = {
78
+ pretendClientProcess = pretendClientProcess,
79
+ pretendServerProcess = pretendServerProcess,
80
+ newNonMockPlayer = newNonMockPlayer,
81
+ newMock = newMock,
82
+ designateLocal = designateLocal,
83
+ Destroy = function(_self)
84
+ maid:DoCleaning()
85
+ end,
86
+ }
73
87
 
74
- -- Parented before designating: the designation is a CollectionService tag, and GetTagged only resolves
75
- -- instances in the DataModel.
76
- local function designateLocal(mock: any): ()
77
- mock.Parent = Workspace
78
- PlayerMock.setMockedLocalPlayer(mock)
88
+ maid:GiveTask(JestUtils.afterThis(controller))
89
+
90
+ return controller
79
91
  end
80
92
 
81
93
  describe("PlayerProductManagerBase._canQueryCloudOwnership()", function()
82
94
  it("should let a server process ask about anybody", function()
83
- designateLocal(newMock())
84
- pretendServerProcess()
95
+ local controller = setup()
96
+
97
+ controller.designateLocal(controller.newMock())
98
+ controller.pretendServerProcess()
85
99
 
86
- expect(canQueryCloudOwnership(newNonMockPlayer())).toEqual(true)
100
+ expect(canQueryCloudOwnership(controller.newNonMockPlayer())).toEqual(true)
101
+
102
+ controller:Destroy()
87
103
  end)
88
104
 
89
105
  it("should refuse a client process asking about a player that is not its own", function()
90
- designateLocal(newMock())
91
- pretendClientProcess()
106
+ local controller = setup()
107
+
108
+ controller.designateLocal(controller.newMock())
109
+ controller.pretendClientProcess()
110
+
111
+ expect(canQueryCloudOwnership(controller.newNonMockPlayer())).toEqual(false)
92
112
 
93
- expect(canQueryCloudOwnership(newNonMockPlayer())).toEqual(false)
113
+ controller:Destroy()
94
114
  end)
95
115
 
96
116
  it("should let a client process ask about its own player", function()
97
- local localMock = newMock()
98
- designateLocal(localMock)
99
- pretendClientProcess()
117
+ local controller = setup()
118
+
119
+ local localMock = controller.newMock()
120
+ controller.designateLocal(localMock)
121
+ controller.pretendClientProcess()
100
122
 
101
123
  expect(canQueryCloudOwnership(localMock)).toEqual(true)
124
+
125
+ controller:Destroy()
102
126
  end)
103
127
 
104
128
  it("should let a client process ask about another mock, which never reaches the engine", function()
105
- designateLocal(newMock())
106
- pretendClientProcess()
129
+ local controller = setup()
130
+
131
+ controller.designateLocal(controller.newMock())
132
+ controller.pretendClientProcess()
107
133
 
108
- expect(canQueryCloudOwnership(newMock())).toEqual(true)
134
+ expect(canQueryCloudOwnership(controller.newMock())).toEqual(true)
135
+
136
+ controller:Destroy()
109
137
  end)
110
138
 
111
139
  it("should let a client process with no local player ask", function()
112
- pretendClientProcess()
140
+ local controller = setup()
141
+
142
+ controller.pretendClientProcess()
113
143
 
114
144
  -- No player to be is not a client to speak for: left able to ask, rather than unwiring ownership
115
145
  -- for the very player the manager is about.
116
- expect(canQueryCloudOwnership(newNonMockPlayer())).toEqual(true)
146
+ expect(canQueryCloudOwnership(controller.newNonMockPlayer())).toEqual(true)
147
+
148
+ controller:Destroy()
117
149
  end)
118
150
  end)