@quenty/saveslot 2.14.2 → 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 CHANGED
@@ -3,6 +3,16 @@
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
+
12
+ ## [2.14.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/saveslot@2.14.2...@quenty/saveslot@2.14.3) (2026-10-09)
13
+
14
+ **Note:** Version bump only for package @quenty/saveslot
15
+
6
16
  ## [2.14.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/saveslot@2.14.1...@quenty/saveslot@2.14.2) (2026-09-30)
7
17
 
8
18
  **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.14.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.43.1",
32
- "@quenty/attributeutils": "14.38.1",
33
- "@quenty/baseobject": "10.16.1",
34
- "@quenty/binder": "14.47.1",
35
- "@quenty/brio": "14.37.1",
36
- "@quenty/cmdrservice": "13.63.2",
37
- "@quenty/datastore": "13.58.2",
38
- "@quenty/instanceutils": "13.37.1",
39
- "@quenty/jestutils": "1.1.1",
40
- "@quenty/loader": "10.11.2",
41
- "@quenty/maid": "3.12.1",
42
- "@quenty/nevermore-test-runner": "1.6.1",
43
- "@quenty/observablecollection": "12.53.1",
44
- "@quenty/playerbinder": "14.51.1",
45
- "@quenty/playermock": "1.10.1",
46
- "@quenty/promise": "10.24.1",
47
- "@quenty/propertyvalue": "7.37.1",
48
- "@quenty/remoting": "12.45.1",
49
- "@quenty/rx": "13.34.1",
50
- "@quenty/servicebag": "11.21.1",
51
- "@quenty/signal": "7.13.3",
31
+ "@quenty/adorneedata": "7.44.0",
32
+ "@quenty/attributeutils": "14.39.0",
33
+ "@quenty/baseobject": "10.16.2",
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",
40
+ "@quenty/jestutils": "1.1.2",
41
+ "@quenty/loader": "10.11.3",
42
+ "@quenty/maid": "3.12.2",
43
+ "@quenty/nevermore-test-runner": "1.6.2",
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",
51
+ "@quenty/servicebag": "11.21.2",
52
+ "@quenty/signal": "7.13.4",
52
53
  "@quenty/table": "3.9.2",
53
- "@quenty/teleportserviceutils": "10.7.1",
54
- "@quenty/tie": "10.51.2",
55
- "@quenty/time": "2.6.2",
56
- "@quenty/valueobject": "13.38.1",
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": "de6ba8b56a04f9f1e423c94a88095653a0207817"
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
- DataStoreTestUtils.awaitServiceShutdown(playerDataStoreService)
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 = awaitValueOf(hasSaveSlots:PromiseCreateSlot(slotIndex))
105
- awaitValueOf(hasSaveSlots:PromiseSelectSlot(slotId))
106
- local store = awaitValueOf(hasSaveSlots:PromiseActiveSlotStore())
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 = awaitValueOf(hasSaveSlots:PromiseActiveSlotStore())
114
- return awaitValueOf(store:LoadAll({}))
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
- runWithContext(function(context)
120
- local hasSaveSlots = context.hasSaveSlots
121
- local sourceSlotId = createSelectAndWrite(hasSaveSlots, 2)
91
+ local context = setup()
92
+ local hasSaveSlots = context.hasSaveSlots
93
+ local sourceSlotId = createSelectAndWrite(hasSaveSlots, 2)
122
94
 
123
- local code = awaitValueOf(hasSaveSlots:PromiseExportSaveSlotToCode(sourceSlotId))
124
- expect(type(code)).toEqual("string")
95
+ local code = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSaveSlotToCode(sourceSlotId))
96
+ expect(type(code)).toEqual("string")
125
97
 
126
- local ephemeralSlotId = awaitValueOf(hasSaveSlots:PromiseImportEphemeralSaveSlotFromCode(code))
127
- expect(hasSaveSlots.ActiveSlotId.Value).toEqual(ephemeralSlotId)
98
+ local ephemeralSlotId =
99
+ PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseImportEphemeralSaveSlotFromCode(code))
100
+ expect(hasSaveSlots.ActiveSlotId.Value).toEqual(ephemeralSlotId)
128
101
 
129
- local data = activeSlotData(hasSaveSlots)
130
- expect(data.Coins).toEqual(7)
131
- expect(data.World_2.Eggs).toEqual(3)
102
+ local data = activeSlotData(hasSaveSlots)
103
+ expect(data.Coins).toEqual(7)
104
+ expect(data.World_2.Eggs).toEqual(3)
132
105
 
