feat(social): local blocklist — hide blocked authors' offers, chats and incoming messages, with unblock management
This commit is contained in:
parent
5d25f65f76
commit
11b242edbf
13 changed files with 399 additions and 4 deletions
|
|
@ -184,6 +184,42 @@ void main() {
|
|||
await cubit.close();
|
||||
});
|
||||
|
||||
test('blocked authors disappear from the visible list and can resurface',
|
||||
() async {
|
||||
final transport = FakeOfferTransport();
|
||||
await transport.publish(OfferMapper.fromSharedLot(
|
||||
lotId: 'lot-good',
|
||||
authorPubkeyHex: 'ab' * 32,
|
||||
summary: 'Tomate rosa',
|
||||
sharing: OfferStatus.shared,
|
||||
areaGeohash: 'sp3e9',
|
||||
));
|
||||
await transport.publish(OfferMapper.fromSharedLot(
|
||||
lotId: 'lot-spam',
|
||||
authorPubkeyHex: 'cd' * 32,
|
||||
summary: 'Spam total',
|
||||
sharing: OfferStatus.shared,
|
||||
areaGeohash: 'sp3e9',
|
||||
));
|
||||
final cubit = OffersCubit(transport);
|
||||
await cubit.discover('sp3');
|
||||
await pumpEventQueue();
|
||||
expect(cubit.state.visibleOffers, hasLength(2));
|
||||
|
||||
cubit.setBlockedAuthors({'cd' * 32});
|
||||
expect(cubit.state.visibleOffers.map((o) => o.summary), ['Tomate rosa']);
|
||||
expect(cubit.state.offers, hasLength(2)); // discoveries kept underneath
|
||||
|
||||
// The blocklist survives a refresh (re-discovery resets results only).
|
||||
await cubit.discover('sp3');
|
||||
await pumpEventQueue();
|
||||
expect(cubit.state.visibleOffers.map((o) => o.summary), ['Tomate rosa']);
|
||||
|
||||
cubit.setBlockedAuthors(const {}); // unblock resurfaces
|
||||
expect(cubit.state.visibleOffers, hasLength(2));
|
||||
await cubit.close();
|
||||
});
|
||||
|
||||
test('the search filter survives a refresh (re-discovery)', () async {
|
||||
final transport = FakeOfferTransport();
|
||||
await transport.publish(OfferMapper.fromSharedLot(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue