Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Models: Tests for chat_message.dart #1425

Closed
palisadoes opened this issue Jan 25, 2023 · 14 comments · Fixed by #1443
Closed

Models: Tests for chat_message.dart #1425

palisadoes opened this issue Jan 25, 2023 · 14 comments · Fixed by #1443
Assignees
Labels
good first issue Good for newcomers test Testing application

Comments

@palisadoes
Copy link
Contributor

palisadoes commented Jan 25, 2023

We will need unittests done for all methods, classes and functions found in this file.

Any widgets referenced in this file must also have unittests done

lib/models/chats/chat_message.dart

PR Acceptance Criteria

@palisadoes palisadoes added the bug Something isn't working label Jan 25, 2023
@github-actions github-actions bot added parent The issue is generating more sub-issues unapproved Unapproved, needs to be triaged labels Jan 25, 2023
@palisadoes palisadoes added good first issue Good for newcomers test Testing application points 01 and removed bug Something isn't working parent The issue is generating more sub-issues labels Jan 25, 2023
@antonio-pedro99
Copy link

@palisadoes can I work on this?

@palisadoes
Copy link
Contributor Author

Please coordinate with the contributors referenced in the issue.

@noman2002 noman2002 removed the unapproved Unapproved, needs to be triaged label Jan 28, 2023
@antonio-pedro99
Copy link

@noman2002 it seems that ChatUser is not fully serializable.
check the output in here:
{_id: 1, sender: Instance of 'ChatUser', receiver: Instance of 'ChatUser', messageContent: Hello, how are you?}

when I call final json = chatMessage.toJson()

I do have the chat_user.g.dart and chat_message.g.dart files, but still it is not serializing properly. any suggestion?

@noman2002
Copy link
Member

@palisadoes Your thought?

@antonio-pedro99
Copy link

@noman2002 I do not have experience with object serialization yet, but allow me sometime to learn about it.
My thoughts now are that this should be printed
{_id: 1, sender: {...}, receiver: {...}, messageContent: Hello, how are you?}
as the objects are serializable.

@antonio-pedro99
Copy link

I just took a look at https://docs.flutter.dev/development/data-and-backend/json and found a possible solution.

@noman2002
Copy link
Member

@antonio-pedro99 I don't think there is any issue with serialisation. It shows like that because we are using models for that and that is being printed over there as Instance of 'chatuser'.

@noman2002
Copy link
Member

I just took a look at https://docs.flutter.dev/development/data-and-backend/json and found a possible solution.

Sure go ahead.

@antonio-pedro99
Copy link

@noman2002 fixed!

`@JsonSerializable(explicitToJson: true)
class ChatMessage {
ChatMessage(
this.id,
this.sender,
this.messageContent,
this.receiver,
);

factory ChatMessage.fromJson(Map<String, dynamic> json) =>
_$ChatMessageFromJson(json);
Map<String, dynamic> toJson() => _$ChatMessageToJson(this);

String? id;
ChatUser? sender;
ChatUser? receiver;
String? messageContent;
}`

@noman2002
Copy link
Member

Great. Have you written the test for it? If yes, check the code coverage, if it is 100%, Please create a PR for it.

@antonio-pedro99
Copy link

@noman2002 how can I check the coverage?

@shivanshu814
Copy link

I want to contribute to this repository and want to get involved in GSoC discussions.

@noman2002
Copy link
Member

You can join the slack channel @shivanshu814

@palisadoes
Copy link
Contributor Author

@noman2002 how can I check the coverage?

Please check the CONTRIBUTING.md file in the repository's root directory. If the instructions are not sufficient then let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers test Testing application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants