Files
buzz/mobile/test/features/profile/user_profile_sheet_names_test.dart
klopez4212 0bdad8ea96 mobile: simplify verified profiles and prioritize full names (#9051)
Simplifies mobile identity presentation: removes verification checkmarks
from messages, threads, mentions and profiles, plus
issuer/time/disclaimer copy. Profiles show the community-verified full
name as the title and the display name below, with fallback when no full
name exists.

Validation: mobile formatting/analysis, full Flutter suite (4,401
passed, 45 skipped), all 4 unconfigured-push checks, and pre-push hooks
passed. Independent review found no blockers. Device and human visual
checks pending.

<details>
<summary>Before / after snapshots</summary>

Real Flutter profile widget with synthetic data, light/dark themes;
widget previews, not device screenshots. Images are PR attachments only.

| Theme | Before | After |
| --- | --- | --- |
| Light | ![Before,
light](https://github.com/user-attachments/assets/d615c010-7f04-4480-ae5e-e11539abc860)
| ![After,
light](https://github.com/user-attachments/assets/5726e504-349c-4c74-afc5-5557b03061bb)
|
| Dark | ![Before,
dark](https://github.com/user-attachments/assets/29204e7c-840b-41b4-b916-784976e6cbc9)
| ![After,
dark](https://github.com/user-attachments/assets/6c399553-4d95-47e8-9a5d-a2d351598ab3)
|

</details>


<details>
<summary>Inline messages — before / after</summary>

Actual Flutter channel and thread widgets with synthetic verified-user
data; local widget previews, not device screenshots.

| Screen | Before | After |
| --- | --- | --- |
| Channel · light | ![Before: channel,
light](https://github.com/user-attachments/assets/e482b562-5b44-4e48-8a24-ea52e78a8936)
| ![After: channel,
light](https://github.com/user-attachments/assets/2dd3689c-3206-4bc0-84be-0828e0fcca84)
|
| Channel · dark | ![Before: channel,
dark](https://github.com/user-attachments/assets/3c848519-3b96-453f-8751-78c573211f13)
| ![After: channel,
dark](https://github.com/user-attachments/assets/cc781417-e7ef-4988-98b4-b562c075fff6)
|
| Thread · light | ![Before: thread,
light](https://github.com/user-attachments/assets/4117bd8b-de7e-45c7-8e5a-3b25ae600405)
| ![After: thread,
light](https://github.com/user-attachments/assets/b2f8bddb-3023-448b-88fa-a9bc1d3b2ec2)
|
| Thread · dark | ![Before: thread,
dark](https://github.com/user-attachments/assets/4b9fd1fc-0a53-41b0-804c-3f06cd7a2e03)
| ![After: thread,
dark](https://github.com/user-attachments/assets/b407c3c6-c67a-445f-8867-feff60ca5973)
|

</details>

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-04 16:00:52 +00:00

134 lines
4.5 KiB
Dart

import 'package:buzz/shared/verified_profiles/verified_profile.dart';
import 'package:buzz/shared/verified_profiles/verified_profile_directory.dart';
import 'package:buzz/features/profile/user_profile_sheet.dart';
import 'package:buzz/shared/identity_names/identity_names.dart';
import 'package:buzz/shared/identity_names/identity_names_provider.dart';
import 'package:buzz/shared/profile/user_cache_provider.dart';
import 'package:buzz/shared/profile/user_profile.dart';
import 'package:buzz/shared/theme/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
class _UserCache extends UserCacheNotifier {
_UserCache(this._initial);
final Map<String, UserProfile> _initial;
@override
Map<String, UserProfile> build() => _initial;
@override
UserProfile? get(String pubkey) => state[pubkey.toLowerCase()];
@override
Future<bool> preload(List<String> pubkeys) async => true;
void replace(UserProfile profile) =>
state = {...state, profile.pubkey: profile};
}
class _VerifiedProfiles extends VerifiedProfilesNotifier {
@override
Map<String, VerifiedProfile> build() => {};
void replace(Map<String, VerifiedProfile> profiles) => state = profiles;
}
void main() {
final scout = 'a' * 64;
final other = 'b' * 64;
testWidgets('a supplied context follows profile changes while open', (
tester,
) async {
final cache = _UserCache({
scout: UserProfile(pubkey: scout, displayName: 'Scout'),
other: UserProfile(pubkey: other, displayName: 'Scout'),
});
final verified = _VerifiedProfiles();
late IdentityNames opened;
await tester.pumpWidget(
ProviderScope(
overrides: [
userCacheProvider.overrideWith(() => cache),
verifiedProfilesProvider.overrideWith(() => verified),
],
child: MaterialApp(
theme: AppTheme.light(),
home: Consumer(
builder: (context, ref, _) {
// The opener's context: both Scouts, so each has a suffix.
opened = ref.read(identityNameSourcesProvider).scope([
scout,
other,
]);
return Scaffold(
body: UserProfileSheet(
pubkey: scout,
names: Provider.autoDispose<IdentityNames>(
(ref) => opened.withSources(
ref.watch(identityNameSourcesProvider),
),
),
),
);
},
),
),
),
);
await tester.pump();
final suffixed = opened.labelFor(scout);
expect(suffixed, startsWith('Scout · '));
expect(find.text(suffixed), findsOneWidget);
// The other Scout renames. The open sheet resolves the opener's context
// against live facts, so its label no longer needs the suffix.
cache.replace(UserProfile(pubkey: other, displayName: 'Renamed'));
await tester.pump();
expect(find.text('Scout'), findsOneWidget);
expect(find.text(suffixed), findsNothing);
// A community full name becomes the title, with the display name below.
for (final checked in [true, false]) {
verified.replace({
scout: VerifiedProfile(
displayName: 'Scout',
username: 'scout',
fullName: 'Scout Example',
issuerLabel: 'Block',
verifiedAt: 1000000,
checked: checked,
multipleIssuers: false,
),
});
await tester.pump();
final title = find.text('Scout Example');
final subtitle = find.text('Scout');
expect(title, findsOneWidget);
expect(subtitle, findsOneWidget);
expect(
tester.getTopLeft(title).dy,
lessThan(tester.getTopLeft(subtitle).dy),
);
expect(
tester.getCenter(title).dx,
closeTo(tester.getCenter(subtitle).dx, 1),
);
expect(
tester.widget<Text>(title).style!.fontSize,
greaterThan(tester.widget<Text>(subtitle).style!.fontSize!),
);
expect(find.byKey(const ValueKey('verified-mark')), findsNothing);
expect(find.textContaining('Name verified'), findsNothing);
expect(find.textContaining('Last verified'), findsNothing);
expect(find.textContaining('current account access'), findsNothing);
}
verified.replace({});
await tester.pump();
expect(find.text('Scout Example'), findsNothing);
expect(find.text('Scout'), findsOneWidget);
});
}