fix tests

Signed-off-by: xsahil03x <xdsahil@gmail.com>
This commit is contained in:
xsahil03x
2023-04-03 20:27:14 +05:30
parent 99dd1dbaab
commit 36d3ca9258
12 changed files with 55 additions and 100 deletions
+7 -7
View File
@@ -65,29 +65,29 @@ scripts:
test:dart:
run: melos exec -c 1 --fail-fast -- "flutter test --coverage"
description: Run Dart tests for a specific package in this project.
select-package:
packageFilters:
flutter: false
dir-exists: test
dirExists: test
test:flutter:
run: melos exec -c 4 --fail-fast -- "flutter test --coverage"
description: Run Flutter tests for a specific package in this project.
select-package:
packageFilters:
flutter: true
dir-exists: test
dirExists: test
clean:flutter:
run: melos exec -c 4 --fail-fast -- "flutter clean"
description: Run Flutter clean for a specific package in this project.
select-package:
packageFilters:
flutter: true
coverage:ignore-file:
run: |
melos exec -c 5 --fail-fast -- "\$MELOS_ROOT_PATH/.github/workflows/scripts/remove-from-coverage.sh"
description: Removes all the ignored files from the coverage report.
select-package:
dir-exists: coverage
packageFilters:
dirExists: coverage
docs:
run: |
@@ -146,13 +146,13 @@ class Attachment extends Equatable {
/// Shortcut for file size.
///
/// {@macro fileSize}
@JsonKey(ignore: true)
@JsonKey(includeToJson: false, includeFromJson: false)
int? get fileSize => extraData['file_size'] as int?;
/// Shortcut for file mimeType.
///
/// {@macro mimeType}
@JsonKey(ignore: true)
@JsonKey(includeToJson: false, includeFromJson: false)
String? get mimeType => extraData['mime_type'] as String?;
/// Known top level fields.
@@ -62,19 +62,19 @@ class ChannelModel {
final String type;
/// The cid of this channel
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final String cid;
/// List of user permissions on this channel
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final List<String>? ownCapabilities;
/// The channel configuration data
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final ChannelConfig config;
/// The user that created this channel
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final User? createdBy;
/// True if this channel is frozen
@@ -82,23 +82,23 @@ class ChannelModel {
final bool frozen;
/// The date of the last message
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final DateTime? lastMessageAt;
/// The date of channel creation
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final DateTime createdAt;
/// The date of the last channel update
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final DateTime updatedAt;
/// The date of channel deletion
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final DateTime? deletedAt;
/// The count of this channel members
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final int memberCount;
/// The number of seconds in a cooldown
@@ -106,15 +106,15 @@ class ChannelModel {
final int cooldown;
/// True if the channel is disabled
@JsonKey(ignore: true)
@JsonKey(includeToJson: false, includeFromJson: false)
bool? get disabled => extraData['disabled'] as bool?;
/// True if the channel is hidden
@JsonKey(ignore: true)
@JsonKey(includeToJson: false, includeFromJson: false)
bool? get hidden => extraData['hidden'] as bool?;
/// The date of the last time channel got truncated
@JsonKey(ignore: true)
@JsonKey(includeToJson: false, includeFromJson: false)
DateTime? get truncatedAt {
final truncatedAt = extraData['truncated_at'] as String?;
if (truncatedAt == null) return null;
@@ -126,7 +126,7 @@ class ChannelModel {
final Map<String, Object?> extraData;
/// The team the channel belongs to
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final String? team;
/// Known top level fields.
@@ -42,17 +42,7 @@ Map<String, dynamic> _$ChannelModelToJson(ChannelModel instance) =>
<String, dynamic>{
'id': instance.id,
'type': instance.type,
'cid': readonly(instance.cid),
'own_capabilities': readonly(instance.ownCapabilities),
'config': readonly(instance.config),
'created_by': readonly(instance.createdBy),
'frozen': instance.frozen,
'last_message_at': readonly(instance.lastMessageAt),
'created_at': readonly(instance.createdAt),
'updated_at': readonly(instance.updatedAt),
'deleted_at': readonly(instance.deletedAt),
'member_count': readonly(instance.memberCount),
'cooldown': instance.cooldown,
'extra_data': instance.extraData,
'team': readonly(instance.team),
};
@@ -95,14 +95,11 @@ class Message extends Equatable {
final String? text;
/// The status of a sending message.
@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
final MessageSendingStatus status;
/// The message type.
@JsonKey(
includeIfNull: false,
toJson: Serializer.readOnly,
)
@JsonKey(includeToJson: false)
final String type;
/// The list of attachments, either provided by the user or generated from a
@@ -115,19 +112,19 @@ class Message extends Equatable {
final List<User> mentionedUsers;
/// A map describing the count of number of every reaction.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final Map<String, int>? reactionCounts;
/// A map describing the count of score of every reaction.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final Map<String, int>? reactionScores;
/// The latest reactions to the message created by any user.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final List<Reaction>? latestReactions;
/// The reactions added to the message by the current user.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final List<Reaction>? ownReactions;
/// The ID of the parent message, if the message is a thread reply.
@@ -143,11 +140,11 @@ class Message extends Equatable {
String? get quotedMessageId => _quotedMessageId ?? quotedMessage?.id;
/// Reserved field indicating the number of replies for this message.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final int? replyCount;
/// Reserved field indicating the thread participants for this message.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final List<User>? threadParticipants;
/// Check if this message needs to show in the channel.
@@ -157,34 +154,31 @@ class Message extends Equatable {
final bool silent;
/// If true the message is shadowed.
@JsonKey(
includeIfNull: false,
toJson: Serializer.readOnly,
)
@JsonKey(includeToJson: false)
final bool shadowed;
/// A used command name.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final String? command;
final DateTime? _createdAt;
/// Reserved field indicating when the message was deleted.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final DateTime? deletedAt;
/// Reserved field indicating when the message was created.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
DateTime get createdAt => _createdAt ?? DateTime.now();
final DateTime? _updatedAt;
/// Reserved field indicating when the message was updated last time.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
DateTime get updatedAt => _updatedAt ?? DateTime.now();
/// User who sent the message.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final User? user;
/// If true the message is pinned.
@@ -75,26 +75,13 @@ Map<String, dynamic> _$MessageToJson(Message instance) {
final val = <String, dynamic>{
'id': instance.id,
'text': instance.text,
'type': readonly(instance.type),
'attachments': instance.attachments.map((e) => e.toJson()).toList(),
'mentioned_users': User.toIds(instance.mentionedUsers),
'reaction_counts': readonly(instance.reactionCounts),
'reaction_scores': readonly(instance.reactionScores),
'latest_reactions': readonly(instance.latestReactions),
'own_reactions': readonly(instance.ownReactions),
'parent_id': instance.parentId,
'quoted_message': readonly(instance.quotedMessage),
'quoted_message_id': instance.quotedMessageId,
'reply_count': readonly(instance.replyCount),
'thread_participants': readonly(instance.threadParticipants),
'show_in_channel': instance.showInChannel,
'silent': instance.silent,
'shadowed': readonly(instance.shadowed),
'command': readonly(instance.command),
'deleted_at': readonly(instance.deletedAt),
'created_at': readonly(instance.createdAt),
'updated_at': readonly(instance.updatedAt),
'user': readonly(instance.user),
'pinned': instance.pinned,
'pinned_at': readonly(instance.pinnedAt),
'pin_expires': instance.pinExpires?.toIso8601String(),
@@ -33,18 +33,18 @@ class Reaction {
final String type;
/// The date of the reaction
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final DateTime createdAt;
/// The user that sent the reaction
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final User? user;
/// The score of the reaction (ie. number of reactions sent)
final int score;
/// The userId that sent the reaction
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final String? userId;
/// Reaction custom extraData
@@ -23,9 +23,6 @@ Reaction _$ReactionFromJson(Map<String, dynamic> json) => Reaction(
Map<String, dynamic> _$ReactionToJson(Reaction instance) => <String, dynamic>{
'message_id': instance.messageId,
'type': instance.type,
'created_at': readonly(instance.createdAt),
'user': readonly(instance.user),
'score': instance.score,
'user_id': readonly(instance.userId),
'extra_data': instance.extraData,
};
@@ -79,7 +79,7 @@ class User extends Equatable {
/// Shortcut for user name.
///
/// {@macro name}
@JsonKey(ignore: true)
@JsonKey(includeToJson: false, includeFromJson: false)
String get name {
if (extraData.containsKey('name') && extraData['name'] != null) {
final name = extraData['name']! as String;
@@ -91,48 +91,39 @@ class User extends Equatable {
/// Shortcut for user image.
///
/// {@macro image}
@JsonKey(ignore: true)
@JsonKey(includeToJson: false, includeFromJson: false)
String? get image => extraData['image'] as String?;
/// User role.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final String? role;
/// User teams
@JsonKey(
includeIfNull: false,
toJson: Serializer.readOnly,
)
@JsonKey(includeToJson: false)
final List<String> teams;
/// Date of user creation.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final DateTime createdAt;
/// Date of last user update.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final DateTime updatedAt;
/// Date of last user connection.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final DateTime? lastActive;
/// True if user is online.
@JsonKey(
includeIfNull: false,
toJson: Serializer.readOnly,
)
@JsonKey(includeToJson: false)
final bool online;
/// True if user is banned from the chat.
@JsonKey(
includeIfNull: false,
toJson: Serializer.readOnly,
)
@JsonKey(includeToJson: false)
final bool banned;
/// The date at which the ban will expire.
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeToJson: false)
final DateTime? banExpires;
/// The language this user prefers.
@@ -33,14 +33,6 @@ User _$UserFromJson(Map<String, dynamic> json) => User(
Map<String, dynamic> _$UserToJson(User instance) {
final val = <String, dynamic>{
'id': instance.id,
'role': readonly(instance.role),
'teams': readonly(instance.teams),
'created_at': readonly(instance.createdAt),
'updated_at': readonly(instance.updatedAt),
'last_active': readonly(instance.lastActive),
'online': readonly(instance.online),
'banned': readonly(instance.banned),
'ban_expires': readonly(instance.banExpires),
};
void writeNotNull(String key, dynamic value) {
@@ -129,7 +129,11 @@ void main() {
await client.get('path');
} on StreamChatNetworkError catch (e) {
expect(e, isA<StreamChatNetworkError>());
expect(e.message, "Dio can't establish new connection after closed.");
expect(
e.message,
"The connection errored: Dio can't establish a new connection"
' after it was closed.',
);
}
});
@@ -93,7 +93,7 @@ void main() {
const errorMessage = 'Error! Error! Error!';
final error = DioError(
type: DioErrorType.badResponse,
error: errorMessage,
message: errorMessage,
requestOptions: RequestOptions(path: ''),
);
when(() => mockChannel.initialized)