@quenty/gameproductservice 14.70.0 → 14.71.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,10 @@
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.71.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/gameproductservice@14.70.0...@quenty/gameproductservice@14.71.0) (2026-08-28)
7
+
8
+ **Note:** Version bump only for package @quenty/gameproductservice
9
+
6
10
  # [14.70.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/gameproductservice@14.69.1...@quenty/gameproductservice@14.70.0) (2026-08-28)
7
11
 
8
12
  **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.70.0",
3
+ "version": "14.71.0",
4
4
  "description": "Generalized monetization system for handling products and purchases correctly.",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -30,39 +30,40 @@
30
30
  "access": "public"
31
31
  },
32
32
  "dependencies": {
33
- "@quenty/attributeutils": "14.37.0",
34
- "@quenty/avatareditorutils": "7.50.0",
33
+ "@quenty/attributeutils": "14.38.0",
34
+ "@quenty/avatareditorutils": "7.51.0",
35
35
  "@quenty/baseobject": "10.16.0",
36
- "@quenty/binder": "14.44.0",
37
- "@quenty/brio": "14.36.0",
38
- "@quenty/cmdrservice": "13.59.0",
36
+ "@quenty/binder": "14.45.0",
37
+ "@quenty/brio": "14.37.0",
38
+ "@quenty/cmdrservice": "13.60.0",
39
39
  "@quenty/enumutils": "3.4.6",
40
- "@quenty/gameconfig": "12.66.0",
41
- "@quenty/instanceutils": "13.36.0",
40
+ "@quenty/gameconfig": "12.67.0",
41
+ "@quenty/instanceutils": "13.37.0",
42
+ "@quenty/jestutils": "1.1.0",
42
43
  "@quenty/loader": "10.11.1",
43
44
  "@quenty/maid": "3.12.0",
44
- "@quenty/marketplaceutils": "11.31.0",
45
+ "@quenty/marketplaceutils": "11.32.0",
45
46
  "@quenty/nevermore-test-runner": "1.6.0",
46
- "@quenty/observablecollection": "12.49.0",
47
- "@quenty/permissionprovider": "14.50.0",
48
- "@quenty/playerbinder": "14.47.0",
49
- "@quenty/playermock": "1.7.0",
50
- "@quenty/playerutils": "8.42.0",
47
+ "@quenty/observablecollection": "12.50.0",
48
+ "@quenty/permissionprovider": "14.51.0",
49
+ "@quenty/playerbinder": "14.48.0",
50
+ "@quenty/playermock": "1.8.0",
51
+ "@quenty/playerutils": "8.43.0",
51
52
  "@quenty/promise": "10.24.0",
52
53
  "@quenty/promisemaid": "5.24.0",
53
- "@quenty/receiptprocessing": "7.43.0",
54
- "@quenty/remoting": "12.42.0",
54
+ "@quenty/receiptprocessing": "7.44.0",
55
+ "@quenty/remoting": "12.43.0",
55
56
  "@quenty/rx": "13.34.0",
56
- "@quenty/rxbinderutils": "14.44.0",
57
+ "@quenty/rxbinderutils": "14.45.0",
57
58
  "@quenty/servicebag": "11.21.0",
58
59
  "@quenty/signal": "7.13.2",
59
- "@quenty/statestack": "14.38.0",
60
- "@quenty/steputils": "3.8.0",
60
+ "@quenty/statestack": "14.39.0",
61
+ "@quenty/steputils": "3.9.0",
61
62
  "@quenty/string": "3.5.0",
62
63
  "@quenty/table": "3.9.2",
63
- "@quenty/tie": "10.48.0",
64
- "@quenty/valueobject": "13.37.0",
64
+ "@quenty/tie": "10.49.0",
65
+ "@quenty/valueobject": "13.38.0",
65
66
  "@quentystudios/jest-lua": "3.10.0-quenty.2"
66
67
  },
67
- "gitHead": "f75f93d5b2ac51cf7da3b7599788dcce31fd8a29"
68
+ "gitHead": "346201e192e467cb71160f43029863853be855b5"
68
69
  }
@@ -25,6 +25,7 @@ local require = require(script.Parent.loader).load(script)
25
25
  local GameConfigAssetTypes = require("GameConfigAssetTypes")
26
26
  local GameProductService = require("GameProductService")
27
27
  local Jest = require("Jest")
28
+ local JestUtils = require("JestUtils")
28
29
  local Maid = require("Maid")
29
30
  local PermissionProviderUtils = require("PermissionProviderUtils")
30
31
  local PlayerMock = require("PlayerMock")
@@ -71,7 +72,7 @@ local function setup()
71
72
  playerMockServiceClient:SetLocalPlayer(playerMock)
72
73
  clientBag:Start()
73
74
 
