@quenty/saveslot 2.14.3 → 2.15.1
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 +12 -0
- package/package.json +26 -25
- package/src/Server/Binders/HasSaveSlots.Code.spec.lua +101 -116
- package/src/Server/Binders/HasSaveSlots.ExportImport.spec.lua +124 -134
- package/src/Server/Binders/HasSaveSlots.PreSelect.spec.lua +21 -28
- package/src/Server/Binders/HasSaveSlots.SharedStore.spec.lua +70 -92
- package/src/Server/Binders/HasSaveSlots.TransferableEphemeral.spec.lua +166 -179
- package/src/Server/Binders/HasSaveSlots.spec.lua +159 -722
- package/src/Server/Cmdr/SaveSlotCmdrService.spec.lua +3 -2
- package/src/Server/OfflineSaveSlots.spec.lua +9 -23
- package/src/Server/SaveSlotService.LateSettle.spec.lua +3 -5
- package/src/Server/SaveSlotService.LoadFlow.spec.lua +3 -5
- package/src/Server/SaveSlotService.Overflow.spec.lua +3 -5
- package/src/Server/SaveSlotService.Playtime.spec.lua +9 -22
- package/src/Server/SaveSlotService.spec.lua +43 -35
- package/src/Server/SaveSlotSharedDataStoreService.spec.lua +22 -45
- package/test/scripts/Server/ServerMain.server.lua +3 -2
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
]]
|
|
10
10
|
local require = require(script.Parent.loader).load(script)
|
|
11
11
|
|
|
12
|
+
local BindToCloseService = require("BindToCloseService")
|
|
12
13
|
local DataStoreMock = require("DataStoreMock")
|
|
13
|
-
local DataStoreTestUtils = require("DataStoreTestUtils")
|
|
14
14
|
local Jest = require("Jest")
|
|
15
15
|
local JestUtils = require("JestUtils")
|
|
16
16
|
local Maid = require("Maid")
|
|
@@ -40,6 +40,7 @@ local function setup(mock: DataStoreMock.DataStoreMock?)
|
|
|
40
40
|
local serviceBag = ServiceBag.new()
|
|
41
41
|
serviceBag:GetService(require("TeleportDataService"))
|
|
42
42
|
serviceBag:GetService(require("SaveSlotSharedDataStoreService"))
|
|
43
|
+
local bindToCloseService: BindToCloseService.BindToCloseService = serviceBag:GetService(BindToCloseService) :: any
|
|
43
44
|
local playerDataStoreService: PlayerDataStoreService.PlayerDataStoreService =
|
|
44
45
|
serviceBag:GetService(PlayerDataStoreService) :: any
|
|
45
46
|
local binder = serviceBag:GetService(require("HasSaveSlots"))
|
|
@@ -53,10 +54,8 @@ local function setup(mock: DataStoreMock.DataStoreMock?)
|
|
|
53
54
|
local hasSaveSlots = assert(binder:Bind(fakePlayer), "Failed to bind HasSaveSlots")
|
|
54
55
|
hasSaveSlots.MaxSlotCount.Value = 5
|
|
55
56
|
|
|
56
|
-
-- A PlayerMock never fires the real Players.PlayerRemoving, and the store the spec loaded is only
|
|
57
|
-
-- destroyed by a removal, so shut it down the way Roblox does or its auto-save loop outlives this spec.
|
|
58
57
|
maid:GiveTask(function()
|
|
59
|
-
|
|
58
|
+
PromiseTestUtils.awaitFulfilled(bindToCloseService:PromiseClose())
|
|
60
59
|
fakePlayer:Destroy()
|
|
61
60
|
serviceBag:Destroy()
|
|
62
61
|
end)
|
|
@@ -84,13 +83,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
84
83
|
local context = setup()
|
|
85
84
|
expect(context.hasSaveSlots).never.toBeNil()
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
if not PromiseTestUtils.awaitSettled(promise, 10) then
|
|
89
|
-
expect("slots load hung").toEqual("slots load settled")
|
|
90
|
-
context:Destroy()
|
|
91
|
-
return
|
|
92
|
-
end
|
|
93
|
-
expect((promise:Yield())).toEqual(true)
|
|
86
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSlotsLoaded(), 10)
|
|
94
87
|
|
|
95
88
|
context:Destroy()
|
|
96
89
|
end)
|
|
@@ -98,31 +91,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
98
91
|
it("should create a slot and find it", function()
|
|
99
92
|
local context = setup()
|
|
100
93
|
|
|
101
|
-
local
|
|
102
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
103
|
-
expect("create hung").toEqual("create settled")
|
|
104
|
-
context:Destroy()
|
|
105
|
-
return
|
|
106
|
-
end
|
|
107
|
-
local ok, slotId = createPromise:Yield()
|
|
108
|
-
expect(ok).toEqual(true)
|
|
94
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
109
95
|
expect(type(slotId)).toEqual("string")
|
|
110
96
|
|
|
111
|
-
|
|
112
|
-
if not PromiseTestUtils.awaitSettled(hasPromise, 10) then
|
|
113
|
-
expect("hasSlot hung").toEqual("hasSlot settled")
|
|
114
|
-
context:Destroy()
|
|
115
|
-
return
|
|
116
|
-
end
|
|
117
|
-
expect((hasPromise:Wait())).toEqual(true)
|
|
97
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseHasSlot(slotId), 10)).toEqual(true)
|
|
118
98
|
|
|
119
|
-
|
|
120
|
-
if not PromiseTestUtils.awaitSettled(indexPromise, 10) then
|
|
121
|
-
expect("slotIdFromIndex hung").toEqual("slotIdFromIndex settled")
|
|
122
|
-
context:Destroy()
|
|
123
|
-
return
|
|
124
|
-
end
|
|
125
|
-
expect((indexPromise:Wait())).toEqual(slotId)
|
|
99
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSlotIdFromIndex(1), 10)).toEqual(slotId)
|
|
126
100
|
|
|
127
101
|
context:Destroy()
|
|
128
102
|
end)
|
|
@@ -130,31 +104,13 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
130
104
|
it("should select a slot and report it active", function()
|
|
131
105
|
local context = setup()
|
|
132
106
|
|
|
133
|
-
local
|
|
134
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
135
|
-
expect("create hung").toEqual("create settled")
|
|
136
|
-
context:Destroy()
|
|
137
|
-
return
|
|
138
|
-
end
|
|
139
|
-
local _, slotId = createPromise:Yield()
|
|
107
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
140
108
|
|
|
141
|
-
|
|
142
|
-
if not PromiseTestUtils.awaitSettled(selectPromise, 10) then
|
|
143
|
-
expect("select hung").toEqual("select settled")
|
|
144
|
-
context:Destroy()
|
|
145
|
-
return
|
|
146
|
-
end
|
|
147
|
-
expect((selectPromise:Yield())).toEqual(true)
|
|
109
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId), 10)
|
|
148
110
|
|
|
149
111
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(slotId)
|
|
150
112
|
|
|
151
|
-
|
|
152
|
-
if not PromiseTestUtils.awaitSettled(lastPromise, 10) then
|
|
153
|
-
expect("lastActive hung").toEqual("lastActive settled")
|
|
154
|
-
context:Destroy()
|
|
155
|
-
return
|
|
156
|
-
end
|
|
157
|
-
expect((lastPromise:Wait())).toEqual(slotId)
|
|
113
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseLastActiveSlotId(), 10)).toEqual(slotId)
|
|
158
114
|
|
|
159
115
|
context:Destroy()
|
|
160
116
|
end)
|
|
@@ -162,20 +118,10 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
162
118
|
it("should observe the active slot store after selection", function()
|
|
163
119
|
local context = setup()
|
|
164
120
|
|
|
165
|
-
local
|
|
166
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
167
|
-
expect("create hung").toEqual("create settled")
|
|
168
|
-
context:Destroy()
|
|
169
|
-
return
|
|
170
|
-
end
|
|
171
|
-
local _, slotId = createPromise:Yield()
|
|
121
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
172
122
|
|
|
173
123
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
174
|
-
|
|
175
|
-
expect("select hung").toEqual("select settled")
|
|
176
|
-
context:Destroy()
|
|
177
|
-
return
|
|
178
|
-
end
|
|
124
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
179
125
|
selectPromise:Yield()
|
|
180
126
|
|
|
181
127
|
local capturedStore
|
|
@@ -198,20 +144,10 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
198
144
|
it("ObserveActiveSlotStoreBrio tears its brio down once the active slot is deselected", function()
|
|
199
145
|
local context = setup()
|
|
200
146
|
|
|
201
|
-
local
|
|
202
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
203
|
-
expect("create hung").toEqual("create settled")
|
|
204
|
-
context:Destroy()
|
|
205
|
-
return
|
|
206
|
-
end
|
|
207
|
-
local _, slotId = createPromise:Yield()
|
|
147
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
208
148
|
|
|
209
149
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
210
|
-
|
|
211
|
-
expect("select hung").toEqual("select settled")
|
|
212
|
-
context:Destroy()
|
|
213
|
-
return
|
|
214
|
-
end
|
|
150
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
215
151
|
selectPromise:Yield()
|
|
216
152
|
|
|
217
153
|
local activeBrio: any = nil
|
|
@@ -228,12 +164,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
228
164
|
expect(activeBrio:IsDead()).toEqual(false)
|
|
229
165
|
|
|
230
166
|
local deselectPromise = context.hasSaveSlots:PromiseDeselectSlot()
|
|
231
|
-
|
|
232
|
-
expect("deselect hung").toEqual("deselect settled")
|
|
233
|
-
subscription:Destroy()
|
|
234
|
-
context:Destroy()
|
|
235
|
-
return
|
|
236
|
-
end
|
|
167
|
+
expect(PromiseTestUtils.awaitSettled(deselectPromise, 10)).toEqual(true)
|
|
237
168
|
deselectPromise:Yield()
|
|
238
169
|
|
|
239
170
|
expect(activeBrio:IsDead()).toEqual(true)
|
|
@@ -245,28 +176,12 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
245
176
|
it("ObserveActiveSlotStoreBrio swaps its brio when switching to another slot", function()
|
|
246
177
|
local context = setup()
|
|
247
178
|
|
|
248
|
-
local
|
|
249
|
-
if not PromiseTestUtils.awaitSettled(firstCreate, 10) then
|
|
250
|
-
expect("first create hung").toEqual("first create settled")
|
|
251
|
-
context:Destroy()
|
|
252
|
-
return
|
|
253
|
-
end
|
|
254
|
-
local _, firstSlotId = firstCreate:Yield()
|
|
179
|
+
local firstSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
255
180
|
|
|
256
|
-
local
|
|
257
|
-
if not PromiseTestUtils.awaitSettled(secondCreate, 10) then
|
|
258
|
-
expect("second create hung").toEqual("second create settled")
|
|
259
|
-
context:Destroy()
|
|
260
|
-
return
|
|
261
|
-
end
|
|
262
|
-
local _, secondSlotId = secondCreate:Yield()
|
|
181
|
+
local secondSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(2), 10)
|
|
263
182
|
|
|
264
183
|
local selectFirst = context.hasSaveSlots:PromiseSelectSlot(firstSlotId)
|
|
265
|
-
|
|
266
|
-
expect("select hung").toEqual("select settled")
|
|
267
|
-
context:Destroy()
|
|
268
|
-
return
|
|
269
|
-
end
|
|
184
|
+
expect(PromiseTestUtils.awaitSettled(selectFirst, 10)).toEqual(true)
|
|
270
185
|
selectFirst:Yield()
|
|
271
186
|
|
|
272
187
|
local currentBrio: any = nil
|
|
@@ -276,33 +191,18 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
276
191
|
end
|
|
277
192
|
end)
|
|
278
193
|
|
|
279
|
-
|
|
194
|
+
expect(PromiseTestUtils.awaitValue(function()
|
|
280
195
|
return currentBrio ~= nil
|
|
281
|
-
end, 10)
|
|
282
|
-
expect("first brio hung").toEqual("first brio emitted")
|
|
283
|
-
subscription:Destroy()
|
|
284
|
-
context:Destroy()
|
|
285
|
-
return
|
|
286
|
-
end
|
|
196
|
+
end, 10)).toEqual(true)
|
|
287
197
|
local firstBrio = currentBrio
|
|
288
198
|
|
|
289
199
|
local selectSecond = context.hasSaveSlots:PromiseSelectSlot(secondSlotId)
|
|
290
|
-
|
|
291
|
-
expect("switch hung").toEqual("switch settled")
|
|
292
|
-
subscription:Destroy()
|
|
293
|
-
context:Destroy()
|
|
294
|
-
return
|
|
295
|
-
end
|
|
200
|
+
expect(PromiseTestUtils.awaitSettled(selectSecond, 10)).toEqual(true)
|
|
296
201
|
selectSecond:Yield()
|
|
297
202
|
|
|
298
|
-
|
|
203
|
+
expect(PromiseTestUtils.awaitValue(function()
|
|
299
204
|
return currentBrio ~= firstBrio
|
|
300
|
-
end, 10)
|
|
301
|
-
expect("second brio hung").toEqual("second brio emitted")
|
|
302
|
-
subscription:Destroy()
|
|
303
|
-
context:Destroy()
|
|
304
|
-
return
|
|
305
|
-
end
|
|
205
|
+
end, 10)).toEqual(true)
|
|
306
206
|
|
|
307
207
|
expect(firstBrio:IsDead()).toEqual(true)
|
|
308
208
|
expect(currentBrio:IsDead()).toEqual(false)
|
|
@@ -315,13 +215,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
315
215
|
local context = setup()
|
|
316
216
|
context.hasSaveSlots.MaxSlotCount.Value = 1
|
|
317
217
|
|
|
318
|
-
|
|
319
|
-
if not PromiseTestUtils.awaitSettled(promise, 10) then
|
|
320
|
-
expect("create hung").toEqual("create settled")
|
|
321
|
-
context:Destroy()
|
|
322
|
-
return
|
|
323
|
-
end
|
|
324
|
-
expect((promise:Yield())).toEqual(false)
|
|
218
|
+
PromiseTestUtils.awaitRejected(context.hasSaveSlots:PromiseCreateSlot(2), 10)
|
|
325
219
|
|
|
326
220
|
context:Destroy()
|
|
327
221
|
end)
|
|
@@ -330,20 +224,10 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
330
224
|
local context = setup()
|
|
331
225
|
|
|
332
226
|
local firstPromise = context.hasSaveSlots:PromiseCreateSlot(1)
|
|
333
|
-
|
|
334
|
-
expect("first create hung").toEqual("first create settled")
|
|
335
|
-
context:Destroy()
|
|
336
|
-
return
|
|
337
|
-
end
|
|
227
|
+
expect(PromiseTestUtils.awaitSettled(firstPromise, 10)).toEqual(true)
|
|
338
228
|
firstPromise:Yield()
|
|
339
229
|
|
|
340
|
-
|
|
341
|
-
if not PromiseTestUtils.awaitSettled(secondPromise, 10) then
|
|
342
|
-
expect("second create hung").toEqual("second create settled")
|
|
343
|
-
context:Destroy()
|
|
344
|
-
return
|
|
345
|
-
end
|
|
346
|
-
expect((secondPromise:Yield())).toEqual(false)
|
|
230
|
+
PromiseTestUtils.awaitRejected(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
347
231
|
|
|
348
232
|
context:Destroy()
|
|
349
233
|
end)
|
|
@@ -351,29 +235,13 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
351
235
|
it("should reject deleting the active slot", function()
|
|
352
236
|
local context = setup()
|
|
353
237
|
|
|
354
|
-
local
|
|
355
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
356
|
-
expect("create hung").toEqual("create settled")
|
|
357
|
-
context:Destroy()
|
|
358
|
-
return
|
|
359
|
-
end
|
|
360
|
-
local _, slotId = createPromise:Yield()
|
|
238
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
361
239
|
|
|
362
240
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
363
|
-
|
|
364
|
-
expect("select hung").toEqual("select settled")
|
|
365
|
-
context:Destroy()
|
|
366
|
-
return
|
|
367
|
-
end
|
|
241
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
368
242
|
selectPromise:Yield()
|
|
369
243
|
|
|
370
|
-
|
|
371
|
-
if not PromiseTestUtils.awaitSettled(deletePromise, 10) then
|
|
372
|
-
expect("delete hung").toEqual("delete settled")
|
|
373
|
-
context:Destroy()
|
|
374
|
-
return
|
|
375
|
-
end
|
|
376
|
-
expect((deletePromise:Yield())).toEqual(false)
|
|
244
|
+
PromiseTestUtils.awaitRejected(context.hasSaveSlots:PromiseDeleteSlot(slotId), 10)
|
|
377
245
|
|
|
378
246
|
context:Destroy()
|
|
379
247
|
end)
|
|
@@ -381,20 +249,10 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
381
249
|
it("should replicate the last active slot after selection", function()
|
|
382
250
|
local context = setup()
|
|
383
251
|
|
|
384
|
-
local
|
|
385
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
386
|
-
expect("create hung").toEqual("create settled")
|
|
387
|
-
context:Destroy()
|
|
388
|
-
return
|
|
389
|
-
end
|
|
390
|
-
local _, slotId = createPromise:Yield()
|
|
252
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
391
253
|
|
|
392
254
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
393
|
-
|
|
394
|
-
expect("select hung").toEqual("select settled")
|
|
395
|
-
context:Destroy()
|
|
396
|
-
return
|
|
397
|
-
end
|
|
255
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
398
256
|
selectPromise:Yield()
|
|
399
257
|
|
|
400
258
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(slotId)
|
|
@@ -405,40 +263,18 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
405
263
|
it("PromiseDeselectSlot clears the active slot but remembers the last active", function()
|
|
406
264
|
local context = setup()
|
|
407
265
|
|
|
408
|
-
local
|
|
409
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
410
|
-
expect("create hung").toEqual("create settled")
|
|
411
|
-
context:Destroy()
|
|
412
|
-
return
|
|
413
|
-
end
|
|
414
|
-
local _, slotId = createPromise:Yield()
|
|
266
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
415
267
|
|
|
416
268
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
417
|
-
|
|
418
|
-
expect("select hung").toEqual("select settled")
|
|
419
|
-
context:Destroy()
|
|
420
|
-
return
|
|
421
|
-
end
|
|
269
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
422
270
|
selectPromise:Yield()
|
|
423
271
|
|
|
424
|
-
|
|
425
|
-
if not PromiseTestUtils.awaitSettled(deselectPromise, 10) then
|
|
426
|
-
expect("deselect hung").toEqual("deselect settled")
|
|
427
|
-
context:Destroy()
|
|
428
|
-
return
|
|
429
|
-
end
|
|
430
|
-
expect((deselectPromise:Yield())).toEqual(true)
|
|
272
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot(), 10)
|
|
431
273
|
|
|
432
274
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
|
|
433
275
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(slotId)
|
|
434
276
|
|
|
435
|
-
|
|
436
|
-
if not PromiseTestUtils.awaitSettled(lastPromise, 10) then
|
|
437
|
-
expect("lastActive hung").toEqual("lastActive settled")
|
|
438
|
-
context:Destroy()
|
|
439
|
-
return
|
|
440
|
-
end
|
|
441
|
-
expect((lastPromise:Wait())).toEqual(slotId)
|
|
277
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseLastActiveSlotId(), 10)).toEqual(slotId)
|
|
442
278
|
|
|
443
279
|
context:Destroy()
|
|
444
280
|
end)
|
|
@@ -448,49 +284,25 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
448
284
|
-- LastActiveSlotId dangling, so the menu kept offering "Continue" for a slot that was gone.
|
|
449
285
|
local context = setup()
|
|
450
286
|
|
|
451
|
-
local
|
|
452
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
453
|
-
expect("create hung").toEqual("create settled")
|
|
454
|
-
context:Destroy()
|
|
455
|
-
return
|
|
456
|
-
end
|
|
457
|
-
local _, slotId = createPromise:Yield()
|
|
287
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
458
288
|
|
|
459
289
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
460
|
-
|
|
461
|
-
expect("select hung").toEqual("select settled")
|
|
462
|
-
context:Destroy()
|
|
463
|
-
return
|
|
464
|
-
end
|
|
290
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
465
291
|
selectPromise:Yield()
|
|
466
292
|
|
|
467
293
|
local deselectPromise = context.hasSaveSlots:PromiseDeselectSlot()
|
|
468
|
-
|
|
469
|
-
expect("deselect hung").toEqual("deselect settled")
|
|
470
|
-
context:Destroy()
|
|
471
|
-
return
|
|
472
|
-
end
|
|
294
|
+
expect(PromiseTestUtils.awaitSettled(deselectPromise, 10)).toEqual(true)
|
|
473
295
|
deselectPromise:Yield()
|
|
474
296
|
|
|
475
297
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(slotId)
|
|
476
298
|
|
|
477
299
|
local deletePromise = context.hasSaveSlots:PromiseDeleteSlot(slotId)
|
|
478
|
-
|
|
479
|
-
expect("delete hung").toEqual("delete settled")
|
|
480
|
-
context:Destroy()
|
|
481
|
-
return
|
|
482
|
-
end
|
|
300
|
+
expect(PromiseTestUtils.awaitSettled(deletePromise, 10)).toEqual(true)
|
|
483
301
|
deletePromise:Yield()
|
|
484
302
|
|
|
485
303
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toBeNil()
|
|
486
304
|
|
|
487
|
-
|
|
488
|
-
if not PromiseTestUtils.awaitSettled(lastPromise, 10) then
|
|
489
|
-
expect("lastActive hung").toEqual("lastActive settled")
|
|
490
|
-
context:Destroy()
|
|
491
|
-
return
|
|
492
|
-
end
|
|
493
|
-
expect((lastPromise:Wait())).toBeNil()
|
|
305
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseLastActiveSlotId(), 10)).toBeNil()
|
|
494
306
|
|
|
495
307
|
context:Destroy()
|
|
496
308
|
end)
|
|
@@ -498,44 +310,20 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
498
310
|
it("deleting a non-last-active slot leaves the continue pointer intact", function()
|
|
499
311
|
local context = setup()
|
|
500
312
|
|
|
501
|
-
local
|
|
502
|
-
if not PromiseTestUtils.awaitSettled(firstPromise, 10) then
|
|
503
|
-
expect("first create hung").toEqual("first create settled")
|
|
504
|
-
context:Destroy()
|
|
505
|
-
return
|
|
506
|
-
end
|
|
507
|
-
local _, firstSlotId = firstPromise:Yield()
|
|
313
|
+
local firstSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
508
314
|
|
|
509
|
-
local
|
|
510
|
-
if not PromiseTestUtils.awaitSettled(secondPromise, 10) then
|
|
511
|
-
expect("second create hung").toEqual("second create settled")
|
|
512
|
-
context:Destroy()
|
|
513
|
-
return
|
|
514
|
-
end
|
|
515
|
-
local _, secondSlotId = secondPromise:Yield()
|
|
315
|
+
local secondSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(2), 10)
|
|
516
316
|
|
|
517
317
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(firstSlotId)
|
|
518
|
-
|
|
519
|
-
expect("select hung").toEqual("select settled")
|
|
520
|
-
context:Destroy()
|
|
521
|
-
return
|
|
522
|
-
end
|
|
318
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
523
319
|
selectPromise:Yield()
|
|
524
320
|
|
|
525
321
|
local deselectPromise = context.hasSaveSlots:PromiseDeselectSlot()
|
|
526
|
-
|
|
527
|
-
expect("deselect hung").toEqual("deselect settled")
|
|
528
|
-
context:Destroy()
|
|
529
|
-
return
|
|
530
|
-
end
|
|
322
|
+
expect(PromiseTestUtils.awaitSettled(deselectPromise, 10)).toEqual(true)
|
|
531
323
|
deselectPromise:Yield()
|
|
532
324
|
|
|
533
325
|
local deletePromise = context.hasSaveSlots:PromiseDeleteSlot(secondSlotId)
|
|
534
|
-
|
|
535
|
-
expect("delete hung").toEqual("delete settled")
|
|
536
|
-
context:Destroy()
|
|
537
|
-
return
|
|
538
|
-
end
|
|
326
|
+
expect(PromiseTestUtils.awaitSettled(deletePromise, 10)).toEqual(true)
|
|
539
327
|
deletePromise:Yield()
|
|
540
328
|
|
|
541
329
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(firstSlotId)
|
|
@@ -546,13 +334,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
546
334
|
it("PromiseDeselectSlot is a no-op when no slot is active", function()
|
|
547
335
|
local context = setup()
|
|
548
336
|
|
|
549
|
-
|
|
550
|
-
if not PromiseTestUtils.awaitSettled(deselectPromise, 10) then
|
|
551
|
-
expect("deselect hung").toEqual("deselect settled")
|
|
552
|
-
context:Destroy()
|
|
553
|
-
return
|
|
554
|
-
end
|
|
555
|
-
expect((deselectPromise:Yield())).toEqual(true)
|
|
337
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot(), 10)
|
|
556
338
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
|
|
557
339
|
|
|
558
340
|
context:Destroy()
|
|
@@ -561,38 +343,18 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
561
343
|
it("PromiseDeselectSlot then PromiseSelectLastSaveSlot round-trips back into the slot", function()
|
|
562
344
|
local context = setup()
|
|
563
345
|
|
|
564
|
-
local
|
|
565
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
566
|
-
expect("create hung").toEqual("create settled")
|
|
567
|
-
context:Destroy()
|
|
568
|
-
return
|
|
569
|
-
end
|
|
570
|
-
local _, slotId = createPromise:Yield()
|
|
346
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
571
347
|
|
|
572
348
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
573
|
-
|
|
574
|
-
expect("select hung").toEqual("select settled")
|
|
575
|
-
context:Destroy()
|
|
576
|
-
return
|
|
577
|
-
end
|
|
349
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
578
350
|
selectPromise:Yield()
|
|
579
351
|
|
|
580
352
|
local deselectPromise = context.hasSaveSlots:PromiseDeselectSlot()
|
|
581
|
-
|
|
582
|
-
expect("deselect hung").toEqual("deselect settled")
|
|
583
|
-
context:Destroy()
|
|
584
|
-
return
|
|
585
|
-
end
|
|
353
|
+
expect(PromiseTestUtils.awaitSettled(deselectPromise, 10)).toEqual(true)
|
|
586
354
|
deselectPromise:Yield()
|
|
587
355
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
|
|
588
356
|
|
|
589
|
-
|
|
590
|
-
if not PromiseTestUtils.awaitSettled(continuePromise, 10) then
|
|
591
|
-
expect("continue hung").toEqual("continue settled")
|
|
592
|
-
context:Destroy()
|
|
593
|
-
return
|
|
594
|
-
end
|
|
595
|
-
expect((continuePromise:Wait())).toEqual(slotId)
|
|
357
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectLastSaveSlot(), 10)).toEqual(slotId)
|
|
596
358
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(slotId)
|
|
597
359
|
|
|
598
360
|
context:Destroy()
|
|
@@ -601,32 +363,16 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
601
363
|
it("PromiseSelectLastSaveSlot re-selects the last active slot after the active slot is cleared", function()
|
|
602
364
|
local context = setup()
|
|
603
365
|
|
|
604
|
-
local
|
|
605
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
606
|
-
expect("create hung").toEqual("create settled")
|
|
607
|
-
context:Destroy()
|
|
608
|
-
return
|
|
609
|
-
end
|
|
610
|
-
local _, slotId = createPromise:Yield()
|
|
366
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
611
367
|
|
|
612
368
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
613
|
-
|
|
614
|
-
expect("select hung").toEqual("select settled")
|
|
615
|
-
context:Destroy()
|
|
616
|
-
return
|
|
617
|
-
end
|
|
369
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
618
370
|
selectPromise:Yield()
|
|
619
371
|
|
|
620
372
|
context.hasSaveSlots.ActiveSlotId.Value = nil
|
|
621
373
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(slotId)
|
|
622
374
|
|
|
623
|
-
|
|
624
|
-
if not PromiseTestUtils.awaitSettled(continuePromise, 10) then
|
|
625
|
-
expect("continue hung").toEqual("continue settled")
|
|
626
|
-
context:Destroy()
|
|
627
|
-
return
|
|
628
|
-
end
|
|
629
|
-
expect((continuePromise:Wait())).toEqual(slotId)
|
|
375
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectLastSaveSlot(), 10)).toEqual(slotId)
|
|
630
376
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(slotId)
|
|
631
377
|
|
|
632
378
|
context:Destroy()
|
|
@@ -635,13 +381,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
635
381
|
it("PromiseSelectLastSaveSlot resolves nil when there is nothing to continue", function()
|
|
636
382
|
local context = setup()
|
|
637
383
|
|
|
638
|
-
|
|
639
|
-
if not PromiseTestUtils.awaitSettled(continuePromise, 10) then
|
|
640
|
-
expect("continue hung").toEqual("continue settled")
|
|
641
|
-
context:Destroy()
|
|
642
|
-
return
|
|
643
|
-
end
|
|
644
|
-
expect((continuePromise:Wait())).toBeNil()
|
|
384
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectLastSaveSlot(), 10)).toBeNil()
|
|
645
385
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
|
|
646
386
|
|
|
647
387
|
context:Destroy()
|
|
@@ -650,23 +390,11 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
650
390
|
it("PromiseSelectNewSaveSlot creates and selects a fresh slot each time", function()
|
|
651
391
|
local context = setup()
|
|
652
392
|
|
|
653
|
-
local
|
|
654
|
-
if not PromiseTestUtils.awaitSettled(firstPromise, 10) then
|
|
655
|
-
expect("new game hung").toEqual("new game settled")
|
|
656
|
-
context:Destroy()
|
|
657
|
-
return
|
|
658
|
-
end
|
|
659
|
-
local firstSlotId = firstPromise:Wait()
|
|
393
|
+
local firstSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectNewSaveSlot(), 10)
|
|
660
394
|
expect(type(firstSlotId)).toEqual("string")
|
|
661
395
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(firstSlotId)
|
|
662
396
|
|
|
663
|
-
local
|
|
664
|
-
if not PromiseTestUtils.awaitSettled(secondPromise, 10) then
|
|
665
|
-
expect("second new game hung").toEqual("second new game settled")
|
|
666
|
-
context:Destroy()
|
|
667
|
-
return
|
|
668
|
-
end
|
|
669
|
-
local secondSlotId = secondPromise:Wait()
|
|
397
|
+
local secondSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectNewSaveSlot(), 10)
|
|
670
398
|
expect(type(secondSlotId)).toEqual("string")
|
|
671
399
|
expect(secondSlotId ~= firstSlotId).toEqual(true)
|
|
672
400
|
|
|
@@ -676,48 +404,24 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
676
404
|
it("PromiseDeleteAllSlots wipes every slot and clears the selection", function()
|
|
677
405
|
local context = setup()
|
|
678
406
|
|
|
679
|
-
local
|
|
680
|
-
if not PromiseTestUtils.awaitSettled(firstPromise, 10) then
|
|
681
|
-
expect("first create hung").toEqual("first create settled")
|
|
682
|
-
context:Destroy()
|
|
683
|
-
return
|
|
684
|
-
end
|
|
685
|
-
local _, firstSlotId = firstPromise:Yield()
|
|
407
|
+
local firstSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
686
408
|
|
|
687
409
|
local secondPromise = context.hasSaveSlots:PromiseCreateSlot(2)
|
|
688
|
-
|
|
689
|
-
expect("second create hung").toEqual("second create settled")
|
|
690
|
-
context:Destroy()
|
|
691
|
-
return
|
|
692
|
-
end
|
|
410
|
+
expect(PromiseTestUtils.awaitSettled(secondPromise, 10)).toEqual(true)
|
|
693
411
|
secondPromise:Yield()
|
|
694
412
|
|
|
695
413
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(firstSlotId)
|
|
696
|
-
|
|
697
|
-
expect("select hung").toEqual("select settled")
|
|
698
|
-
context:Destroy()
|
|
699
|
-
return
|
|
700
|
-
end
|
|
414
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
701
415
|
selectPromise:Yield()
|
|
702
416
|
|
|
703
417
|
local wipePromise = context.hasSaveSlots:PromiseDeleteAllSlots()
|
|
704
|
-
|
|
705
|
-
expect("wipe hung").toEqual("wipe settled")
|
|
706
|
-
context:Destroy()
|
|
707
|
-
return
|
|
708
|
-
end
|
|
418
|
+
expect(PromiseTestUtils.awaitSettled(wipePromise, 10)).toEqual(true)
|
|
709
419
|
wipePromise:Yield()
|
|
710
420
|
|
|
711
421
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
|
|
712
422
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toBeNil()
|
|
713
423
|
|
|
714
|
-
|
|
715
|
-
if not PromiseTestUtils.awaitSettled(hasPromise, 10) then
|
|
716
|
-
expect("hasSlot hung").toEqual("hasSlot settled")
|
|
717
|
-
context:Destroy()
|
|
718
|
-
return
|
|
719
|
-
end
|
|
720
|
-
expect((hasPromise:Wait())).toEqual(false)
|
|
424
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseHasSlot(firstSlotId), 10)).toEqual(false)
|
|
721
425
|
|
|
722
426
|
context:Destroy()
|
|
723
427
|
end)
|
|
@@ -727,40 +431,20 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
727
431
|
|
|
728
432
|
local slotIdsByIndex = {}
|
|
729
433
|
for index = 1, 3 do
|
|
730
|
-
local
|
|
731
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
732
|
-
expect("create hung").toEqual("create settled")
|
|
733
|
-
context:Destroy()
|
|
734
|
-
return
|
|
735
|
-
end
|
|
736
|
-
local _, slotId = createPromise:Yield()
|
|
434
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(index), 10)
|
|
737
435
|
slotIdsByIndex[index] = slotId
|
|
738
436
|
end
|
|
739
437
|
|
|
740
438
|
local deletePromise = context.hasSaveSlots:PromiseDeleteSlot(slotIdsByIndex[2])
|
|
741
|
-
|
|
742
|
-
expect("delete hung").toEqual("delete settled")
|
|
743
|
-
context:Destroy()
|
|
744
|
-
return
|
|
745
|
-
end
|
|
439
|
+
expect(PromiseTestUtils.awaitSettled(deletePromise, 10)).toEqual(true)
|
|
746
440
|
deletePromise:Yield()
|
|
747
441
|
|
|
748
|
-
local
|
|
749
|
-
if not PromiseTestUtils.awaitSettled(newPromise, 10) then
|
|
750
|
-
expect("new game hung").toEqual("new game settled")
|
|
751
|
-
context:Destroy()
|
|
752
|
-
return
|
|
753
|
-
end
|
|
754
|
-
local newSlotId = newPromise:Wait()
|
|
442
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectNewSaveSlot(), 10)
|
|
755
443
|
expect(type(newSlotId)).toEqual("string")
|
|
756
444
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
context:Destroy()
|
|
761
|
-
return
|
|
762
|
-
end
|
|
763
|
-
expect((metadataPromise:Wait()).SlotIndex).toEqual(2)
|
|
445
|
+
expect((PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseGetSlotMetadata(newSlotId), 10)).SlotIndex).toEqual(
|
|
446
|
+
2
|
|
447
|
+
)
|
|
764
448
|
|
|
765
449
|
context:Destroy()
|
|
766
450
|
end)
|
|
@@ -768,44 +452,21 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
768
452
|
it("PromiseDuplicateSlot copies saved data into a fresh slot and marks the name", function()
|
|
769
453
|
local context = setup()
|
|
770
454
|
|
|
771
|
-
local
|
|
772
|
-
|
|
773
|
-
expect("create hung").toEqual("create settled")
|
|
774
|
-
context:Destroy()
|
|
775
|
-
return
|
|
776
|
-
end
|
|
777
|
-
local _, slotId = createPromise:Yield()
|
|
455
|
+
local slotId =
|
|
456
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1, { SlotName = "Adventure" }), 10)
|
|
778
457
|
|
|
779
458
|
local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
|
|
780
459
|
tracker:_getSlotStore(slotId):Store("Coins", 500)
|
|
781
460
|
|
|
782
|
-
local
|
|
783
|
-
if not PromiseTestUtils.awaitSettled(duplicatePromise, 10) then
|
|
784
|
-
expect("duplicate hung").toEqual("duplicate settled")
|
|
785
|
-
context:Destroy()
|
|
786
|
-
return
|
|
787
|
-
end
|
|
788
|
-
local newSlotId = duplicatePromise:Wait()
|
|
461
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDuplicateSlot(slotId), 10)
|
|
789
462
|
expect(type(newSlotId)).toEqual("string")
|
|
790
463
|
expect(newSlotId ~= slotId).toEqual(true)
|
|
791
464
|
|
|
792
|
-
local
|
|
793
|
-
if not PromiseTestUtils.awaitSettled(metadataPromise, 10) then
|
|
794
|
-
expect("metadata hung").toEqual("metadata settled")
|
|
795
|
-
context:Destroy()
|
|
796
|
-
return
|
|
797
|
-
end
|
|
798
|
-
local metadata = metadataPromise:Wait()
|
|
465
|
+
local metadata = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseGetSlotMetadata(newSlotId), 10)
|
|
799
466
|
expect(metadata.SlotIndex).toEqual(2)
|
|
800
467
|
expect(metadata.SlotName).toEqual("Adventure (Copy)")
|
|
801
468
|
|
|
802
|
-
|
|
803
|
-
if not PromiseTestUtils.awaitSettled(dataPromise, 10) then
|
|
804
|
-
expect("data hung").toEqual("data settled")
|
|
805
|
-
context:Destroy()
|
|
806
|
-
return
|
|
807
|
-
end
|
|
808
|
-
expect((dataPromise:Wait())).toEqual(500)
|
|
469
|
+
expect(PromiseTestUtils.awaitFulfilled(tracker:_getSlotStore(newSlotId):Load("Coins"), 10)).toEqual(500)
|
|
809
470
|
|
|
810
471
|
context:Destroy()
|
|
811
472
|
end)
|
|
@@ -813,48 +474,21 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
813
474
|
it("PromiseDuplicateSlot into the default slot preserves the system store", function()
|
|
814
475
|
local context = setup()
|
|
815
476
|
|
|
816
|
-
local
|
|
817
|
-
|
|
818
|
-
expect("create hung").toEqual("create settled")
|
|
819
|
-
context:Destroy()
|
|
820
|
-
return
|
|
821
|
-
end
|
|
822
|
-
local _, slotId = createPromise:Yield()
|
|
477
|
+
local slotId =
|
|
478
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(2, { SlotName = "Save" }), 10)
|
|
823
479
|
|
|
824
480
|
local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
|
|
825
481
|
tracker:_getSlotStore(slotId):Store("Coins", 750)
|
|
826
482
|
|
|
827
|
-
local
|
|
828
|
-
if not PromiseTestUtils.awaitSettled(duplicatePromise, 10) then
|
|
829
|
-
expect("duplicate hung").toEqual("duplicate settled")
|
|
830
|
-
context:Destroy()
|
|
831
|
-
return
|
|
832
|
-
end
|
|
833
|
-
local newSlotId = duplicatePromise:Wait()
|
|
483
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDuplicateSlot(slotId), 10)
|
|
834
484
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
context:Destroy()
|
|
839
|
-
return
|
|
840
|
-
end
|
|
841
|
-
expect((metadataPromise:Wait()).SlotIndex).toEqual(1)
|
|
485
|
+
expect((PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseGetSlotMetadata(newSlotId), 10)).SlotIndex).toEqual(
|
|
486
|
+
1
|
|
487
|
+
)
|
|
842
488
|
|
|
843
|
-
|
|
844
|
-
if not PromiseTestUtils.awaitSettled(sourceStillThere, 10) then
|
|
845
|
-
expect("lookup hung").toEqual("lookup settled")
|
|
846
|
-
context:Destroy()
|
|
847
|
-
return
|
|
848
|
-
end
|
|
849
|
-
expect((sourceStillThere:Wait())).toEqual(slotId)
|
|
489
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSlotIdFromIndex(2), 10)).toEqual(slotId)
|
|
850
490
|
|
|
851
|
-
|
|
852
|
-
if not PromiseTestUtils.awaitSettled(dataPromise, 10) then
|
|
853
|
-
expect("data hung").toEqual("data settled")
|
|
854
|
-
context:Destroy()
|
|
855
|
-
return
|
|
856
|
-
end
|
|
857
|
-
expect((dataPromise:Wait())).toEqual(750)
|
|
491
|
+
expect(PromiseTestUtils.awaitFulfilled(tracker:_getSlotStore(newSlotId):Load("Coins"), 10)).toEqual(750)
|
|
858
492
|
|
|
859
493
|
context:Destroy()
|
|
860
494
|
end)
|
|
@@ -862,13 +496,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
862
496
|
it("PromiseDuplicateSlot rejects when the source slot is missing", function()
|
|
863
497
|
local context = setup()
|
|
864
498
|
|
|
865
|
-
|
|
866
|
-
if not PromiseTestUtils.awaitSettled(duplicatePromise, 10) then
|
|
867
|
-
expect("duplicate hung").toEqual("duplicate settled")
|
|
868
|
-
context:Destroy()
|
|
869
|
-
return
|
|
870
|
-
end
|
|
871
|
-
expect((duplicatePromise:Yield())).toEqual(false)
|
|
499
|
+
PromiseTestUtils.awaitRejected(context.hasSaveSlots:PromiseDuplicateSlot("does-not-exist"), 10)
|
|
872
500
|
|
|
873
501
|
context:Destroy()
|
|
874
502
|
end)
|
|
@@ -876,61 +504,28 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
876
504
|
it("PromiseResetActiveSlot wipes saved data but keeps the slot's index and name", function()
|
|
877
505
|
local context = setup()
|
|
878
506
|
|
|
879
|
-
local
|
|
880
|
-
|
|
881
|
-
expect("create hung").toEqual("create settled")
|
|
882
|
-
context:Destroy()
|
|
883
|
-
return
|
|
884
|
-
end
|
|
885
|
-
local _, slotId = createPromise:Yield()
|
|
507
|
+
local slotId =
|
|
508
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(2, { SlotName = "Adventure" }), 10)
|
|
886
509
|
|
|
887
510
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
888
|
-
|
|
889
|
-
expect("select hung").toEqual("select settled")
|
|
890
|
-
context:Destroy()
|
|
891
|
-
return
|
|
892
|
-
end
|
|
511
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
893
512
|
selectPromise:Yield()
|
|
894
513
|
|
|
895
514
|
local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
|
|
896
515
|
tracker:_getSlotStore(slotId):Store("Coins", 500)
|
|
897
516
|
|
|
898
|
-
local
|
|
899
|
-
if not PromiseTestUtils.awaitSettled(resetPromise, 10) then
|
|
900
|
-
expect("reset hung").toEqual("reset settled")
|
|
901
|
-
context:Destroy()
|
|
902
|
-
return
|
|
903
|
-
end
|
|
904
|
-
local newSlotId = resetPromise:Wait()
|
|
517
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseResetActiveSlot(), 10)
|
|
905
518
|
expect(type(newSlotId)).toEqual("string")
|
|
906
519
|
expect(newSlotId ~= slotId).toEqual(true)
|
|
907
520
|
|
|
908
521
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(newSlotId)
|
|
909
|
-
|
|
910
|
-
if not PromiseTestUtils.awaitSettled(hasOldPromise, 10) then
|
|
911
|
-
expect("hasSlot hung").toEqual("hasSlot settled")
|
|
912
|
-
context:Destroy()
|
|
913
|
-
return
|
|
914
|
-
end
|
|
915
|
-
expect((hasOldPromise:Wait())).toEqual(false)
|
|
522
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseHasSlot(slotId), 10)).toEqual(false)
|
|
916
523
|
|
|
917
|
-
local
|
|
918
|
-
if not PromiseTestUtils.awaitSettled(metadataPromise, 10) then
|
|
919
|
-
expect("metadata hung").toEqual("metadata settled")
|
|
920
|
-
context:Destroy()
|
|
921
|
-
return
|
|
922
|
-
end
|
|
923
|
-
local metadata = metadataPromise:Wait()
|
|
524
|
+
local metadata = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseGetSlotMetadata(newSlotId), 10)
|
|
924
525
|
expect(metadata.SlotIndex).toEqual(2)
|
|
925
526
|
expect(metadata.SlotName).toEqual("Adventure")
|
|
926
527
|
|
|
927
|
-
|
|
928
|
-
if not PromiseTestUtils.awaitSettled(dataPromise, 10) then
|
|
929
|
-
expect("data hung").toEqual("data settled")
|
|
930
|
-
context:Destroy()
|
|
931
|
-
return
|
|
932
|
-
end
|
|
933
|
-
expect((dataPromise:Wait())).toBeNil()
|
|
528
|
+
expect(PromiseTestUtils.awaitFulfilled(tracker:_getSlotStore(newSlotId):Load("Coins"), 10)).toBeNil()
|
|
934
529
|
|
|
935
530
|
context:Destroy()
|
|
936
531
|
end)
|
|
@@ -938,48 +533,21 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
938
533
|
it("PromiseResetActiveSlot resets the default slot in place, preserving the system store", function()
|
|
939
534
|
local context = setup()
|
|
940
535
|
|
|
941
|
-
local
|
|
942
|
-
|
|
943
|
-
expect("create hung").toEqual("create settled")
|
|
944
|
-
context:Destroy()
|
|
945
|
-
return
|
|
946
|
-
end
|
|
947
|
-
local _, slotId = createPromise:Yield()
|
|
536
|
+
local slotId =
|
|
537
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1, { SlotName = "Save" }), 10)
|
|
948
538
|
|
|
949
539
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
950
|
-
|
|
951
|
-
expect("select hung").toEqual("select settled")
|
|
952
|
-
context:Destroy()
|
|
953
|
-
return
|
|
954
|
-
end
|
|
540
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
955
541
|
selectPromise:Yield()
|
|
956
542
|
|
|
957
543
|
local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
|
|
958
544
|
tracker:_getSlotStore(slotId):Store("Coins", 750)
|
|
959
545
|
|
|
960
|
-
local
|
|
961
|
-
if not PromiseTestUtils.awaitSettled(resetPromise, 10) then
|
|
962
|
-
expect("reset hung").toEqual("reset settled")
|
|
963
|
-
context:Destroy()
|
|
964
|
-
return
|
|
965
|
-
end
|
|
966
|
-
local newSlotId = resetPromise:Wait()
|
|
546
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseResetActiveSlot(), 10)
|
|
967
547
|
|
|
968
|
-
|
|
969
|
-
if not PromiseTestUtils.awaitSettled(lookupPromise, 10) then
|
|
970
|
-
expect("lookup hung").toEqual("lookup settled")
|
|
971
|
-
context:Destroy()
|
|
972
|
-
return
|
|
973
|
-
end
|
|
974
|
-
expect((lookupPromise:Wait())).toEqual(newSlotId)
|
|
548
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSlotIdFromIndex(1), 10)).toEqual(newSlotId)
|
|
975
549
|
|
|
976
|
-
|
|
977
|
-
if not PromiseTestUtils.awaitSettled(dataPromise, 10) then
|
|
978
|
-
expect("data hung").toEqual("data settled")
|
|
979
|
-
context:Destroy()
|
|
980
|
-
return
|
|
981
|
-
end
|
|
982
|
-
expect((dataPromise:Wait())).toBeNil()
|
|
550
|
+
expect(PromiseTestUtils.awaitFulfilled(tracker:_getSlotStore(newSlotId):Load("Coins"), 10)).toBeNil()
|
|
983
551
|
|
|
984
552
|
context:Destroy()
|
|
985
553
|
end)
|
|
@@ -987,13 +555,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
987
555
|
it("PromiseResetActiveSlot is a no-op resolving nil when no slot is active", function()
|
|
988
556
|
local context = setup()
|
|
989
557
|
|
|
990
|
-
|
|
991
|
-
if not PromiseTestUtils.awaitSettled(resetPromise, 10) then
|
|
992
|
-
expect("reset hung").toEqual("reset settled")
|
|
993
|
-
context:Destroy()
|
|
994
|
-
return
|
|
995
|
-
end
|
|
996
|
-
expect((resetPromise:Wait())).toBeNil()
|
|
558
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseResetActiveSlot(), 10)).toBeNil()
|
|
997
559
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
|
|
998
560
|
|
|
999
561
|
context:Destroy()
|
|
@@ -1002,62 +564,29 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
1002
564
|
it("PromiseResetSlot wipes a non-active slot without touching the active selection", function()
|
|
1003
565
|
local context = setup()
|
|
1004
566
|
|
|
1005
|
-
local
|
|
1006
|
-
if not PromiseTestUtils.awaitSettled(activePromise, 10) then
|
|
1007
|
-
expect("active create hung").toEqual("active create settled")
|
|
1008
|
-
context:Destroy()
|
|
1009
|
-
return
|
|
1010
|
-
end
|
|
1011
|
-
local _, activeSlotId = activePromise:Yield()
|
|
567
|
+
local activeSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
1012
568
|
|
|
1013
569
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(activeSlotId)
|
|
1014
|
-
|
|
1015
|
-
expect("select hung").toEqual("select settled")
|
|
1016
|
-
context:Destroy()
|
|
1017
|
-
return
|
|
1018
|
-
end
|
|
570
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
1019
571
|
selectPromise:Yield()
|
|
1020
572
|
|
|
1021
|
-
local
|
|
1022
|
-
|
|
1023
|
-
expect("target create hung").toEqual("target create settled")
|
|
1024
|
-
context:Destroy()
|
|
1025
|
-
return
|
|
1026
|
-
end
|
|
1027
|
-
local _, targetSlotId = targetPromise:Yield()
|
|
573
|
+
local targetSlotId =
|
|
574
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(2, { SlotName = "Adventure" }), 10)
|
|
1028
575
|
|
|
1029
576
|
local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
|
|
1030
577
|
tracker:_getSlotStore(targetSlotId):Store("Coins", 500)
|
|
1031
578
|
|
|
1032
|
-
local
|
|
1033
|
-
if not PromiseTestUtils.awaitSettled(resetPromise, 10) then
|
|
1034
|
-
expect("reset hung").toEqual("reset settled")
|
|
1035
|
-
context:Destroy()
|
|
1036
|
-
return
|
|
1037
|
-
end
|
|
1038
|
-
local newSlotId = resetPromise:Wait()
|
|
579
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseResetSlot(targetSlotId), 10)
|
|
1039
580
|
expect(type(newSlotId)).toEqual("string")
|
|
1040
581
|
expect(newSlotId ~= targetSlotId).toEqual(true)
|
|
1041
582
|
|
|
1042
583
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(activeSlotId)
|
|
1043
584
|
|
|
1044
|
-
local
|
|
1045
|
-
if not PromiseTestUtils.awaitSettled(metadataPromise, 10) then
|
|
1046
|
-
expect("metadata hung").toEqual("metadata settled")
|
|
1047
|
-
context:Destroy()
|
|
1048
|
-
return
|
|
1049
|
-
end
|
|
1050
|
-
local metadata = metadataPromise:Wait()
|
|
585
|
+
local metadata = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseGetSlotMetadata(newSlotId), 10)
|
|
1051
586
|
expect(metadata.SlotIndex).toEqual(2)
|
|
1052
587
|
expect(metadata.SlotName).toEqual("Adventure")
|
|
1053
588
|
|
|
1054
|
-
|
|
1055
|
-
if not PromiseTestUtils.awaitSettled(dataPromise, 10) then
|
|
1056
|
-
expect("data hung").toEqual("data settled")
|
|
1057
|
-
context:Destroy()
|
|
1058
|
-
return
|
|
1059
|
-
end
|
|
1060
|
-
expect((dataPromise:Wait())).toBeNil()
|
|
589
|
+
expect(PromiseTestUtils.awaitFulfilled(tracker:_getSlotStore(newSlotId):Load("Coins"), 10)).toBeNil()
|
|
1061
590
|
|
|
1062
591
|
context:Destroy()
|
|
1063
592
|
end)
|
|
@@ -1065,49 +594,23 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
1065
594
|
it("PromiseResetSlot keeps the continue pointer on the reset slot when it was last-active", function()
|
|
1066
595
|
local context = setup()
|
|
1067
596
|
|
|
1068
|
-
local
|
|
1069
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
1070
|
-
expect("create hung").toEqual("create settled")
|
|
1071
|
-
context:Destroy()
|
|
1072
|
-
return
|
|
1073
|
-
end
|
|
1074
|
-
local _, slotId = createPromise:Yield()
|
|
597
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
1075
598
|
|
|
1076
599
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
1077
|
-
|
|
1078
|
-
expect("select hung").toEqual("select settled")
|
|
1079
|
-
context:Destroy()
|
|
1080
|
-
return
|
|
1081
|
-
end
|
|
600
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
1082
601
|
selectPromise:Yield()
|
|
1083
602
|
|
|
1084
603
|
local deselectPromise = context.hasSaveSlots:PromiseDeselectSlot()
|
|
1085
|
-
|
|
1086
|
-
expect("deselect hung").toEqual("deselect settled")
|
|
1087
|
-
context:Destroy()
|
|
1088
|
-
return
|
|
1089
|
-
end
|
|
604
|
+
expect(PromiseTestUtils.awaitSettled(deselectPromise, 10)).toEqual(true)
|
|
1090
605
|
deselectPromise:Yield()
|
|
1091
606
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(slotId)
|
|
1092
607
|
|
|
1093
|
-
local
|
|
1094
|
-
if not PromiseTestUtils.awaitSettled(resetPromise, 10) then
|
|
1095
|
-
expect("reset hung").toEqual("reset settled")
|
|
1096
|
-
context:Destroy()
|
|
1097
|
-
return
|
|
1098
|
-
end
|
|
1099
|
-
local newSlotId = resetPromise:Wait()
|
|
608
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseResetSlot(slotId), 10)
|
|
1100
609
|
|
|
1101
610
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toBeNil()
|
|
1102
611
|
expect(context.hasSaveSlots.LastActiveSlotId.Value).toEqual(newSlotId)
|
|
1103
612
|
|
|
1104
|
-
|
|
1105
|
-
if not PromiseTestUtils.awaitSettled(lastPromise, 10) then
|
|
1106
|
-
expect("lastActive hung").toEqual("lastActive settled")
|
|
1107
|
-
context:Destroy()
|
|
1108
|
-
return
|
|
1109
|
-
end
|
|
1110
|
-
expect((lastPromise:Wait())).toEqual(newSlotId)
|
|
613
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseLastActiveSlotId(), 10)).toEqual(newSlotId)
|
|
1111
614
|
|
|
1112
615
|
context:Destroy()
|
|
1113
616
|
end)
|
|
@@ -1115,13 +618,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
1115
618
|
it("PromiseResetSlot rejects when the slot is missing", function()
|
|
1116
619
|
local context = setup()
|
|
1117
620
|
|
|
1118
|
-
|
|
1119
|
-
if not PromiseTestUtils.awaitSettled(resetPromise, 10) then
|
|
1120
|
-
expect("reset hung").toEqual("reset settled")
|
|
1121
|
-
context:Destroy()
|
|
1122
|
-
return
|
|
1123
|
-
end
|
|
1124
|
-
expect((resetPromise:Yield())).toEqual(false)
|
|
621
|
+
PromiseTestUtils.awaitRejected(context.hasSaveSlots:PromiseResetSlot("does-not-exist"), 10)
|
|
1125
622
|
|
|
1126
623
|
context:Destroy()
|
|
1127
624
|
end)
|
|
@@ -1130,14 +627,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
1130
627
|
local context = setup()
|
|
1131
628
|
context.hasSaveSlots.MaxSlotCount.Value = math.huge
|
|
1132
629
|
|
|
1133
|
-
local
|
|
1134
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
1135
|
-
expect("create hung").toEqual("create settled")
|
|
1136
|
-
context:Destroy()
|
|
1137
|
-
return
|
|
1138
|
-
end
|
|
1139
|
-
local ok, slotId = createPromise:Yield()
|
|
1140
|
-
expect(ok).toEqual(true)
|
|
630
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(6), 10)
|
|
1141
631
|
expect(type(slotId)).toEqual("string")
|
|
1142
632
|
|
|
1143
633
|
context:Destroy()
|
|
@@ -1148,13 +638,9 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
|
|
|
1148
638
|
context.hasSaveSlots.MaxSlotCount.Value = math.huge
|
|
1149
639
|
|
|
1150
640
|
for _ = 1, 7 do
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
context:Destroy()
|
|
1155
|
-
return
|
|
1156
|
-
end
|
|
1157
|
-
expect(type(newPromise:Wait())).toEqual("string")
|
|
641
|
+
expect(type(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectNewSaveSlot(), 10))).toEqual(
|
|
642
|
+
"string"
|
|
643
|
+
)
|
|
1158
644
|
end
|
|
1159
645
|
|
|
1160
646
|
context:Destroy()
|
|
@@ -1163,18 +649,10 @@ end)
|
|
|
1163
649
|
|
|
1164
650
|
describe("HasSaveSlots playtime tracking", function()
|
|
1165
651
|
local function createAndSelect(context: any, slotIndex: number): any
|
|
1166
|
-
local
|
|
1167
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
1168
|
-
expect("create hung").toEqual("create settled")
|
|
1169
|
-
return nil
|
|
1170
|
-
end
|
|
1171
|
-
local _, slotId = createPromise:Yield()
|
|
652
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(slotIndex), 10)
|
|
1172
653
|
|
|
1173
654
|
local selectPromise = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
1174
|
-
|
|
1175
|
-
expect("select hung").toEqual("select settled")
|
|
1176
|
-
return nil
|
|
1177
|
-
end
|
|
655
|
+
expect(PromiseTestUtils.awaitSettled(selectPromise, 10)).toEqual(true)
|
|
1178
656
|
selectPromise:Yield()
|
|
1179
657
|
|
|
1180
658
|
return slotId
|
|
@@ -1182,10 +660,7 @@ describe("HasSaveSlots playtime tracking", function()
|
|
|
1182
660
|
|
|
1183
661
|
local function getMetadata(context: any, slotId): any
|
|
1184
662
|
local promise = context.hasSaveSlots:PromiseGetSlotMetadata(slotId)
|
|
1185
|
-
|
|
1186
|
-
expect("metadata hung").toEqual("metadata settled")
|
|
1187
|
-
return nil
|
|
1188
|
-
end
|
|
663
|
+
expect(PromiseTestUtils.awaitSettled(promise, 10)).toEqual(true)
|
|
1189
664
|
return promise:Wait()
|
|
1190
665
|
end
|
|
1191
666
|
|
|
@@ -1205,11 +680,7 @@ describe("HasSaveSlots playtime tracking", function()
|
|
|
1205
680
|
local secondSlotId = createAndSelect(context, 2)
|
|
1206
681
|
|
|
1207
682
|
local reselectPromise = context.hasSaveSlots:PromiseSelectSlot(firstSlotId)
|
|
1208
|
-
|
|
1209
|
-
expect("reselect hung").toEqual("reselect settled")
|
|
1210
|
-
context:Destroy()
|
|
1211
|
-
return
|
|
1212
|
-
end
|
|
683
|
+
expect(PromiseTestUtils.awaitSettled(reselectPromise, 10)).toEqual(true)
|
|
1213
684
|
reselectPromise:Yield()
|
|
1214
685
|
|
|
1215
686
|
expect(getMetadata(context, firstSlotId).PlayCount).toEqual(2)
|
|
@@ -1265,13 +736,7 @@ describe("HasSaveSlots playtime tracking", function()
|
|
|
1265
736
|
local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
|
|
1266
737
|
tracker:_flushPlaytime()
|
|
1267
738
|
|
|
1268
|
-
local
|
|
1269
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
1270
|
-
expect("create hung").toEqual("create settled")
|
|
1271
|
-
context:Destroy()
|
|
1272
|
-
return
|
|
1273
|
-
end
|
|
1274
|
-
local _, slotId = createPromise:Yield()
|
|
739
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
1275
740
|
|
|
1276
741
|
expect(getMetadata(context, slotId).TimePlayed).toBeNil()
|
|
1277
742
|
|
|
@@ -1289,11 +754,7 @@ describe("HasSaveSlots playtime tracking", function()
|
|
|
1289
754
|
tracker:_flushPlaytime()
|
|
1290
755
|
|
|
1291
756
|
local deselectPromise = context.hasSaveSlots:PromiseDeselectSlot()
|
|
1292
|
-
|
|
1293
|
-
expect("deselect hung").toEqual("deselect settled")
|
|
1294
|
-
context:Destroy()
|
|
1295
|
-
return
|
|
1296
|
-
end
|
|
757
|
+
expect(PromiseTestUtils.awaitSettled(deselectPromise, 10)).toEqual(true)
|
|
1297
758
|
deselectPromise:Yield()
|
|
1298
759
|
|
|
1299
760
|
local afterDeselect = getMetadata(context, slotId).TimePlayed
|
|
@@ -1316,13 +777,7 @@ describe("HasSaveSlots playtime tracking", function()
|
|
|
1316
777
|
tracker._playSessionStart = os.time() - 120
|
|
1317
778
|
tracker._playSessionLastFlush = os.time() - 120
|
|
1318
779
|
|
|
1319
|
-
local
|
|
1320
|
-
if not PromiseTestUtils.awaitSettled(duplicatePromise, 10) then
|
|
1321
|
-
expect("duplicate hung").toEqual("duplicate settled")
|
|
1322
|
-
context:Destroy()
|
|
1323
|
-
return
|
|
1324
|
-
end
|
|
1325
|
-
local newSlotId = duplicatePromise:Wait()
|
|
780
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDuplicateSlot(slotId), 10)
|
|
1326
781
|
|
|
1327
782
|
local copied = getMetadata(context, newSlotId).TimePlayed
|
|
1328
783
|
expect(copied ~= nil and copied >= 120).toEqual(true)
|
|
@@ -1333,20 +788,10 @@ describe("HasSaveSlots playtime tracking", function()
|
|
|
1333
788
|
it("leaves a duplicate of a never-played slot without playtime", function()
|
|
1334
789
|
local context = setup()
|
|
1335
790
|
|
|
1336
|
-
local
|
|
1337
|
-
if not PromiseTestUtils.awaitSettled(createPromise, 10) then
|
|
1338
|
-
expect("create hung").toEqual("create settled")
|
|
1339
|
-
context:Destroy()
|
|
1340
|
-
return
|
|
1341
|
-
end
|
|
1342
|
-
local _, slotId = createPromise:Yield()
|
|
791
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1), 10)
|
|
1343
792
|
|
|
1344
793
|
local duplicatePromise = context.hasSaveSlots:PromiseDuplicateSlot(slotId)
|
|
1345
|
-
|
|
1346
|
-
expect("duplicate hung").toEqual("duplicate settled")
|
|
1347
|
-
context:Destroy()
|
|
1348
|
-
return
|
|
1349
|
-
end
|
|
794
|
+
expect(PromiseTestUtils.awaitSettled(duplicatePromise, 10)).toEqual(true)
|
|
1350
795
|
|
|
1351
796
|
expect(getMetadata(context, duplicatePromise:Wait()).TimePlayed).toBeNil()
|
|
1352
797
|
|
|
@@ -1526,20 +971,13 @@ describe("HasSaveSlots against a fake player (datastore down)", function()
|
|
|
1526
971
|
end)
|
|
1527
972
|
|
|
1528
973
|
describe("HasSaveSlots ephemeral slots", function()
|
|
1529
|
-
local function resolve(promise, timeout: number?)
|
|
1530
|
-
expect(PromiseTestUtils.awaitSettled(promise, timeout or 10)).toEqual(true)
|
|
1531
|
-
local ok, value = promise:Yield()
|
|
1532
|
-
expect(ok).toEqual(true)
|
|
1533
|
-
return value
|
|
1534
|
-
end
|
|
1535
|
-
|
|
1536
974
|
local function selectEphemeral(context: any, metadata: any?)
|
|
1537
|
-
return
|
|
975
|
+
return PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectEphemeralSlot(metadata))
|
|
1538
976
|
end
|
|
1539
977
|
|
|
1540
978
|
local function createAndSelectReal(context: any, slotIndex: number)
|
|
1541
|
-
local slotId =
|
|
1542
|
-
|
|
979
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(slotIndex))
|
|
980
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId))
|
|
1543
981
|
return slotId
|
|
1544
982
|
end
|
|
1545
983
|
|
|
@@ -1554,7 +992,7 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1554
992
|
local slotId = selectEphemeral(context)
|
|
1555
993
|
expect(type(slotId)).toEqual("string")
|
|
1556
994
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(slotId)
|
|
1557
|
-
expect(
|
|
995
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseHasSlot(slotId))).toEqual(true)
|
|
1558
996
|
|
|
1559
997
|
context:Destroy()
|
|
1560
998
|
end)
|
|
@@ -1565,8 +1003,9 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1565
1003
|
local realId = createAndSelectReal(context, 1)
|
|
1566
1004
|
local ephemeralId = selectEphemeral(context)
|
|
1567
1005
|
|
|
1568
|
-
local realMetadata =
|
|
1569
|
-
local ephemeralMetadata =
|
|
1006
|
+
local realMetadata = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseGetSlotMetadata(realId))
|
|
1007
|
+
local ephemeralMetadata =
|
|
1008
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseGetSlotMetadata(ephemeralId))
|
|
1570
1009
|
|
|
1571
1010
|
expect(ephemeralMetadata.IsEphemeral).toEqual(true)
|
|
1572
1011
|
expect(realMetadata.IsEphemeral).never.toEqual(true)
|
|
@@ -1654,7 +1093,7 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1654
1093
|
return observed ~= nil and observed.SlotName == "Lobby run"
|
|
1655
1094
|
end, 10)).toEqual(true)
|
|
1656
1095
|
|
|
1657
|
-
|
|
1096
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot())
|
|
1658
1097
|
|
|
1659
1098
|
expect(PromiseTestUtils.awaitValue(function()
|
|
1660
1099
|
return observed == nil
|
|
@@ -1686,7 +1125,7 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1686
1125
|
|
|
1687
1126
|
-- Adding a real slot after the ephemeral one forces a re-emission that must have seen both, so the
|
|
1688
1127
|
-- ephemeral slot's absence below is a filtered list rather than a list that never updated.
|
|
1689
|
-
local laterRealId =
|
|
1128
|
+
local laterRealId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(3))
|
|
1690
1129
|
expect(PromiseTestUtils.awaitValue(function()
|
|
1691
1130
|
return observedIds[laterRealId] == true
|
|
1692
1131
|
end, 10)).toEqual(true)
|
|
@@ -1702,10 +1141,10 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1702
1141
|
local context = setup()
|
|
1703
1142
|
|
|
1704
1143
|
local realId = createAndSelectReal(context, 2)
|
|
1705
|
-
|
|
1144
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseActiveSlotStore()):Store("coins", 12321)
|
|
1706
1145
|
|
|
1707
1146
|
local ephemeralId = selectEphemeral(context)
|
|
1708
|
-
|
|
1147
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseActiveSlotStore()):Store("coins", 98789)
|
|
1709
1148
|
|
|
1710
1149
|
local raw = (context.mock :: any):GetRaw(tostring(FAKE_USER_ID))
|
|
1711
1150
|
local encoded = if raw ~= nil then HttpService:JSONEncode(raw) else ""
|
|
@@ -1728,10 +1167,10 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1728
1167
|
local context = setup()
|
|
1729
1168
|
|
|
1730
1169
|
selectEphemeral(context)
|
|
1731
|
-
local store =
|
|
1170
|
+
local store = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseActiveSlotStore())
|
|
1732
1171
|
expect(getmetatable(store)).never.toBeNil()
|
|
1733
1172
|
|
|
1734
|
-
|
|
1173
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot())
|
|
1735
1174
|
|
|
1736
1175
|
-- BaseObject.Destroy clears the metatable, so a nil metatable means the store was torn down (and is
|
|
1737
1176
|
-- now GC-eligible) when the slot was retired, rather than lingering.
|
|
@@ -1755,12 +1194,12 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1755
1194
|
local context = setup()
|
|
1756
1195
|
|
|
1757
1196
|
local ephemeralId = selectEphemeral(context)
|
|
1758
|
-
expect(
|
|
1197
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseHasSlot(ephemeralId))).toEqual(true)
|
|
1759
1198
|
|
|
1760
|
-
|
|
1199
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot())
|
|
1761
1200
|
|
|
1762
1201
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(nil)
|
|
1763
|
-
expect(
|
|
1202
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseHasSlot(ephemeralId))).toEqual(false)
|
|
1764
1203
|
expect(slotContainerHasChild(context, ephemeralId)).toEqual(false)
|
|
1765
1204
|
|
|
1766
1205
|
context:Destroy()
|
|
@@ -1770,15 +1209,15 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1770
1209
|
local context = setup()
|
|
1771
1210
|
|
|
1772
1211
|
local slotA = createAndSelectReal(context, 1)
|
|
1773
|
-
local slotB =
|
|
1212
|
+
local slotB = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(2))
|
|
1774
1213
|
local ephemeralId = selectEphemeral(context)
|
|
1775
1214
|
|
|
1776
|
-
|
|
1215
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotB))
|
|
1777
1216
|
|
|
1778
1217
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(slotB)
|
|
1779
|
-
expect(
|
|
1780
|
-
expect(
|
|
1781
|
-
expect(
|
|
1218
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseHasSlot(ephemeralId))).toEqual(false)
|
|
1219
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseHasSlot(slotA))).toEqual(true)
|
|
1220
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseHasSlot(slotB))).toEqual(true)
|
|
1782
1221
|
|
|
1783
1222
|
context:Destroy()
|
|
1784
1223
|
end)
|
|
@@ -1806,9 +1245,7 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1806
1245
|
|
|
1807
1246
|
local ephemeralId = selectEphemeral(context)
|
|
1808
1247
|
|
|
1809
|
-
|
|
1810
|
-
expect(PromiseTestUtils.awaitSettled(resetPromise, 10)).toEqual(true)
|
|
1811
|
-
expect((resetPromise:Yield())).toEqual(false)
|
|
1248
|
+
PromiseTestUtils.awaitRejected(context.hasSaveSlots:PromiseResetSlot(ephemeralId), 10)
|
|
1812
1249
|
|
|
1813
1250
|
context:Destroy()
|
|
1814
1251
|
end)
|
|
@@ -1818,15 +1255,15 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1818
1255
|
|
|
1819
1256
|
createAndSelectReal(context, 1)
|
|
1820
1257
|
local ephemeralId = selectEphemeral(context, { SlotName = "Lobby run" })
|
|
1821
|
-
|
|
1258
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseActiveSlotStore()):Store("Coins", 12)
|
|
1822
1259
|
|
|
1823
|
-
local newSlotId =
|
|
1260
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDuplicateSlot(ephemeralId))
|
|
1824
1261
|
|
|
1825
|
-
local metadata =
|
|
1262
|
+
local metadata = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseGetSlotMetadata(newSlotId))
|
|
1826
1263
|
expect(metadata.IsEphemeral).never.toEqual(true)
|
|
1827
1264
|
expect(metadata.SlotName).toEqual("Lobby run")
|
|
1828
1265
|
|
|
1829
|
-
local export =
|
|
1266
|
+
local export = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseExportSlot(newSlotId))
|
|
1830
1267
|
expect(export.data.Coins).toEqual(12)
|
|
1831
1268
|
|
|
1832
1269
|
-- Duplicating leaves the session running on the ephemeral slot, like any other duplicate.
|
|
@@ -1839,12 +1276,12 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1839
1276
|
local context = setup()
|
|
1840
1277
|
|
|
1841
1278
|
local ephemeralId = selectEphemeral(context, { SlotName = "Lobby run" })
|
|
1842
|
-
|
|
1279
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseActiveSlotStore()):Store("Coins", 12)
|
|
1843
1280
|
|
|
1844
|
-
local newSlotId =
|
|
1281
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromisePersistEphemeralSlot())
|
|
1845
1282
|
|
|
1846
1283
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(newSlotId)
|
|
1847
|
-
expect(
|
|
1284
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseHasSlot(ephemeralId))).toEqual(false)
|
|
1848
1285
|
|
|
1849
1286
|
local listedIds = {}
|
|
1850
1287
|
for _, metadata in (SaveSlotDataService :: any):GetSlotList(context.fakePlayer) do
|
|
@@ -1854,7 +1291,9 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1854
1291
|
|
|
1855
1292
|
-- The copy landed on the default index, whose store is the player's root: the session's data is
|
|
1856
1293
|
-- there and the SaveSlots system data alongside it survived the merge.
|
|
1857
|
-
local data =
|
|
1294
|
+
local data = PromiseTestUtils.awaitFulfilled(
|
|
1295
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseActiveSlotStore()):LoadAll({})
|
|
1296
|
+
)
|
|
1858
1297
|
expect(data.Coins).toEqual(12)
|
|
1859
1298
|
expect(data.SaveSlots).never.toBeNil()
|
|
1860
1299
|
|
|
@@ -1866,9 +1305,7 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1866
1305
|
|
|
1867
1306
|
createAndSelectReal(context, 1)
|
|
1868
1307
|
|
|
1869
|
-
|
|
1870
|
-
expect(PromiseTestUtils.awaitSettled(persistPromise, 10)).toEqual(true)
|
|
1871
|
-
expect((persistPromise:Yield())).toEqual(false)
|
|
1308
|
+
PromiseTestUtils.awaitRejected(context.hasSaveSlots:PromisePersistEphemeralSlot(), 10)
|
|
1872
1309
|
|
|
1873
1310
|
context:Destroy()
|
|
1874
1311
|
end)
|
|
@@ -1877,10 +1314,10 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1877
1314
|
local context = setup()
|
|
1878
1315
|
|
|
1879
1316
|
local ephemeralId = selectEphemeral(context)
|
|
1880
|
-
|
|
1317
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeleteSlot(ephemeralId))
|
|
1881
1318
|
|
|
1882
1319
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(nil)
|
|
1883
|
-
expect(
|
|
1320
|
+
expect(PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseHasSlot(ephemeralId))).toEqual(false)
|
|
1884
1321
|
expect(slotContainerHasChild(context, ephemeralId)).toEqual(false)
|
|
1885
1322
|
|
|
1886
1323
|
context:Destroy()
|
|
@@ -1890,12 +1327,12 @@ describe("HasSaveSlots ephemeral slots", function()
|
|
|
1890
1327
|
local context = setup()
|
|
1891
1328
|
|
|
1892
1329
|
local realId = createAndSelectReal(context, 2)
|
|
1893
|
-
|
|
1330
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot())
|
|
1894
1331
|
|
|
1895
1332
|
selectEphemeral(context)
|
|
1896
|
-
|
|
1333
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseDeselectSlot())
|
|
1897
1334
|
|
|
1898
|
-
local continuedId =
|
|
1335
|
+
local continuedId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectLastSaveSlot())
|
|
1899
1336
|
expect(continuedId).toEqual(realId)
|
|
1900
1337
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(realId)
|
|
1901
1338
|
|