mirror of
https://github.com/block/buzz.git
synced 2026-11-28 04:01:45 +00:00
## Summary `CommunityListNotifier.addCommunity` has no callers in the app. Communities are saved through the auth flow (`authenticateWithCommunity`), so the method, including its same-relay credential replacement branch, is dead code that tests kept alive. This deletes the method and the test that covered it. Tests that used it only for setup now seed `CommunityStorage` before building the provider container, which is how the app loads communities at startup. ## Changes - Delete `addCommunity` and its now-unused import. - Delete the `addCommunity adds to list` test. - Trim the two credential replacement tests to the startup sweep and removal coverage they also held, and delete the storage helper only they used. The trimmed tests still seed a retired signer's channel-directory file at startup, and check that the saved-message scope is cleared while the active community still holds a removed account. - `community_entry_requirements_test` keeps only the authentication path; the community addition variant tested the deleted method. ### Added lines Ignoring whitespace the diff is +99/-282. The added lines are: - `await communityStorage.save(...)` in place of each removed `addCommunity(...)` setup call. - `createContainer()` and the initial list read, moved below the seeded communities so the notifier loads them. - Reindentation in `community_entry_requirements_test` after removing its outer loop. - In the startup sweep and saved-message purge tests: a channel-directory seed helper with its assertions, and a listener that checks the saved-message scope during removal. These keep coverage of the provider's per-signer directory sweep and the scope's retained-identity guard, which the replacement assertions used to provide. ## Validation - Full mobile test suite, analyze, format and file-size checks pass. - No user-visible change, so no screenshots; the deleted code had no production caller. --------- Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
65 lines
2.4 KiB
Dart
65 lines
2.4 KiB
Dart
import 'package:buzz/shared/hosted/hosted_environment.dart';
|
|
import 'package:buzz/shared/auth/auth_provider.dart';
|
|
import 'package:buzz/shared/community/community.dart';
|
|
import 'package:buzz/shared/community/community_provider.dart';
|
|
import 'package:buzz/shared/community/community_storage.dart';
|
|
import 'package:buzz/shared/hosted/builderlab_account.dart';
|
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:nostr/nostr.dart' as nostr;
|
|
|
|
import '../community/community_storage_test.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
for (final host in [
|
|
'team.communities.buzz.xyz',
|
|
'team.communities.public.builderlabstaging.xyz',
|
|
'team.communities.public.builderlabstaging.xyz.',
|
|
]) {
|
|
test(
|
|
'accountless entry follows domain policy through authentication: $host',
|
|
() async {
|
|
FlutterSecureStorage.setMockInitialValues({});
|
|
final storage = CommunityStorage(secure: FakeSecureStorage());
|
|
final container = ProviderContainer(
|
|
overrides: [communityStorageProvider.overrideWithValue(storage)],
|
|
);
|
|
addTearDown(container.dispose);
|
|
await container.read(authProvider.future);
|
|
await container.read(communityListProvider.future);
|
|
var transitions = 0;
|
|
container.read(communityTransitionProvider).register(() async {
|
|
transitions++;
|
|
});
|
|
final keys = nostr.Keys.generate();
|
|
final community = Community.create(
|
|
name: 'Hosted',
|
|
relayUrl: 'wss://$host',
|
|
pubkey: keys.public,
|
|
nsec: keys.nsec,
|
|
);
|
|
final pending = container
|
|
.read(authProvider.notifier)
|
|
.authenticateWithCommunity(community);
|
|
if (!HostedEnvironment.requiresAuth(host)) {
|
|
await pending;
|
|
expect((await storage.loadAll()).single.nsec, keys.nsec);
|
|
expect(await storage.loadActiveId(), community.id);
|
|
expect(transitions, 1);
|
|
return;
|
|
}
|
|
await expectLater(pending, throwsA(isA<AccountFailure>()));
|
|
expect(await storage.loadAll(), isEmpty);
|
|
expect(await storage.loadActiveId(), isNull);
|
|
expect(transitions, 0);
|
|
expect(
|
|
container.read(authProvider).value!.status,
|
|
AuthStatus.unauthenticated,
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|