mirror of
https://github.com/block/buzz.git
synced 2026-11-07 01:41:06 +00:00
## Summary Deletes mobile code that no longer has a user-reachable path and has no counterpart in buzz-app, so it is unlikely to come back for parity. Net: 104 files, about 5,500 lines removed. No intended behavior change. - **iOS native message menu and action surface:** `NativeMessageMenu.swift` and `NativeMessageActionSurface.swift`, the `message`/`supportsMessage` coordinator branches, and the Dart selection hook. Dart stopped creating this view in [#8280](https://github.com/block/buzz/pull/8280). The native reactions sheet in the same coordinator is kept. - **Old home quick-actions launcher and `ComposeMorphIcon`:** only instantiated in tests since the nav-bar creation actions replaced them. - **Retired local theme stack:** `ThemeNotifier`, `AccentNotifier`, `SchemeNotifier`, `adaptive_theme.dart`, `AccentPickerPage`, the appearance-mode sheet and their helpers. These predate per-community theme sync. The legacy prefs migration in `community_theme_preference.dart` is kept. - **Unused widgets:** `ProfileAvatar` and `MaskedAvatarBadge`. - **Push permission-status plumbing:** the iOS `notificationAuthorizationStatus`/`openNotificationSettings` handlers, plus the uncalled strict age-gate snapshot registration and its Swift `syncAgeGatePushSnapshot` path. - **Orphaned files** with no importer: `profile_text_edit_sheet`, `editor_option_button`, `retained_page_transition`, `tappable_flapping_bee`, `agent_model_info`, `community_bot_profiles`, `sheet_divider`, `success_haptic`. - **Uncalled helpers:** the `pickAndUpload*`/camera helpers in `media_upload.dart`, unused `NostrFilters` builders, `mediaGetHeadersFor*`, and about 20 other uncalled functions, providers and styles. - **Removed-UI leftovers:** the never-wired invite directory providers, `AuthNotifier.signOut` and `removeActiveCommunityForSignOut` (the Sign out row is gone), `renameCommunity`, `HomePage.profilePageBuilder`/`SettingsPage.embedded`, and the create-forum branches of the create-channel sheet. Forum viewing is unchanged. Tests that only covered deleted code are removed. Tests of surviving code that used deleted helpers as drivers were repointed to the surviving API. An audit of `mobile/android` found no dead Kotlin, resources, manifest entries or Gradle dependencies, so Android code is unchanged. ## Validation - `flutter analyze`: no issues. - After rebasing onto main ([93b8b8f](https://github.com/block/buzz/commit/93b8b8febc)), `just mobile-check` is clean (format and analyze), and `just mobile-test` passes (4,070 passed, 35 skipped, 0 failed, plus the push-unconfigured and secp256k1 suites). - `dart format`: clean. - Android: `just mobile-build-android` builds the debug APK, and `./gradlew :app:testDebugUnitTest` passes. - iOS: `build-for-testing` succeeds and BuzzPushKit `swift test` passes (65 tests). In RunnerTests, 97 of 98 pass. `testNativeNavigationTitleExpandsAgainAtTop` fails, but it fails the same way on unmodified `main` (acf56fff6f) on the same machine (Xcode 27, iPhone 17 Pro simulator), so it is not caused by this change. - Agent review of the diff ran. Its one blocker (stale `project.pbxproj` entries for the deleted Swift files) is fixed. - In-app smoke run at [66141c1](66141c10b9): a debug build on a fresh iPhone 17 Pro simulator (iOS 27), signed in to the internal community. The following flows all worked with no errors: - Home: the New menu (channel, DM, workspace, chat) and the create-channel sheet, including its channel-type options. - A chat, with the message action sheet (reactions row, Reply, Copy link, Remind me, Mark unread, Copy text, Edit and Delete). - Appearance: the previews, and cycling the System and Light modes. - Settings: the profile header, the display name editor, and Edit photo (Image and Emoji tabs). - The Agents directory. - Search, including the Channels filter, plus opening a team channel from the results. - Tapping a reaction summary, which opens the native iOS Reactions sheet. - The recording isn't attached here because it shows internal channels and messages. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Tom Brow <tomb@squareup.com> Co-authored-by: Tom Brow <tomb@squareup.com> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
500 lines
16 KiB
Dart
500 lines
16 KiB
Dart
import 'dart:async';
|
|
import 'dart:convert';
|
|
|
|
import 'package:buzz/features/profile/profile_provider.dart';
|
|
import 'package:buzz/features/profile/settings_profile_header.dart';
|
|
import 'package:buzz/shared/profile/user_profile.dart';
|
|
import 'package:buzz/features/profile/user_status.dart';
|
|
import 'package:buzz/features/profile/user_status_provider.dart';
|
|
import 'package:buzz/shared/custom_emoji/custom_emoji_provider.dart';
|
|
import 'package:buzz/shared/custom_emoji/custom_emoji.dart';
|
|
import 'package:buzz/shared/custom_emoji/custom_emoji_render.dart';
|
|
import 'package:buzz/shared/relay/media_auth.dart';
|
|
import 'package:buzz/shared/relay/media_image.dart';
|
|
import 'package:buzz/shared/theme/theme.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:http/http.dart' as http;
|
|
import 'package:http/testing.dart' as http_testing;
|
|
|
|
import '../../helpers/widget_helpers.dart';
|
|
|
|
void main() {
|
|
testWidgets('reserves half of the 24dp settings section gap', (tester) async {
|
|
await tester.pumpWidget(
|
|
WidgetHelpers.testable(
|
|
overrides: [
|
|
profileProvider.overrideWith(_FakeProfileNotifier.new),
|
|
presenceProvider.overrideWith(() => _FakePresenceNotifier('online')),
|
|
userStatusProvider.overrideWith(() => _FakeUserStatusNotifier(null)),
|
|
customEmojiListProvider.overrideWithValue(const []),
|
|
],
|
|
child: const SettingsProfileHeader(),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
final header = tester.widget<Padding>(
|
|
find.byKey(const ValueKey('settings-profile-header')),
|
|
);
|
|
expect((header.padding as EdgeInsets).bottom, Grid.twelve);
|
|
});
|
|
|
|
testWidgets('shows the display name directly beneath the avatar', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(
|
|
WidgetHelpers.testable(
|
|
overrides: [
|
|
profileProvider.overrideWith(_FakeProfileNotifier.new),
|
|
presenceProvider.overrideWith(() => _FakePresenceNotifier('online')),
|
|
userStatusProvider.overrideWith(() => _FakeUserStatusNotifier(null)),
|
|
customEmojiListProvider.overrideWithValue(const []),
|
|
],
|
|
child: const SettingsProfileHeader(),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
final avatar = find.byKey(const ValueKey('settings-profile-avatar'));
|
|
final name = find.text('Test');
|
|
expect(name, findsOneWidget);
|
|
expect(
|
|
tester.getTopLeft(name).dy,
|
|
greaterThan(tester.getBottomLeft(avatar).dy),
|
|
);
|
|
});
|
|
|
|
testWidgets('shows the poster until the animated avatar is ready', (
|
|
tester,
|
|
) async {
|
|
const posterUrl = 'https://relay.example/media/poster.png';
|
|
const animationUrl = 'https://relay.example/media/animation.png';
|
|
final profileUrl =
|
|
'$posterUrl#buzz-anim=${Uri.encodeComponent(animationUrl)}';
|
|
final animationResponse = Completer<http.Response>();
|
|
final client = http_testing.MockClient(
|
|
(request) => request.url.toString() == animationUrl
|
|
? animationResponse.future
|
|
: Future.value(http.Response.bytes(_transparentPng, 200)),
|
|
);
|
|
addTearDown(client.close);
|
|
|
|
await tester.pumpWidget(
|
|
WidgetHelpers.testable(
|
|
overrides: [
|
|
profileProvider.overrideWith(
|
|
() => _FakeProfileNotifier(avatarUrl: profileUrl),
|
|
),
|
|
presenceProvider.overrideWith(() => _FakePresenceNotifier('online')),
|
|
userStatusProvider.overrideWith(() => _FakeUserStatusNotifier(null)),
|
|
customEmojiListProvider.overrideWithValue(const []),
|
|
mediaGetAuthServiceProvider.overrideWithValue(
|
|
MediaGetAuthService(baseUrl: 'https://relay.example', nsec: null),
|
|
),
|
|
mediaHttpClientProvider.overrideWithValue(client),
|
|
],
|
|
child: const SettingsProfileHeader(),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
await tester.pump();
|
|
|
|
expect(
|
|
find.byKey(const ValueKey('progressive-animated-avatar-poster')),
|
|
findsOneWidget,
|
|
);
|
|
expect(
|
|
tester
|
|
.widget<ColoredBox>(
|
|
find.byKey(const ValueKey('settings-profile-avatar-background')),
|
|
)
|
|
.color,
|
|
Colors.transparent,
|
|
);
|
|
expect(
|
|
find.byKey(
|
|
const ValueKey('progressive-animated-avatar-animation-loading'),
|
|
),
|
|
findsOneWidget,
|
|
);
|
|
expect(
|
|
tester
|
|
.widgetList<MediaImage>(find.byType(MediaImage, skipOffstage: false))
|
|
.map((image) => image.url),
|
|
containsAll([posterUrl, animationUrl]),
|
|
);
|
|
animationResponse.complete(http.Response.bytes(_transparentPng, 200));
|
|
final animationReady = find.byKey(
|
|
const ValueKey('progressive-animated-avatar-animation-ready'),
|
|
);
|
|
await WidgetHelpers.pumpUntilFound(tester, animationReady);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(animationReady, findsOneWidget);
|
|
expect(
|
|
find.byKey(const ValueKey('progressive-animated-avatar-poster')),
|
|
findsNothing,
|
|
);
|
|
expect(
|
|
tester
|
|
.widgetList<MediaImage>(find.byType(MediaImage))
|
|
.map((image) => image.url),
|
|
[animationUrl],
|
|
);
|
|
|
|
await tester.tap(find.byKey(const ValueKey('settings-profile-avatar')));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(
|
|
find.byKey(const ValueKey('progressive-animated-avatar-animation')),
|
|
findsNothing,
|
|
);
|
|
expect(tester.widget<MediaImage>(find.byType(MediaImage)).url, posterUrl);
|
|
|
|
await tester.tap(find.byKey(const ValueKey('settings-profile-avatar')));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(
|
|
find.byKey(const ValueKey('progressive-animated-avatar-animation')),
|
|
findsOneWidget,
|
|
);
|
|
expect(
|
|
find.byKey(const ValueKey('progressive-animated-avatar-poster')),
|
|
findsNothing,
|
|
);
|
|
});
|
|
|
|
testWidgets('warms and clears a paused animated-avatar handoff', (
|
|
tester,
|
|
) async {
|
|
const posterUrl = 'https://relay.example/media/poster.png';
|
|
const animationUrl = 'https://relay.example/media/animation.png';
|
|
final profileUrl =
|
|
'$posterUrl#buzz-anim=${Uri.encodeComponent(animationUrl)}';
|
|
final posterResponse = Completer<http.Response>();
|
|
final animationResponse = Completer<http.Response>();
|
|
final client = http_testing.MockClient(
|
|
(request) => switch (request.url.toString()) {
|
|
posterUrl => posterResponse.future,
|
|
animationUrl => animationResponse.future,
|
|
_ => Future.value(http.Response.bytes(_transparentPng, 200)),
|
|
},
|
|
);
|
|
addTearDown(client.close);
|
|
final container = ProviderContainer(
|
|
overrides: [
|
|
profileProvider.overrideWith(
|
|
() => _FakeProfileNotifier(avatarUrl: profileUrl),
|
|
),
|
|
presenceProvider.overrideWith(() => _FakePresenceNotifier('online')),
|
|
userStatusProvider.overrideWith(() => _FakeUserStatusNotifier(null)),
|
|
customEmojiListProvider.overrideWithValue(const []),
|
|
mediaGetAuthServiceProvider.overrideWithValue(
|
|
MediaGetAuthService(baseUrl: 'https://relay.example', nsec: null),
|
|
),
|
|
mediaHttpClientProvider.overrideWithValue(client),
|
|
],
|
|
);
|
|
addTearDown(container.dispose);
|
|
container
|
|
.read(profileAvatarHandoffProvider.notifier)
|
|
.show(
|
|
ProfileAvatarHandoff(
|
|
avatarUrl: profileUrl,
|
|
animation: _transparentPng,
|
|
poster: _transparentPng,
|
|
),
|
|
);
|
|
|
|
await tester.pumpWidget(
|
|
UncontrolledProviderScope(
|
|
container: container,
|
|
child: MaterialApp(
|
|
theme: AppTheme.light(),
|
|
home: const Scaffold(body: SettingsProfileHeader()),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.byKey(const ValueKey('settings-profile-avatar')));
|
|
await tester.pump();
|
|
|
|
expect(
|
|
find.byKey(
|
|
ValueKey('settings-profile-paused-handoff-$profileUrl'),
|
|
skipOffstage: false,
|
|
),
|
|
findsOneWidget,
|
|
);
|
|
expect(container.read(profileAvatarHandoffProvider), isNotNull);
|
|
|
|
posterResponse.complete(http.Response.bytes(_transparentPng, 200));
|
|
await tester.runAsync(
|
|
() => Future<void>.delayed(const Duration(milliseconds: 50)),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(container.read(profileAvatarHandoffProvider), isNull);
|
|
// Finish the deliberately paused transport so its deadline is cancelled.
|
|
animationResponse.complete(http.Response.bytes(_transparentPng, 200));
|
|
await tester.pump();
|
|
});
|
|
testWidgets('keeps the avatar unbadged while showing the current status', (
|
|
tester,
|
|
) async {
|
|
const missingShortcode = ':very_long_missing_custom_emoji:';
|
|
await tester.pumpWidget(
|
|
WidgetHelpers.testable(
|
|
overrides: [
|
|
profileProvider.overrideWith(_FakeProfileNotifier.new),
|
|
presenceProvider.overrideWith(() => _FakePresenceNotifier('online')),
|
|
userStatusProvider.overrideWith(
|
|
() => _FakeUserStatusNotifier(
|
|
const UserStatus(
|
|
text: 'Focusing',
|
|
emoji: missingShortcode,
|
|
updatedAt: 1,
|
|
),
|
|
),
|
|
),
|
|
customEmojiListProvider.overrideWithValue(const []),
|
|
],
|
|
child: const SettingsProfileHeader(),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(Hero), findsNothing);
|
|
expect(find.text('$missingShortcode Focusing'), findsOneWidget);
|
|
expect(
|
|
tester.getSize(find.byKey(const ValueKey('settings-profile-avatar'))),
|
|
const Size(128, 128),
|
|
);
|
|
});
|
|
|
|
for (final scenario in [
|
|
(emoji: '🎯', text: 'Focusing', resolved: false),
|
|
(emoji: ':party_parrot:', text: '', resolved: true),
|
|
(emoji: ':party_parrot:', text: 'Celebrating', resolved: true),
|
|
(emoji: ':unknown:', text: '', resolved: false),
|
|
]) {
|
|
testWidgets('preserves status ${scenario.emoji} ${scenario.text}', (
|
|
tester,
|
|
) async {
|
|
final client = http_testing.MockClient(
|
|
(_) async => http.Response.bytes(_transparentPng, 200),
|
|
);
|
|
addTearDown(client.close);
|
|
await tester.pumpWidget(
|
|
WidgetHelpers.testable(
|
|
overrides: [
|
|
profileProvider.overrideWith(_FakeProfileNotifier.new),
|
|
presenceProvider.overrideWith(
|
|
() => _FakePresenceNotifier('online'),
|
|
),
|
|
userStatusProvider.overrideWith(
|
|
() => _FakeUserStatusNotifier(
|
|
UserStatus(
|
|
emoji: scenario.emoji,
|
|
text: scenario.text,
|
|
updatedAt: 1,
|
|
),
|
|
),
|
|
),
|
|
customEmojiListProvider.overrideWithValue(const [
|
|
CustomEmoji(
|
|
shortcode: 'party_parrot',
|
|
url: 'https://relay.example/parrot.png',
|
|
),
|
|
]),
|
|
mediaHttpClientProvider.overrideWithValue(client),
|
|
],
|
|
child: const SettingsProfileHeader(),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
if (scenario.resolved) {
|
|
final image = tester.widget<CustomEmojiImage>(
|
|
find.byType(CustomEmojiImage),
|
|
);
|
|
expect(image.shortcode, 'party_parrot');
|
|
expect(image.url, 'https://relay.example/parrot.png');
|
|
expect(find.text(':party_parrot:'), findsNothing);
|
|
if (scenario.text.isNotEmpty) {
|
|
expect(find.textContaining(scenario.text), findsOneWidget);
|
|
}
|
|
} else {
|
|
expect(find.byType(CustomEmojiImage), findsNothing);
|
|
expect(
|
|
find.text(
|
|
[
|
|
scenario.emoji,
|
|
scenario.text,
|
|
].where((s) => s.isNotEmpty).join(' '),
|
|
),
|
|
findsOneWidget,
|
|
);
|
|
}
|
|
await tester.tap(
|
|
scenario.resolved
|
|
? find.byType(CustomEmojiImage)
|
|
: find.textContaining(scenario.emoji),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Set a status'), findsOneWidget);
|
|
});
|
|
}
|
|
|
|
testWidgets(
|
|
'keeps text-only status visible beside a changeable presence pill',
|
|
(tester) async {
|
|
final presenceNotifier = _FakePresenceNotifier('away');
|
|
await tester.pumpWidget(
|
|
WidgetHelpers.testable(
|
|
overrides: [
|
|
profileProvider.overrideWith(_FakeProfileNotifier.new),
|
|
presenceProvider.overrideWith(() => presenceNotifier),
|
|
userStatusProvider.overrideWith(
|
|
() => _FakeUserStatusNotifier(
|
|
const UserStatus(text: 'Focusing', emoji: '', updatedAt: 1),
|
|
),
|
|
),
|
|
customEmojiListProvider.overrideWithValue(const []),
|
|
],
|
|
child: const SettingsProfileHeader(),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Focusing'), findsOneWidget);
|
|
await tester.tap(find.text('Focusing'));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Set a status'), findsOneWidget);
|
|
expect(
|
|
tester.widget<TextField>(find.byType(TextField)).controller?.text,
|
|
'Focusing',
|
|
);
|
|
await tester.binding.handlePopRoute();
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(
|
|
find.byKey(const ValueKey('settings-presence-label')),
|
|
findsOneWidget,
|
|
);
|
|
expect(find.text('Away'), findsOneWidget);
|
|
expect(
|
|
tester
|
|
.widget<Text>(find.byKey(const ValueKey('settings-presence-label')))
|
|
.style
|
|
?.fontSize,
|
|
filterChipTextStyle.fontSize,
|
|
);
|
|
expect(
|
|
tester
|
|
.getSize(find.byKey(const ValueKey('settings-presence-target')))
|
|
.height,
|
|
48,
|
|
);
|
|
expect(
|
|
tester
|
|
.getSize(find.byKey(const ValueKey('settings-presence-pill')))
|
|
.height,
|
|
greaterThanOrEqualTo(31),
|
|
);
|
|
|
|
final presenceTarget = find.byKey(
|
|
const ValueKey('settings-presence-target'),
|
|
);
|
|
final haptics = <Object?>[];
|
|
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
|
SystemChannels.platform,
|
|
(call) async {
|
|
if (call.method == 'HapticFeedback.vibrate') {
|
|
haptics.add(call.arguments);
|
|
}
|
|
return null;
|
|
},
|
|
);
|
|
addTearDown(() {
|
|
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
|
SystemChannels.platform,
|
|
null,
|
|
);
|
|
});
|
|
final targetRect = tester.getRect(presenceTarget);
|
|
await tester.tapAt(Offset(targetRect.center.dx, targetRect.bottom - 1));
|
|
await tester.pump();
|
|
|
|
expect(haptics, contains('HapticFeedbackType.selectionClick'));
|
|
final scale = tester.widget<ScaleTransition>(
|
|
find.byKey(const ValueKey('activity-popover-scale')),
|
|
);
|
|
expect(scale.alignment, Alignment.topCenter);
|
|
expect(
|
|
find.byKey(const ValueKey('settings-presence-popover')),
|
|
findsOneWidget,
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(
|
|
find.byKey(const ValueKey('settings-presence-online')),
|
|
findsOneWidget,
|
|
);
|
|
expect(
|
|
find.byKey(const ValueKey('settings-presence-away')),
|
|
findsOneWidget,
|
|
);
|
|
expect(
|
|
find.byKey(const ValueKey('settings-presence-offline')),
|
|
findsOneWidget,
|
|
);
|
|
|
|
await tester.tap(find.byKey(const ValueKey('settings-presence-offline')));
|
|
await tester.pumpAndSettle();
|
|
expect(presenceNotifier.selected, ['offline']);
|
|
},
|
|
);
|
|
}
|
|
|
|
class _FakeProfileNotifier extends ProfileNotifier {
|
|
_FakeProfileNotifier({this.avatarUrl});
|
|
|
|
final String? avatarUrl;
|
|
|
|
@override
|
|
Future<UserProfile?> build() async =>
|
|
UserProfile(pubkey: 'aabb', displayName: 'Test', avatarUrl: avatarUrl);
|
|
}
|
|
|
|
class _FakeUserStatusNotifier extends UserStatusNotifier {
|
|
_FakeUserStatusNotifier(this._status);
|
|
|
|
final UserStatus? _status;
|
|
|
|
@override
|
|
Future<UserStatus?> build() async => _status;
|
|
}
|
|
|
|
class _FakePresenceNotifier extends PresenceNotifier {
|
|
_FakePresenceNotifier(this._presence);
|
|
|
|
final String _presence;
|
|
final List<String> selected = [];
|
|
|
|
@override
|
|
Future<String> build() async => _presence;
|
|
|
|
@override
|
|
Future<void> setPresence(String status) async {
|
|
selected.add(status);
|
|
}
|
|
}
|
|
|
|
final _transparentPng = base64Decode(
|
|
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAA'
|
|
'AAYAAjCB0C8AAAAASUVORK5CYII=',
|
|
);
|