mirror of
https://github.com/block/buzz.git
synced 2026-10-28 21:11:48 +00:00
## Summary - add foreground mobile Huddles on Android and iOS with native Opus capture/playback, mute, speaker routing, participants, lifecycle, and minimized drawer UI - keep mobile Huddle cards and roster state live, including ended rooms, relay-resolved profiles, and agents - broadcast desktop agent TTS through the existing Huddle audio protocol ## Scope Foreground human-to-human voice MVP only. Agent setup/transcripts, background calling, recording, and advanced device controls remain out of scope. ## Validation - `just mobile-check` - `just mobile-test` — 1,500 passed - `just desktop-check` and `just desktop-test` — 4,957 passed - desktop typecheck, strict Clippy, and Tauri tests — 2,445 passed, 15 ignored - mobile worktree identity contract checks - physical Pixel/iPhone behavior reviewed during development --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: Kenny Lopez <klopez4212@gmail.com> Signed-off-by: Princess Donut <b238ea756dee4d98afa5883fc7f1de61eeabe65bf700e3a5a5a80db5e42e2c2b@buzz.block.builderlab.xyz> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Carl <3c4caeafb646d23867f1c4832e68211d77e2561946171625f75c3ce1a3f2670f@buzz.block.builderlab.xyz> Co-authored-by: Princess Donut <b238ea756dee4d98afa5883fc7f1de61eeabe65bf700e3a5a5a80db5e42e2c2b@buzz.block.builderlab.xyz> Co-authored-by: leader <71e9f2c44a6932b6772caaaccda1911d010463c3e2c6c40410b8329956046801@buzz.block.builderlab.xyz> Co-authored-by: Tom Brow <tomb@block.xyz> Co-authored-by: Mongo <9cfd347903944d5b85aa6c93d2ab67381b978a92a31914bca69998968752a1d7@buzz.block.builderlab.xyz>
179 lines
6.2 KiB
Dart
179 lines
6.2 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:nostr/nostr.dart' as nostr;
|
|
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 '../community/community_storage_test.dart';
|
|
|
|
void main() {
|
|
test('waits for transition teardown before replacing credentials', () async {
|
|
final storage = CommunityStorage(secure: FakeSecureStorage());
|
|
final active = Community.create(
|
|
name: 'Active',
|
|
relayUrl: 'https://active.example',
|
|
nsec: nostr.Keys.generate().nsec,
|
|
);
|
|
final replacement = Community.create(
|
|
name: 'Replacement',
|
|
relayUrl: 'https://replacement.example',
|
|
nsec: nostr.Keys.generate().nsec,
|
|
);
|
|
await storage.save(active);
|
|
await storage.saveActiveId(active.id);
|
|
final container = ProviderContainer(
|
|
overrides: [communityStorageProvider.overrideWithValue(storage)],
|
|
);
|
|
addTearDown(container.dispose);
|
|
await container.read(authProvider.future);
|
|
final teardown = Completer<void>();
|
|
container.read(communityTransitionProvider).register(() => teardown.future);
|
|
|
|
final authenticating = container
|
|
.read(authProvider.notifier)
|
|
.authenticateWithCommunity(replacement);
|
|
await Future<void>.delayed(Duration.zero);
|
|
|
|
expect(await storage.loadActiveId(), active.id);
|
|
expect(
|
|
(await storage.loadAll()).map((community) => community.id),
|
|
isNot(contains(replacement.id)),
|
|
);
|
|
teardown.complete();
|
|
await authenticating;
|
|
expect(await storage.loadActiveId(), replacement.id);
|
|
expect(
|
|
(await storage.loadAll()).map((community) => community.id),
|
|
contains(replacement.id),
|
|
);
|
|
});
|
|
|
|
test('waits for transition teardown before removing credentials', () async {
|
|
final storage = CommunityStorage(secure: FakeSecureStorage());
|
|
final community = Community.create(
|
|
name: 'Active',
|
|
relayUrl: 'https://relay.example',
|
|
nsec: nostr.Keys.generate().nsec,
|
|
);
|
|
await storage.save(community);
|
|
await storage.saveActiveId(community.id);
|
|
final container = ProviderContainer(
|
|
overrides: [communityStorageProvider.overrideWithValue(storage)],
|
|
);
|
|
addTearDown(container.dispose);
|
|
await container.read(authProvider.future);
|
|
final teardown = Completer<void>();
|
|
container.read(communityTransitionProvider).register(() => teardown.future);
|
|
|
|
final signingOut = container.read(authProvider.notifier).signOut();
|
|
await Future<void>.delayed(Duration.zero);
|
|
|
|
expect(await storage.loadActiveId(), community.id);
|
|
final saved = await storage.loadAll();
|
|
expect(saved, hasLength(1));
|
|
expect(saved.single.id, community.id);
|
|
teardown.complete();
|
|
await signingOut;
|
|
expect(await storage.loadActiveId(), isNull);
|
|
expect(await storage.loadAll(), isEmpty);
|
|
});
|
|
|
|
test('serializes overlapping switch and sign-out mutations', () async {
|
|
final storage = CommunityStorage(secure: FakeSecureStorage());
|
|
final active = Community.create(
|
|
name: 'Active',
|
|
relayUrl: 'https://active.example',
|
|
nsec: nostr.Keys.generate().nsec,
|
|
);
|
|
final replacement = Community.create(
|
|
name: 'Replacement',
|
|
relayUrl: 'https://replacement.example',
|
|
nsec: nostr.Keys.generate().nsec,
|
|
);
|
|
await storage.save(active);
|
|
await storage.save(replacement);
|
|
await storage.saveActiveId(active.id);
|
|
final container = ProviderContainer(
|
|
overrides: [communityStorageProvider.overrideWithValue(storage)],
|
|
);
|
|
addTearDown(container.dispose);
|
|
await container.read(authProvider.future);
|
|
await container.read(communityListProvider.future);
|
|
final teardown = Completer<void>();
|
|
container.read(communityTransitionProvider).register(() => teardown.future);
|
|
|
|
final switching = container
|
|
.read(communityListProvider.notifier)
|
|
.switchCommunity(replacement.id);
|
|
final signingOut = container.read(authProvider.notifier).signOut();
|
|
await Future<void>.delayed(Duration.zero);
|
|
|
|
expect(await storage.loadActiveId(), active.id);
|
|
teardown.complete();
|
|
await Future.wait([switching, signingOut]);
|
|
|
|
expect(await storage.loadActiveId(), active.id);
|
|
expect(
|
|
(await storage.loadAll()).map((community) => community.id),
|
|
unorderedEquals([active.id]),
|
|
);
|
|
final auth = await container.read(authProvider.future);
|
|
expect(auth.status, AuthStatus.authenticated);
|
|
expect(auth.community?.id, active.id);
|
|
});
|
|
|
|
test(
|
|
'removes an invalid saved community instead of authenticating',
|
|
() async {
|
|
final storage = CommunityStorage(secure: FakeSecureStorage());
|
|
final invalid = Community.create(
|
|
name: 'Invalid',
|
|
relayUrl: 'https://relay.example',
|
|
nsec: 'not-an-nsec',
|
|
);
|
|
await storage.save(invalid);
|
|
await storage.saveActiveId(invalid.id);
|
|
final container = ProviderContainer(
|
|
overrides: [communityStorageProvider.overrideWithValue(storage)],
|
|
);
|
|
addTearDown(container.dispose);
|
|
|
|
final auth = await container.read(authProvider.future);
|
|
|
|
expect(auth.status, AuthStatus.unauthenticated);
|
|
expect(await storage.loadAll(), isEmpty);
|
|
expect(await storage.loadActiveId(), isNull);
|
|
},
|
|
);
|
|
|
|
test('falls through to the next valid saved community', () async {
|
|
final storage = CommunityStorage(secure: FakeSecureStorage());
|
|
final invalid = Community.create(
|
|
name: 'Invalid',
|
|
relayUrl: 'https://invalid.example',
|
|
);
|
|
final valid = Community.create(
|
|
name: 'Valid',
|
|
relayUrl: 'https://valid.example',
|
|
nsec: nostr.Keys.generate().nsec,
|
|
);
|
|
await storage.save(invalid);
|
|
await storage.save(valid);
|
|
await storage.saveActiveId(invalid.id);
|
|
final container = ProviderContainer(
|
|
overrides: [communityStorageProvider.overrideWithValue(storage)],
|
|
);
|
|
addTearDown(container.dispose);
|
|
|
|
final auth = await container.read(authProvider.future);
|
|
|
|
expect(auth.status, AuthStatus.authenticated);
|
|
expect(auth.community?.id, valid.id);
|
|
expect(await storage.loadActiveId(), valid.id);
|
|
});
|
|
}
|