Files
tatuchat/test/utils/test_client.dart
Welton Moura 0037b0b9cf
Some checks failed
Main Deploy Workflow / deploy_web (push) Has been cancelled
Main Deploy Workflow / deploy_playstore_internal (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
Initial commit
2026-09-11 15:59:56 -03:00

49 lines
1.4 KiB
Dart

// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
//
// SPDX-License-Identifier: AGPL-3.0-or-later
// ignore_for_file: depend_on_referenced_packages
import 'package:matrix/encryption/utils/key_verification.dart';
import 'package:matrix/matrix.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
Future<Client> prepareTestClient({
bool loggedIn = false,
Uri? homeserver,
String id = 'FluffyChat Widget Test',
}) async {
homeserver ??= Uri.parse('https://fakeserver.notexisting');
final client = Client(
'FluffyChat Widget Tests',
httpClient: FakeMatrixApi()
..api['GET']!['/.well-known/matrix/client'] = (req) => {},
verificationMethods: {
KeyVerificationMethod.numbers,
KeyVerificationMethod.emoji,
},
importantStateEvents: <String>{
'im.ponies.room_emotes', // we want emotes to work properly
},
database: await MatrixSdkDatabase.init(
'test',
database: await databaseFactoryFfi.openDatabase(':memory:'),
sqfliteFactory: databaseFactoryFfi,
),
supportedLoginTypes: {
AuthenticationTypes.password,
AuthenticationTypes.sso,
},
);
await client.checkHomeserver(homeserver);
if (loggedIn) {
await client.login(
LoginType.mLoginToken,
identifier: AuthenticationUserIdentifier(user: '@alice:example.invalid'),
password: '1234',
);
}
return client;
}