-
Notifications
You must be signed in to change notification settings - Fork 221
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
message: Handle message deletion event. #766
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,6 +375,39 @@ void main() { | |
}); | ||
}); | ||
|
||
group('handleDeleteMessageEvent', () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will also need tests for the behavior of Those tests can go in Note one key thing those tests do is they call that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I see that in the 'MessageEvent, before fetch' test, but not the other 'MessageEvent' tests. Is that intended? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's there 🙂 Via this part:
See There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Quite possibly we should have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see! So the call is added in a listener. Then the post event invariant check of 'MessageEvent, not in narrow' seems to be missing because it isn't expecting a notification. Yeah it makes sense to add it to |
||
test('delete an unknown message', () async { | ||
final message1 = eg.streamMessage(); | ||
final message2 = eg.streamMessage(); | ||
await prepare(); | ||
await prepareMessages([message1]); | ||
await store.handleEvent(eg.deleteMessageEvent([message2])); | ||
checkNotNotified(); | ||
check(store).messages.values.single.id.equals(message1.id); | ||
}); | ||
|
||
test('delete messages', () async { | ||
final message1 = eg.streamMessage(); | ||
final message2 = eg.streamMessage(); | ||
await prepare(); | ||
await prepareMessages([message1, message2]); | ||
await store.handleEvent(eg.deleteMessageEvent([message1, message2])); | ||
checkNotifiedOnce(); | ||
check(store).messages.isEmpty(); | ||
}); | ||
|
||
test('delete an unknown message with a known message', () async { | ||
final message1 = eg.streamMessage(); | ||
final message2 = eg.streamMessage(); | ||
final message3 = eg.streamMessage(); | ||
await prepare(); | ||
await prepareMessages([message1, message2]); | ||
await store.handleEvent(eg.deleteMessageEvent([message2, message3])); | ||
checkNotifiedOnce(); | ||
check(store).messages.values.single.id.equals(message1.id); | ||
}); | ||
}); | ||
|
||
group('handleReactionEvent', () { | ||
test('add reaction', () async { | ||
final originalMessage = eg.streamMessage(reactions: []); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat solution. I think this algorithm works fine.
I might replace it with a direct loop if I find that convenient in the course of building the other features (like #421) that will reuse a version of this method, but I'll cross that bridge if I come to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Leaving it as-is for this revision.