133
- local metadata = awaitValueOf(hasSaveSlots:PromiseGetSlotMetadata(ephemeralSlotId))
134
- expect(metadata.IsEphemeral).toEqual(true)
135
- end)
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
- runWithContext(function(context)
140
- local hasSaveSlots = context.hasSaveSlots
141
- createSelectAndWrite(hasSaveSlots, 2)
113
+ local context = setup()
114
+ local hasSaveSlots = context.hasSaveSlots
115
+ createSelectAndWrite(hasSaveSlots, 2)
142
116
 
143
- local code = awaitValueOf(hasSaveSlots:PromiseExportSaveSlotToCode())
144
- awaitValueOf(hasSaveSlots:PromiseImportEphemeralSaveSlotFromCode(code))
145
- expect(activeSlotData(hasSaveSlots).Coins).toEqual(7)
146
- end)
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
- runWithContext(function(context)
151
- local hasSaveSlots = context.hasSaveSlots
152
- local mainSlotId = awaitValueOf(hasSaveSlots:PromiseCreateSlot(SaveSlotConstants.DEFAULT_SLOT_INDEX))
153
- awaitValueOf(hasSaveSlots:PromiseSelectSlot(mainSlotId))
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
- expect(awaitResolved(hasSaveSlots:PromiseExportSaveSlotToCode())).toEqual(false)
156
- end)
131
+ PromiseTestUtils.awaitRejected(hasSaveSlots:PromiseExportSaveSlotToCode())
132
+
133
+ context:Destroy()
157
134
  end)
158
135
 
159
136
  it("rejects loading an unknown code", function()
160
- runWithContext(function(context)
161
- expect(awaitResolved(context.hasSaveSlots:PromiseImportEphemeralSaveSlotFromCode("nope"))).toEqual(false)
162
- end)
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
- runWithContext(function(context)
167
- local hasSaveSlots = context.hasSaveSlots
168
- createSelectAndWrite(hasSaveSlots, 2)
144
+ local context = setup()
145
+ local hasSaveSlots = context.hasSaveSlots
146
+ createSelectAndWrite(hasSaveSlots, 2)
169
147
 
170
- local json = awaitValueOf(hasSaveSlots:PromiseExportSaveSlotToJson())
171
- expect(type(json)).toEqual("string")
148
+ local json = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSaveSlotToJson())
149
+ expect(type(json)).toEqual("string")
172
150
 
173
- local decoded = HttpService:JSONDecode(json)
174
- expect(decoded.data.Coins).toEqual(7)
175
- expect(decoded.data.World_2.Eggs).toEqual(3)
176
- end)
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
- runWithContext(function(context)
181
- local hasSaveSlots = context.hasSaveSlots
182
- local mainSlotId = awaitValueOf(hasSaveSlots:PromiseCreateSlot(SaveSlotConstants.DEFAULT_SLOT_INDEX))
183
- awaitValueOf(hasSaveSlots:PromiseSelectSlot(mainSlotId))
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
- expect(awaitResolved(hasSaveSlots:PromiseExportSaveSlotToJson())).toEqual(false)
186
- end)
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
- runWithContext(function(context)
191
- local hasSaveSlots = context.hasSaveSlots
192
- createSelectAndWrite(hasSaveSlots, 2)
193
-
194
- local code = awaitValueOf(hasSaveSlots:PromiseExportSaveSlotToCode())
195
- -- Date-prefixed, lowercase alphanumeric + hyphens, safe as a datastore key.
196
- expect(string.match(code, "^%d%d%d%d%d%d%d%d%-") ~= nil).toEqual(true)
197
- expect(string.match(code, "^[a-z0-9%-]+$") ~= nil).toEqual(true)
198
- expect(#code <= 50).toEqual(true)
199
- end)
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
- runWithContext(function(context)
204
- local hasSaveSlots = context.hasSaveSlots
205
- hasSaveSlots:SetCodeGenerator(function(generatorContext)
206
- return `custom-{generatorContext.slotIndex}`
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
- runWithContext(function(context)
221
- local hasSaveSlots = context.hasSaveSlots
222
- createSelectAndWrite(hasSaveSlots, 2)
203
+ local context = setup()
204
+ local hasSaveSlots = context.hasSaveSlots
205
+ createSelectAndWrite(hasSaveSlots, 2)
223
206
 
224
- context.sharedMock:FailNextRequests(1)
225
- expect(awaitResolved(hasSaveSlots:PromiseExportSaveSlotToCode())).toEqual(false)
226
- end)
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
- runWithContext(function(context)
231
- local hasSaveSlots = context.hasSaveSlots
232
- createSelectAndWrite(hasSaveSlots, 2)
233
- local code = awaitValueOf(hasSaveSlots:PromiseExportSaveSlotToCode())
214
+ local context = setup()
215
+ local hasSaveSlots = context.hasSaveSlots
216
+ createSelectAndWrite(hasSaveSlots, 2)
217
+ local code = PromiseTestUtils.awaitFulfilled(hasSaveSlots:PromiseExportSaveSlotToCode())
234
218
 
235
- context.sharedMock:FailNextRequests(1)
236
- expect(awaitResolved(hasSaveSlots:PromiseImportEphemeralSaveSlotFromCode(code))).toEqual(false)
237
- end)
219
+ context.sharedMock:FailNextRequests(1)
220
+ PromiseTestUtils.awaitRejected(hasSaveSlots:PromiseImportEphemeralSaveSlotFromCode(code))
221
+
222
+ context:Destroy()
238
223
  end)
239
224
  end)