@quenty/gameproductservice 14.76.0 → 14.76.2

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,14 @@
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.76.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/gameproductservice@14.76.1...@quenty/gameproductservice@14.76.2) (2026-11-18)
7
+
8
+ **Note:** Version bump only for package @quenty/gameproductservice
9
+
10
+ ## [14.76.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/gameproductservice@14.76.0...@quenty/gameproductservice@14.76.1) (2026-10-24)
11
+
12
+ **Note:** Version bump only for package @quenty/gameproductservice
13
+
6
14
  # [14.76.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/gameproductservice@14.75.1...@quenty/gameproductservice@14.76.0) (2026-10-24)
7
15
 
8
16
  **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.76.0",
3
+ "version": "14.76.2",
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.39.1",
34
- "@quenty/avatareditorutils": "7.56.0",
35
- "@quenty/baseobject": "10.16.3",
36
- "@quenty/binder": "14.48.1",
37
- "@quenty/brio": "14.38.1",
38
- "@quenty/cmdrservice": "13.65.0",
33
+ "@quenty/attributeutils": "14.39.2",
34
+ "@quenty/avatareditorutils": "7.56.1",
35
+ "@quenty/baseobject": "10.16.4",
36
+ "@quenty/binder": "14.48.2",
37
+ "@quenty/brio": "14.38.2",
38
+ "@quenty/cmdrservice": "13.65.1",
39
39
  "@quenty/enumutils": "3.4.6",
40
- "@quenty/gameconfig": "12.72.0",
41
- "@quenty/instanceutils": "13.38.1",
42
- "@quenty/jestutils": "1.1.3",
40
+ "@quenty/gameconfig": "12.72.2",
41
+ "@quenty/instanceutils": "13.38.2",
42
+ "@quenty/jestutils": "1.1.4",
43
43
  "@quenty/loader": "10.11.3",
44
- "@quenty/maid": "3.12.3",
45
- "@quenty/marketplaceutils": "11.35.1",
46
- "@quenty/nevermore-test-runner": "1.6.3",
47
- "@quenty/observablecollection": "12.55.0",
48
- "@quenty/permissionprovider": "14.54.1",
49
- "@quenty/playerbinder": "14.52.1",
50
- "@quenty/playermock": "1.11.1",
51
- "@quenty/playerutils": "8.46.1",
52
- "@quenty/promise": "10.25.1",
53
- "@quenty/promisemaid": "5.25.1",
54
- "@quenty/receiptprocessing": "7.47.1",
55
- "@quenty/remoting": "12.46.1",
56
- "@quenty/rx": "13.35.1",
57
- "@quenty/rxbinderutils": "14.48.1",
58
- "@quenty/servicebag": "11.21.3",
59
- "@quenty/signal": "7.13.4",
60
- "@quenty/statestack": "14.40.1",
61
- "@quenty/steputils": "3.9.3",
62
- "@quenty/string": "3.5.3",
44
+ "@quenty/maid": "3.12.4",
45
+ "@quenty/marketplaceutils": "11.35.2",
46
+ "@quenty/nevermore-test-runner": "1.6.4",
47
+ "@quenty/observablecollection": "12.55.1",
48
+ "@quenty/permissionprovider": "14.54.2",
49
+ "@quenty/playerbinder": "14.52.2",
50
+ "@quenty/playermock": "1.11.2",
51
+ "@quenty/playerutils": "8.46.2",
52
+ "@quenty/promise": "10.25.2",
53
+ "@quenty/promisemaid": "5.25.2",
54
+ "@quenty/receiptprocessing": "7.47.2",
55
+ "@quenty/remoting": "12.46.2",
56
+ "@quenty/rx": "13.35.2",
57
+ "@quenty/rxbinderutils": "14.48.2",
58
+ "@quenty/servicebag": "11.21.4",
59
+ "@quenty/signal": "7.13.5",
60
+ "@quenty/statestack": "14.40.2",
61
+ "@quenty/steputils": "3.9.4",
62
+ "@quenty/string": "3.5.4",
63
63
  "@quenty/table": "3.9.2",
64
- "@quenty/tie": "10.52.1",
65
- "@quenty/valueobject": "13.39.1",
66
- "@quentystudios/jest-lua": "3.10.0-quenty.2"
64
+ "@quenty/tie": "10.52.2",
65
+ "@quenty/valueobject": "13.39.2",
66
+ "@quentystudios/jest-lua": "3.10.0-quenty.3"
67
67
  },
68
- "gitHead": "eefcb7e24fe7642e06e4ceed920aceecdad97cd1"
68
+ "gitHead": "f51b2de38a02f8d92758da8d381a378e760170aa"
69
69
  }
