[Tests] Bugfixes
This commit is contained in:
parent
cacf7cc530
commit
bb41db7f14
|
@ -110,14 +110,14 @@ class Client {
|
|||
}
|
||||
}
|
||||
|
||||
Map<String, List<String>> get directChats =>
|
||||
Map<String, dynamic> get directChats =>
|
||||
accountData["m.direct"] != null ? accountData["m.direct"].content : {};
|
||||
|
||||
/// Returns the (first) room ID from the store which is a private chat with the user [userId].
|
||||
/// Returns null if there is none.
|
||||
String getDirectChatFromUserId(String userId) =>
|
||||
accountData["m.direct"] != null &&
|
||||
accountData["m.direct"].content[userId] is List<String> &&
|
||||
accountData["m.direct"].content[userId] is List<dynamic> &&
|
||||
accountData["m.direct"].content[userId].length > 0
|
||||
? accountData["m.direct"].content[userId][0]
|
||||
: null;
|
||||
|
@ -266,7 +266,7 @@ class Client {
|
|||
if (contactDiscoveryRoom != null)
|
||||
contacts = await contactDiscoveryRoom.requestParticipants();
|
||||
else
|
||||
contacts = await store.loadContacts();
|
||||
contacts = await store?.loadContacts();
|
||||
return contacts;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ class Room {
|
|||
|
||||
/// The address in the format: #roomname:homeserver.org.
|
||||
String get canonicalAlias => states["m.room.canonical_alias"] != null
|
||||
? states["m.room.canonical_alias"].content["canonical_alias"]
|
||||
? states["m.room.canonical_alias"].content["alias"]
|
||||
: "";
|
||||
|
||||
/// If this room is a direct chat, this is the matrix ID of the user
|
||||
|
|
|
@ -105,6 +105,7 @@ class RoomList {
|
|||
mInvitedMemberCount: chatUpdate.summary?.mInvitedMemberCount,
|
||||
states: {},
|
||||
roomAccountData: {},
|
||||
client: client,
|
||||
);
|
||||
rooms.insert(position, newRoom);
|
||||
if (onInsert != null) onInsert(position);
|
||||
|
|
|
@ -62,9 +62,9 @@ void main() {
|
|||
matrix.connection.onError.stream.first;
|
||||
|
||||
final bool checkResp1 =
|
||||
await matrix.checkServer("https://fakeServer.wrongaddress");
|
||||
await matrix.checkServer("https://fakeserver.wrongaddress");
|
||||
final bool checkResp2 =
|
||||
await matrix.checkServer("https://fakeServer.notExisting");
|
||||
await matrix.checkServer("https://fakeserver.notexisting");
|
||||
|
||||
ErrorResponse checkError = await errorFuture;
|
||||
|
||||
|
@ -108,8 +108,17 @@ void main() {
|
|||
expect(firstSync, true);
|
||||
expect(sync["next_batch"] == matrix.prevBatch, true);
|
||||
|
||||
expect(matrix.accountData.length, 1);
|
||||
expect(matrix.presences.length, 0);
|
||||
expect(matrix.accountData.length, 2);
|
||||
expect(matrix.getDirectChatFromUserId("@bob:example.com"),
|
||||
"!abcdefgh:example.com");
|
||||
expect(matrix.directChats, matrix.accountData["m.direct"].content);
|
||||
expect(matrix.presences.length, 1);
|
||||
expect(matrix.roomList.rooms.length, 2);
|
||||
expect(matrix.roomList.rooms[1].canonicalAlias,
|
||||
"#famedlyContactDiscovery:${matrix.userID.split(":")[1]}");
|
||||
final List<User> contacts = await matrix.loadFamedlyContacts();
|
||||
expect(contacts.length, 1);
|
||||
expect(contacts[0].senderId, "@alice:example.com");
|
||||
});
|
||||
|
||||
test('Try to get ErrorResponse', () async {
|
||||
|
@ -212,16 +221,13 @@ void main() {
|
|||
|
||||
List<UserUpdate> eventUpdateList = await userUpdateListFuture;
|
||||
|
||||
expect(eventUpdateList.length, 3);
|
||||
expect(eventUpdateList.length, 4);
|
||||
|
||||
expect(eventUpdateList[0].eventType == "m.presence", true);
|
||||
expect(eventUpdateList[0].type == "presence", true);
|
||||
|
||||
expect(eventUpdateList[1].eventType == "org.example.custom.config", true);
|
||||
expect(eventUpdateList[1].type == "account_data", true);
|
||||
|
||||
expect(eventUpdateList[2].eventType == "m.new_device", true);
|
||||
expect(eventUpdateList[2].type == "to_device", true);
|
||||
});
|
||||
|
||||
testWidgets('should get created', create);
|
||||
|
|
|
@ -153,6 +153,24 @@ class FakeMatrixApi extends MockClient {
|
|||
{"type": "m.login.password"}
|
||||
]
|
||||
},
|
||||
"/client/r0/rooms/!726s6s6q:example.com/members": (var req) => {
|
||||
"chunk": [
|
||||
{
|
||||
"content": {
|
||||
"membership": "join",
|
||||
"avatar_url": "mxc://example.org/SEsfnsuifSDFSSEF",
|
||||
"displayname": "Alice Margatroid"
|
||||
},
|
||||
"type": "m.room.member",
|
||||
"event_id": "§143273582443PhrSn:example.org",
|
||||
"room_id": "!636q39766251:example.com",
|
||||
"sender": "@alice:example.org",
|
||||
"origin_server_ts": 1432735824653,
|
||||
"unsigned": {"age": 1234},
|
||||
"state_key": "@alice:example.org"
|
||||
}
|
||||
]
|
||||
},
|
||||
"/client/r0/rooms/!localpart:server.abc/members": (var req) => {
|
||||
"chunk": [
|
||||
{
|
||||
|
@ -333,7 +351,16 @@ class FakeMatrixApi extends MockClient {
|
|||
{
|
||||
"type": "org.example.custom.config",
|
||||
"content": {"custom_config_key": "custom_config_value"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"content": {
|
||||
"@bob:example.com": [
|
||||
"!abcdefgh:example.com",
|
||||
"!hgfedcba:example.com"
|
||||
]
|
||||
},
|
||||
"type": "m.direct"
|
||||
},
|
||||
]
|
||||
},
|
||||
"to_device": {
|
||||
|
@ -364,6 +391,17 @@ class FakeMatrixApi extends MockClient {
|
|||
"content": {"membership": "join"},
|
||||
"origin_server_ts": 1417731086795,
|
||||
"event_id": "66697273743031:example.com"
|
||||
},
|
||||
{
|
||||
"sender": "@alice:example.com",
|
||||
"type": "m.room.canonical_alias",
|
||||
"content": {
|
||||
"alias":
|
||||
"#famedlyContactDiscovery:fakeServer.notExisting"
|
||||
},
|
||||
"state_key": "",
|
||||
"origin_server_ts": 1417731086796,
|
||||
"event_id": "66697273743032:example.com"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue