@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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.15.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/saveslot@2.14.3...@quenty/saveslot@2.15.0) (2026-10-14)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- BindToClose service has a public method tests can use, simplify tests ([be4ca98](https://github.com/Quenty/NevermoreEngine/commit/be4ca986671cfd9b0757acc4f9ab85e6bfb7f38e))
|
|
11
|
+
|
|
6
12
|
## [2.14.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/saveslot@2.14.2...@quenty/saveslot@2.14.3) (2026-10-09)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @quenty/saveslot
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/saveslot",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"description": "PlayerDataStoreService wrapper for save slots",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,36 +28,37 @@
|
|
|
28
28
|
"Quenty"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@quenty/adorneedata": "7.
|
|
32
|
-
"@quenty/attributeutils": "14.
|
|
31
|
+
"@quenty/adorneedata": "7.44.0",
|
|
32
|
+
"@quenty/attributeutils": "14.39.0",
|
|
33
33
|
"@quenty/baseobject": "10.16.2",
|
|
34
|
-
"@quenty/binder": "14.
|
|
35
|
-
"@quenty/
|
|
36
|
-
"@quenty/
|
|
37
|
-
"@quenty/
|
|
38
|
-
"@quenty/
|
|
34
|
+
"@quenty/binder": "14.48.0",
|
|
35
|
+
"@quenty/bindtocloseservice": "8.46.0",
|
|
36
|
+
"@quenty/brio": "14.38.0",
|
|
37
|
+
"@quenty/cmdrservice": "13.64.0",
|
|
38
|
+
"@quenty/datastore": "13.59.0",
|
|
39
|
+
"@quenty/instanceutils": "13.38.0",
|
|
39
40
|
"@quenty/jestutils": "1.1.2",
|
|
40
41
|
"@quenty/loader": "10.11.3",
|
|
41
42
|
"@quenty/maid": "3.12.2",
|
|
42
43
|
"@quenty/nevermore-test-runner": "1.6.2",
|
|
43
|
-
"@quenty/observablecollection": "12.
|
|
44
|
-
"@quenty/playerbinder": "14.
|
|
45
|
-
"@quenty/playermock": "1.
|
|
46
|
-
"@quenty/promise": "10.
|
|
47
|
-
"@quenty/propertyvalue": "7.
|
|
48
|
-
"@quenty/remoting": "12.
|
|
49
|
-
"@quenty/rx": "13.
|
|
44
|
+
"@quenty/observablecollection": "12.54.0",
|
|
45
|
+
"@quenty/playerbinder": "14.52.0",
|
|
46
|
+
"@quenty/playermock": "1.11.0",
|
|
47
|
+
"@quenty/promise": "10.25.0",
|
|
48
|
+
"@quenty/propertyvalue": "7.38.0",
|
|
49
|
+
"@quenty/remoting": "12.46.0",
|
|
50
|
+
"@quenty/rx": "13.35.0",
|
|
50
51
|
"@quenty/servicebag": "11.21.2",
|
|
51
52
|
"@quenty/signal": "7.13.4",
|
|
52
53
|
"@quenty/table": "3.9.2",
|
|
53
|
-
"@quenty/teleportserviceutils": "10.
|
|
54
|
-
"@quenty/tie": "10.
|
|
55
|
-
"@quenty/time": "2.
|
|
56
|
-
"@quenty/valueobject": "13.
|
|
54
|
+
"@quenty/teleportserviceutils": "10.8.0",
|
|
55
|
+
"@quenty/tie": "10.52.0",
|
|
56
|
+
"@quenty/time": "2.7.0",
|
|
57
|
+
"@quenty/valueobject": "13.39.0",
|
|
57
58
|
"@quentystudios/jest-lua": "3.10.0-quenty.2"
|
|
58
59
|
},
|
|
59
60
|
"publishConfig": {
|
|
60
61
|
"access": "public"
|
|
61
62
|
},
|
|
62
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "6b26147a6b432f17270769342498b4f2f08f60b1"
|
|
63
64
|
}
|
|
@@ -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")
|
|
@@ -36,6 +36,7 @@ local function setup()
|
|
|
36
36
|
|
|
37
37
|
local serviceBag = ServiceBag.new()
|
|
38
38
|
serviceBag:GetService(require("TeleportDataService"))
|
|
39
|
+
local bindToCloseService: BindToCloseService.BindToCloseService = serviceBag:GetService(BindToCloseService) :: any
|
|
39
40
|
local playerDataStoreService: PlayerDataStoreService.PlayerDataStoreService =
|
|
40
41
|
serviceBag:GetService(PlayerDataStoreService) :: any
|
|
41
42
|
local sharedService: SaveSlotSharedDataStoreService.SaveSlotSharedDataStoreService =
|
|
@@ -52,10 +53,8 @@ local function setup()
|
|
|
52
53
|
local hasSaveSlots = assert(binder:Bind(fakePlayer), "Failed to bind HasSaveSlots")
|
|
53
54
|
hasSaveSlots.MaxSlotCount.Value = 5
|
|
54
55
|
|
|
55
|
-
-- A PlayerMock never fires the real Players.PlayerRemoving, and the store the spec loaded is only
|
|
56
|
-
-- destroyed by a removal, so shut it down the way Roblox does or its auto-save loop outlives this spec.
|
|
57
56
|
maid:GiveTask(function()
|
|
58
|
-
|
|
57
|
+
PromiseTestUtils.awaitFulfilled(bindToCloseService:PromiseClose())
|
|
59
58
|
fakePlayer:Destroy()
|
|
60
59
|
serviceBag:Destroy()
|
|
61
60
|
end)
|
|
@@ -73,167 +72,153 @@ local function setup()
|
|
|
73
72
|
return controller
|
|
74
73
|
end
|
|
75
74
|
|
|
76
|
-
local function runWithContext(body)
|
|
77
|
-
local context = setup()
|
|
78
|
-
local ok, err = pcall(body, context)
|
|
79
|
-
context:Destroy()
|
|
80
|
-
if not ok then
|
|
81
|
-
error(err, 0)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
local function awaitValueOf(promise)
|
|
86
|
-
if not PromiseTestUtils.awaitSettled(promise, 10) then
|
|
87
|
-
error("promise hung", 0)
|
|
88
|
-
end
|
|
89
|
-
local ok, value = promise:Yield()
|
|
90
|
-
if not ok then
|
|
91
|
-
error(`promise rejected: {tostring(value)}`, 0)
|
|
92
|
-
end
|
|
93
|
-
return value
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
local function awaitResolved(promise): boolean
|
|
97
|
-
if not PromiseTestUtils.awaitSettled(promise, 10) then
|
|
98
|
-
error("promise hung", 0)
|
|
99
|
-
end
|
|
100
|
-
return (promise:Yield())
|
|
101
|
-
end
|
|
102
|
-
|
|
103
75
|
local function createSelectAndWrite(hasSaveSlots, slotIndex: number): string
|
|
104
|
-
local slotId =
|
|
105
|
-
|
|
106
|
-
local store =
|
|
76
|
+
local slotId = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseCreateSlot(slotIndex))
|
|
77
|
+
PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseSelectSlot(slotId))
|
|
78
|
+
local store = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseActiveSlotStore())
|
|
107
79
|
store:Store("Coins", 7)
|
|
108
80
|
store:GetSubStore("World_2"):Store("Eggs", 3)
|
|
109
81
|
return slotId
|
|
110
82
|
end
|
|
111
83
|
|
|
112
84
|
local function activeSlotData(hasSaveSlots)
|
|
113
|
-
local store =
|
|
114
|
-
return
|
|
85
|
+
local store = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseActiveSlotStore())
|
|
86
|
+
return PromiseTestUtils.awaitFulfilled(store:LoadAll({}))
|
|
115
87
|
end
|
|
116
88
|
|
|
117
89
|
describe("HasSaveSlots export-to-code / load-from-code", function()
|
|
118
90
|
it("round-trips a slot through a code into a fresh ephemeral slot", function()
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
91
|
+
local context = setup()
|
|
92
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
93
|
+
local sourceSlotId = createSelectAndWrite(hasSaveSlots, 2)
|
|
122
94
|
|
|
123
|
-
|
|
124
|
-
|
|
95
|
+
local code = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSaveSlotToCode(sourceSlotId))
|
|
96
|
+
expect(type(code)).toEqual("string")
|
|
125
97
|
|
|
126
|
-
|
|
127
|
-
|
|
98
|
+
local ephemeralSlotId =
|
|
99
|
+
PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseImportEphemeralSaveSlotFromCode(code))
|
|
100
|
+
expect(hasSaveSlots.ActiveSlotId.Value).toEqual(ephemeralSlotId)
|
|
128
101
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
102
|
+
local data = activeSlotData(hasSaveSlots)
|
|
103
|
+
expect(data.Coins).toEqual(7)
|
|
104
|
+
expect(data.World_2.Eggs).toEqual(3)
|
|
132
105
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
106
|
+
local metadata = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseGetSlotMetadata(ephemeralSlotId))
|
|
107
|
+
expect(metadata.IsEphemeral).toEqual(true)
|
|
108
|
+
|
|
109
|
+
context:Destroy()
|
|
136
110
|
end)
|
|
137
111
|
|
|
138
112
|
it("defaults the exported slot to the active slot", function()
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
113
|
+
local context = setup()
|
|
114
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
115
|
+
createSelectAndWrite(hasSaveSlots, 2)
|
|
142
116
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
117
|
+
local code = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSaveSlotToCode())
|
|
118
|
+
PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseImportEphemeralSaveSlotFromCode(code))
|
|
119
|
+
expect(activeSlotData(hasSaveSlots).Coins).toEqual(7)
|
|
120
|
+
|
|
121
|
+
context:Destroy()
|
|
147
122
|
end)
|
|
148
123
|
|
|
149
124
|
it("refuses to export the main slot to a code", function()
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
125
|
+
local context = setup()
|
|
126
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
127
|
+
local mainSlotId =
|
|
128
|
+
PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseCreateSlot(SaveSlotConstants.DEFAULT_SLOT_INDEX))
|
|
129
|
+
PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseSelectSlot(mainSlotId))
|
|
154
130
|
|
|
155
|
-
|
|
156
|
-
|
|
131
|
+
PromiseTestUtils.awaitRejected(hasSaveSlots:PromiseExportSaveSlotToCode())
|
|
132
|
+
|
|
133
|
+
context:Destroy()
|
|
157
134
|
end)
|
|
158
135
|
|
|
159
136
|
it("rejects loading an unknown code", function()
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
137
|
+
local context = setup()
|
|
138
|
+
PromiseTestUtils.awaitRejected(context.hasSaveSlots:PromiseImportEphemeralSaveSlotFromCode("nope"))
|
|
139
|
+
|
|
140
|
+
context:Destroy()
|
|
163
141
|
end)
|
|
164
142
|
|
|
165
143
|
it("exports a slot as JSON that decodes back to its data", function()
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
144
|
+
local context = setup()
|
|
145
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
146
|
+
createSelectAndWrite(hasSaveSlots, 2)
|
|
169
147
|
|
|
170
|
-
|
|
171
|
-
|
|
148
|
+
local json = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSaveSlotToJson())
|
|
149
|
+
expect(type(json)).toEqual("string")
|
|
172
150
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
151
|
+
local decoded = HttpService:JSONDecode(json)
|
|
152
|
+
expect(decoded.data.Coins).toEqual(7)
|
|
153
|
+
expect(decoded.data.World_2.Eggs).toEqual(3)
|
|
154
|
+
|
|
155
|
+
context:Destroy()
|
|
177
156
|
end)
|
|
178
157
|
|
|
179
158
|
it("refuses to export the main slot as JSON", function()
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
159
|
+
local context = setup()
|
|
160
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
161
|
+
local mainSlotId =
|
|
162
|
+
PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseCreateSlot(SaveSlotConstants.DEFAULT_SLOT_INDEX))
|
|
163
|
+
PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseSelectSlot(mainSlotId))
|
|
184
164
|
|
|
185
|
-
|
|
186
|
-
|
|
165
|
+
PromiseTestUtils.awaitRejected(hasSaveSlots:PromiseExportSaveSlotToJson())
|
|
166
|
+
|
|
167
|
+
context:Destroy()
|
|
187
168
|
end)
|
|
188
169
|
|
|
189
170
|
it("generates a sanity-checkable default code (date-state-user-token)", function()
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
171
|
+
local context = setup()
|
|
172
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
173
|
+
createSelectAndWrite(hasSaveSlots, 2)
|
|
174
|
+
|
|
175
|
+
local code = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSaveSlotToCode())
|
|
176
|
+
-- Date-prefixed, lowercase alphanumeric + hyphens, safe as a datastore key.
|
|
177
|
+
expect(string.match(code, "^%d%d%d%d%d%d%d%d%-") ~= nil).toEqual(true)
|
|
178
|
+
expect(string.match(code, "^[a-z0-9%-]+$") ~= nil).toEqual(true)
|
|
179
|
+
expect(#code <= 50).toEqual(true)
|
|
180
|
+
|
|
181
|
+
context:Destroy()
|
|
200
182
|
end)
|
|
201
183
|
|
|
202
184
|
it("honors an injected code generator", function()
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
end)
|
|
208
|
-
local sourceSlotId = createSelectAndWrite(hasSaveSlots, 2)
|
|
209
|
-
|
|
210
|
-
local code = awaitValueOf(hasSaveSlots:PromiseExportSaveSlotToCode(sourceSlotId))
|
|
211
|
-
expect(code).toEqual("custom-2")
|
|
212
|
-
|
|
213
|
-
-- The custom code still round-trips through the shared store.
|
|
214
|
-
awaitValueOf(hasSaveSlots:PromiseImportEphemeralSaveSlotFromCode(code))
|
|
215
|
-
expect(activeSlotData(hasSaveSlots).Coins).toEqual(7)
|
|
185
|
+
local context = setup()
|
|
186
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
187
|
+
hasSaveSlots:SetCodeGenerator(function(generatorContext)
|
|
188
|
+
return `custom-{generatorContext.slotIndex}`
|
|
216
189
|
end)
|
|
190
|
+
local sourceSlotId = createSelectAndWrite(hasSaveSlots, 2)
|
|
191
|
+
|
|
192
|
+
local code = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSaveSlotToCode(sourceSlotId))
|
|
193
|
+
expect(code).toEqual("custom-2")
|
|
194
|
+
|
|
195
|
+
-- The custom code still round-trips through the shared store.
|
|
196
|
+
PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseImportEphemeralSaveSlotFromCode(code))
|
|
197
|
+
expect(activeSlotData(hasSaveSlots).Coins).toEqual(7)
|
|
198
|
+
|
|
199
|
+
context:Destroy()
|
|
217
200
|
end)
|
|
218
201
|
|
|
219
202
|
it("rejects export-to-code when the shared store write fails", function()
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
203
|
+
local context = setup()
|
|
204
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
205
|
+
createSelectAndWrite(hasSaveSlots, 2)
|
|
223
206
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
207
|
+
context.sharedMock:FailNextRequests(1)
|
|
208
|
+
PromiseTestUtils.awaitRejected(hasSaveSlots:PromiseExportSaveSlotToCode())
|
|
209
|
+
|
|
210
|
+
context:Destroy()
|
|
227
211
|
end)
|
|
228
212
|
|
|
229
213
|
it("rejects load-from-code when the shared store read fails", function()
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
214
|
+
local context = setup()
|
|
215
|
+
local hasSaveSlots = context.hasSaveSlots
|
|
216
|
+
createSelectAndWrite(hasSaveSlots, 2)
|
|
217
|
+
local code = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSaveSlotToCode())
|
|
234
218
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
219
|
+
context.sharedMock:FailNextRequests(1)
|
|
220
|
+
PromiseTestUtils.awaitRejected(hasSaveSlots:PromiseImportEphemeralSaveSlotFromCode(code))
|
|
221
|
+
|
|
222
|
+
context:Destroy()
|
|
238
223
|
end)
|
|
239
224
|
end)
|