74
- return {
75
+ local controller = {
75
76
  serverBag = serverBag,
76
77
  clientBag = clientBag,
77
78
  gameProductService = gameProductService,
@@ -84,12 +85,16 @@ local function setup()
84
85
  expect(ok).toEqual(true)
85
86
  return value
86
87
  end,
87
- destroy = function(_self)
88
+ Destroy = function(_self)
88
89
  clientBag:Destroy()
89
90
  serverBag:Destroy()
90
91
  maid:DoCleaning()
91
92
  end,
92
93
  }
94
+
95
+ maid:GiveTask(JestUtils.afterThis(controller))
96
+
97
+ return controller
93
98
  end
94
99
 
95
100
  describe("GameProductService dual-realm boot", function()
@@ -99,7 +104,7 @@ describe("GameProductService dual-realm boot", function()
99
104
  expect(controller.gameProductService).never.toBeNil()
100
105
  expect(controller.gameProductServiceClient).never.toBeNil()
101
106
 
102
- controller:destroy()
107
+ controller:Destroy()
103
108
  end)
104
109
  end)
105
110
 
@@ -114,7 +119,7 @@ describe("PlayerProductManager discovers a PlayerMock", function()
114
119
 
115
120
  expect(binder:Get(controller.playerMock)).never.toBeNil()
116
121
 
117
- controller:destroy()
122
+ controller:Destroy()
118
123
  end)
119
124
  end)
120
125
 
@@ -142,7 +147,7 @@ describe("GameProductService server ownership from an injected lookup", function
142
147
  )
143
148
  ).toEqual(true)
144
149
 
145
- controller:destroy()
150
+ controller:Destroy()
146
151
  end)
147
152
 
148
153
  it("resolves ownership queried by a configured asset key", function()
@@ -160,7 +165,7 @@ describe("GameProductService server ownership from an injected lookup", function
160
165
  )
161
166
  ).toEqual(true)
162
167
 
163
- controller:destroy()
168
+ controller:Destroy()
164
169
  end)
165
170
 
166
171
  it("rejects an unconfigured asset key", function()
@@ -176,7 +181,7 @@ describe("GameProductService server ownership from an injected lookup", function
176
181
  )
177
182
  expect(outcome).toEqual("rejected")
178
183
 
179
- controller:destroy()
184
+ controller:Destroy()
180
185
  end)
181
186
  end)
182
187
 
@@ -204,7 +209,7 @@ describe("GameProductService ownership override", function()
204
209
  )
205
210
  ).toEqual(false)
206
211
 
207
- controller:destroy()
212
+ controller:Destroy()
208
213
  end)
209
214
 
210
215
  it("clears back to the injected cloud answer", function()
@@ -237,7 +242,7 @@ describe("GameProductService ownership override", function()
237
242
  )
238
243
  ).toEqual(true)
239
244
 
240
- controller:destroy()
245
+ controller:Destroy()
241
246
  end)
242
247
  end)
243
248
 
@@ -265,7 +270,7 @@ describe("GameProductServiceClient ownership for the designated mock", function(
265
270
  )
266
271
  ).toEqual(true)
267
272
 
268
- controller:destroy()
273
+ controller:Destroy()
269
274
  end)
270
275
 
271
276
  it("reports no session purchases for the mock on either realm", function()
@@ -286,7 +291,7 @@ describe("GameProductServiceClient ownership for the designated mock", function(
286
291
  )
287
292
  ).toEqual(false)
288
293
 
289
- controller:destroy()
294
+ controller:Destroy()
290
295
  end)
291
296
  end)
292
297
 
@@ -349,7 +354,7 @@ describe("client-initiated gamepass prompt", function()
349
354
  )
350
355
  ).toEqual(true)
351
356
 
352
- controller:destroy()
357
+ controller:Destroy()
353
358
  end)
354
359
 
355
360
  it("takes the client's word for a purchase the marketplace never confirms", function()
@@ -389,7 +394,7 @@ describe("client-initiated gamepass prompt", function()
389
394
  )
390
395
  ).toEqual(true)
391
396
 
392
- controller:destroy()
397
+ controller:Destroy()
393
398
  end)
394
399
 
395
400
  it("resolves false on reject and marks nothing purchased on either realm", function()
@@ -430,7 +435,7 @@ describe("client-initiated gamepass prompt", function()
430
435
  )
431
436
  ).toEqual(false)
432
437
 
433
- controller:destroy()
438
+ controller:Destroy()
434
439
  end)
435
440
  end)
436
441
 
@@ -482,7 +487,7 @@ describe("gamepass purchase verification under server-only prompting", function(
482
487
  )
483
488
  ).toEqual(false)
484
489
 
485
- controller:destroy()
490
+ controller:Destroy()
486
491
  end)
487
492
 
488
493
  it("grants the pass for a claim the marketplace confirms", function()
@@ -514,7 +519,7 @@ describe("gamepass purchase verification under server-only prompting", function(
514
519
  )
515
520
  ).toEqual(true)
516
521
 
517
- controller:destroy()
522
+ controller:Destroy()
518
523
  end)
519
524
 
520
525
  it("still refuses a client-initiated prompt", function()
@@ -533,7 +538,7 @@ describe("gamepass purchase verification under server-only prompting", function(
533
538
  )
534
539
  expect(outcome).toEqual("rejected")
535
540
 
536
- controller:destroy()
541
+ controller:Destroy()
537
542
  end)
538
543
  end)
539
544
 
@@ -580,7 +585,7 @@ describe("server-initiated gamepass prompt", function()
580
585
  )
581
586
  ).toEqual(true)
582
587
 
583
- controller:destroy()
588
+ controller:Destroy()
584
589
  end)
585
590
 
586
591
  it("resolves false on reject and leaves ownership untouched", function()
@@ -613,6 +618,6 @@ describe("server-initiated gamepass prompt", function()
613
618
  )
614
619
  ).toEqual(false)
615
620
 
616
- controller:destroy()
621
+ controller:Destroy()
617
622
  end)
618
623
  end)
@@ -14,6 +14,8 @@ local require = require(script.Parent.loader).load(script)
14
14
  local GameConfigAssetTypes = require("GameConfigAssetTypes")
15
15
  local GameProductDataService = require("GameProductDataService")
16
16
  local Jest = require("Jest")
17
+ local JestUtils = require("JestUtils")
18
+ local Maid = require("Maid")
17
19
  local PlayerMock = require("PlayerMock")
18
20
  local PromiseTestUtils = require("PromiseTestUtils")
19
21
  local ServiceBag = require("ServiceBag")
@@ -26,7 +28,8 @@ local expect = Jest.Globals.expect
26
28
  local it = Jest.Globals.it
27
29
 
28
30
  local function setup(tieRealm: TieRealms.TieRealm?)
29
- local serviceBag = ServiceBag.new()
31
+ local maid = Maid.new()
32
+ local serviceBag = maid:Add(ServiceBag.new())
30
33
  local tieRealmService: TieRealmService.TieRealmService = serviceBag:GetService(TieRealmService) :: any
31
34
  local gameProductDataService: GameProductDataService.GameProductDataService =
32
35
  serviceBag:GetService(GameProductDataService) :: any
@@ -34,14 +37,18 @@ local function setup(tieRealm: TieRealms.TieRealm?)
34
37
  tieRealmService:SetTieRealm(tieRealm or TieRealms.SERVER)
35
38
  serviceBag:Start()
36
39
 