@@ -96,7 +96,7 @@ function PlayerProductManagerClient.new(player: Player, serviceBag: ServiceBag.S
96
96
  end
97
97
  end
98
98
 
99
- local impl = self._maid:Add((PlayerProductManagerInterface :: any).Client:Implement(self._obj, self))
99
+ local impl = self._maid:Add(PlayerProductManagerInterface.Client:Implement(self._obj, self))
100
100
  self:ExportMarketTrackers(impl:GetImplParent())
101
101
 
102
102
  return self
@@ -31,6 +31,7 @@ local PermissionProviderUtils = require("PermissionProviderUtils")
31
31
  local PlayerMock = require("PlayerMock")
32
32
  local PromiseTestUtils = require("PromiseTestUtils")
33
33
  local ServiceBag = require("ServiceBag")
34
+ local SignalTestUtils = require("SignalTestUtils")
34
35
  local StepUtils = require("StepUtils")
35
36
 
36
37
  local describe = Jest.Globals.describe
@@ -73,6 +74,7 @@ local function setup()
73
74
  clientBag:Start()
74
75
 
75
76
  local controller = {
77
+ maid = maid,
76
78
  serverBag = serverBag,
77
79
  clientBag = clientBag,
78
80
  gameProductService = gameProductService,
@@ -107,10 +109,6 @@ describe("PlayerProductManager discovers a PlayerMock", function()
107
109
  local controller = setup()
108
110
  local binder = controller.serverBag:GetService((require :: any)("PlayerProductManager"))
109
111
 
110
- PromiseTestUtils.awaitValue(function()
111
- return binder:Get(controller.playerMock) ~= nil
112
- end, 10)
113
-
114
112
  expect(binder:Get(controller.playerMock)).never.toBeNil()
115
113
 
116
114
  controller:Destroy()
@@ -294,11 +292,9 @@ describe("client-initiated gamepass prompt", function()
294
292
  local controller = setup()
295
293
  PlayerMock.writeLookup(controller.playerMock, "MarketplaceService.PromptGamePassPurchase", true, GAME_PASS_ID)
296
294
 
297
- local serverFired = {}
295
+ local serverFired =
296
+ SignalTestUtils.collectFireListTuples(controller.maid, controller.gameProductService.GamePassPurchased)
298
297
  local clientFired = {}
299
- controller.gameProductService.GamePassPurchased:Connect(function(player, gamePassId)
300
- table.insert(serverFired, { player = player, gamePassId = gamePassId })
301
- end)
302
298
  -- The pass is not owned when the prompt opens, so the client genuinely prompts. Model the
303
299
  -- purchase going through by marking the marketplace as owning it the instant the client reports
304
300
  -- success -- the same false-before / true-after transition a real purchase produces, and what
@@ -323,13 +319,11 @@ describe("client-initiated gamepass prompt", function()
323
319
  )
324
320
  ).toEqual(true)
325
321
 
326
- PromiseTestUtils.awaitValue(function()
327
- return #serverFired > 0
328
- end, 10)
322
+ StepUtils.deferWait()
329
323
 
330
324
  expect(#serverFired).toEqual(1)
331
- expect(serverFired[1].player).toBe(controller.playerMock)
332
- expect(serverFired[1].gamePassId).toEqual(GAME_PASS_ID)
325
+ expect(serverFired[1][1]).toBe(controller.playerMock)
326
+ expect(serverFired[1][2]).toEqual(GAME_PASS_ID)
333
327
  expect(clientFired[1]).toEqual(GAME_PASS_ID)
334
328
  expect(
335
329
  controller.gameProductService:HasPlayerPurchasedThisSession(
@@ -360,10 +354,8 @@ describe("client-initiated gamepass prompt", function()
360
354
  -- that want the claim checked enable server-only prompting; see the verification describe below.
361
355
  PlayerMock.writeLookup(controller.playerMock, "MarketplaceService.PromptGamePassPurchase", true, GAME_PASS_ID)
362
356
 
363
- local serverFired = {}
364
- controller.gameProductService.GamePassPurchased:Connect(function(player, gamePassId)
365
- table.insert(serverFired, { player = player, gamePassId = gamePassId })
366
- end)
357
+ local serverFired =
358
+ SignalTestUtils.collectFireListTuples(controller.maid, controller.gameProductService.GamePassPurchased)
367
359
 
368
360
  expect(
369
361
  PromiseTestUtils.awaitFulfilled(
@@ -375,9 +367,7 @@ describe("client-initiated gamepass prompt", function()
375
367
  )
376
368
  ).toEqual(true)
377
369
 
378
- PromiseTestUtils.awaitValue(function()
379
- return #serverFired > 0
380
- end, 10)
370
+ StepUtils.deferWait()
381
371
 
382
372
  expect(#serverFired).toEqual(1)
383
373
  expect(
@@ -394,10 +384,7 @@ describe("client-initiated gamepass prompt", function()
394
384
  it("resolves false on reject and marks nothing purchased on either realm", function()
395
385
  local controller = setup()
396
386
 
397
- local serverFired = {}
398
- controller.gameProductService.GamePassPurchased:Connect(function()
399
- table.insert(serverFired, true)
400
- end)
387
+ local serverFired = SignalTestUtils.countFires(controller.maid, controller.gameProductService.GamePassPurchased)
401
388
 
402
389
  expect(
403
390
  PromiseTestUtils.awaitFulfilled(
@@ -413,7 +400,7 @@ describe("client-initiated gamepass prompt", function()
413
400
  -- remaining work (the decline forward to the server) run before tearing down.
414
401
  StepUtils.deferWait()
415
402
 
416
- expect(#serverFired).toEqual(0)
403
+ expect(serverFired()).toEqual(0)
417
404
  expect(
418
405
  controller.gameProductService:HasPlayerPurchasedThisSession(
419
406
  controller.playerMock,
@@ -441,9 +428,7 @@ describe("gamepass purchase verification under server-only prompting", function(
441
428
  local function claimPurchaseFromClient(controller: any, gamePassId: number)
442
429
  local clientBinder = controller.clientBag:GetService((require :: any)("PlayerProductManagerClient"))
443
430
 
444
- PromiseTestUtils.awaitValue(function()
445
- return clientBinder:Get(controller.playerMock) ~= nil
446
- end, 10)
431
+ expect(clientBinder:Get(controller.playerMock)).never.toBeNil()
447
432
 
448
433
  local manager: any = clientBinder:Get(controller.playerMock)
449
434
  manager:_handleGamePassPromptFinished(gamePassId, true)
@@ -455,10 +440,8 @@ describe("gamepass purchase verification under server-only prompting", function(
455
440
 
456
441
  -- UserOwnsGamePassAsync stays at its false default: the player never bought this pass. Any
457
442
  -- client can fire this remote for any gamepass id, so on its own the claim must grant nothing.
458
- local serverFired = {}
459
- controller.gameProductService.GamePassPurchased:Connect(function(player, gamePassId)
460
- table.insert(serverFired, { player = player, gamePassId = gamePassId })
461
- end)
443
+ local serverFired =
444
+ SignalTestUtils.collectFireListTuples(controller.maid, controller.gameProductService.GamePassPurchased)
462
445
 
463
446
  claimPurchaseFromClient(controller, GAME_PASS_ID)
464
447
 
@@ -491,20 +474,14 @@ describe("gamepass purchase verification under server-only prompting", function(
491
474
  -- The marketplace shows the player owning the pass, as it would after a real purchase.
492
475
  PlayerMock.writeLookup(controller.playerMock, "MarketplaceService.UserOwnsGamePassAsync", true, GAME_PASS_ID)
493
476
 
494
- local serverFired = {}
495
- controller.gameProductService.GamePassPurchased:Connect(function(player, gamePassId)
496
- table.insert(serverFired, { player = player, gamePassId = gamePassId })
497
- end)
477
+ local serverFired =
478
+ SignalTestUtils.collectFireListTuples(controller.maid, controller.gameProductService.GamePassPurchased)
498
479
 
499
480
  claimPurchaseFromClient(controller, GAME_PASS_ID)
500
481
 
501
- PromiseTestUtils.awaitValue(function()
502
- return #serverFired > 0
503
- end, 10)
504
-
505
482
  expect(#serverFired).toEqual(1)
506
- expect(serverFired[1].player).toBe(controller.playerMock)
507
- expect(serverFired[1].gamePassId).toEqual(GAME_PASS_ID)
483
+ expect(serverFired[1][1]).toBe(controller.playerMock)
484
+ expect(serverFired[1][2]).toEqual(GAME_PASS_ID)
508
485
  expect(
509
486
  controller.gameProductService:HasPlayerPurchasedThisSession(
510
487
  controller.playerMock,
@@ -541,10 +518,8 @@ describe("server-initiated gamepass prompt", function()
541
518
  local controller = setup()
542
519
  PlayerMock.writeLookup(controller.playerMock, "MarketplaceService.PromptGamePassPurchase", true, GAME_PASS_ID)
543
520
 
544
- local serverFired = {}
545
- controller.gameProductService.GamePassPurchased:Connect(function(player, gamePassId)
546
- table.insert(serverFired, { player = player, gamePassId = gamePassId })
547
- end)
521
+ local serverFired =
522
+ SignalTestUtils.collectFireListTuples(controller.maid, controller.gameProductService.GamePassPurchased)
548
523
 
549
524
  expect(
550
525
  PromiseTestUtils.awaitFulfilled(
@@ -556,12 +531,8 @@ describe("server-initiated gamepass prompt", function()
556
531
  )
557
532
  ).toEqual(true)
558
533
 
559
- PromiseTestUtils.awaitValue(function()
560
- return #serverFired > 0
561
- end, 10)
562
-
563
534
  expect(#serverFired).toEqual(1)
564
- expect(serverFired[1].gamePassId).toEqual(GAME_PASS_ID)
535
+ expect(serverFired[1][2]).toEqual(GAME_PASS_ID)
565
536
  expect(
566
537
  controller.gameProductService:HasPlayerPurchasedThisSession(
567
538
  controller.playerMock,
@@ -16,6 +16,7 @@ local GameProductDataService = require("GameProductDataService")
16
16
  local Jest = require("Jest")
17
17
  local JestUtils = require("JestUtils")
18
18
  local Maid = require("Maid")
19
+ local ObservableSpy = require("ObservableSpy")
19
20
  local PlayerMock = require("PlayerMock")
20
21
  local PromiseTestUtils = require("PromiseTestUtils")
21
22
  local ServiceBag = require("ServiceBag")
@@ -96,13 +97,10 @@ describe("GameProductDataService server-only prompting", function()
96
97
  local context = setup()
97
98
  local service = context.gameProductDataService
98
99
 
99
- local values = {}
100
- local sub = service:GetServerOnlyPromptingValue():Observe():Subscribe(function(value)
101
- table.insert(values, value)
102
- end)
100
+ local values = ObservableSpy.new(service:GetServerOnlyPromptingValue():Observe())
103
101
 
104
102
  service:SetServerOnlyPrompting(true)
105
- sub:Destroy()
103
+ values:Destroy()
106
104
 
107
105
  expect(values[1]).toEqual(false)
108
106
  expect(values[#values]).toEqual(true)
@@ -17,11 +17,13 @@ local Jest = require("Jest")
17
17
  local JestUtils = require("JestUtils")
18
18
  local Maid = require("Maid")
19
19
  local Observable = require("Observable")
20
+ local ObservableSpy = require("ObservableSpy")
20
21
  local PlayerAssetOwnershipTracker = require("PlayerAssetOwnershipTracker")
21
22
  local PlayerMock = require("PlayerMock")
22
23
  local PlayerProductOwnershipOverrideUtils = require("PlayerProductOwnershipOverrideUtils")
23
24
  local Promise = require("Promise")
24
25
  local PromiseTestUtils = require("PromiseTestUtils")
26
+ local RxTestUtils = require("RxTestUtils")
25
27
  local Signal = require("Signal")
26
28
 
27
29
  local describe = Jest.Globals.describe
@@ -86,6 +88,7 @@ local function setup()
86
88
  end)
87
89
 
88
90
  local controller = {
91
+ maid = maid,
89
92
  tracker = tracker,
90
93
  marketTracker = marketTracker,
91
94
  Destroy = function(_self)
@@ -146,13 +149,10 @@ describe("PlayerAssetOwnershipTracker:PromiseOwnsAsset()", function()
146
149
  return Promise.resolved(true)
147
150
  end)
148
151
 
149
- local first = context.tracker:PromiseOwnsAsset("swordKey")
150
- PromiseTestUtils.awaitSettled(first, 5)
151
- local second = context.tracker:PromiseOwnsAsset("swordKey")
152
- PromiseTestUtils.awaitSettled(second, 5)
152
+ PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"))
153
+ local owns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"))
153
154
 
154
155
  expect(callCount).toEqual(1)
155
- local _, owns = second:Yield()
156
156
  expect(owns).toEqual(true)
157
157
  context:Destroy()
158
158
  end)
@@ -195,10 +195,7 @@ describe("PlayerAssetOwnershipTracker:SetQueryOwnershipCallback()", function()
195
195
  context.tracker:SetQueryOwnershipCallback(function()
196
196
  return Promise.resolved(false)
197
197
  end)
198
- local first = context.tracker:PromiseOwnsAsset("swordKey")
199
- PromiseTestUtils.awaitSettled(first, 5)
200
- local _, firstOwns = first:Yield()
201
- expect(firstOwns).toEqual(false)
198
+ expect(PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"))).toEqual(false)
202
199
 
203
200
  local secondCallbackCalls = 0
204
201
  context.tracker:SetQueryOwnershipCallback(function()
@@ -206,10 +203,8 @@ describe("PlayerAssetOwnershipTracker:SetQueryOwnershipCallback()", function()
206
203
  return Promise.resolved(true)
207
204
  end)
208
205
 
209
- local second = context.tracker:PromiseOwnsAsset("swordKey")
210
- PromiseTestUtils.awaitSettled(second, 5)
206
+ local secondOwns = PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"))
211
207
  expect(secondCallbackCalls).toEqual(1)
212
- local _, secondOwns = second:Yield()
213
208
  expect(secondOwns).toEqual(true)
214
209
  context:Destroy()
215
210
  end)
@@ -222,22 +217,15 @@ describe("PlayerAssetOwnershipTracker:ObserveOwnsAsset()", function()
222
217
  return Promise.resolved(false)
223
218
  end)
224
219
 
225
- local values = {}
226
- local sub = context.tracker:ObserveOwnsAsset(KEY_TO_ID.swordKey):Subscribe(function(value)
227
- table.insert(values, value)
228
- end)
220
+ local values = ObservableSpy.new(context.tracker:ObserveOwnsAsset(KEY_TO_ID.swordKey))
229
221
 
230
- expect(PromiseTestUtils.awaitValue(function()
231
- return #values >= 1
232
- end, 5)).toEqual(true)
222
+ expect(#values >= 1).toBe(true)
233
223
  expect(values[1]).toEqual(false)
234
224
 
235
225
  context.tracker:SetOwnership(KEY_TO_ID.swordKey, true)
236
226
 
237
- expect(PromiseTestUtils.awaitValue(function()
238
- return values[#values] == true
239
- end, 5)).toEqual(true)
240
- sub:Destroy()
227
+ expect(values[#values]).toBe(true)
228
+ values:Destroy()
241
229
  context:Destroy()
242
230
  end)
243
231
  end)
@@ -311,8 +299,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() ownership wins", fu
311
299
  end)
312
300
 
313
301
  context.tracker:SetOwnershipOverride("swordKey", true)
314
- local promise = context.tracker:PromiseOwnsAsset("swordKey")
315
- PromiseTestUtils.awaitSettled(promise, 5)
302
+ expect(PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"))).toEqual(true)
316
303
 
317
304
  expect(callCount).toEqual(0)
318
305
  context:Destroy()
@@ -354,16 +341,10 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() lifecycle", functio
354
341
  local context = setup()
355
342
 
356
343
  context.tracker:SetOwnershipOverride("swordKey", true)
357
- local first = context.tracker:PromiseOwnsAsset("swordKey")
358
- PromiseTestUtils.awaitSettled(first, 5)
359
- local _, firstOwns = first:Yield()
360
- expect(firstOwns).toEqual(true)
344
+ expect(PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"))).toEqual(true)
361
345
 
362
346
  context.tracker:SetOwnershipOverride("swordKey", false)
363
- local second = context.tracker:PromiseOwnsAsset("swordKey")
364
- PromiseTestUtils.awaitSettled(second, 5)
365
- local _, secondOwns = second:Yield()
366
- expect(secondOwns).toEqual(false)
347
+ expect(PromiseTestUtils.awaitFulfilled(context.tracker:PromiseOwnsAsset("swordKey"))).toEqual(false)
367
348
  context:Destroy()
368
349
  end)
369
350
  end)
@@ -462,32 +443,20 @@ describe("PlayerAssetOwnershipTracker query failures", function()
462
443
  return pending
463
444
  end)
464
445
 
465
- local values = {}
466
- -- Typed `any`: the test place holds more than one copy of Subscription (a package graph
467
- -- duplicated per dependent), and a list inferred from one copy rejects another.
468
- local subs: { any } = {}
446
+ local emitted = {}
469
447
  for _ = 1, 3 do
470
448
  table.insert(
471
- subs,
472
- context.tracker:ObserveOwnsAsset(KEY_TO_ID.swordKey):Subscribe(function(value)
473
- table.insert(values, value)
474
- end)
449
+ emitted,
450
+ RxTestUtils.collectList(context.maid, context.tracker:ObserveOwnsAsset(KEY_TO_ID.swordKey))
475
451
  )
476
452
  end
477
453
 
478
454
  local asked = context.tracker:PromiseOwnsAsset("swordKey")
479
455
  pending:Reject("cloud refused")
480
456
 
481
- expect(PromiseTestUtils.awaitSettled(asked, 5)).toEqual(true)
482
- -- Yielded, not merely awaited: reading the outcome is this caller consuming its own copy, which is
483
- -- what a real caller does with the promise it asked for. Bound first, because Yield returns the
484
- -- rejection alongside the outcome and expect takes one argument.
485
- local askedOk = asked:Yield()
486
- expect(askedOk).toEqual(false)
457
+ PromiseTestUtils.awaitRejected(asked)
487
458
 
488
- expect(PromiseTestUtils.awaitValue(function()
489
- return #consumed >= 3
490
- end, 5)).toEqual(true)
459
+ expect(#consumed >= 3).toBe(true)
491
460
 
492
461
  -- One report for the query, one consumption per subscriber.
493
462
  expect(#reports).toEqual(1)
@@ -497,11 +466,8 @@ describe("PlayerAssetOwnershipTracker query failures", function()
497
466
 
498
467
  -- An unresolvable asset emits nothing at all: silence reads as unresolved, where `false` would
499
468
  -- read as "does not own it" and turn a failed lookup into a refusal.
500
- expect(#values).toEqual(0)
469
+ expect(emitted).toEqual({ {}, {}, {} })
501
470
 
502
- for _, sub in subs do
503
- sub:Destroy()
504
- end
505
471
  context:Destroy()
506
472
  end)
507
473
 
@@ -549,26 +515,17 @@ describe("PlayerAssetOwnershipTracker:ObserveOwnsAsset() overrides", function()
549
515
  return Promise.resolved(false)
550
516
  end)
551
517
 
552
- local values = {}
553
- local sub = context.tracker:ObserveOwnsAsset(KEY_TO_ID.swordKey):Subscribe(function(value)
554
- table.insert(values, value)
555
- end)
518
+ local values = ObservableSpy.new(context.tracker:ObserveOwnsAsset(KEY_TO_ID.swordKey))
556
519
 
557
- expect(PromiseTestUtils.awaitValue(function()
558
- return values[#values] == false
559
- end, 5)).toEqual(true)
520
+ expect(values[#values]).toBe(false)
560
521
 
561
522
  context.tracker:SetOwnershipOverride(KEY_TO_ID.swordKey, true)
562
- expect(PromiseTestUtils.awaitValue(function()
563
- return values[#values] == true
564
- end, 5)).toEqual(true)
523
+ expect(values[#values]).toBe(true)
565
524
 
566
525
  context.tracker:ClearOwnershipOverride(KEY_TO_ID.swordKey)
567
- expect(PromiseTestUtils.awaitValue(function()
568
- return values[#values] == false
569
- end, 5)).toEqual(true)
526
+ expect(values[#values]).toBe(false)
570
527
 
571
- sub:Destroy()
528
+ values:Destroy()
572
529
  context:Destroy()
573
530
  end)
574
531
 
@@ -580,16 +537,11 @@ describe("PlayerAssetOwnershipTracker:ObserveOwnsAsset() overrides", function()
580
537
 
581
538
  context.tracker:SetOwnershipOverride(KEY_TO_ID.swordKey, false)
582
539
 
583
- local values = {}
584
- local sub = context.tracker:ObserveOwnsAsset(KEY_TO_ID.swordKey):Subscribe(function(value)
585
- table.insert(values, value)
586
- end)
540
+ local values = ObservableSpy.new(context.tracker:ObserveOwnsAsset(KEY_TO_ID.swordKey))
587
541
 
588
- expect(PromiseTestUtils.awaitValue(function()
589
- return values[#values] == false
590
- end, 5)).toEqual(true)
542
+ expect(values[#values]).toBe(false)
591
543
 
592
- sub:Destroy()
544
+ values:Destroy()
593
545
  context:Destroy()
594
546
  end)
595
547
  end)
@@ -14,8 +14,10 @@ local Jest = require("Jest")
14
14
  local JestUtils = require("JestUtils")
15
15
  local Maid = require("Maid")
16
16
  local Observable = require("Observable")
17
+ local ObservableSpy = require("ObservableSpy")
17
18
  local PlayerAssetMarketTracker = require("PlayerAssetMarketTracker")
18
19
  local PromiseTestUtils = require("PromiseTestUtils")
20
+ local SignalTestUtils = require("SignalTestUtils")
19
21
 
20
22
  local describe = Jest.Globals.describe
21
23
  local expect = Jest.Globals.expect
@@ -50,12 +52,19 @@ local function observeIdsBrio(idOrKey)
50
52
  end)
51
53
  end
52
54
 
53
- local function setup()
55
+ type Controller = {
56
+ maid: Maid.Maid,
57
+ tracker: PlayerAssetMarketTracker.PlayerAssetMarketTracker,
58
+ Destroy: (self: Controller) -> (),
59
+ }
60
+
61
+ local function setup(): Controller
54
62
  local maid = Maid.new()
55
63
  local tracker = PlayerAssetMarketTracker.new(GameConfigAssetTypes.PRODUCT, convertIds, observeIdsBrio)
56
64
  maid:GiveTask(tracker)
57
65
 
58
- local controller = {
66
+ local controller: Controller = {
67
+ maid = maid,
59
68
  tracker = tracker,
60
69
  Destroy = function(_self)
61
70
  maid:DoCleaning()
@@ -67,12 +76,13 @@ local function setup()
67
76
  return controller
68
77
  end
69
78
 
70
- local function setupNonPromptable()
79
+ local function setupNonPromptable(): Controller
71
80
  local maid = Maid.new()
72
81
  local tracker = PlayerAssetMarketTracker.new(GameConfigAssetTypes.GAME, convertIds, observeIdsBrio, false)
73
82
  maid:GiveTask(tracker)
74
83
 
75
- local controller = {
84
+ local controller: Controller = {
85
+ maid = maid,
76
86
  tracker = tracker,
77
87
  Destroy = function(_self)
78
88
  maid:DoCleaning()
@@ -84,19 +94,13 @@ local function setupNonPromptable()
84
94
  return controller
85
95
  end
86
96
 
87
- local function promptAndCapture(tracker, idOrKey)
88
- local capturedId
89
- local conn = tracker.ShowPromptRequested:Connect(function(id)
90
- capturedId = id
91
- end)
97
+ local function promptAndCapture(context: Controller, idOrKey: string | number)
98
+ local requestedIds = SignalTestUtils.collectFireList(context.maid, context.tracker.ShowPromptRequested)
92
99
 
93
- local promise = tracker:PromisePromptPurchase(idOrKey)
94
- PromiseTestUtils.awaitValue(function()
95
- return capturedId ~= nil
96
- end, 5)
97
- conn:Disconnect()
100
+ local promise = context.tracker:PromisePromptPurchase(idOrKey)
101
+ expect(requestedIds[1]).never.toBeNil()
98
102
 
99
- return promise, capturedId
103
+ return promise, requestedIds[1]
100
104
  end
101
105
 
102
106
  describe("PlayerAssetMarketTracker basics", function()
@@ -142,16 +146,12 @@ describe("PlayerAssetMarketTracker non-promptable asset types", function()
142
146
  it("should reject PromisePromptPurchase for a known id without opening a prompt", function()
143
147
  local context = setupNonPromptable()
144
148
 
145
- local promptRequested = false
146
- local conn = context.tracker.ShowPromptRequested:Connect(function()
147
- promptRequested = true
148
- end)
149
+ local promptRequested = SignalTestUtils.countFires(context.maid, context.tracker.ShowPromptRequested)
149
150
 
150
151
  local outcome = PromiseTestUtils.awaitOutcome(context.tracker:PromisePromptPurchase("swordKey"), 5)
151
- conn:Disconnect()
152
152
 
153
153
  expect(outcome).toEqual("rejected")
154
- expect(promptRequested).toEqual(false)
154
+ expect(promptRequested()).toEqual(0)
155
155
  expect(context.tracker:IsPromptOpen()).toEqual(false)
156
156
  context:Destroy()
157
157
  end)
@@ -204,13 +204,9 @@ describe("PlayerAssetMarketTracker:HandlePurchaseEvent()", function()
204
204
  it("should fire the Purchased signal with the id on a successful purchase", function()
205
205
  local context = setup()
206
206
 
207
- local fired = {}
208
- local conn = context.tracker.Purchased:Connect(function(id)
209
- table.insert(fired, id)
210
- end)
207
+ local fired = SignalTestUtils.collectFireList(context.maid, context.tracker.Purchased)
211
208
 
212
209
  context.tracker:HandlePurchaseEvent(KEY_TO_ID.swordKey, true)
213
- conn:Disconnect()
214
210
 
215
211
  expect(#fired).toEqual(1)
216
212
  expect(fired[1]).toEqual(KEY_TO_ID.swordKey)
@@ -220,15 +216,11 @@ describe("PlayerAssetMarketTracker:HandlePurchaseEvent()", function()
220
216
  it("should not fire Purchased on a failed purchase", function()
221
217
  local context = setup()
222
218
 
223
- local firedCount = 0
224
- local conn = context.tracker.Purchased:Connect(function()
225
- firedCount += 1
226
- end)
219
+ local firedCount = SignalTestUtils.countFires(context.maid, context.tracker.Purchased)
227
220
 
228
221
  context.tracker:HandlePurchaseEvent(KEY_TO_ID.swordKey, false)
229
- conn:Disconnect()
230
222
 
231
- expect(firedCount).toEqual(0)
223
+ expect(firedCount()).toEqual(0)
232
224
  context:Destroy()
233
225
  end)
234
226
  end)
@@ -245,7 +237,7 @@ describe("PlayerAssetMarketTracker:PromisePromptPurchase()", function()
245
237
  it("should request a prompt and resolve true once the purchase succeeds", function()
246
238
  local context = setup()
247
239
 
248
- local promise, capturedId = promptAndCapture(context.tracker, "swordKey")
240
+ local promise, capturedId = promptAndCapture(context, "swordKey")
249
241
  expect(capturedId).toEqual(KEY_TO_ID.swordKey)
250
242
  expect(context.tracker:IsPromptOpen()).toEqual(true)
251
243
 
@@ -260,7 +252,7 @@ describe("PlayerAssetMarketTracker:PromisePromptPurchase()", function()
260
252
  it("should resolve false when the purchase is declined", function()
261
253
  local context = setup()
262
254
 
263
- local promise, capturedId = promptAndCapture(context.tracker, "swordKey")
255
+ local promise, capturedId = promptAndCapture(context, "swordKey")
264
256
  context.tracker:HandlePurchaseEvent(capturedId, false)
265
257
  context.tracker:HandlePromptClosedEvent(capturedId)
266
258
 
@@ -272,7 +264,7 @@ describe("PlayerAssetMarketTracker:PromisePromptPurchase()", function()
272
264
  it("should reject a second prompt while one is already open", function()
273
265
  local context = setup()
274
266
 
275
- local firstPromise, firstId = promptAndCapture(context.tracker, "swordKey")
267
+ local firstPromise, firstId = promptAndCapture(context, "swordKey")
276
268
  expect(context.tracker:IsPromptOpen()).toEqual(true)
277
269
 
278
270
  local secondOutcome = PromiseTestUtils.awaitOutcome(context.tracker:PromisePromptPurchase("shieldKey"), 5)
@@ -280,7 +272,7 @@ describe("PlayerAssetMarketTracker:PromisePromptPurchase()", function()
280
272
 
281
273
  context.tracker:HandlePurchaseEvent(firstId, true)
282
274
  context.tracker:HandlePromptClosedEvent(firstId)
283
- PromiseTestUtils.awaitSettled(firstPromise, 5)
275
+ PromiseTestUtils.awaitFulfilled(firstPromise)
284
276
  context:Destroy()
285
277
  end)
286
278
  end)
@@ -289,32 +281,27 @@ describe("PlayerAssetMarketTracker prompt open counting", function()
289
281
  it("should report the prompt closed after HandlePromptClosedEvent", function()
290
282
  local context = setup()
291
283
 
292
- local promise, capturedId = promptAndCapture(context.tracker, "swordKey")
284
+ local promise, capturedId = promptAndCapture(context, "swordKey")
293
285
  expect(context.tracker:IsPromptOpen()).toEqual(true)
294
286
 
295
287
  context.tracker:HandlePurchaseEvent(capturedId, true)
296
288
  context.tracker:HandlePromptClosedEvent(capturedId)
297
- PromiseTestUtils.awaitSettled(promise, 5)
289
+ PromiseTestUtils.awaitFulfilled(promise)
298
290
 
299
- expect(PromiseTestUtils.awaitValue(function()
300
- return not context.tracker:IsPromptOpen()
301
- end, 5)).toEqual(true)
291
+ expect(not context.tracker:IsPromptOpen()).toBe(true)
302
292
  context:Destroy()
303
293
  end)
304
294
 
305
295
  it("should surface the open count through ObservePromptOpenCount", function()
306
296
  local context = setup()
307
297
 
308
- local counts = {}
309
- local sub = context.tracker:ObservePromptOpenCount():Subscribe(function(value)
310
- table.insert(counts, value)
311
- end)
298
+ local counts = ObservableSpy.new(context.tracker:ObservePromptOpenCount())
312
299
 
313
- local promise, capturedId = promptAndCapture(context.tracker, "swordKey")
300
+ local promise, capturedId = promptAndCapture(context, "swordKey")
314
301
  context.tracker:HandlePurchaseEvent(capturedId, true)
315
302
  context.tracker:HandlePromptClosedEvent(capturedId)
316
- PromiseTestUtils.awaitSettled(promise, 5)
317
- sub:Destroy()
303
+ PromiseTestUtils.awaitFulfilled(promise)
304
+ counts:Destroy()
318
305
 
319
306
  expect(counts[1]).toEqual(0)
320
307
  local sawOpen = false
@@ -332,33 +319,24 @@ describe("PlayerAssetMarketTracker:ObserveAssetPurchased()", function()
332
319
  it("should fire when the tracked id is purchased", function()
333
320
  local context = setup()
334
321
 
335
- local fireCount = 0
336
- local sub = context.tracker:ObserveAssetPurchased("swordKey"):Subscribe(function()
337
- fireCount += 1
338
- end)
322
+ local emissions = ObservableSpy.new(context.tracker:ObserveAssetPurchased("swordKey") :: any)
339
323
 
340
324
  context.tracker:HandlePurchaseEvent(KEY_TO_ID.swordKey, true)
341
325
 
342
- expect(PromiseTestUtils.awaitValue(function()
343
- return fireCount > 0
344
- end, 5)).toEqual(true)
345
- sub:Destroy()
326
+ expect(#emissions > 0).toBe(true)
327
+ emissions:Destroy()
346
328
  context:Destroy()
347
329
  end)
348
330
 
349
331
  it("should not fire when a different id is purchased", function()
350
332
  local context = setup()
351
333
 
352
- local fireCount = 0
353
- local sub = context.tracker:ObserveAssetPurchased("swordKey"):Subscribe(function()
354
- fireCount += 1
355
- end)
334
+ local emissions = ObservableSpy.new(context.tracker:ObserveAssetPurchased("swordKey") :: any)
356
335
 
357
336
  context.tracker:HandlePurchaseEvent(KEY_TO_ID.shieldKey, true)
358
- task.wait()
359
- sub:Destroy()
337
+ emissions:Destroy()
360
338
 
361
- expect(fireCount).toEqual(0)
339
+ expect(#emissions).toEqual(0)
362
340
  context:Destroy()
363
341
  end)
364
342
  end)