[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 : {};
|
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 the (first) room ID from the store which is a private chat with the user [userId].
|
||||||
/// Returns null if there is none.
|
/// Returns null if there is none.
|
||||||
String getDirectChatFromUserId(String userId) =>
|
String getDirectChatFromUserId(String userId) =>
|
||||||
accountData["m.direct"] != null &&
|
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].length > 0
|
||||||
? accountData["m.direct"].content[userId][0]
|
? accountData["m.direct"].content[userId][0]
|
||||||
: null;
|
: null;
|
||||||
|
|
@ -266,7 +266,7 @@ class Client {
|
||||||
if (contactDiscoveryRoom != null)
|
if (contactDiscoveryRoom != null)
|
||||||
contacts = await contactDiscoveryRoom.requestParticipants();
|
contacts = await contactDiscoveryRoom.requestParticipants();
|
||||||
else
|
else
|
||||||
contacts = await store.loadContacts();
|
contacts = await store?.loadContacts();
|
||||||
return contacts;
|
return contacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ class Room {
|
||||||
|
|
||||||
/// The address in the format: #roomname:homeserver.org.
|
/// The address in the format: #roomname:homeserver.org.
|
||||||
String get canonicalAlias => states["m.room.canonical_alias"] != null
|
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
|
/// 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,
|
mInvitedMemberCount: chatUpdate.summary?.mInvitedMemberCount,
|
||||||
states: {},
|
states: {},
|
||||||
roomAccountData: {},
|
roomAccountData: {},
|
||||||
|
client: client,
|
||||||
);
|
);
|
||||||
rooms.insert(position, newRoom);
|
rooms.insert(position, newRoom);
|
||||||
if (onInsert != null) onInsert(position);
|
if (onInsert != null) onInsert(position);
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,9 @@ void main() {
|
||||||
matrix.connection.onError.stream.first;
|
matrix.connection.onError.stream.first;
|
||||||
|
|
||||||
final bool checkResp1 =
|
final bool checkResp1 =
|
||||||
await matrix.checkServer("https://fakeServer.wrongaddress");
|
await matrix.checkServer("https://fakeserver.wrongaddress");
|
||||||
final bool checkResp2 =
|
final bool checkResp2 =
|
||||||
await matrix.checkServer("https://fakeServer.notExisting");
|
await matrix.checkServer("https://fakeserver.notexisting");
|
||||||
|
|
||||||
ErrorResponse checkError = await errorFuture;
|
ErrorResponse checkError = await errorFuture;
|
||||||
|
|
||||||
|
|
@ -108,8 +108,17 @@ void main() {
|
||||||
expect(firstSync, true);
|
expect(firstSync, true);
|
||||||
expect(sync["next_batch"] == matrix.prevBatch, true);
|
expect(sync["next_batch"] == matrix.prevBatch, true);
|
||||||
|
|
||||||
expect(matrix.accountData.length, 1);
|
expect(matrix.accountData.length, 2);
|
||||||
expect(matrix.presences.length, 0);
|
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 {
|
test('Try to get ErrorResponse', () async {
|
||||||
|
|
@ -212,16 +221,13 @@ void main() {
|
||||||
|
|
||||||
List<UserUpdate> eventUpdateList = await userUpdateListFuture;
|
List<UserUpdate> eventUpdateList = await userUpdateListFuture;
|
||||||
|
|
||||||
expect(eventUpdateList.length, 3);
|
expect(eventUpdateList.length, 4);
|
||||||
|
|
||||||
expect(eventUpdateList[0].eventType == "m.presence", true);
|
expect(eventUpdateList[0].eventType == "m.presence", true);
|
||||||
expect(eventUpdateList[0].type == "presence", true);
|
expect(eventUpdateList[0].type == "presence", true);
|
||||||
|
|
||||||
expect(eventUpdateList[1].eventType == "org.example.custom.config", true);
|
expect(eventUpdateList[1].eventType == "org.example.custom.config", true);
|
||||||
expect(eventUpdateList[1].type == "account_data", 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);
|
testWidgets('should get created', create);
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,24 @@ class FakeMatrixApi extends MockClient {
|
||||||
{"type": "m.login.password"}
|
{"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) => {
|
"/client/r0/rooms/!localpart:server.abc/members": (var req) => {
|
||||||
"chunk": [
|
"chunk": [
|
||||||
{
|
{
|
||||||
|
|
@ -333,7 +351,16 @@ class FakeMatrixApi extends MockClient {
|
||||||
{
|
{
|
||||||
"type": "org.example.custom.config",
|
"type": "org.example.custom.config",
|
||||||
"content": {"custom_config_key": "custom_config_value"}
|
"content": {"custom_config_key": "custom_config_value"}
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"content": {
|
||||||
|
"@bob:example.com": [
|
||||||
|
"!abcdefgh:example.com",
|
||||||
|
"!hgfedcba:example.com"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"type": "m.direct"
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"to_device": {
|
"to_device": {
|
||||||
|
|
@ -364,6 +391,17 @@ class FakeMatrixApi extends MockClient {
|
||||||
"content": {"membership": "join"},
|
"content": {"membership": "join"},
|
||||||
"origin_server_ts": 1417731086795,
|
"origin_server_ts": 1417731086795,
|
||||||
"event_id": "66697273743031:example.com"
|
"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 New Issue