37
- return {
40
+ local controller = {
38
41
  serviceBag = serviceBag,
39
42
  tieRealmService = tieRealmService,
40
43
  gameProductDataService = gameProductDataService,
41
- destroy = function()
42
- serviceBag:Destroy()
44
+ Destroy = function(_self)
45
+ maid:DoCleaning()
43
46
  end,
44
47
  }
48
+
49
+ maid:GiveTask(JestUtils.afterThis(controller))
50
+
51
+ return controller
45
52
  end
46
53
 
47
54
  describe("GameProductDataService purchase signals", function()
@@ -62,7 +69,7 @@ describe("GameProductDataService purchase signals", function()
62
69
  expect(Signal.isSignal((service :: any)[signalName])).toEqual(true)
63
70
  end
64
71
 
65
- context.destroy()
72
+ context:Destroy()
66
73
  end)
67
74
  end)
68
75
 
@@ -70,7 +77,7 @@ describe("GameProductDataService server-only prompting", function()
70
77
  it("should default to disabled", function()
71
78
  local context = setup()
72
79
  expect(context.gameProductDataService:GetServerOnlyPromptingValue().Value).toEqual(false)
73
- context.destroy()
80
+ context:Destroy()
74
81
  end)
75
82
 
76
83
  it("should enable and disable via SetServerOnlyPrompting on the server", function()
@@ -82,7 +89,7 @@ describe("GameProductDataService server-only prompting", function()
82
89
 
83
90
  service:SetServerOnlyPrompting(false)
84
91
  expect(service:GetServerOnlyPromptingValue().Value).toEqual(false)
85
- context.destroy()
92
+ context:Destroy()
86
93
  end)
87
94
 
88
95
  it("should replicate the change through the ValueObject observable", function()
@@ -99,7 +106,7 @@ describe("GameProductDataService server-only prompting", function()
99
106
 
100
107
  expect(values[1]).toEqual(false)
101
108
  expect(values[#values]).toEqual(true)
102
- context.destroy()
109
+ context:Destroy()
103
110
  end)
104
111
 
105
112
  it("should reject a non-boolean argument", function()
@@ -109,7 +116,7 @@ describe("GameProductDataService server-only prompting", function()
109
116
  expect(function()
110
117
  service:SetServerOnlyPrompting("nope" :: any)
111
118
  end).toThrow()
112
- context.destroy()
119
+ context:Destroy()
113
120
  end)
114
121
 
115
122
  it("should refuse to configure server-only prompting from the client realm", function()
@@ -119,7 +126,7 @@ describe("GameProductDataService server-only prompting", function()
119
126
  expect(function()
120
127
  service:SetServerOnlyPrompting(true)
121
128
  end).toThrow()
122
- context.destroy()
129
+ context:Destroy()
123
130
  end)
124
131
  end)
125
132
 
@@ -134,7 +141,7 @@ describe("GameProductDataService ownership overrides", function()
134
141
  end).toThrow()
135
142
 
136
143
  fakePlayer:Destroy()
137
- context.destroy()
144
+ context:Destroy()
138
145
  end)
139
146
 
140
147
  it("should refuse to clear an ownership override from the client realm", function()
@@ -147,7 +154,7 @@ describe("GameProductDataService ownership overrides", function()
147
154
  end).toThrow()
148
155
 
149
156
  fakePlayer:Destroy()
150
- context.destroy()
157
+ context:Destroy()
151
158
  end)
152
159
  end)
153
160
 
@@ -161,6 +168,6 @@ describe("GameProductDataService prompt guard", function()
161
168
  expect(outcome).toEqual("resolved")
162
169
 
163
170
  fakePlayer:Destroy()
164
- context.destroy()
171
+ context:Destroy()
165
172
  end)
166
173
  end)
@@ -4,8 +4,7 @@
4
4
  config picker (key -> id lookup) and a fake market tracker exposing only a Purchased signal, so
5
5
  no ServiceBag, GameConfig, or real MarketplaceService is involved. A PlayerMock stands in for
6
6
  the player because the tracker only stores the player, never reads properties off it in the code
7
- paths under test. Each test destroys everything it creates so nothing leaks into the shared test
8
- place.
7
+ paths under test.
9
8
 
10
9
  @class PlayerAssetOwnershipTracker.spec.lua
11
10
  ]]
@@ -15,6 +14,8 @@ local Brio = require("Brio")
15
14
  local GameConfigAssetTypes = require("GameConfigAssetTypes")
16
15
  local GameConfigPicker = require("GameConfigPicker")
17
16
  local Jest = require("Jest")
17
+ local JestUtils = require("JestUtils")
18
+ local Maid = require("Maid")
18
19
  local Observable = require("Observable")
19
20
  local PlayerAssetOwnershipTracker = require("PlayerAssetOwnershipTracker")
20
21
  local PlayerMock = require("PlayerMock")
@@ -65,6 +66,8 @@ local function makeConfigPicker()
65
66
  end
66
67
 
67
68
  local function setup()
69
+ local maid = Maid.new()
70
+
68
71
  local purchased = Signal.new()
69
72
  local marketTracker = { Purchased = purchased }
70
73
  local player = PlayerMock.new()
@@ -77,15 +80,23 @@ local function setup()
77
80
  marketTracker
78
81
  )
79
82
 
80
- return {
83
+ maid:GiveTask(function()
84
+ tracker:Destroy()
85
+ purchased:Destroy()
86
+ player:Destroy()
87
+ end)
88
+
89
+ local controller = {
81
90
  tracker = tracker,
82
91
  marketTracker = marketTracker,
83
- destroy = function()
84
- tracker:Destroy()
85
- purchased:Destroy()
86
- player:Destroy()
92
+ Destroy = function(_self)
93
+ maid:DoCleaning()
87
94
  end,
88
95
  }
96
+
97
+ maid:GiveTask(JestUtils.afterThis(controller))
98
+
99
+ return controller
89
100
  end
90
101
 
91
102
  describe("PlayerAssetOwnershipTracker:PromiseOwnsAsset()", function()
@@ -94,7 +105,7 @@ describe("PlayerAssetOwnershipTracker:PromiseOwnsAsset()", function()
94
105
 
95
106
  local outcome = PromiseTestUtils.awaitOutcome(context.tracker:PromiseOwnsAsset("doesNotExist"), 5)
96
107
  expect(outcome).toEqual("rejected")
97
- context.destroy()
108
+ context:Destroy()
98
109
  end)
99
110
 
100
111
  it("should reject when no ownership callback is set and the asset is not already owned", function()
@@ -102,7 +113,7 @@ describe("PlayerAssetOwnershipTracker:PromiseOwnsAsset()", function()
102
113
 
103
114
  local outcome = PromiseTestUtils.awaitOutcome(context.tracker:PromiseOwnsAsset("swordKey"), 5)
104
115
  expect(outcome).toEqual("rejected")
105
- context.destroy()
116
+ context:Destroy()
106
117
  end)
107
118
 
108
119
  it("should resolve true when the callback reports ownership", function()
@@ -116,7 +127,7 @@ describe("PlayerAssetOwnershipTracker:PromiseOwnsAsset()", function()
116
127
  local ok, owns = promise:Yield()
117
128
  expect(ok).toEqual(true)
118
129
  expect(owns).toEqual(true)
119
- context.destroy()
130
+ context:Destroy()
120
131
  end)
121
132
 
122
133
  it("should resolve false when the callback reports no ownership", function()
@@ -130,7 +141,7 @@ describe("PlayerAssetOwnershipTracker:PromiseOwnsAsset()", function()
130
141
  local ok, owns = promise:Yield()
131
142
  expect(ok).toEqual(true)
132
143
  expect(owns).toEqual(false)
133
- context.destroy()
144
+ context:Destroy()
134
145
  end)
135
146
 
136
147
  it("should cache the callback result and not query twice", function()
@@ -150,7 +161,7 @@ describe("PlayerAssetOwnershipTracker:PromiseOwnsAsset()", function()
150
161
  expect(callCount).toEqual(1)
151
162
  local _, owns = second:Yield()
152
163
  expect(owns).toEqual(true)
153
- context.destroy()
164
+ context:Destroy()
154
165
  end)
155
166
  end)
156
167
 
@@ -164,13 +175,13 @@ describe("PlayerAssetOwnershipTracker:SetOwnership()", function()
164
175
  expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
165
176
  local _, owns = promise:Yield()
166
177
  expect(owns).toEqual(true)
167
- context.destroy()
178
+ context:Destroy()
168
179
  end)
169
180
 
170
181
  it("should ignore an unknown key without erroring", function()
171
182
  local context = setup()
172
183
  context.tracker:SetOwnership("doesNotExist", true)
173
- context.destroy()
184
+ context:Destroy()
174
185
  end)
175
186
  end)
176
187
 
@@ -184,7 +195,7 @@ describe("PlayerAssetOwnershipTracker market tracker integration", function()
184
195
  expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
185
196
  local _, owns = promise:Yield()
186
197
  expect(owns).toEqual(true)
187
- context.destroy()
198
+ context:Destroy()
188
199
  end)
189
200
  end)
190
201
 
@@ -211,7 +222,7 @@ describe("PlayerAssetOwnershipTracker:SetQueryOwnershipCallback()", function()
211
222
  expect(secondCallbackCalls).toEqual(1)
212
223
  local _, secondOwns = second:Yield()
213
224
  expect(secondOwns).toEqual(true)
214
- context.destroy()
225
+ context:Destroy()
215
226
  end)
216
227
  end)
217
228
 
@@ -238,7 +249,7 @@ describe("PlayerAssetOwnershipTracker:ObserveOwnsAsset()", function()
238
249
  return values[#values] == true
239
250
  end, 5)).toEqual(true)
240
251
  sub:Destroy()
241
- context.destroy()
252
+ context:Destroy()
242
253
  end)
243
254
  end)
244
255
 
@@ -255,7 +266,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() ownership wins", fu
255
266
  expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
256
267
  local _, owns = promise:Yield()
257
268
  expect(owns).toEqual(true)
258
- context.destroy()
269
+ context:Destroy()
259
270
  end)
