@@ -225,6 +225,54 @@ test("can use groupInfo enums", async () => {
225
225
await ctx . close ( ) ;
226
226
} ) ;
227
227
228
+ test ( "Setting data persists to DB" , async ( ) => {
229
+ const [ ctx , page ] = await initBrowser ( ) ;
230
+
231
+ const [ firstResult , expectedSecondResult , secondResult ] =
232
+ await page . evaluate ( async ( ) => {
233
+ const { CoreCrypto, Ciphersuite } = await import ( "./corecrypto.js" ) ;
234
+ const ciphersuite =
235
+ Ciphersuite . MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519 ;
236
+
237
+ const client2Config = {
238
+ databaseName : "test" ,
239
+ key : "test" ,
240
+ ciphersuites : [ ciphersuite ] ,
241
+ clientId : "test" ,
242
+ } ;
243
+
244
+ const cc = await CoreCrypto . init ( client2Config ) ;
245
+
246
+ const text = "my message processing checkpoint" ;
247
+ const encoder = new TextEncoder ( ) ;
248
+ const expectedSecondResult = encoder . encode ( text ) ;
249
+
250
+ let firstResult ;
251
+ await cc . transaction ( async ( ctx ) => {
252
+ firstResult = await ctx . getData ( ) ;
253
+ await ctx . setData ( expectedSecondResult ) ;
254
+ } ) ;
255
+
256
+ let secondResult ;
257
+ await cc . transaction ( async ( ctx ) => {
258
+ secondResult = await ctx . getData ( ) ;
259
+ } ) ;
260
+
261
+ // To be sure we're not obscuring the case in which firstResult would be null, as when it gets
262
+ // passed out of this closure, undefined becomes null.
263
+ firstResult = firstResult === null ? "null" : firstResult ;
264
+
265
+ return [ firstResult , expectedSecondResult , secondResult ] ;
266
+ } ) ;
267
+
268
+ // Undefined becomes null.
269
+ expect ( firstResult ) . toBe ( null ) ;
270
+ expect ( secondResult ) . toEqual ( expectedSecondResult ) ;
271
+
272
+ await page . close ( ) ;
273
+ await ctx . close ( ) ;
274
+ } ) ;
275
+
228
276
test ( "Using invalid context throws error" , async ( ) => {
229
277
const [ ctx , page ] = await initBrowser ( ) ;
230
278
0 commit comments