@quenty/saveslot 2.14.3 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +21 -20
- 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
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
]]
|
|
9
9
|
local require = require(script.Parent.loader).load(script)
|
|
10
10
|
|
|
11
|
+
local BindToCloseService = require("BindToCloseService")
|
|
11
12
|
local DataStoreMock = require("DataStoreMock")
|
|
12
|
-
local DataStoreTestUtils = require("DataStoreTestUtils")
|
|
13
13
|
local Jest = require("Jest")
|
|
14
14
|
local JestUtils = require("JestUtils")
|
|
15
15
|
local Maid = require("Maid")
|
|
@@ -35,6 +35,7 @@ local function setup()
|
|
|
35
35
|
local serviceBag = ServiceBag.new()
|
|
36
36
|
serviceBag:GetService(require("TeleportDataService"))
|
|
37
37
|
serviceBag:GetService(require("SaveSlotSharedDataStoreService"))
|
|
38
|
+
local bindToCloseService: BindToCloseService.BindToCloseService = serviceBag:GetService(BindToCloseService) :: any
|
|
38
39
|
local playerDataStoreService: PlayerDataStoreService.PlayerDataStoreService =
|
|
39
40
|
serviceBag:GetService(PlayerDataStoreService) :: any
|
|
40
41
|
local binder = serviceBag:GetService(require("HasSaveSlots"))
|
|
@@ -48,10 +49,8 @@ local function setup()
|
|
|
48
49
|
local hasSaveSlots = assert(binder:Bind(fakePlayer), "Failed to bind HasSaveSlots")
|
|
49
50
|
hasSaveSlots.MaxSlotCount.Value = 5
|
|
50
51
|
|
|
51
|
-
-- A PlayerMock never fires the real Players.PlayerRemoving, and the store the spec loaded is only
|
|
52
|
-
-- destroyed by a removal, so shut it down the way Roblox does or its auto-save loop outlives this spec.
|
|
53
52
|
maid:GiveTask(function()
|
|
54
|
-
|
|
53
|
+
PromiseTestUtils.awaitFulfilled(bindToCloseService:PromiseClose())
|
|
55
54
|
fakePlayer:Destroy()
|
|
56
55
|
serviceBag:Destroy()
|
|
57
56
|
end)
|
|
@@ -74,39 +73,14 @@ local function setup()
|
|
|
74
73
|
return controller
|
|
75
74
|
end
|
|
76
75
|
|
|
77
|
-
local function runWithContext(body)
|
|
78
|
-
local context = setup()
|
|
79
|
-
local ok, err = pcall(body, context)
|
|
80
|
-
context:Destroy()
|
|
81
|
-
if not ok then
|
|
82
|
-
error(err, 0)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
76
|
-- Settles a promise (failing loudly on a hang) and returns its resolved value, throwing on rejection.
|
|
87
|
-
local function awaitValueOf(promise)
|
|
88
|
-
if not PromiseTestUtils.awaitSettled(promise, 10) then
|
|
89
|
-
error("promise hung", 0)
|
|
90
|
-
end
|
|
91
|
-
local ok, value = promise:Yield()
|
|
92
|
-
if not ok then
|
|
93
|
-
error(`promise rejected: {tostring(value)}`, 0)
|
|
94
|
-
end
|
|
95
|
-
return value
|
|
96
|
-
end
|
|
97
77
|
|
|
98
78
|
-- Settles a promise and returns whether it resolved (true) or rejected (false).
|
|
99
|
-
local function awaitResolved(promise): boolean
|
|
100
|
-
if not PromiseTestUtils.awaitSettled(promise, 10) then
|
|
101
|
-
error("promise hung", 0)
|
|
102
|
-
end
|
|
103
|
-
return (promise:Yield())
|
|
104
|
-
end
|
|
105
79
|
|
|
106
80
|
local function createSelectAndWrite(hasSaveSlots, slotIndex: number): string
|
|
107
|
-
local slotId =
|
|
108
|
-
|
|
109
|
-
local store =
|
|
81
|
+
local slotId = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseCreateSlot(slotIndex))
|
|
82
|
+
PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseSelectSlot(slotId))
|
|
83
|
+
local store = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseActiveSlotStore())
|
|
110
84
|
store:Store("Coins", 7)
|
|
111
85
|
store:GetSubStore("World_2"):Store("Eggs", 3)
|
|
112
86
|
return slotId
|
|
@@ -114,169 +88,185 @@ end
|
|
|
114
88
|
|
|
115
89
|
describe("HasSaveSlots.PromiseExportSlot / PromiseImportSlot", function()
|
|
116
90
|
it("round-trips a non-main slot's data into a fresh non-main slot", function()
|
|
117
|
-
|
|
118
|
-
|
|
91
|
+
local context = setup()
|
|
92
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
93
|
+
|
|
94
|
+
local sourceSlotId = createSelectAndWrite(hasSaveSlots, 2)
|
|
119
95
|
|
|
120
|
-
|
|
96
|
+
local export = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSlot(sourceSlotId))
|
|
97
|
+
expect(export.data.Coins).toEqual(7)
|
|
98
|
+
expect(export.data.World_2.Eggs).toEqual(3)
|
|
121
99
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
expect(export.data.World_2.Eggs).toEqual(3)
|
|
100
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseImportSlot(export))
|
|
101
|
+
expect(newSlotId).never.toEqual(sourceSlotId)
|
|
125
102
|
|
|
126
|
-
|
|
127
|
-
|
|
103
|
+
-- Re-export the imported slot to prove its store carries the seeded data (public-API only).
|
|
104
|
+
local reexport = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSlot(newSlotId))
|
|
105
|
+
expect(reexport.data.Coins).toEqual(7)
|
|
106
|
+
expect(reexport.data.World_2.Eggs).toEqual(3)
|
|
128
107
|
|
|
129
|
-
|
|
130
|
-
local reexport = awaitValueOf(hasSaveSlots:PromiseExportSlot(newSlotId))
|
|
131
|
-
expect(reexport.data.Coins).toEqual(7)
|
|
132
|
-
expect(reexport.data.World_2.Eggs).toEqual(3)
|
|
133
|
-
end)
|
|
108
|
+
context:Destroy()
|
|
134
109
|
end)
|
|
135
110
|
|
|
136
111
|
it("imports into a non-main index even when the main index is free", function()
|
|
137
|
-
|
|
138
|
-
|
|
112
|
+
local context = setup()
|
|
113
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
139
114
|
|
|
140
|
-
|
|
115
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseImportSlot({ data = { Coins = 1 } }))
|
|
141
116
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
117
|
+
local metadata = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseGetSlotMetadata(newSlotId))
|
|
118
|
+
expect(metadata.SlotIndex).toEqual(SaveSlotConstants.DEFAULT_SLOT_INDEX + 1)
|
|
119
|
+
expect(metadata.SlotIndex).never.toEqual(SaveSlotConstants.DEFAULT_SLOT_INDEX)
|
|
120
|
+
|
|
121
|
+
context:Destroy()
|
|
146
122
|
end)
|
|
147
123
|
|
|
148
124
|
it("carries slot name and summary through the export", function()
|
|
149
|
-
|
|
150
|
-
|
|
125
|
+
local context = setup()
|
|
126
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
127
|
+
|
|
128
|
+
local sourceSlotId = PromiseTestUtils.awaitFulfilled(
|
|
129
|
+
hasSaveSlots:PromiseCreateSlot(2, { SlotName = "Hero", Summary = { pct = 42 } })
|
|
130
|
+
)
|
|
151
131
|
|
|
152
|
-
|
|
153
|
-
|
|
132
|
+
local export = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSlot(sourceSlotId))
|
|
133
|
+
expect(export.slotName).toEqual("Hero")
|
|
134
|
+
expect(export.summary.pct).toEqual(42)
|
|
154
135
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
136
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseImportSlot(export))
|
|
137
|
+
local metadata = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseGetSlotMetadata(newSlotId))
|
|
138
|
+
expect(metadata.SlotName).toEqual("Hero")
|
|
158
139
|
|
|
159
|
-
|
|
160
|
-
local metadata = awaitValueOf(hasSaveSlots:PromiseGetSlotMetadata(newSlotId))
|
|
161
|
-
expect(metadata.SlotName).toEqual("Hero")
|
|
162
|
-
end)
|
|
140
|
+
context:Destroy()
|
|
163
141
|
end)
|
|
164
142
|
|
|
165
143
|
it("carries accrued playtime through the export", function()
|
|
166
|
-
|
|
167
|
-
|
|
144
|
+
local context = setup()
|
|
145
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
168
146
|
|
|
169
|
-
|
|
147
|
+
local sourceSlotId = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseCreateSlot(2, { TimePlayed = 3600 }))
|
|
170
148
|
|
|
171
|
-
|
|
172
|
-
|
|
149
|
+
local export = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSlot(sourceSlotId))
|
|
150
|
+
expect(export.timePlayed).toEqual(3600)
|
|
173
151
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
152
|
+
local newSlotId = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseImportSlot(export))
|
|
153
|
+
local metadata = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseGetSlotMetadata(newSlotId))
|
|
154
|
+
expect(metadata.TimePlayed).toEqual(3600)
|
|
155
|
+
|
|
156
|
+
context:Destroy()
|
|
178
157
|
end)
|
|
179
158
|
|
|
180
159
|
it("exports the live session's playtime, not just what was last saved", function()
|
|
181
|
-
|
|
182
|
-
|
|
160
|
+
local context = setup()
|
|
161
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
162
|
+
|
|
163
|
+
local sourceSlotId = createSelectAndWrite(hasSaveSlots, 2)
|
|
183
164
|
|
|
184
|
-
|
|
165
|
+
-- Rewind the live session's clock so the export observes ~120s of unflushed play.
|
|
166
|
+
local tracker: any = hasSaveSlots:GetSlotsDataStore()
|
|
167
|
+
tracker._playSessionStart = os.time() - 120
|
|
168
|
+
tracker._playSessionLastFlush = os.time() - 120
|
|
185
169
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
tracker._playSessionStart = os.time() - 120
|
|
189
|
-
tracker._playSessionLastFlush = os.time() - 120
|
|
170
|
+
local export = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSlot(sourceSlotId))
|
|
171
|
+
expect(export.timePlayed ~= nil and export.timePlayed >= 120).toEqual(true)
|
|
190
172
|
|
|
191
|
-
|
|
192
|
-
expect(export.timePlayed ~= nil and export.timePlayed >= 120).toEqual(true)
|
|
193
|
-
end)
|
|
173
|
+
context:Destroy()
|
|
194
174
|
end)
|
|
195
175
|
|
|
196
176
|
it("imports an export written before playtime was carried", function()
|
|
197
|
-
|
|
198
|
-
|
|
177
|
+
local context = setup()
|
|
178
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
179
|
+
|
|
180
|
+
local newSlotId =
|
|
181
|
+
PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseImportSlot({ data = { Coins = 1 }, slotName = "Hero" }))
|
|
199
182
|
|
|
200
|
-
|
|
183
|
+
local metadata = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseGetSlotMetadata(newSlotId))
|
|
184
|
+
expect(metadata.SlotName).toEqual("Hero")
|
|
185
|
+
expect(metadata.TimePlayed).toBeNil()
|
|
201
186
|
|
|
202
|
-
|
|
203
|
-
expect(metadata.SlotName).toEqual("Hero")
|
|
204
|
-
expect(metadata.TimePlayed).toBeNil()
|
|
205
|
-
end)
|
|
187
|
+
context:Destroy()
|
|
206
188
|
end)
|
|
207
189
|
|
|
208
190
|
it("refuses to import an export whose timePlayed is not a number", function()
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
end)
|
|
191
|
+
local context = setup()
|
|
192
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
193
|
+
PromiseTestUtils.awaitRejected(hasSaveSlots:PromiseImportSlot(({ data = {}, timePlayed = "600" }) :: any))
|
|
194
|
+
|
|
195
|
+
context:Destroy()
|
|
215
196
|
end)
|
|
216
197
|
|
|
217
198
|
it("refuses to export the main slot", function()
|
|
218
|
-
|
|
219
|
-
|
|
199
|
+
local context = setup()
|
|
200
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
201
|
+
|
|
202
|
+
local mainSlotId =
|
|
203
|
+
PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseCreateSlot(SaveSlotConstants.DEFAULT_SLOT_INDEX))
|
|
204
|
+
PromiseTestUtils.awaitRejected(hasSaveSlots:PromiseExportSlot(mainSlotId))
|
|
220
205
|
|
|
221
|
-
|
|
222
|
-
expect(awaitResolved(hasSaveSlots:PromiseExportSlot(mainSlotId))).toEqual(false)
|
|
223
|
-
end)
|
|
206
|
+
context:Destroy()
|
|
224
207
|
end)
|
|
225
208
|
|
|
226
209
|
it("exports the main slot when allowMainSlot is set", function()
|
|
227
|
-
|
|
228
|
-
|
|
210
|
+
local context = setup()
|
|
211
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
212
|
+
|
|
213
|
+
local mainSlotId = createSelectAndWrite(hasSaveSlots, SaveSlotConstants.DEFAULT_SLOT_INDEX)
|
|
229
214
|
|
|
230
|
-
|
|
215
|
+
local export = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSlot(mainSlotId, true))
|
|
216
|
+
expect(export.data.Coins).toEqual(7)
|
|
217
|
+
expect(export.data.World_2.Eggs).toEqual(3)
|
|
231
218
|
|
|
232
|
-
|
|
233
|
-
expect(export.data.Coins).toEqual(7)
|
|
234
|
-
expect(export.data.World_2.Eggs).toEqual(3)
|
|
235
|
-
end)
|
|
219
|
+
context:Destroy()
|
|
236
220
|
end)
|
|
237
221
|
|
|
238
222
|
it("strips the SaveSlots system data from a main slot export", function()
|
|
239
|
-
|
|
240
|
-
|
|
223
|
+
local context = setup()
|
|
224
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
241
225
|
|
|
242
|
-
|
|
243
|
-
|
|
226
|
+
local mainSlotId = createSelectAndWrite(hasSaveSlots, SaveSlotConstants.DEFAULT_SLOT_INDEX)
|
|
227
|
+
createSelectAndWrite(hasSaveSlots, 2)
|
|
244
228
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
229
|
+
local export = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSlot(mainSlotId, true))
|
|
230
|
+
expect(export.data[SaveSlotConstants.SYSTEM_STORE_KEY]).toBeNil()
|
|
231
|
+
|
|
232
|
+
context:Destroy()
|
|
248
233
|
end)
|
|
249
234
|
|
|
250
235
|
it("still refuses the main slot when allowMainSlot is false", function()
|
|
251
|
-
|
|
252
|
-
|
|
236
|
+
local context = setup()
|
|
237
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
238
|
+
|
|
239
|
+
local mainSlotId =
|
|
240
|
+
PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseCreateSlot(SaveSlotConstants.DEFAULT_SLOT_INDEX))
|
|
241
|
+
PromiseTestUtils.awaitRejected(hasSaveSlots:PromiseExportSlot(mainSlotId, false))
|
|
253
242
|
|
|
254
|
-
|
|
255
|
-
expect(awaitResolved(hasSaveSlots:PromiseExportSlot(mainSlotId, false))).toEqual(false)
|
|
256
|
-
end)
|
|
243
|
+
context:Destroy()
|
|
257
244
|
end)
|
|
258
245
|
|
|
259
246
|
it("refuses to export a missing slot", function()
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
247
|
+
local context = setup()
|
|
248
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
249
|
+
PromiseTestUtils.awaitRejected(hasSaveSlots:PromiseExportSlot("does-not-exist"))
|
|
250
|
+
|
|
251
|
+
context:Destroy()
|
|
264
252
|
end)
|
|
265
253
|
|
|
266
254
|
it("refuses to import a malformed export", function()
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
255
|
+
local context = setup()
|
|
256
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
257
|
+
PromiseTestUtils.awaitRejected(hasSaveSlots:PromiseImportSlot(({}) :: any))
|
|
258
|
+
PromiseTestUtils.awaitRejected(hasSaveSlots:PromiseImportSlot(({ data = 5 }) :: any))
|
|
259
|
+
|
|
260
|
+
context:Destroy()
|
|
272
261
|
end)
|
|
273
262
|
|
|
274
263
|
it("rejects import when no non-main index is free", function()
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
264
|
+
local context = setup()
|
|
265
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
266
|
+
-- Only the main index is allowed, so there is no safe (non-main) home for an import.
|
|
267
|
+
hasSaveSlots.MaxSlotCount.Value = 1
|
|
268
|
+
PromiseTestUtils.awaitRejected(hasSaveSlots:PromiseImportSlot({ data = { Coins = 1 } }))
|
|
269
|
+
|
|
270
|
+
context:Destroy()
|
|
281
271
|
end)
|
|
282
272
|
end)
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
]]
|
|
8
8
|
local require = require(script.Parent.loader).load(script)
|
|
9
9
|
|
|
10
|
+
local BindToCloseService = require("BindToCloseService")
|
|
10
11
|
local DataStoreMock = require("DataStoreMock")
|
|
11
|
-
local DataStoreTestUtils = require("DataStoreTestUtils")
|
|
12
12
|
local Jest = require("Jest")
|
|
13
13
|
local JestUtils = require("JestUtils")
|
|
14
14
|
local Maid = require("Maid")
|
|
@@ -34,6 +34,7 @@ local function setup()
|
|
|
34
34
|
local serviceBag = ServiceBag.new()
|
|
35
35
|
serviceBag:GetService(require("TeleportDataService"))
|
|
36
36
|
serviceBag:GetService(require("SaveSlotSharedDataStoreService"))
|
|
37
|
+
local bindToCloseService: BindToCloseService.BindToCloseService = serviceBag:GetService(BindToCloseService) :: any
|
|
37
38
|
local playerDataStoreService: PlayerDataStoreService.PlayerDataStoreService =
|
|
38
39
|
serviceBag:GetService(PlayerDataStoreService) :: any
|
|
39
40
|
local binder = serviceBag:GetService(require("HasSaveSlots"))
|
|
@@ -57,10 +58,8 @@ local function setup()
|
|
|
57
58
|
return verdict or Promise.resolved(true)
|
|
58
59
|
end
|
|
59
60
|
|
|
60
|
-
-- A PlayerMock never fires the real Players.PlayerRemoving, and the store the spec loaded is only
|
|
61
|
-
-- destroyed by a removal, so shut it down the way Roblox does or its auto-save loop outlives this spec.
|
|
62
61
|
maid:GiveTask(function()
|
|
63
|
-
|
|
62
|
+
PromiseTestUtils.awaitFulfilled(bindToCloseService:PromiseClose())
|
|
64
63
|
fakePlayer:Destroy()
|
|
65
64
|
serviceBag:Destroy()
|
|
66
65
|
end)
|
|
@@ -85,19 +84,12 @@ local function setup()
|
|
|
85
84
|
return context
|
|
86
85
|
end
|
|
87
86
|
|
|
88
|
-
local function await(promise: any): any
|
|
89
|
-
assert(PromiseTestUtils.awaitSettled(promise, 10), "promise never settled")
|
|
90
|
-
local ok, value = promise:Yield()
|
|
91
|
-
assert(ok, `promise rejected: {tostring(value)}`)
|
|
92
|
-
return value
|
|
93
|
-
end
|
|
94
|
-
|
|
95
87
|
describe("HasSaveSlots pre-select", function()
|
|
96
88
|
it("asks before the slot becomes active", function()
|
|
97
89
|
local context = setup()
|
|
98
90
|
|
|
99
|
-
local slotId =
|
|
100
|
-
|
|
91
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1))
|
|
92
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId))
|
|
101
93
|
|
|
102
94
|
expect(#context.asks).toEqual(1)
|
|
103
95
|
expect(context.asks[1].slotId).toEqual(slotId)
|
|
@@ -110,10 +102,10 @@ describe("HasSaveSlots pre-select", function()
|
|
|
110
102
|
it("reports the selection being replaced when switching slots", function()
|
|
111
103
|
local context = setup()
|
|
112
104
|
|
|
113
|
-
local firstId =
|
|
114
|
-
local secondId =
|
|
115
|
-
|
|
116
|
-
|
|
105
|
+
local firstId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1))
|
|
106
|
+
local secondId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(2))
|
|
107
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(firstId))
|
|
108
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(secondId))
|
|
117
109
|
|
|
118
110
|
expect(#context.asks).toEqual(2)
|
|
119
111
|
expect(context.asks[2].slotId).toEqual(secondId)
|
|
@@ -125,8 +117,9 @@ describe("HasSaveSlots pre-select", function()
|
|
|
125
117
|
it("asks for a new slot and for an ephemeral slot alike", function()
|
|
126
118
|
local context = setup()
|
|
127
119
|
|
|
128
|
-
local newId =
|
|
129
|
-
local ephemeralId =
|
|
120
|
+
local newId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectNewSaveSlot())
|
|
121
|
+
local ephemeralId =
|
|
122
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectEphemeralSlot({ SlotName = "Throwaway" }))
|
|
130
123
|
|
|
131
124
|
expect(#context.asks).toEqual(2)
|
|
132
125
|
expect(context.asks[1].slotId).toEqual(newId)
|
|
@@ -138,9 +131,9 @@ describe("HasSaveSlots pre-select", function()
|
|
|
138
131
|
it("does not ask when the slot is already active", function()
|
|
139
132
|
local context = setup()
|
|
140
133
|
|
|
141
|
-
local slotId =
|
|
142
|
-
|
|
143
|
-
|
|
134
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1))
|
|
135
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId))
|
|
136
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(slotId))
|
|
144
137
|
|
|
145
138
|
expect(#context.asks).toEqual(1)
|
|
146
139
|
|
|
@@ -153,7 +146,7 @@ describe("HasSaveSlots pre-select", function()
|
|
|
153
146
|
local gate = Promise.new()
|
|
154
147
|
context.answerWith(gate)
|
|
155
148
|
|
|
156
|
-
local slotId =
|
|
149
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1))
|
|
157
150
|
local selection = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
158
151
|
|
|
159
152
|
expect(PromiseTestUtils.awaitSettled(selection, 0.5)).toEqual(false)
|
|
@@ -161,7 +154,7 @@ describe("HasSaveSlots pre-select", function()
|
|
|
161
154
|
|
|
162
155
|
gate:Resolve(true)
|
|
163
156
|
|
|
164
|
-
|
|
157
|
+
PromiseTestUtils.awaitFulfilled(selection)
|
|
165
158
|
expect(context.hasSaveSlots.ActiveSlotId.Value).toEqual(slotId)
|
|
166
159
|
|
|
167
160
|
context:Destroy()
|
|
@@ -172,7 +165,7 @@ describe("HasSaveSlots pre-select", function()
|
|
|
172
165
|
|
|
173
166
|
context.answerWith(Promise.resolved(false))
|
|
174
167
|
|
|
175
|
-
local slotId =
|
|
168
|
+
local slotId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1))
|
|
176
169
|
local selection = context.hasSaveSlots:PromiseSelectSlot(slotId)
|
|
177
170
|
|
|
178
171
|
assert(PromiseTestUtils.awaitSettled(selection, 10), "selection never settled")
|
|
@@ -185,9 +178,9 @@ describe("HasSaveSlots pre-select", function()
|
|
|
185
178
|
it("leaves the previous selection standing when a switch is refused", function()
|
|
186
179
|
local context = setup()
|
|
187
180
|
|
|
188
|
-
local firstId =
|
|
189
|
-
local secondId =
|
|
190
|
-
|
|
181
|
+
local firstId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(1))
|
|
182
|
+
local secondId = PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseCreateSlot(2))
|
|
183
|
+
PromiseTestUtils.awaitFulfilled(context.hasSaveSlots:PromiseSelectSlot(firstId))
|
|
191
184
|
|
|
192
185
|
context.answerWith(Promise.resolved(false))
|
|
193
186
|
local selection = context.hasSaveSlots:PromiseSelectSlot(secondId)
|