260
271
 
261
272
  it("should resolve false for a false override even when the callback reports ownership", function()
@@ -270,7 +281,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() ownership wins", fu
270
281
  expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
271
282
  local _, owns = promise:Yield()
272
283
  expect(owns).toEqual(false)
273
- context.destroy()
284
+ context:Destroy()
274
285
  end)
275
286
 
276
287
  it("should resolve true for a true override even with no callback set", function()
@@ -282,7 +293,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() ownership wins", fu
282
293
  expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
283
294
  local _, owns = promise:Yield()
284
295
  expect(owns).toEqual(true)
285
- context.destroy()
296
+ context:Destroy()
286
297
  end)
287
298
 
288
299
  it("should let a false override revoke an asset already in the owned set", function()
@@ -295,7 +306,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() ownership wins", fu
295
306
  expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
296
307
  local _, owns = promise:Yield()
297
308
  expect(owns).toEqual(false)
298
- context.destroy()
309
+ context:Destroy()
299
310
  end)
300
311
 
301
312
  it("should let a false override revoke an asset after a purchase fires", function()
@@ -308,7 +319,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() ownership wins", fu
308
319
  expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
309
320
  local _, owns = promise:Yield()
310
321
  expect(owns).toEqual(false)
311
- context.destroy()
322
+ context:Destroy()
312
323
  end)
313
324
 
314
325
  it("should not invoke the cloud callback while an override is set", function()
@@ -325,7 +336,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() ownership wins", fu
325
336
  PromiseTestUtils.awaitSettled(promise, 5)
326
337
 
327
338
  expect(callCount).toEqual(0)
328
- context.destroy()
339
+ context:Destroy()
329
340
  end)
330
341
  end)
331
342
 
@@ -347,7 +358,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() lifecycle", functio
347
358
  expect(PromiseTestUtils.awaitSettled(afterClear, 5)).toEqual(true)
348
359
  local _, ownsAfterClear = afterClear:Yield()
349
360
  expect(ownsAfterClear).toEqual(false)
350
- context.destroy()
361
+ context:Destroy()
351
362
  end)
352
363
 
353
364
  it("should treat SetOwnershipOverride(nil) as clearing the override", function()
@@ -363,7 +374,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() lifecycle", functio
363
374
  expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
364
375
  local _, owns = promise:Yield()
365
376
  expect(owns).toEqual(false)
366
- context.destroy()
377
+ context:Destroy()
367
378
  end)
368
379
 
369
380
  it("should flip when the override is re-set", function()
@@ -380,7 +391,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() lifecycle", functio
380
391
  PromiseTestUtils.awaitSettled(second, 5)
381
392
  local _, secondOwns = second:Yield()
382
393
  expect(secondOwns).toEqual(false)
383
- context.destroy()
394
+ context:Destroy()
384
395
  end)
385
396
  end)
