Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 40 additions & 40 deletions mobile/test/features/channels/channel_messages_provider_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,46 @@ void main() {
);
});

test('reconnect hydration cannot retain a rolled-back local row', () async {
final relaySession = _RecordingRelaySessionNotifier(
queryResults: [
[_event(id: 'history', createdAt: 10), _bounds()],
[_event(id: 'history', createdAt: 10), _bounds()],
],
);
final container = _buildContainer(relaySession);
addTearDown(container.dispose);

container.read(channelMessagesProvider(_channelId));
await relaySession.subscribed;
await _pumpEventQueue();
final notifier = container.read(
channelMessagesProvider(_channelId).notifier,
);
notifier.addLocalMessage(_event(id: 'local', createdAt: 20));

relaySession.setConnected(false);
await _pumpEventQueue();
relaySession.setConnected(true);
await _pumpEventQueue();
expect(
container
.read(channelMessagesProvider(_channelId))
.value
?.map((event) => event.id),
['history', 'local'],
);

notifier.removeLocalMessage('local');
expect(
container
.read(channelMessagesProvider(_channelId))
.value
?.map((event) => event.id),
['history'],
);
});

test('live non-broadcast reply updates its parent thread summary', () async {
final relaySession = _RecordingRelaySessionNotifier(
queryResults: [
Expand Down Expand Up @@ -316,46 +356,6 @@ void main() {
},
);

test('reconnect hydration cannot retain a rolled-back local row', () async {
final relaySession = _RecordingRelaySessionNotifier(
queryResults: [
[_event(id: 'history', createdAt: 10), _bounds()],
[_event(id: 'history', createdAt: 10), _bounds()],
],
);
final container = _buildContainer(relaySession);
addTearDown(container.dispose);

container.read(channelMessagesProvider(_channelId));
await relaySession.subscribed;
await _pumpEventQueue();
final notifier = container.read(
channelMessagesProvider(_channelId).notifier,
);
notifier.addLocalMessage(_event(id: 'local', createdAt: 20));

relaySession.setConnected(false);
await _pumpEventQueue();
relaySession.setConnected(true);
await _pumpEventQueue();
expect(
container
.read(channelMessagesProvider(_channelId))
.value
?.map((event) => event.id),
['history', 'local'],
);

notifier.removeLocalMessage('local');
expect(
container
.read(channelMessagesProvider(_channelId))
.value
?.map((event) => event.id),
['history'],
);
});

test(
'thread replies are inserted, deduped, and rolled back locally',
() async {
Expand Down