@quenty/saveslot 2.16.1 → 2.16.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 +4 -0
- package/package.json +28 -28
- package/src/Client/Binders/HasSaveSlotsClient.spec.lua +54 -89
- package/src/Server/Binders/HasSaveSlots.PreSelect.spec.lua +4 -5
- package/src/Server/Binders/HasSaveSlots.spec.lua +72 -212
- package/src/Server/SaveSlotService.LateSettle.spec.lua +12 -13
- package/src/Server/SaveSlotService.spec.lua +8 -4
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
|
+
## [2.16.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/saveslot@2.16.1...@quenty/saveslot@2.16.2) (2026-11-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/saveslot
|
|
9
|
+
|
|
6
10
|
## [2.16.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/saveslot@2.16.0...@quenty/saveslot@2.16.1) (2026-10-24)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @quenty/saveslot
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/saveslot",
|
|
3
|
-
"version": "2.16.
|
|
3
|
+
"version": "2.16.2",
|
|
4
4
|
"description": "PlayerDataStoreService wrapper for save slots",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,37 +28,37 @@
|
|
|
28
28
|
"Quenty"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@quenty/adorneedata": "7.44.
|
|
32
|
-
"@quenty/attributeutils": "14.39.
|
|
33
|
-
"@quenty/baseobject": "10.16.
|
|
34
|
-
"@quenty/binder": "14.48.
|
|
35
|
-
"@quenty/bindtocloseservice": "8.46.
|
|
36
|
-
"@quenty/brio": "14.38.
|
|
37
|
-
"@quenty/cmdrservice": "13.65.
|
|
38
|
-
"@quenty/datastore": "13.60.
|
|
39
|
-
"@quenty/instanceutils": "13.38.
|
|
40
|
-
"@quenty/jestutils": "1.1.
|
|
31
|
+
"@quenty/adorneedata": "7.44.2",
|
|
32
|
+
"@quenty/attributeutils": "14.39.2",
|
|
33
|
+
"@quenty/baseobject": "10.16.4",
|
|
34
|
+
"@quenty/binder": "14.48.2",
|
|
35
|
+
"@quenty/bindtocloseservice": "8.46.2",
|
|
36
|
+
"@quenty/brio": "14.38.2",
|
|
37
|
+
"@quenty/cmdrservice": "13.65.1",
|
|
38
|
+
"@quenty/datastore": "13.60.1",
|
|
39
|
+
"@quenty/instanceutils": "13.38.2",
|
|
40
|
+
"@quenty/jestutils": "1.1.4",
|
|
41
41
|
"@quenty/loader": "10.11.3",
|
|
42
|
-
"@quenty/maid": "3.12.
|
|
43
|
-
"@quenty/nevermore-test-runner": "1.6.
|
|
44
|
-
"@quenty/observablecollection": "12.55.
|
|
45
|
-
"@quenty/playerbinder": "14.52.
|
|
46
|
-
"@quenty/playermock": "1.11.
|
|
47
|
-
"@quenty/promise": "10.25.
|
|
48
|
-
"@quenty/propertyvalue": "7.38.
|
|
49
|
-
"@quenty/remoting": "12.46.
|
|
50
|
-
"@quenty/rx": "13.35.
|
|
51
|
-
"@quenty/servicebag": "11.21.
|
|
52
|
-
"@quenty/signal": "7.13.
|
|
42
|
+
"@quenty/maid": "3.12.4",
|
|
43
|
+
"@quenty/nevermore-test-runner": "1.6.4",
|
|
44
|
+
"@quenty/observablecollection": "12.55.1",
|
|
45
|
+
"@quenty/playerbinder": "14.52.2",
|
|
46
|
+
"@quenty/playermock": "1.11.2",
|
|
47
|
+
"@quenty/promise": "10.25.2",
|
|
48
|
+
"@quenty/propertyvalue": "7.38.2",
|
|
49
|
+
"@quenty/remoting": "12.46.2",
|
|
50
|
+
"@quenty/rx": "13.35.2",
|
|
51
|
+
"@quenty/servicebag": "11.21.4",
|
|
52
|
+
"@quenty/signal": "7.13.5",
|
|
53
53
|
"@quenty/table": "3.9.2",
|
|
54
|
-
"@quenty/teleportserviceutils": "10.8.
|
|
55
|
-
"@quenty/tie": "10.52.
|
|
56
|
-
"@quenty/time": "2.8.
|
|
57
|
-
"@quenty/valueobject": "13.39.
|
|
58
|
-
"@quentystudios/jest-lua": "3.10.0-quenty.
|
|
54
|
+
"@quenty/teleportserviceutils": "10.8.2",
|
|
55
|
+
"@quenty/tie": "10.52.2",
|
|
56
|
+
"@quenty/time": "2.8.2",
|
|
57
|
+
"@quenty/valueobject": "13.39.2",
|
|
58
|
+
"@quentystudios/jest-lua": "3.10.0-quenty.3"
|
|
59
59
|
},
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "f51b2de38a02f8d92758da8d381a378e760170aa"
|
|
64
64
|
}
|
|
@@ -11,8 +11,8 @@ local HasSaveSlotsInterface = require("HasSaveSlotsInterface")
|
|
|
11
11
|
local Jest = require("Jest")
|
|
12
12
|
local JestUtils = require("JestUtils")
|
|
13
13
|
local Maid = require("Maid")
|
|
14
|
+
local ObservableSpy = require("ObservableSpy")
|
|
14
15
|
local PlayerMock = require("PlayerMock")
|
|
15
|
-
local PromiseTestUtils = require("PromiseTestUtils")
|
|
16
16
|
local SaveSlotDataService = require("SaveSlotDataService")
|
|
17
17
|
local ServiceBag = require("ServiceBag")
|
|
18
18
|
local TeleportDataServiceClient = require("TeleportDataServiceClient")
|
|
@@ -82,21 +82,12 @@ describe("HasSaveSlotsClient active-slot observation", function()
|
|
|
82
82
|
|
|
83
83
|
playerMock:SetAttribute("ActiveSlotId", "slot-a")
|
|
84
84
|
|
|
85
|
-
local
|
|
86
|
-
maid:GiveTask(dataService:ObserveActiveSlotId(playerMock):Subscribe(function(slotId: string?)
|
|
87
|
-
observed = slotId
|
|
88
|
-
end))
|
|
85
|
+
local observedValues = maid:Add(ObservableSpy.new(dataService:ObserveActiveSlotId(playerMock)))
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
return observed == "slot-a"
|
|
92
|
-
end, 5)
|
|
93
|
-
expect(observed).toEqual("slot-a")
|
|
87
|
+
expect(observedValues:GetLastValue()).toEqual("slot-a")
|
|
94
88
|
|
|
95
89
|
playerMock:SetAttribute("ActiveSlotId", "slot-b")
|
|
96
|
-
|
|
97
|
-
return observed == "slot-b"
|
|
98
|
-
end, 5)
|
|
99
|
-
expect(observed).toEqual("slot-b")
|
|
90
|
+
expect(observedValues:GetLastValue()).toEqual("slot-b")
|
|
100
91
|
end)
|
|
101
92
|
end)
|
|
102
93
|
|
|
@@ -121,28 +112,8 @@ local function newSlotContainer(maid: Maid.Maid): Folder
|
|
|
121
112
|
return container
|
|
122
113
|
end
|
|
123
114
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
-- `values` collects only non-nil emissions (a Lua array cannot hold nils); streams that never emit nil
|
|
127
|
-
-- -- the boolean ones -- can assert their full sequence against it, everything else uses count/latest.
|
|
128
|
-
local function subscribeRecording(maid: Maid.Maid, observable: any): Record
|
|
129
|
-
local record: Record = { count = 0, latest = nil, values = {} }
|
|
130
|
-
|
|
131
|
-
maid:GiveTask(observable:Subscribe(function(value)
|
|
132
|
-
record.count += 1
|
|
133
|
-
record.latest = value
|
|
134
|
-
if value ~= nil then
|
|
135
|
-
table.insert(record.values, value)
|
|
136
|
-
end
|
|
137
|
-
end))
|
|
138
|
-
|
|
139
|
-
return record
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
local function awaitLatest(record: Record, predicate: (any) -> boolean): boolean
|
|
143
|
-
return PromiseTestUtils.awaitValue(function()
|
|
144
|
-
return predicate(record.latest)
|
|
145
|
-
end, 5)
|
|
115
|
+
local function latestMatches(record: ObservableSpy.ObservableSpy<any>, predicate: (any) -> boolean): boolean
|
|
116
|
+
return predicate(record:GetLastValue())
|
|
146
117
|
end
|
|
147
118
|
|
|
148
119
|
local function listedIds(slotList: { any }?): { [string]: boolean }
|
|
@@ -158,10 +129,10 @@ describe("SaveSlotDataService active-slot metadata on the client", function()
|
|
|
158
129
|
local maid, _, dataService = setup()
|
|
159
130
|
local playerMock = newPlayerMock(maid, true)
|
|
160
131
|
|
|
161
|
-
local record =
|
|
132
|
+
local record = maid:Add(ObservableSpy.new(dataService:ObserveActiveSlotMetadata(playerMock)))
|
|
162
133
|
|
|
163
|
-
expect(record
|
|
164
|
-
expect(record
|
|
134
|
+
expect(#record).toEqual(1)
|
|
135
|
+
expect(record:GetLastValue()).toBeNil()
|
|
165
136
|
end)
|
|
166
137
|
|
|
167
138
|
it("resolves the active ephemeral slot when its folder arrives after the active-slot id", function()
|
|
@@ -170,18 +141,18 @@ describe("SaveSlotDataService active-slot metadata on the client", function()
|
|
|
170
141
|
binder:Bind(playerMock)
|
|
171
142
|
playerMock:SetAttribute("ActiveSlotId", EPHEMERAL_ID)
|
|
172
143
|
|
|
173
|
-
local record =
|
|
174
|
-
expect(record
|
|
144
|
+
local record = maid:Add(ObservableSpy.new(dataService:ObserveActiveSlotMetadata(playerMock)))
|
|
145
|
+
expect(record:GetLastValue()).toBeNil()
|
|
175
146
|
|
|
176
147
|
local container = newSlotContainer(maid)
|
|
177
148
|
newSlot(EPHEMERAL_ID, 0, "Lobby run", true).Parent = container
|
|
178
149
|
container.Parent = playerMock
|
|
179
150
|
|
|
180
|
-
expect(
|
|
151
|
+
expect(latestMatches(record, function(metadata)
|
|
181
152
|
return metadata ~= nil and metadata.SlotName == "Lobby run"
|
|
182
153
|
end)).toEqual(true)
|
|
183
|
-
expect(record.
|
|
184
|
-
expect(record.
|
|
154
|
+
expect(record:GetLastValue().SlotId).toEqual(EPHEMERAL_ID)
|
|
155
|
+
expect(record:GetLastValue().IsEphemeral).toEqual(true)
|
|
185
156
|
end)
|
|
186
157
|
|
|
187
158
|
it("resolves the active ephemeral slot when the active-slot id arrives after its folder", function()
|
|
@@ -193,12 +164,12 @@ describe("SaveSlotDataService active-slot metadata on the client", function()
|
|
|
193
164
|
newSlot(EPHEMERAL_ID, 0, "Lobby run", true).Parent = container
|
|
194
165
|
container.Parent = playerMock
|
|
195
166
|
|
|
196
|
-
local record =
|
|
197
|
-
expect(record
|
|
167
|
+
local record = maid:Add(ObservableSpy.new(dataService:ObserveActiveSlotMetadata(playerMock)))
|
|
168
|
+
expect(record:GetLastValue()).toBeNil()
|
|
198
169
|
|
|
199
170
|
playerMock:SetAttribute("ActiveSlotId", EPHEMERAL_ID)
|
|
200
171
|
|
|
201
|
-
expect(
|
|
172
|
+
expect(latestMatches(record, function(metadata)
|
|
202
173
|
return metadata ~= nil and metadata.SlotId == EPHEMERAL_ID
|
|
203
174
|
end)).toEqual(true)
|
|
204
175
|
end)
|
|
@@ -214,15 +185,15 @@ describe("SaveSlotDataService active-slot metadata on the client", function()
|
|
|
214
185
|
container.Parent = playerMock
|
|
215
186
|
playerMock:SetAttribute("ActiveSlotId", EPHEMERAL_ID)
|
|
216
187
|
|
|
217
|
-
local record =
|
|
218
|
-
expect(
|
|
188
|
+
local record = maid:Add(ObservableSpy.new(dataService:ObserveActiveSlotMetadata(playerMock)))
|
|
189
|
+
expect(latestMatches(record, function(metadata)
|
|
219
190
|
return metadata ~= nil
|
|
220
191
|
end)).toEqual(true)
|
|
221
192
|
|
|
222
193
|
-- A retire replicates as the folder disappearing; the id can still name it for a frame.
|
|
223
194
|
ephemeralSlot:Destroy()
|
|
224
195
|
|
|
225
|
-
expect(
|
|
196
|
+
expect(latestMatches(record, function(metadata)
|
|
226
197
|
return metadata == nil
|
|
227
198
|
end)).toEqual(true)
|
|
228
199
|
end)
|
|
@@ -239,18 +210,18 @@ describe("SaveSlotDataService active-slot metadata on the client", function()
|
|
|
239
210
|
container.Parent = playerMock
|
|
240
211
|
playerMock:SetAttribute("ActiveSlotId", EPHEMERAL_ID)
|
|
241
212
|
|
|
242
|
-
local record =
|
|
243
|
-
expect(
|
|
213
|
+
local record = maid:Add(ObservableSpy.new(dataService:ObserveActiveSlotMetadata(playerMock)))
|
|
214
|
+
expect(latestMatches(record, function(metadata)
|
|
244
215
|
return metadata ~= nil and metadata.SlotId == EPHEMERAL_ID
|
|
245
216
|
end)).toEqual(true)
|
|
246
217
|
|
|
247
218
|
playerMock:SetAttribute("ActiveSlotId", REAL_ID)
|
|
248
219
|
ephemeralSlot:Destroy()
|
|
249
220
|
|
|
250
|
-
expect(
|
|
221
|
+
expect(latestMatches(record, function(metadata)
|
|
251
222
|
return metadata ~= nil and metadata.SlotId == REAL_ID
|
|
252
223
|
end)).toEqual(true)
|
|
253
|
-
expect(record.
|
|
224
|
+
expect(record:GetLastValue().IsEphemeral).toBeNil()
|
|
254
225
|
end)
|
|
255
226
|
|
|
256
227
|
it("reads the active ephemeral slot synchronously too", function()
|
|
@@ -263,9 +234,7 @@ describe("SaveSlotDataService active-slot metadata on the client", function()
|
|
|
263
234
|
container.Parent = playerMock
|
|
264
235
|
playerMock:SetAttribute("ActiveSlotId", EPHEMERAL_ID)
|
|
265
236
|
|
|
266
|
-
expect(
|
|
267
|
-
return dataService:GetActiveSlotMetadata(playerMock) ~= nil
|
|
268
|
-
end, 5)).toEqual(true)
|
|
237
|
+
expect(dataService:GetActiveSlotMetadata(playerMock)).never.toBeNil()
|
|
269
238
|
|
|
270
239
|
local metadata = dataService:GetActiveSlotMetadata(playerMock)
|
|
271
240
|
expect(metadata.SlotId).toEqual(EPHEMERAL_ID)
|
|
@@ -286,15 +255,15 @@ describe("SaveSlotDataService ephemeral-state observation on the client", functi
|
|
|
286
255
|
container.Parent = playerMock
|
|
287
256
|
playerMock:SetAttribute("ActiveSlotId", EPHEMERAL_ID)
|
|
288
257
|
|
|
289
|
-
local record =
|
|
290
|
-
expect(record
|
|
258
|
+
local record = maid:Add(ObservableSpy.new(dataService:ObserveIsActiveSlotEphemeral(playerMock)))
|
|
259
|
+
expect(record:GetLastValue()).toEqual(false)
|
|
291
260
|
|
|
292
261
|
slot:SetAttribute("IsEphemeral", true)
|
|
293
262
|
|
|
294
|
-
expect(
|
|
263
|
+
expect(latestMatches(record, function(isEphemeral)
|
|
295
264
|
return isEphemeral == true
|
|
296
265
|
end)).toEqual(true)
|
|
297
|
-
expect(record.
|
|
266
|
+
expect(record.Values).toEqual({ false, true })
|
|
298
267
|
end)
|
|
299
268
|
|
|
300
269
|
it("does not re-emit when unrelated metadata on the active slot changes", function()
|
|
@@ -308,19 +277,17 @@ describe("SaveSlotDataService ephemeral-state observation on the client", functi
|
|
|
308
277
|
container.Parent = playerMock
|
|
309
278
|
playerMock:SetAttribute("ActiveSlotId", EPHEMERAL_ID)
|
|
310
279
|
|
|
311
|
-
local record =
|
|
312
|
-
expect(
|
|
280
|
+
local record = maid:Add(ObservableSpy.new(dataService:ObserveIsActiveSlotEphemeral(playerMock)))
|
|
281
|
+
expect(latestMatches(record, function(isEphemeral)
|
|
313
282
|
return isEphemeral == true
|
|
314
283
|
end)).toEqual(true)
|
|
315
284
|
|
|
316
|
-
local countAfterResolve = record
|
|
285
|
+
local countAfterResolve = #record
|
|
317
286
|
slot:SetAttribute("SlotName", "Lobby run 2")
|
|
318
287
|
slot:SetAttribute("TimePlayed", 90)
|
|
319
288
|
|
|
320
|
-
expect(
|
|
321
|
-
|
|
322
|
-
end, 1)).toEqual(false)
|
|
323
|
-
expect(record.latest).toEqual(true)
|
|
289
|
+
expect(#record).toEqual(countAfterResolve)
|
|
290
|
+
expect(record:GetLastValue()).toEqual(true)
|
|
324
291
|
end)
|
|
325
292
|
|
|
326
293
|
it("returns to false when the ephemeral slot is retired", function()
|
|
@@ -334,15 +301,15 @@ describe("SaveSlotDataService ephemeral-state observation on the client", functi
|
|
|
334
301
|
container.Parent = playerMock
|
|
335
302
|
playerMock:SetAttribute("ActiveSlotId", EPHEMERAL_ID)
|
|
336
303
|
|
|
337
|
-
local record =
|
|
338
|
-
expect(
|
|
304
|
+
local record = maid:Add(ObservableSpy.new(dataService:ObserveIsActiveSlotEphemeral(playerMock)))
|
|
305
|
+
expect(latestMatches(record, function(isEphemeral)
|
|
339
306
|
return isEphemeral == true
|
|
340
307
|
end)).toEqual(true)
|
|
341
308
|
|
|
342
309
|
playerMock:SetAttribute("ActiveSlotId", nil)
|
|
343
310
|
slot:Destroy()
|
|
344
311
|
|
|
345
|
-
expect(
|
|
312
|
+
expect(latestMatches(record, function(isEphemeral)
|
|
346
313
|
return isEphemeral == false
|
|
347
314
|
end)).toEqual(true)
|
|
348
315
|
expect(dataService:IsActiveSlotEphemeral(playerMock)).toEqual(false)
|
|
@@ -358,12 +325,10 @@ describe("SaveSlotDataService ephemeral-state observation on the client", functi
|
|
|
358
325
|
container.Parent = playerMock
|
|
359
326
|
playerMock:SetAttribute("ActiveSlotId", REAL_ID)
|
|
360
327
|
|
|
361
|
-
local record =
|
|
328
|
+
local record = maid:Add(ObservableSpy.new(dataService:ObserveIsActiveSlotEphemeral(playerMock)))
|
|
362
329
|
|
|
363
|
-
expect(
|
|
364
|
-
|
|
365
|
-
end, 5)).toEqual(true)
|
|
366
|
-
expect(record.values).toEqual({ false })
|
|
330
|
+
expect(dataService:GetActiveSlotMetadata(playerMock)).never.toBeNil()
|
|
331
|
+
expect(record.Values).toEqual({ false })
|
|
367
332
|
expect(dataService:IsActiveSlotEphemeral(playerMock)).toEqual(false)
|
|
368
333
|
end)
|
|
369
334
|
end)
|
|
@@ -374,10 +339,10 @@ describe("SaveSlotDataService slot list on the client", function()
|
|
|
374
339
|
local playerMock = newPlayerMock(maid, true)
|
|
375
340
|
binder:Bind(playerMock)
|
|
376
341
|
|
|
377
|
-
local record =
|
|
342
|
+
local record = maid:Add(ObservableSpy.new(dataService:ObserveSlotList(playerMock)))
|
|
378
343
|
|
|
379
|
-
expect(record
|
|
380
|
-
expect(record
|
|
344
|
+
expect(#record).toEqual(1)
|
|
345
|
+
expect(record:GetLastValue()).toBeNil()
|
|
381
346
|
end)
|
|
382
347
|
|
|
383
348
|
it("lists the real slot but not the ephemeral one", function()
|
|
@@ -394,11 +359,11 @@ describe("SaveSlotDataService slot list on the client", function()
|
|
|
394
359
|
expect(synchronous[REAL_ID]).toEqual(true)
|
|
395
360
|
expect(synchronous[EPHEMERAL_ID]).toBeNil()
|
|
396
361
|
|
|
397
|
-
local record =
|
|
398
|
-
expect(
|
|
362
|
+
local record = maid:Add(ObservableSpy.new(dataService:ObserveSlotList(playerMock)))
|
|
363
|
+
expect(latestMatches(record, function(slotList)
|
|
399
364
|
return listedIds(slotList)[REAL_ID] == true
|
|
400
365
|
end)).toEqual(true)
|
|
401
|
-
expect(listedIds(record
|
|
366
|
+
expect(listedIds(record:GetLastValue())[EPHEMERAL_ID]).toBeNil()
|
|
402
367
|
end)
|
|
403
368
|
|
|
404
369
|
it("replaces rather than appends a slot's entry when its metadata changes", function()
|
|
@@ -411,17 +376,17 @@ describe("SaveSlotDataService slot list on the client", function()
|
|
|
411
376
|
slot.Parent = container
|
|
412
377
|
container.Parent = playerMock
|
|
413
378
|
|
|
414
|
-
local record =
|
|
415
|
-
expect(
|
|
379
|
+
local record = maid:Add(ObservableSpy.new(dataService:ObserveSlotList(playerMock)))
|
|
380
|
+
expect(latestMatches(record, function(slotList)
|
|
416
381
|
return listedIds(slotList)[REAL_ID] == true
|
|
417
382
|
end)).toEqual(true)
|
|
418
383
|
|
|
419
384
|
slot:SetAttribute("SlotName", "Renamed")
|
|
420
385
|
|
|
421
|
-
expect(
|
|
386
|
+
expect(latestMatches(record, function(slotList)
|
|
422
387
|
return slotList ~= nil and slotList[1] ~= nil and slotList[1].SlotName == "Renamed"
|
|
423
388
|
end)).toEqual(true)
|
|
424
|
-
expect(#record
|
|
389
|
+
expect(#record:GetLastValue()).toEqual(1)
|
|
425
390
|
end)
|
|
426
391
|
|
|
427
392
|
it("drops the slot from the list when its IsEphemeral attribute lands after the folder", function()
|
|
@@ -435,17 +400,17 @@ describe("SaveSlotDataService slot list on the client", function()
|
|
|
435
400
|
slot.Parent = container
|
|
436
401
|
container.Parent = playerMock
|
|
437
402
|
|
|
438
|
-
local record =
|
|
439
|
-
expect(
|
|
403
|
+
local record = maid:Add(ObservableSpy.new(dataService:ObserveSlotList(playerMock)))
|
|
404
|
+
expect(latestMatches(record, function(slotList)
|
|
440
405
|
return listedIds(slotList)[EPHEMERAL_ID] == true
|
|
441
406
|
end)).toEqual(true)
|
|
442
407
|
|
|
443
408
|
slot:SetAttribute("IsEphemeral", true)
|
|
444
409
|
|
|
445
|
-
expect(
|
|
410
|
+
expect(latestMatches(record, function(slotList)
|
|
446
411
|
return listedIds(slotList)[EPHEMERAL_ID] == nil
|
|
447
412
|
end)).toEqual(true)
|
|
448
|
-
expect(listedIds(record
|
|
413
|
+
expect(listedIds(record:GetLastValue())[REAL_ID]).toEqual(true)
|
|
449
414
|
expect(listedIds(dataService:GetSlotList(playerMock))[EPHEMERAL_ID]).toBeNil()
|
|
450
415
|
end)
|
|
451
416
|
end)
|
|
@@ -149,7 +149,8 @@ describe("HasSaveSlots pre-select", function()
|
|
|
149
149
|
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1))
|
|
150
150
|
local selection = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
151
151
|
|
|
152
|
-
expect(
|
|
152
|
+
expect(#context.asks).toEqual(1)
|
|
153
|
+
expect(selection:IsPending()).toEqual(true)
|
|
153
154
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
|
|
154
155
|
|
|
155
156
|
gate:Resolve(true)
|
|
@@ -168,8 +169,7 @@ describe("HasSaveSlots pre-select", function()
|
|
|
168
169
|
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1))
|
|
169
170
|
local selection = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
170
171
|
|
|
171
|
-
|
|
172
|
-
expect(selection:IsRejected()).toEqual(true)
|
|
172
|
+
PromiseTestUtils.awaitRejected(selection, 10)
|
|
173
173
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
|
|
174
174
|
|
|
175
175
|
context:Destroy()
|
|
@@ -185,8 +185,7 @@ describe("HasSaveSlots pre-select", function()
|
|
|
185
185
|
context.answerWith(Promise.resolved(false))
|
|
186
186
|
local selection = context.hasSaveSlots:PromiseSelectSlot(secondId)
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
expect(selection:IsRejected()).toEqual(true)
|
|
188
|
+
PromiseTestUtils.awaitRejected(selection, 10)
|
|
190
189
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(firstId)
|
|
191
190
|
|
|
192
191
|
context:Destroy()
|
|
@@ -15,10 +15,12 @@ local Jest = require("Jest")
|
|
|
15
15
|
local JestUtils = require("JestUtils")
|
|
16
16
|
local Maid = require("Maid")
|
|
17
17
|
local Observable = require("Observable")
|
|
18
|
+
local ObservableSpy = require("ObservableSpy")
|
|
18
19
|
local PlayerDataStoreService = require("PlayerDataStoreService")
|
|
19
20
|
local PlayerMock = require("PlayerMock")
|
|
20
21
|
local PromiseTestUtils = require("PromiseTestUtils")
|
|
21
22
|
local Rx = require("Rx")
|
|
23
|
+
local RxBrioTestUtils = require("RxBrioTestUtils")
|
|
22
24
|
local SaveSlotDataService = require("SaveSlotDataService")
|
|
23
25
|
local ServiceBag = require("ServiceBag")
|
|
24
26
|
local ValueObject = require("ValueObject")
|
|
@@ -65,6 +67,7 @@ local function setup(mock: DataStoreMock.DataStoreMock?)
|
|
|
65
67
|
end
|
|
66
68
|
|
|
67
69
|
local controller = {
|
|
70
|
+
maid = maid,
|
|
68
71
|
serviceBag = serviceBag,
|
|
69
72
|
binder = binder,
|
|
70
73
|
fakePlayer = fakePlayer,
|
|
@@ -120,23 +123,11 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
120
123
|
|
|
121
124
|
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
122
125
|
|
|
123
|
-
|
|
124
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
125
|
-
selectPromise:Yield()
|
|
126
|
-
|
|
127
|
-
local capturedStore
|
|
128
|
-
local subscription = context.hasSaveSlots:ObserveActiveSlotStoreBrio():Subscribe(function(brio)
|
|
129
|
-
if not brio:IsDead() then
|
|
130
|
-
capturedStore = brio:GetValue()
|
|
131
|
-
end
|
|
132
|
-
end)
|
|
126
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
133
127
|
|
|
134
|
-
local
|
|
135
|
-
return capturedStore ~= nil
|
|
136
|
-
end, 10)
|
|
137
|
-
subscription:Destroy()
|
|
128
|
+
local stores = RxBrioTestUtils.collectAliveList(context.maid, context.hasSaveSlots:ObserveActiveSlotStoreBrio())
|
|
138
129
|
|
|
139
|
-
expect(
|
|
130
|
+
expect(#stores).toEqual(1)
|
|
140
131
|
|
|
141
132
|
context:Destroy()
|
|
142
133
|
end)
|
|
@@ -146,30 +137,16 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
146
137
|
|
|
147
138
|
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
148
139
|
|
|
149
|
-
|
|
150
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
151
|
-
selectPromise:Yield()
|
|
140
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
152
141
|
|
|
153
|
-
local
|
|
154
|
-
local subscription = context.hasSaveSlots:ObserveActiveSlotStoreBrio():Subscribe(function(brio)
|
|
155
|
-
if not brio:IsDead() then
|
|
156
|
-
activeBrio = brio
|
|
157
|
-
end
|
|
158
|
-
end)
|
|
142
|
+
local stores = RxBrioTestUtils.collectAliveList(context.maid, context.hasSaveSlots:ObserveActiveSlotStoreBrio())
|
|
159
143
|
|
|
160
|
-
|
|
161
|
-
return activeBrio ~= nil
|
|
162
|
-
end, 10)
|
|
163
|
-
expect(emitted).toEqual(true)
|
|
164
|
-
expect(activeBrio:IsDead()).toEqual(false)
|
|
144
|
+
expect(#stores).toEqual(1)
|
|
165
145
|
|
|
166
|
-
|
|
167
|
-
expect(PromiseTestUtils.awaitSettled(deselectPromise, 10)).toEqual(true)
|
|
168
|
-
deselectPromise:Yield()
|
|
146
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot(), 10)
|
|
169
147
|
|
|
170
|
-
expect(
|
|
148
|
+
expect(#stores).toEqual(0)
|
|
171
149
|
|
|
172
|
-
subscription:Destroy()
|
|
173
150
|
context:Destroy()
|
|
174
151
|
end)
|
|
175
152
|
|
|
@@ -180,34 +157,18 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
180
157
|
|
|
181
158
|
local secondSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(2), 10)
|
|
182
159
|
|
|
183
|
-
|
|
184
|
-
expect(PromiseTestUtils.awaitSettled(selectFirst, 10)).toEqual(true)
|
|
185
|
-
selectFirst:Yield()
|
|
186
|
-
|
|
187
|
-
local currentBrio: any = nil
|
|
188
|
-
local subscription = context.hasSaveSlots:ObserveActiveSlotStoreBrio():Subscribe(function(brio)
|
|
189
|
-
if not brio:IsDead() then
|
|
190
|
-
currentBrio = brio
|
|
191
|
-
end
|
|
192
|
-
end)
|
|
160
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(firstSlotId), 10)
|
|
193
161
|
|
|
194
|
-
|
|
195
|
-
return currentBrio ~= nil
|
|
196
|
-
end, 10)).toEqual(true)
|
|
197
|
-
local firstBrio = currentBrio
|
|
162
|
+
local stores = RxBrioTestUtils.collectAliveList(context.maid, context.hasSaveSlots:ObserveActiveSlotStoreBrio())
|
|
198
163
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
selectSecond:Yield()
|
|
164
|
+
expect(#stores).toEqual(1)
|
|
165
|
+
local firstStore = stores[1]
|
|
202
166
|
|
|
203
|
-
|
|
204
|
-
return currentBrio ~= firstBrio
|
|
205
|
-
end, 10)).toEqual(true)
|
|
167
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(secondSlotId), 10)
|
|
206
168
|
|
|
207
|
-
expect(
|
|
208
|
-
expect(
|
|
169
|
+
expect(#stores).toEqual(1)
|
|
170
|
+
expect(stores[1]).never.toBe(firstStore)
|
|
209
171
|
|
|
210
|
-
subscription:Destroy()
|
|
211
172
|
context:Destroy()
|
|
212
173
|
end)
|
|
213
174
|
|
|
@@ -223,9 +184,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
223
184
|
it("should reject creating a duplicate slot index", function()
|
|
224
185
|
local context = setup()
|
|
225
186
|
|
|
226
|
-
|
|
227
|
-
expect(PromiseTestUtils.awaitSettled(firstPromise, 10)).toEqual(true)
|
|
228
|
-
firstPromise:Yield()
|
|
187
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
229
188
|
|
|
230
189
|
PromiseTestUtils.awaitRejected(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
231
190
|
|
|
@@ -237,9 +196,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
237
196
|
|
|
238
197
|
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
239
198
|
|
|
240
|
-
|
|
241
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
242
|
-
selectPromise:Yield()
|
|
199
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
243
200
|
|
|
244
201
|
PromiseTestUtils.awaitRejected(context.hasSaveSlots:PromiseDeleteSlot(slotId), 10)
|
|
245
202
|
|
|
@@ -251,9 +208,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
251
208
|
|
|
252
209
|
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
253
210
|
|
|
254
|
-
|
|
255
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
256
|
-
selectPromise:Yield()
|
|
211
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
257
212
|
|
|
258
213
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(slotId)
|
|
259
214
|
|
|
@@ -265,9 +220,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
265
220
|
|
|
266
221
|
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
267
222
|
|
|
268
|
-
|
|
269
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
270
|
-
selectPromise:Yield()
|
|
223
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
271
224
|
|
|
272
225
|
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot(), 10)
|
|
273
226
|
|
|
@@ -286,19 +239,13 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
286
239
|
|
|
287
240
|
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
288
241
|
|
|
289
|
-
|
|
290
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
291
|
-
selectPromise:Yield()
|
|
242
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
292
243
|
|
|
293
|
-
|
|
294
|
-
expect(PromiseTestUtils.awaitSettled(deselectPromise, 10)).toEqual(true)
|
|
295
|
-
deselectPromise:Yield()
|
|
244
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot(), 10)
|
|
296
245
|
|
|
297
246
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(slotId)
|
|
298
247
|
|
|
299
|
-
|
|
300
|
-
expect(PromiseTestUtils.awaitSettled(deletePromise, 10)).toEqual(true)
|
|
301
|
-
deletePromise:Yield()
|
|
248
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeleteSlot(slotId), 10)
|
|
302
249
|
|
|
303
250
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toBeNil()
|
|
304
251
|
|
|
@@ -314,17 +261,11 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
314
261
|
|
|
315
262
|
local secondSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(2), 10)
|
|
316
263
|
|
|
317
|
-
|
|
318
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
319
|
-
selectPromise:Yield()
|
|
264
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(firstSlotId), 10)
|
|
320
265
|
|
|
321
|
-
|
|
322
|
-
expect(PromiseTestUtils.awaitSettled(deselectPromise, 10)).toEqual(true)
|
|
323
|
-
deselectPromise:Yield()
|
|
266
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot(), 10)
|
|
324
267
|
|
|
325
|
-
|
|
326
|
-
expect(PromiseTestUtils.awaitSettled(deletePromise, 10)).toEqual(true)
|
|
327
|
-
deletePromise:Yield()
|
|
268
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeleteSlot(secondSlotId), 10)
|
|
328
269
|
|
|
329
270
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(firstSlotId)
|
|
330
271
|
|
|
@@ -345,13 +286,9 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
345
286
|
|
|
346
287
|
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
347
288
|
|
|
348
|
-
|
|
349
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
350
|
-
selectPromise:Yield()
|
|
289
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
351
290
|
|
|
352
|
-
|
|
353
|
-
expect(PromiseTestUtils.awaitSettled(deselectPromise, 10)).toEqual(true)
|
|
354
|
-
deselectPromise:Yield()
|
|
291
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot(), 10)
|
|
355
292
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
|
|
356
293
|
|
|
357
294
|
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectLastSaveSlot(), 10)).toEqual(slotId)
|
|
@@ -365,9 +302,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
365
302
|
|
|
366
303
|
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
367
304
|
|
|
368
|
-
|
|
369
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
370
|
-
selectPromise:Yield()
|
|
305
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
371
306
|
|
|
372
307
|
context.hasSaveSlots.ActiveSlotId.Value = nil
|
|
373
308
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(slotId)
|
|
@@ -406,17 +341,11 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
406
341
|
|
|
407
342
|
local firstSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
408
343
|
|
|
409
|
-
|
|
410
|
-
expect(PromiseTestUtils.awaitSettled(secondPromise, 10)).toEqual(true)
|
|
411
|
-
secondPromise:Yield()
|
|
344
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(2), 10)
|
|
412
345
|
|
|
413
|
-
|
|
414
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
415
|
-
selectPromise:Yield()
|
|
346
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(firstSlotId), 10)
|
|
416
347
|
|
|
417
|
-
|
|
418
|
-
expect(PromiseTestUtils.awaitSettled(wipePromise, 10)).toEqual(true)
|
|
419
|
-
wipePromise:Yield()
|
|
348
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeleteAllSlots(), 10)
|
|
420
349
|
|
|
421
350
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
|
|
422
351
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toBeNil()
|
|
@@ -435,9 +364,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
435
364
|
slotIdsByIndex[index] = slotId
|
|
436
365
|
end
|
|
437
366
|
|
|
438
|
-
|
|
439
|
-
expect(PromiseTestUtils.awaitSettled(deletePromise, 10)).toEqual(true)
|
|
440
|
-
deletePromise:Yield()
|
|
367
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeleteSlot(slotIdsByIndex[2]), 10)
|
|
441
368
|
|
|
442
369
|
local newSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectNewSaveSlot(), 10)
|
|
443
370
|
expect(type(newSlotId)).toEqual("string")
|
|
@@ -507,9 +434,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
507
434
|
local slotId =
|
|
508
435
|
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(2, { SlotName = "Adventure" }), 10)
|
|
509
436
|
|
|
510
|
-
|
|
511
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
512
|
-
selectPromise:Yield()
|
|
437
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
513
438
|
|
|
514
439
|
local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
|
|
515
440
|
tracker:_getSlotStore(slotId):Store("Coins", 500)
|
|
@@ -536,9 +461,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
536
461
|
local slotId =
|
|
537
462
|
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1, { SlotName = "Save" }), 10)
|
|
538
463
|
|
|
539
|
-
|
|
540
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
541
|
-
selectPromise:Yield()
|
|
464
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
542
465
|
|
|
543
466
|
local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
|
|
544
467
|
tracker:_getSlotStore(slotId):Store("Coins", 750)
|
|
@@ -566,9 +489,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
566
489
|
|
|
567
490
|
local activeSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
568
491
|
|
|
569
|
-
|
|
570
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
571
|
-
selectPromise:Yield()
|
|
492
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(activeSlotId), 10)
|
|
572
493
|
|
|
573
494
|
local targetSlotId =
|
|
574
495
|
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(2, { SlotName = "Adventure" }), 10)
|
|
@@ -596,13 +517,9 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
596
517
|
|
|
597
518
|
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
598
519
|
|
|
599
|
-
|
|
600
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
601
|
-
selectPromise:Yield()
|
|
520
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
602
521
|
|
|
603
|
-
|
|
604
|
-
expect(PromiseTestUtils.awaitSettled(deselectPromise, 10)).toEqual(true)
|
|
605
|
-
deselectPromise:Yield()
|
|
522
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot(), 10)
|
|
606
523
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(slotId)
|
|
607
524
|
|
|
608
525
|
local newSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseResetSlot(slotId), 10)
|
|
@@ -651,17 +568,13 @@ describe("HasSaveSlots playtime tracking", function()
|
|
|
651
568
|
local function createAndSelect(context: any, slotIndex: number): any
|
|
652
569
|
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(slotIndex), 10)
|
|
653
570
|
|
|
654
|
-
|
|
655
|
-
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
656
|
-
selectPromise:Yield()
|
|
571
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
657
572
|
|
|
658
573
|
return slotId
|
|
659
574
|
end
|
|
660
575
|
|
|
661
576
|
local function getMetadata(context: any, slotId): any
|
|
662
|
-
|
|
663
|
-
expect(PromiseTestUtils.awaitSettled(promise, 10)).toEqual(true)
|
|
664
|
-
return promise:Wait()
|
|
577
|
+
return PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseGetSlotMetadata(slotId), 10)
|
|
665
578
|
end
|
|
666
579
|
|
|
667
580
|
it("increments PlayCount to 1 the first time a slot is selected", function()
|
|
@@ -679,9 +592,7 @@ describe("HasSaveSlots playtime tracking", function()
|
|
|
679
592
|
local firstSlotId = createAndSelect(context, 1)
|
|
680
593
|
local secondSlotId = createAndSelect(context, 2)
|
|
681
594
|
|
|
682
|
-
|
|
683
|
-
expect(PromiseTestUtils.awaitSettled(reselectPromise, 10)).toEqual(true)
|
|
684
|
-
reselectPromise:Yield()
|
|
595
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(firstSlotId), 10)
|
|
685
596
|
|
|
686
597
|
expect(getMetadata(context, firstSlotId).PlayCount).toEqual(2)
|
|
687
598
|
expect(getMetadata(context, secondSlotId).PlayCount).toEqual(1)
|
|
@@ -719,9 +630,7 @@ describe("HasSaveSlots playtime tracking", function()
|
|
|
719
630
|
|
|
720
631
|
-- Switching away ends the session with its length recorded; coming back must not carry it over
|
|
721
632
|
createAndSelect(context, 2)
|
|
722
|
-
|
|
723
|
-
expect(PromiseTestUtils.awaitSettled(reselectPromise, 10)).toEqual(true)
|
|
724
|
-
reselectPromise:Yield()
|
|
633
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
725
634
|
|
|
726
635
|
local metadata = getMetadata(context, slotId)
|
|
727
636
|
expect(metadata.TimePlayed ~= nil and metadata.TimePlayed >= 120).toEqual(true)
|
|
@@ -753,9 +662,7 @@ describe("HasSaveSlots playtime tracking", function()
|
|
|
753
662
|
tracker._playSessionLastFlush = os.time() - 120
|
|
754
663
|
tracker:_flushPlaytime()
|
|
755
664
|
|
|
756
|
-
|
|
757
|
-
expect(PromiseTestUtils.awaitSettled(deselectPromise, 10)).toEqual(true)
|
|
758
|
-
deselectPromise:Yield()
|
|
665
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot(), 10)
|
|
759
666
|
|
|
760
667
|
local afterDeselect = getMetadata(context, slotId).TimePlayed
|
|
761
668
|
|
|
@@ -790,10 +697,9 @@ describe("HasSaveSlots playtime tracking", function()
|
|
|
790
697
|
|
|
791
698
|
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
792
699
|
|
|
793
|
-
local
|
|
794
|
-
expect(PromiseTestUtils.awaitSettled(duplicatePromise, 10)).toEqual(true)
|
|
700
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDuplicateSlot(slotId), 10)
|
|
795
701
|
|
|
796
|
-
expect(getMetadata(context,
|
|
702
|
+
expect(getMetadata(context, newSlotId).TimePlayed).toBeNil()
|
|
797
703
|
|
|
798
704
|
context:Destroy()
|
|
799
705
|
end)
|
|
@@ -801,35 +707,18 @@ end)
|
|
|
801
707
|
|
|
802
708
|
describe("HasSaveSlots summary providers", function()
|
|
803
709
|
local function readSummary(context: any, slotId): any
|
|
804
|
-
local
|
|
805
|
-
if not PromiseTestUtils.awaitSettled(promise, 10) then
|
|
806
|
-
return nil
|
|
807
|
-
end
|
|
808
|
-
local metadata = promise:Wait()
|
|
710
|
+
local metadata = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseGetSlotMetadata(slotId), 10)
|
|
809
711
|
return metadata and metadata.Summary
|
|
810
712
|
end
|
|
811
713
|
|
|
812
|
-
local function
|
|
813
|
-
local
|
|
814
|
-
|
|
815
|
-
last = readSummary(context, slotId)
|
|
816
|
-
return last ~= nil and predicate(last)
|
|
817
|
-
end, 10)
|
|
818
|
-
return ok, last
|
|
714
|
+
local function matchSummary(context: any, slotId, predicate: (any) -> boolean): (boolean, any)
|
|
715
|
+
local summary = readSummary(context, slotId)
|
|
716
|
+
return summary ~= nil and predicate(summary), summary
|
|
819
717
|
end
|
|
820
718
|
|
|
821
719
|
local function createAndSelect(context: any): any
|
|
822
|
-
local
|
|
823
|
-
|
|
824
|
-
return nil
|
|
825
|
-
end
|
|
826
|
-
local _, slotId = createPromise:Yield()
|
|
827
|
-
|
|
828
|
-
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
829
|
-
if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
|
|
830
|
-
return nil
|
|
831
|
-
end
|
|
832
|
-
selectPromise:Yield()
|
|
720
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
721
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
833
722
|
|
|
834
723
|
return slotId
|
|
835
724
|
end
|
|
@@ -845,7 +734,7 @@ describe("HasSaveSlots summary providers", function()
|
|
|
845
734
|
end)
|
|
846
735
|
|
|
847
736
|
local slotId = createAndSelect(context)
|
|
848
|
-
local matched, summary =
|
|
737
|
+
local matched, summary = matchSummary(context, slotId, function(s)
|
|
849
738
|
return s.coins == 100 and s.world == 3
|
|
850
739
|
end)
|
|
851
740
|
|
|
@@ -867,13 +756,13 @@ describe("HasSaveSlots summary providers", function()
|
|
|
867
756
|
end)
|
|
868
757
|
|
|
869
758
|
local slotId = createAndSelect(context)
|
|
870
|
-
expect((
|
|
759
|
+
expect((matchSummary(context, slotId, function(s)
|
|
871
760
|
return s.coins == 100 and s.world == 3
|
|
872
761
|
end))).toEqual(true)
|
|
873
762
|
|
|
874
763
|
unregisterWorld()
|
|
875
764
|
|
|
876
|
-
local matched, summary =
|
|
765
|
+
local matched, summary = matchSummary(context, slotId, function(s)
|
|
877
766
|
return s.coins == 100 and s.world == nil
|
|
878
767
|
end)
|
|
879
768
|
expect(matched).toEqual(true)
|
|
@@ -893,7 +782,7 @@ describe("HasSaveSlots summary providers", function()
|
|
|
893
782
|
end)
|
|
894
783
|
|
|
895
784
|
local slotId = createAndSelect(context)
|
|
896
|
-
local matched, summary =
|
|
785
|
+
local matched, summary = matchSummary(context, slotId, function(s)
|
|
897
786
|
return s.good == 1
|
|
898
787
|
end)
|
|
899
788
|
|
|
@@ -917,7 +806,7 @@ describe("HasSaveSlots summary providers", function()
|
|
|
917
806
|
end)
|
|
918
807
|
|
|
919
808
|
local slotId = createAndSelect(context)
|
|
920
|
-
local matched, summary =
|
|
809
|
+
local matched, summary = matchSummary(context, slotId, function(s)
|
|
921
810
|
return s.good == 1
|
|
922
811
|
end)
|
|
923
812
|
|
|
@@ -935,15 +824,13 @@ describe("HasSaveSlots summary providers", function()
|
|
|
935
824
|
end)
|
|
936
825
|
|
|
937
826
|
local slotId = createAndSelect(context)
|
|
938
|
-
expect((
|
|
827
|
+
expect((matchSummary(context, slotId, function(s)
|
|
939
828
|
return s.coins == 100
|
|
940
829
|
end))).toEqual(true)
|
|
941
830
|
|
|
942
831
|
unregister()
|
|
943
832
|
|
|
944
|
-
local cleared =
|
|
945
|
-
return readSummary(context, slotId) == nil
|
|
946
|
-
end, 10)
|
|
833
|
+
local cleared = readSummary(context, slotId) == nil
|
|
947
834
|
expect(cleared).toEqual(true)
|
|
948
835
|
|
|
949
836
|
context:Destroy()
|
|
@@ -958,13 +845,7 @@ describe("HasSaveSlots against a fake player (datastore down)", function()
|
|
|
958
845
|
local context = setup(mock)
|
|
959
846
|
expect(context.hasSaveSlots).never.toBeNil()
|
|
960
847
|
|
|
961
|
-
|
|
962
|
-
expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
|
|
963
|
-
|
|
964
|
-
if not promise:IsPending() then
|
|
965
|
-
local ok = promise:Yield()
|
|
966
|
-
expect(ok).toEqual(false)
|
|
967
|
-
end
|
|
848
|
+
PromiseTestUtils.awaitRejected(context.hasSaveSlots:PromiseSlotsLoaded(), 5)
|
|
968
849
|
|
|
969
850
|
context:Destroy()
|
|
970
851
|
end)
|
|
@@ -1061,14 +942,10 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1061
942
|
return metadata and metadata.Summary and metadata.Summary.coins
|
|
1062
943
|
end
|
|
1063
944
|
|
|
1064
|
-
expect(
|
|
1065
|
-
return summaryCoins() == 7
|
|
1066
|
-
end, 10)).toEqual(true)
|
|
945
|
+
expect(summaryCoins()).toEqual(7)
|
|
1067
946
|
|
|
1068
947
|
coins.Value = 9
|
|
1069
|
-
expect(
|
|
1070
|
-
return summaryCoins() == 9
|
|
1071
|
-
end, 10)).toEqual(true)
|
|
948
|
+
expect(summaryCoins()).toEqual(9)
|
|
1072
949
|
|
|
1073
950
|
coins:Destroy()
|
|
1074
951
|
context:Destroy()
|
|
@@ -1079,27 +956,17 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1079
956
|
|
|
1080
957
|
local ephemeralId = selectEphemeral(context, { SlotName = "Lobby run" })
|
|
1081
958
|
|
|
1082
|
-
local
|
|
1083
|
-
|
|
1084
|
-
maid:GiveTask(
|
|
1085
|
-
(SaveSlotDataService :: any)
|
|
1086
|
-
:ObserveSlotMetadata(context.fakePlayer, ephemeralId)
|
|
1087
|
-
:Subscribe(function(metadata)
|
|
1088
|
-
observed = metadata
|
|
1089
|
-
end)
|
|
959
|
+
local observed = context.maid:Add(
|
|
960
|
+
ObservableSpy.new((SaveSlotDataService :: any):ObserveSlotMetadata(context.fakePlayer, ephemeralId))
|
|
1090
961
|
)
|
|
1091
962
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
end, 10)).toEqual(true)
|
|
963
|
+
local metadata = observed:GetLastValue()
|
|
964
|
+
expect(metadata and metadata.SlotName).toEqual("Lobby run")
|
|
1095
965
|
|
|
1096
966
|
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot())
|
|
1097
967
|
|
|
1098
|
-
expect(
|
|
1099
|
-
return observed == nil
|
|
1100
|
-
end, 10)).toEqual(true)
|
|
968
|
+
expect(observed:GetLastValue()).toBeNil()
|
|
1101
969
|
|
|
1102
|
-
maid:DoCleaning()
|
|
1103
970
|
context:Destroy()
|
|
1104
971
|
end)
|
|
1105
972
|
|
|
@@ -1117,18 +984,14 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1117
984
|
end
|
|
1118
985
|
end))
|
|
1119
986
|
|
|
1120
|
-
expect(
|
|
1121
|
-
return observedIds[realId] == true
|
|
1122
|
-
end, 10)).toEqual(true)
|
|
987
|
+
expect(observedIds[realId]).toBe(true)
|
|
1123
988
|
|
|
1124
989
|
local ephemeralId = selectEphemeral(context)
|
|
1125
990
|
|
|
1126
991
|
-- Adding a real slot after the ephemeral one forces a re-emission that must have seen both, so the
|
|
1127
992
|
-- ephemeral slot's absence below is a filtered list rather than a list that never updated.
|
|
1128
993
|
local laterRealId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(3))
|
|
1129
|
-
expect(
|
|
1130
|
-
return observedIds[laterRealId] == true
|
|
1131
|
-
end, 10)).toEqual(true)
|
|
994
|
+
expect(observedIds[laterRealId]).toBe(true)
|
|
1132
995
|
|
|
1133
996
|
expect(observedIds[ephemeralId]).toBeNil()
|
|
1134
997
|
expect(observedIds[realId]).toEqual(true)
|
|
@@ -1231,11 +1094,8 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1231
1094
|
|
|
1232
1095
|
local ephemeralId = selectEphemeral(context)
|
|
1233
1096
|
|
|
1234
|
-
local
|
|
1235
|
-
|
|
1236
|
-
return metadata ~= nil and metadata.Summary ~= nil and metadata.Summary.coins == 42
|
|
1237
|
-
end, 10)
|
|
1238
|
-
expect(matched).toEqual(true)
|
|
1097
|
+
local metadata = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseGetSlotMetadata(ephemeralId))
|
|
1098
|
+
expect(metadata.Summary.coins).toEqual(42)
|
|
1239
1099
|
|
|
1240
1100
|
context:Destroy()
|
|
1241
1101
|
end)
|
|
@@ -21,6 +21,7 @@ local Maid = require("Maid")
|
|
|
21
21
|
local PlayerDataStoreService = require("PlayerDataStoreService")
|
|
22
22
|
local PlayerMock = require("PlayerMock")
|
|
23
23
|
local PromiseTestUtils = require("PromiseTestUtils")
|
|
24
|
+
local Rx = require("Rx")
|
|
24
25
|
local SaveSlotConstants = require("SaveSlotConstants")
|
|
25
26
|
local ServiceBag = require("ServiceBag")
|
|
26
27
|
|
|
@@ -34,7 +35,7 @@ local EXISTING_SLOT_ID = "e6f0c1a2-late-settle"
|
|
|
34
35
|
-- Every datastore read yields this long, so the spec can land the unbind inside a chosen
|
|
35
36
|
-- read's in-flight window. Kept as short as the window can be while still spanning several frames:
|
|
36
37
|
-- these four tests otherwise spend their whole runtime waiting out real datastore latency, and the
|
|
37
|
-
-- window is guarded -- a read that has already settled fails the
|
|
38
|
+
-- window is guarded -- a read that has already settled fails the pending assertion before the
|
|
38
39
|
-- unbind, rather than quietly reducing the test to nothing.
|
|
39
40
|
local READ_YIELD_SECONDS = 0.15
|
|
40
41
|
|
|
@@ -61,9 +62,6 @@ local function setup()
|
|
|
61
62
|
PromiseTestUtils.awaitFulfilled(bindToCloseService:PromiseClose())
|
|
62
63
|
serviceBag:Destroy()
|
|
63
64
|
maid:DoCleaning()
|
|
64
|
-
-- Any straggler continuation blows up here, inside the test that owns it, rather
|
|
65
|
-
-- than as flake in a later suite.
|
|
66
|
-
task.wait(READ_YIELD_SECONDS * 3)
|
|
67
65
|
end
|
|
68
66
|
|
|
69
67
|
local controller = {
|
|
@@ -104,9 +102,7 @@ describe("SaveSlotService selection chain vs a player who leaves mid-load", func
|
|
|
104
102
|
|
|
105
103
|
local slotsLoaded = controller.join():PromiseSlotsLoaded()
|
|
106
104
|
|
|
107
|
-
|
|
108
|
-
task.wait()
|
|
109
|
-
expect(PromiseTestUtils.awaitSettled(slotsLoaded, 0)).toEqual(false)
|
|
105
|
+
expect(slotsLoaded:IsPending()).toEqual(true)
|
|
110
106
|
controller.leave()
|
|
111
107
|
|
|
112
108
|
controller:Destroy()
|
|
@@ -128,9 +124,14 @@ describe("SaveSlotService selection chain vs a player who leaves mid-load", func
|
|
|
128
124
|
|
|
129
125
|
-- Waiting on the selection itself, rather than PromiseLastActiveSlotId (which can answer from
|
|
130
126
|
-- _lastActiveSlotId while the selection is still in flight), also quiesces the chain before teardown.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
PromiseTestUtils.awaitFulfilled(
|
|
128
|
+
Rx.toPromise((hasSaveSlots.ActiveSlotId:Observe() :: any):Pipe({
|
|
129
|
+
Rx.where(function(slotId)
|
|
130
|
+
return slotId == EXISTING_SLOT_ID
|
|
131
|
+
end),
|
|
132
|
+
})),
|
|
133
|
+
10
|
|
134
|
+
)
|
|
134
135
|
|
|
135
136
|
controller:Destroy()
|
|
136
137
|
end)
|
|
@@ -145,8 +146,7 @@ describe("SaveSlotService selection chain vs a player who leaves mid-load", func
|
|
|
145
146
|
|
|
146
147
|
local slotsLoaded = controller.join():PromiseSlotsLoaded()
|
|
147
148
|
|
|
148
|
-
|
|
149
|
-
expect(PromiseTestUtils.awaitSettled(slotsLoaded, 0)).toEqual(false)
|
|
149
|
+
expect(slotsLoaded:IsPending()).toEqual(true)
|
|
150
150
|
controller.leave()
|
|
151
151
|
|
|
152
152
|
controller:Destroy()
|
|
@@ -160,7 +160,6 @@ describe("SaveSlotService selection chain vs a player who leaves mid-load", func
|
|
|
160
160
|
-- Play the chain forward to the default-slot resolution: slots loaded, teleport read
|
|
161
161
|
-- consumed, and the last-active-slot datastore read now in its in-flight window.
|
|
162
162
|
expect(PromiseTestUtils.awaitSettled(hasSaveSlots:PromiseSlotsLoaded(), 10)).toEqual(true)
|
|
163
|
-
task.wait()
|
|
164
163
|
|
|
165
164
|
-- The player leaves inside that window; the read settles after the binder is gone.
|
|
166
165
|
-- With the regression, the settle's continuation calls the destroyed binder and a
|
|
@@ -220,7 +220,7 @@ describe("SaveSlotService:PromisePreSelect", function()
|
|
|
220
220
|
local verdict = controller.saveSlotService:PromisePreSelect(controller.fakePlayer(), "slot-1")
|
|
221
221
|
|
|
222
222
|
first:Resolve()
|
|
223
|
-
expect(
|
|
223
|
+
expect(verdict:IsPending()).toEqual(true)
|
|
224
224
|
|
|
225
225
|
second:Resolve()
|
|
226
226
|
expect(PromiseTestUtils.awaitFulfilled(verdict)).toEqual(true)
|
|
@@ -399,7 +399,8 @@ describe("SaveSlotService internal teleport", function()
|
|
|
399
399
|
local player = controller.fakePlayer(111)
|
|
400
400
|
player:SetAttribute("ActiveSlotId", "slot-xyz")
|
|
401
401
|
|
|
402
|
-
local data =
|
|
402
|
+
local data =
|
|
403
|
+
PromiseTestUtils.awaitFulfilled(controller.teleportDataService:PromiseBuildTeleportData({ player }))
|
|
403
404
|
local slice = TeleportDataEnvelopeUtils.readSlice(data, 111)
|
|
404
405
|
expect(slice and slice[SaveSlotConstants.TELEPORT_DATA_SLOT_KEY]).toEqual("slot-xyz")
|
|
405
406
|
|
|
@@ -412,7 +413,8 @@ describe("SaveSlotService internal teleport", function()
|
|
|
412
413
|
|
|
413
414
|
local player = controller.fakePlayer(111)
|
|
414
415
|
|
|
415
|
-
local data =
|
|
416
|
+
local data =
|
|
417
|
+
PromiseTestUtils.awaitFulfilled(controller.teleportDataService:PromiseBuildTeleportData({ player }))
|
|
416
418
|
local slice = TeleportDataEnvelopeUtils.readSlice(data, 111)
|
|
417
419
|
expect(slice and slice[SaveSlotConstants.TELEPORT_DATA_SLOT_KEY]).toBeNil()
|
|
418
420
|
|
|
@@ -428,7 +430,9 @@ describe("SaveSlotService internal teleport", function()
|
|
|
428
430
|
playerA:SetAttribute("ActiveSlotId", "slot-a")
|
|
429
431
|
playerB:SetAttribute("ActiveSlotId", "slot-b")
|
|
430
432
|
|
|
431
|
-
local data =
|
|
433
|
+
local data = PromiseTestUtils.awaitFulfilled(
|
|
434
|
+
controller.teleportDataService:PromiseBuildTeleportData({ playerA, playerB })
|
|
435
|
+
)
|
|
432
436
|
local sliceA = TeleportDataEnvelopeUtils.readSlice(data, 111)
|
|
433
437
|
local sliceB = TeleportDataEnvelopeUtils.readSlice(data, 222)
|
|
434
438
|
expect(sliceA and sliceA[SaveSlotConstants.TELEPORT_DATA_SLOT_KEY]).toEqual("slot-a")
|