386
397
 
@@ -394,7 +405,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() combined keys", fun
394
405
  expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
395
406
  local _, owns = promise:Yield()
396
407
  expect(owns).toEqual(true)
397
- context.destroy()
408
+ context:Destroy()
398
409
  end)
399
410
 
400
411
  it("should honor an override set by id when queried by key", function()
@@ -409,7 +420,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() combined keys", fun
409
420
  expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
410
421
  local _, owns = promise:Yield()
411
422
  expect(owns).toEqual(false)
412
- context.destroy()
423
+ context:Destroy()
413
424
  end)
414
425
 
415
426
  it("should not affect a different asset", function()
@@ -424,7 +435,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() combined keys", fun
424
435
  expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
425
436
  local _, owns = promise:Yield()
426
437
  expect(owns).toEqual(false)
427
- context.destroy()
438
+ context:Destroy()
428
439
  end)
429
440
 
430
441
  it("should ignore an override for an unknown key without erroring", function()
@@ -433,7 +444,7 @@ describe("PlayerAssetOwnershipTracker:SetOwnershipOverride() combined keys", fun
433
444
 
434
445
  local outcome = PromiseTestUtils.awaitOutcome(context.tracker:PromiseOwnsAsset("doesNotExist"), 5)
435
446
  expect(outcome).toEqual("rejected")
436
- context.destroy()
447
+ context:Destroy()
437
448
  end)
438
449
  end)
439
450
 
@@ -524,7 +535,7 @@ describe("PlayerAssetOwnershipTracker query failures", function()
524
535
  for _, sub in subs do
525
536
  sub:Destroy()
526
537
  end
527
- context.destroy()
538
+ context:Destroy()
528
539
  end)
529
540
 
530
541
  it("should not report an asset it was never given a callback to query", function()
@@ -537,7 +548,7 @@ describe("PlayerAssetOwnershipTracker query failures", function()
537
548
  expect(outcome).toEqual("rejected")
538
549
 
539
550
  expect(#reports).toEqual(0)
540
- context.destroy()
551
+ context:Destroy()
541
552
  end)
542
553
 
543
554
  it("should not report a query cancelled by teardown as a failure", function()
@@ -553,7 +564,7 @@ describe("PlayerAssetOwnershipTracker query failures", function()
553
564
 
554
565
  -- Destroying the tracker rejects the query with nothing, which is teardown rather than a refusal.
555
566
  -- The real _warnQueryFailed drops it on the nil check; here we see it arrive and assert the shape.
556
- context.destroy()
567
+ context:Destroy()
557
568
  expect(PromiseTestUtils.awaitSettled(asked, 5)).toEqual(true)
558
569
  local askedOk = asked:Yield()
559
570
  expect(askedOk).toEqual(false)
@@ -593,7 +604,7 @@ describe("PlayerAssetOwnershipTracker:ObserveOwnsAsset() overrides", function()
593
604
  end, 5)).toEqual(true)
594
605
 
595
606
  sub:Destroy()
596
- context.destroy()
607
+ context:Destroy()
597
608
  end)
598
609
 
599
610
  it("should emit false for a false override even when the cloud query reports ownership", function()
@@ -614,7 +625,7 @@ describe("PlayerAssetOwnershipTracker:ObserveOwnsAsset() overrides", function()
614
625
  end, 5)).toEqual(true)
615
626
 
616
627
  sub:Destroy()
617
- context.destroy()
628
+ context:Destroy()
618
629
  end)
619
630
  end)
620
631
 
@@ -2,8 +2,7 @@
2
2
  --[[
3
3
  Unit coverage for PlayerAssetMarketTracker. The tracker is constructed directly with a fake
4
4
  id-conversion table and a synchronous brio observable, so no ServiceBag, GameConfig, or real
5
- MarketplaceService is involved. Each test builds a fresh tracker and destroys it so nothing
6
- leaks into the shared test place.
5
+ MarketplaceService is involved.
7
6
 
8
7
  @class PlayerAssetMarketTracker.spec.lua
9
8
  ]]
@@ -12,6 +11,8 @@ local require = require(script.Parent.loader).load(script)
12
11
  local Brio = require("Brio")
13
12
  local GameConfigAssetTypes = require("GameConfigAssetTypes")
14
13
  local Jest = require("Jest")
14
+ local JestUtils = require("JestUtils")
15
+ local Maid = require("Maid")
15
16
  local Observable = require("Observable")
16
17
  local PlayerAssetMarketTracker = require("PlayerAssetMarketTracker")
17
18
  local PromiseTestUtils = require("PromiseTestUtils")
@@ -32,9 +33,6 @@ local function convertIds(idOrKey)
32
33
  return KEY_TO_ID[idOrKey]
33
34
  end
34
35
 
35
- -- Emits a single live brio wrapping the resolved id, synchronously on subscribe, then completes
36
- -- for unknown keys. Synchronous emission lets ObserveAssetPurchased register the known id before
37
- -- the test fires Purchased.
38
36
  local function observeIdsBrio(idOrKey)
