@quenty/saveslot 2.7.0 → 2.8.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.
@@ -434,7 +434,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
434
434
  end)
435
435
 
436
436
  it("deleting the last-active slot clears the continue pointer", function()
437
- -- Repro for the `delete-save-slot *` bug: deleting the (deselected) active slot left
437
+ -- Repro for the `saveslot-delete *` bug: deleting the (deselected) active slot left
438
438
  -- LastActiveSlotId dangling, so the menu kept offering "Continue" for a slot that was gone.
439
439
  local context = setup()
440
440
 
@@ -766,7 +766,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
766
766
  end
767
767
  local _, slotId = createPromise:Yield()
768
768
 
769
- local tracker: any = context.hasSaveSlots
769
+ local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
770
770
  tracker:_getSlotStore(slotId):Store("Coins", 500)
771
771
 
772
772
  local duplicatePromise = context.hasSaveSlots:PromiseDuplicateSlot(slotId)
@@ -811,7 +811,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
811
811
  end
812
812
  local _, slotId = createPromise:Yield()
813
813
 
814
- local tracker: any = context.hasSaveSlots
814
+ local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
815
815
  tracker:_getSlotStore(slotId):Store("Coins", 750)
816
816
 
817
817
  local duplicatePromise = context.hasSaveSlots:PromiseDuplicateSlot(slotId)
@@ -882,7 +882,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
882
882
  end
883
883
  selectPromise:Yield()
884
884
 
885
- local tracker: any = context.hasSaveSlots
885
+ local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
886
886
  tracker:_getSlotStore(slotId):Store("Coins", 500)
887
887
 
888
888
  local resetPromise = context.hasSaveSlots:PromiseResetActiveSlot()
@@ -944,7 +944,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
944
944
  end
945
945
  selectPromise:Yield()
946
946
 
947
- local tracker: any = context.hasSaveSlots
947
+ local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
948
948
  tracker:_getSlotStore(slotId):Store("Coins", 750)
949
949
 
950
950
  local resetPromise = context.hasSaveSlots:PromiseResetActiveSlot()
@@ -1016,7 +1016,7 @@ describe("HasSaveSlots against a fake player (healthy datastore)", function()
1016
1016
  end
1017
1017
  local _, targetSlotId = targetPromise:Yield()
1018
1018
 
1019
- local tracker: any = context.hasSaveSlots
1019
+ local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
1020
1020
  tracker:_getSlotStore(targetSlotId):Store("Coins", 500)
1021
1021
 
1022
1022
  local resetPromise = context.hasSaveSlots:PromiseResetSlot(targetSlotId)
@@ -1215,7 +1215,7 @@ describe("HasSaveSlots playtime tracking", function()
1215
1215
 
1216
1216
  -- Rewind the live session's clock so a flush observes ~120s elapsed without waiting on it. The
1217
1217
  -- flush adds now - lastFlush, so the total is >= 120 (real time may nudge it a second higher).
1218
- local tracker: any = context.hasSaveSlots
1218
+ local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
1219
1219
  tracker._playSessionStart = os.time() - 120
1220
1220
  tracker._playSessionLastFlush = os.time() - 120
1221
1221
  tracker:_flushPlaytime()
@@ -1230,7 +1230,7 @@ describe("HasSaveSlots playtime tracking", function()
1230
1230
  it("does not accrue time before any slot is selected", function()
1231
1231
  local context = setup()
1232
1232
 
1233
- local tracker: any = context.hasSaveSlots
1233
+ local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
1234
1234
  tracker:_flushPlaytime()
1235
1235
 
1236
1236
  local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
@@ -1251,7 +1251,7 @@ describe("HasSaveSlots playtime tracking", function()
1251
1251
 
1252
1252
  local slotId = createAndSelect(context, 1)
1253
1253
 
1254
- local tracker: any = context.hasSaveSlots
1254
+ local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
1255
1255
  tracker._playSessionStart = os.time() - 120
1256
1256
  tracker._playSessionLastFlush = os.time() - 120
1257
1257
  tracker:_flushPlaytime()
@@ -1273,6 +1273,53 @@ describe("HasSaveSlots playtime tracking", function()
1273
1273
 
1274
1274
  context.destroy()
1275
1275
  end)
1276
+
1277
+ it("carries the source slot's playtime onto a duplicate, live session included", function()
1278
+ local context = setup()
1279
+
1280
+ local slotId = createAndSelect(context, 1)
1281
+
1282
+ -- Rewind the live session's clock so the duplicate observes ~120s that no flush has written yet.
1283
+ local tracker: any = context.hasSaveSlots:GetSlotsDataStore()
1284
+ tracker._playSessionStart = os.time() - 120
1285
+ tracker._playSessionLastFlush = os.time() - 120
1286
+
1287
+ local duplicatePromise = context.hasSaveSlots:PromiseDuplicateSlot(slotId)
1288
+ if not PromiseTestUtils.awaitSettled(duplicatePromise, 10) then
1289
+ expect("duplicate hung").toEqual("duplicate settled")
1290
+ context.destroy()
1291
+ return
1292
+ end
1293
+ local newSlotId = duplicatePromise:Wait()
1294
+
1295
+ local copied = getMetadata(context, newSlotId).TimePlayed
1296
+ expect(copied ~= nil and copied >= 120).toEqual(true)
1297
+
1298
+ context.destroy()
1299
+ end)
1300
+
1301
+ it("leaves a duplicate of a never-played slot without playtime", function()
1302
+ local context = setup()
1303
+
1304
+ local createPromise = context.hasSaveSlots:PromiseCreateSlot(1)
1305
+ if not PromiseTestUtils.awaitSettled(createPromise, 10) then
1306
+ expect("create hung").toEqual("create settled")
1307
+ context.destroy()
1308
+ return
1309
+ end
1310
+ local _, slotId = createPromise:Yield()
1311
+
1312
+ local duplicatePromise = context.hasSaveSlots:PromiseDuplicateSlot(slotId)
1313
+ if not PromiseTestUtils.awaitSettled(duplicatePromise, 10) then
1314
+ expect("duplicate hung").toEqual("duplicate settled")
1315
+ context.destroy()
1316
+ return
1317
+ end
1318
+
1319
+ expect(getMetadata(context, duplicatePromise:Wait()).TimePlayed).toBeNil()
1320
+
1321
+ context.destroy()
1322
+ end)
1276
1323
  end)
1277
1324
 
1278
1325
  describe("HasSaveSlots summary providers", function()