diff --git a/test/configuration_test.dart b/test/configuration_test.dart index 43da31903e..813b1520b5 100644 --- a/test/configuration_test.dart +++ b/test/configuration_test.dart @@ -20,6 +20,7 @@ import 'dart:io'; import 'dart:math'; import 'package:test/test.dart' hide test, throws; +import 'package:path/path.dart' as path_; import '../lib/realm.dart'; import 'test.dart'; @@ -414,4 +415,26 @@ Future main([List? args]) async { expect(config.path, 'my-custom-path.realm'); }); + + baasTest('Configuration.sessionlessSync', (appConfig) async { + final app = App(appConfig); + final user = await app.logIn(Credentials.emailPassword(testUsername, testPassword)); + + final dir = await Directory.systemTemp.createTemp(); + final path = path_.join(dir.path, 'test.realm'); + + final schema = [Task.schema]; + final flexibleSyncConfig = Configuration.flexibleSync(user, schema, path: path); + final realm = Realm(flexibleSyncConfig); + final oid = ObjectId(); + realm.subscriptions.update((mutableSubscriptions) { + mutableSubscriptions.add(realm.query(r'_id == $0', [oid])); + }); + realm.write(() => realm.add(Task(oid))); + realm.close(); + + final sessionlessSyncConfig = Configuration.sessionlessSync(schema, path: path); + final sessionlessRealm = Realm(sessionlessSyncConfig); + expect(sessionlessRealm.find(oid), isNotNull); + }); }