39
37
  return Observable.new(function(sub)
40
38
  local id = convertIds(idOrKey)
@@ -53,25 +51,37 @@ local function observeIdsBrio(idOrKey)
53
51
  end
54
52
 
55
53
  local function setup()
54
+ local maid = Maid.new()
56
55
  local tracker = PlayerAssetMarketTracker.new(GameConfigAssetTypes.PRODUCT, convertIds, observeIdsBrio)
56
+ maid:GiveTask(tracker)
57
57
 
58
- return {
58
+ local controller = {
59
59
  tracker = tracker,
60
- destroy = function()
61
- tracker:Destroy()
60
+ Destroy = function(_self)
61
+ maid:DoCleaning()
62
62
  end,
63
63
  }
64
+
65
+ maid:GiveTask(JestUtils.afterThis(controller))
66
+
67
+ return controller
64
68
  end
65
69
 
66
70
  local function setupNonPromptable()
71
+ local maid = Maid.new()
67
72
  local tracker = PlayerAssetMarketTracker.new(GameConfigAssetTypes.GAME, convertIds, observeIdsBrio, false)
73
+ maid:GiveTask(tracker)
68
74
 
69
- return {
75
+ local controller = {
70
76
  tracker = tracker,
71
- destroy = function()
72
- tracker:Destroy()
77
+ Destroy = function(_self)
78
+ maid:DoCleaning()
73
79
  end,
74
80
  }
81
+
82
+ maid:GiveTask(JestUtils.afterThis(controller))
83
+
84
+ return controller
75
85
  end
76
86
 
77
87
  local function promptAndCapture(tracker, idOrKey)
@@ -93,13 +103,13 @@ describe("PlayerAssetMarketTracker basics", function()
93
103
  it("should report its asset type", function()
94
104
  local context = setup()
95
105
  expect(context.tracker:GetAssetType()).toEqual(GameConfigAssetTypes.PRODUCT)
96
- context.destroy()
106
+ context:Destroy()
97
107
  end)
98
108
 
99
109
  it("should start with no prompt open", function()
100
110
  local context = setup()
101
111
  expect(context.tracker:IsPromptOpen()).toEqual(false)
102
- context.destroy()
112
+ context:Destroy()
103
113
  end)
104
114
 
105
115
  it("should hold and return an ownership tracker", function()
@@ -112,13 +122,13 @@ describe("PlayerAssetMarketTracker basics", function()
112
122
 
113
123
  context.tracker:SetOwnershipTracker(nil)
114
124
  expect(context.tracker:GetOwnershipTracker()).toBeNil()
115
- context.destroy()
125
+ context:Destroy()
116
126
  end)
117
127
 
118
128
  it("should be promptable by default", function()
119
129
  local context = setup()
120
130
  expect(context.tracker:IsPromptable()).toEqual(true)
121
- context.destroy()
131
+ context:Destroy()
122
132
  end)
123
133
  end)
124
134
 
@@ -126,7 +136,7 @@ describe("PlayerAssetMarketTracker non-promptable asset types", function()
126
136
  it("should report IsPromptable() as false", function()
127
137
  local context = setupNonPromptable()
128
138
  expect(context.tracker:IsPromptable()).toEqual(false)
129
- context.destroy()
139
+ context:Destroy()
130
140
  end)
131
141
 
132
142
  it("should reject PromisePromptPurchase for a known id without opening a prompt", function()
@@ -143,7 +153,7 @@ describe("PlayerAssetMarketTracker non-promptable asset types", function()
143
153
  expect(outcome).toEqual("rejected")
144
154
  expect(promptRequested).toEqual(false)
145
155
  expect(context.tracker:IsPromptOpen()).toEqual(false)
146
- context.destroy()
156
+ context:Destroy()
147
157
  end)
148
158
 
149
159
  it("should reject PromisePromptPurchase for an unknown key too", function()
@@ -151,7 +161,7 @@ describe("PlayerAssetMarketTracker non-promptable asset types", function()
151
161
 
152
162
  local outcome = PromiseTestUtils.awaitOutcome(context.tracker:PromisePromptPurchase("doesNotExist"), 5)
153
163
  expect(outcome).toEqual("rejected")
154
- context.destroy()
164
+ context:Destroy()
155
165
  end)
156
166
  end)
157
167
 
@@ -159,34 +169,34 @@ describe("PlayerAssetMarketTracker:HasPurchasedThisSession()", function()
159
169
  it("should return false before anything is purchased", function()
160
170
  local context = setup()
161
171
  expect(context.tracker:HasPurchasedThisSession("swordKey")).toEqual(false)
162
- context.destroy()
172
+ context:Destroy()
163
173
  end)
164
174
 
165
175
  it("should return true after a purchase event for that id", function()
166
176
  local context = setup()
167
177
  context.tracker:HandlePurchaseEvent(KEY_TO_ID.swordKey, true)
168
178
  expect(context.tracker:HasPurchasedThisSession("swordKey")).toEqual(true)
169
- context.destroy()
179
+ context:Destroy()
170
180
  end)
171
181
 
172
182
  it("should stay false for a different id than the one purchased", function()
173
183
  local context = setup()
174
184
  context.tracker:HandlePurchaseEvent(KEY_TO_ID.swordKey, true)
175
185
  expect(context.tracker:HasPurchasedThisSession("shieldKey")).toEqual(false)
176
- context.destroy()
186
+ context:Destroy()
177
187
  end)
178
188
 
179
189
  it("should return false for an unknown key", function()
180
190
  local context = setup()
181
191
  expect(context.tracker:HasPurchasedThisSession("doesNotExist")).toEqual(false)
182
- context.destroy()
192
+ context:Destroy()
183
193
  end)
184
194
 
185
195
  it("should not mark a failed purchase as purchased", function()
186
196
  local context = setup()
187
197
  context.tracker:HandlePurchaseEvent(KEY_TO_ID.swordKey, false)
188
198
  expect(context.tracker:HasPurchasedThisSession("swordKey")).toEqual(false)
189
- context.destroy()
199
+ context:Destroy()
190
200
  end)
191
201
  end)
192
202
 
@@ -204,7 +214,7 @@ describe("PlayerAssetMarketTracker:HandlePurchaseEvent()", function()
204
214
 
205
215
  expect(#fired).toEqual(1)
206
216
  expect(fired[1]).toEqual(KEY_TO_ID.swordKey)
207
- context.destroy()
217
+ context:Destroy()
208
218
  end)
209
219
 
210
220
  it("should not fire Purchased on a failed purchase", function()
@@ -219,7 +229,7 @@ describe("PlayerAssetMarketTracker:HandlePurchaseEvent()", function()
219
229
  conn:Disconnect()
220
230
 
221
231
  expect(firedCount).toEqual(0)
222
- context.destroy()
232
+ context:Destroy()
223
233
  end)
224
234
  end)
225
235
 
@@ -229,7 +239,7 @@ describe("PlayerAssetMarketTracker:PromisePromptPurchase()", function()
229
239
 
230
240
  local outcome = PromiseTestUtils.awaitOutcome(context.tracker:PromisePromptPurchase("doesNotExist"), 5)
231
241
  expect(outcome).toEqual("rejected")
232
- context.destroy()
242
+ context:Destroy()
233
243
  end)
234
244
 
235
245
  it("should request a prompt and resolve true once the purchase succeeds", function()
@@ -246,7 +256,7 @@ describe("PlayerAssetMarketTracker:PromisePromptPurchase()", function()
246
256
  local ok, purchased = promise:Yield()
247
257
  expect(ok).toEqual(true)
248
258
  expect(purchased).toEqual(true)
249
- context.destroy()
259
+ context:Destroy()
250
260
  end)
251
261
 
252
262
  it("should resolve false when the purchase is declined", function()
@@ -260,7 +270,7 @@ describe("PlayerAssetMarketTracker:PromisePromptPurchase()", function()
260
270
  local ok, purchased = promise:Yield()
261
271
  expect(ok).toEqual(true)
262
272
  expect(purchased).toEqual(false)
263
- context.destroy()
273
+ context:Destroy()
264
274
  end)
265
275
 
266
276
  it("should reject a second prompt while one is already open", function()
@@ -275,7 +285,7 @@ describe("PlayerAssetMarketTracker:PromisePromptPurchase()", function()
275
285
  context.tracker:HandlePurchaseEvent(firstId, true)
276
286
  context.tracker:HandlePromptClosedEvent(firstId)
277
287
  PromiseTestUtils.awaitSettled(firstPromise, 5)
278
- context.destroy()
288
+ context:Destroy()
279
289
  end)
280
290
  end)
281
291
 
@@ -293,7 +303,7 @@ describe("PlayerAssetMarketTracker prompt open counting", function()
293
303
  expect(PromiseTestUtils.awaitValue(function()
294
304
  return not context.tracker:IsPromptOpen()
295
305
  end, 5)).toEqual(true)
296
- context.destroy()
306
+ context:Destroy()
297
307
  end)
298
308
 
299
309
  it("should surface the open count through ObservePromptOpenCount", function()
@@ -318,7 +328,7 @@ describe("PlayerAssetMarketTracker prompt open counting", function()
318
328
  end
319
329
  end
320
330
  expect(sawOpen).toEqual(true)
321
- context.destroy()
331
+ context:Destroy()
322
332
  end)
323
333
  end)
324
334
 
@@ -337,7 +347,7 @@ describe("PlayerAssetMarketTracker:ObserveAssetPurchased()", function()
337
347
  return fireCount > 0
338
348
  end, 5)).toEqual(true)
339
349
  sub:Destroy()
340
- context.destroy()
350
+ context:Destroy()
341
351
  end)
342
352
 
343
353
  it("should not fire when a different id is purchased", function()
@@ -353,6 +363,6 @@ describe("PlayerAssetMarketTracker:ObserveAssetPurchased()", function()
353
363
  sub:Destroy()
354
364
 
355
365
  expect(fireCount).toEqual(0)
356
- context.destroy()
366
+ context:Destroy()
357
367
  end)
358
368
  end)