Files
buzz/mobile/test/shared/widgets/message_author_meta_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

171 lines
5.1 KiB
Dart

import 'package:buzz/shared/theme/theme.dart';
import 'package:buzz/shared/widgets/message_author_meta.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets(
'hidden identity stays accessible without a visible name or gap',
(tester) async {
final semantics = tester.ensureSemantics();
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SizedBox(
width: 300,
child: MessageAuthorMeta(
displayName: 'Alice',
username: 'alice@example.com',
timestamp: '2m',
showIdentity: false,
nameColor: Colors.black,
metadataColor: Colors.grey,
),
),
),
),
);
expect(find.text('Alice'), findsNothing);
expect(find.text('alice@example.com'), findsNothing);
expect(find.byIcon(Icons.verified), findsNothing);
expect(find.bySemanticsLabel(RegExp('Alice')), findsOneWidget);
expect(
tester.getTopLeft(find.text('2m')).dx,
tester.getTopLeft(find.byType(MessageAuthorMeta)).dx,
);
semantics.dispose();
},
);
testWidgets('keeps the timestamp next to a short name without a separator', (
tester,
) async {
const displayNameKey = Key('author-display-name');
const timestampKey = Key('author-timestamp');
await tester.pumpWidget(
MaterialApp(
theme: AppTheme.light(),
home: const Scaffold(
body: SizedBox(
width: 300,
child: MessageAuthorMeta(
displayName: 'Alice',
timestamp: '2m',
displayNameKey: displayNameKey,
timestampKey: timestampKey,
nameColor: Colors.black,
metadataColor: Colors.grey,
),
),
),
),
);
await tester.pumpAndSettle();
final displayNameRect = tester.getRect(find.byKey(displayNameKey));
final timestampRect = tester.getRect(find.byKey(timestampKey));
expect(find.text('·'), findsNothing);
expect(timestampRect.left - displayNameRect.right, Grid.xxs);
expect(
tester.widget<Text>(find.byKey(timestampKey)).style?.fontSize,
messageTimestampTextStyle.fontSize,
);
expect(tester.takeException(), isNull);
});
testWidgets('reallocates unused metadata width to the display name', (
tester,
) async {
const displayNameKey = Key('author-display-name');
const timestampKey = Key('author-timestamp');
await tester.pumpWidget(
MaterialApp(
theme: AppTheme.light(),
home: const Scaffold(
body: SizedBox(
width: 300,
child: MessageAuthorMeta(
displayName: 'A display name that needs the available width',
username: 'al',
timestamp: '2m',
displayNameKey: displayNameKey,
timestampKey: timestampKey,
nameColor: Colors.black,
metadataColor: Colors.grey,
),
),
),
),
);
await tester.pumpAndSettle();
final row = find.byType(MessageAuthorMeta);
final displayName = find.byKey(displayNameKey);
final timestamp = find.byKey(timestampKey);
expect(
tester.getSize(displayName).width,
greaterThan(tester.getSize(row).width / 2),
);
expect(
tester.getTopRight(timestamp).dx,
closeTo(tester.getTopRight(row).dx, 0.01),
);
expect(tester.takeException(), isNull);
});
testWidgets('constrains long metadata at large accessible text sizes', (
tester,
) async {
const displayNameKey = Key('author-display-name');
const timestampKey = Key('author-timestamp');
await tester.pumpWidget(
MaterialApp(
theme: AppTheme.light(),
home: const MediaQuery(
data: MediaQueryData(textScaler: TextScaler.linear(2)),
child: Scaffold(
body: SizedBox(
width: 220,
child: MessageAuthorMeta(
displayName: 'A very long display name',
username: 'a-very-long-username',
timestamp: 'Mar 15, 2025',
displayNameKey: displayNameKey,
timestampKey: timestampKey,
nameColor: Colors.black,
metadataColor: Colors.grey,
),
),
),
),
),
);
await tester.pumpAndSettle();
final timestamp = tester.widget<Text>(find.byKey(timestampKey));
expect(timestamp.maxLines, 1);
expect(timestamp.overflow, TextOverflow.ellipsis);
final nameRichText = tester.widget<RichText>(
find.descendant(
of: find.byKey(displayNameKey),
matching: find.byType(RichText),
),
);
final timestampRichText = tester.widget<RichText>(
find.descendant(
of: find.byKey(timestampKey),
matching: find.byType(RichText),
),
);
expect(nameRichText.textScaler.scale(15), 30);
expect(timestampRichText.textScaler.scale(13.1), 26.2);
expect(tester.takeException(), isNull);
});
}