Files
buzz/mobile/test/features/profile/set_status_sheet_test.dart
klopez4212 b30f1f6129 Polish mobile profiles, DMs, and sheets (#5401)
## Summary
- add poster-first, tap-to-toggle animated avatars on profile surfaces
while preserving transparent/static behavior elsewhere
- align mobile DM headers, membership actions, and invisible agent
recipient addressing with established desktop semantics
- polish titled sheets and status editing, preserve native iOS sheet
corners, and batch relay reads to improve review-build responsiveness

## Snapshots

<table>
  <tr>
    <th>Profile avatar</th>
    <th>Agent DM header and composer</th>
  </tr>
  <tr>
<td><img
src="https://raw.githubusercontent.com/block/buzz/e8de7495451dbe1a393ab43c5e204ca7425f2ba5/pr-5401--profile-avatar.png"
width="360" alt="Mobile profile settings with animated avatar
surface"></td>
<td><img
src="https://raw.githubusercontent.com/block/buzz/e8de7495451dbe1a393ab43c5e204ca7425f2ba5/pr-5401--agent-dm.png"
width="360" alt="Agent direct message with masked presence and normal
composer"></td>
  </tr>
  <tr>
    <th>Members sheet</th>
    <th>Status editor</th>
  </tr>
  <tr>
<td><img
src="https://raw.githubusercontent.com/block/buzz/e8de7495451dbe1a393ab43c5e204ca7425f2ba5/pr-5401--members-sheet.png"
width="360" alt="Members bottom sheet with centered title and padded
content"></td>
<td><img
src="https://raw.githubusercontent.com/block/buzz/e8de7495451dbe1a393ab43c5e204ca7425f2ba5/pr-5401--status-sheet.png"
width="360" alt="Status editor bottom sheet with duration and quick
statuses"></td>
  </tr>
  <tr>
    <th colspan="2">Switch Community</th>
  </tr>
  <tr>
<td colspan="2" align="center"><img
src="https://raw.githubusercontent.com/block/buzz/e8de7495451dbe1a393ab43c5e204ca7425f2ba5/pr-5401--switch-community.png"
width="720" alt="Switch Community bottom sheet with centered title and
aligned Edit action"></td>
  </tr>
</table>

## Validation
- `just mobile-check`
- `just mobile-test` (1,283 tests)
- installed and reviewed isolated debug builds on iPhone and Pixel

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Signed-off-by: Princess Donut <b238ea756dee4d98afa5883fc7f1de61eeabe65bf700e3a5a5a80db5e42e2c2b@buzz.block.builderlab.xyz>
Signed-off-by: Kenny Lopez <klopez4212@gmail.com>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
Co-authored-by: Princess Donut <b238ea756dee4d98afa5883fc7f1de61eeabe65bf700e3a5a5a80db5e42e2c2b@buzz.block.builderlab.xyz>
Co-authored-by: Wes <wesbillman@users.noreply.github.com>
Co-authored-by: Carl <c7ebe626f000404285d3686e1dc74cc07cc60a9754a150041ba132e14bd3e2ec@buzz.block.builderlab.xyz>
2026-08-13 20:16:04 -07:00

255 lines
8.2 KiB
Dart

import 'package:buzz/features/profile/set_status_sheet.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:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../helpers/widget_helpers.dart';
void main() {
testWidgets('keeps its resting top edge when the keyboard appears', (
tester,
) async {
addTearDown(tester.view.reset);
await tester.pumpWidget(
WidgetHelpers.testable(
overrides: [
customEmojiListProvider.overrideWithValue(const []),
userStatusProvider.overrideWith(() => _RecordingUserStatusNotifier()),
],
child: Builder(
builder: (context) => FilledButton(
onPressed: () => showSetStatusSheet(context),
child: const Text('Open status editor'),
),
),
),
);
await tester.tap(find.text('Open status editor'));
await tester.pumpAndSettle();
final restingTop = tester.getTopLeft(find.byType(BottomSheet)).dy;
tester.view.viewInsets = const FakeViewPadding(bottom: 300);
await tester.pumpAndSettle();
expect(
tester.getTopLeft(find.byType(BottomSheet)).dy,
closeTo(restingTop, 0.01),
);
});
testWidgets('uses Buzz rows, desktop presets, and a real duration', (
tester,
) async {
final statusNotifier = _RecordingUserStatusNotifier();
await tester.pumpWidget(
WidgetHelpers.testable(
overrides: [
customEmojiListProvider.overrideWithValue(const []),
userStatusProvider.overrideWith(() => statusNotifier),
],
child: Builder(
builder: (context) => FilledButton(
onPressed: () => showSetStatusSheet(
context,
currentStatus: const UserStatus(
text: 'Focusing',
emoji: '\u{1F3AF}',
updatedAt: 1,
),
),
child: const Text('Open status editor'),
),
),
),
);
await tester.tap(find.text('Open status editor'));
await tester.pumpAndSettle();
expect(find.text('\u{1F3AF}'), findsOneWidget);
expect(find.byTooltip('Remove status emoji'), findsOneWidget);
expect(find.byKey(const ValueKey('status-input-outline')), findsOneWidget);
expect(find.text('Visible in chats to everyone'), findsNothing);
expect(find.text('Let others know what you\u2019re up to.'), findsNothing);
expect(find.text('1 day'), findsOneWidget);
expect(find.text('In a meeting'), findsOneWidget);
expect(find.text('Commuting'), findsOneWidget);
expect(find.text('Out sick'), findsOneWidget);
expect(find.text('Vacationing'), findsOneWidget);
expect(find.text('Working remotely'), findsOneWidget);
await tester.tap(find.text('1 day'));
await tester.pumpAndSettle();
expect(find.text('1 hour'), findsOneWidget);
expect(find.text('8 hours'), findsOneWidget);
expect(find.text('1 week'), findsOneWidget);
expect(find.text('Custom'), findsOneWidget);
await tester.tap(find.text('8 hours'));
await tester.pumpAndSettle();
expect(find.text('8 hours'), findsOneWidget);
await tester.tap(find.byTooltip('Remove status emoji'));
await tester.pump();
expect(find.text('\u{1F3AF}'), findsNothing);
expect(find.byIcon(LucideIcons.smilePlus), findsOneWidget);
expect(
tester.widget<TextField>(find.byType(TextField)).controller?.text,
'Focusing',
);
final beforeSave = DateTime.now();
await tester.tap(find.byTooltip('Save status'));
await tester.pumpAndSettle();
expect(statusNotifier.savedText, 'Focusing');
expect(statusNotifier.savedEmoji, isEmpty);
expect(statusNotifier.savedExpiresAt, isNotNull);
expect(
statusNotifier.savedExpiresAt!.difference(beforeSave).inSeconds,
inInclusiveRange(
const Duration(hours: 8).inSeconds - 2,
const Duration(hours: 8).inSeconds + 2,
),
);
});
testWidgets('opens with an out-of-range remote expiration', (tester) async {
await tester.pumpWidget(
WidgetHelpers.testable(
overrides: [
customEmojiListProvider.overrideWithValue(const []),
userStatusProvider.overrideWith(() => _RecordingUserStatusNotifier()),
],
child: Builder(
builder: (context) => FilledButton(
onPressed: () => showSetStatusSheet(
context,
currentStatus: const UserStatus(
text: 'Focusing',
emoji: '',
updatedAt: 1,
expiresAt: 9_000_000_000_000,
),
),
child: const Text('Open status editor'),
),
),
),
);
await tester.tap(find.text('Open status editor'));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
expect(find.text('Focusing'), findsOneWidget);
expect(find.text('1 day'), findsOneWidget);
});
testWidgets('clamps an existing custom date to the Android picker range', (
tester,
) async {
debugDefaultTargetPlatformOverride = TargetPlatform.android;
addTearDown(() => debugDefaultTargetPlatformOverride = null);
final expiresAt = DateTime.now().add(const Duration(days: 730));
await tester.pumpWidget(
WidgetHelpers.testable(
overrides: [
customEmojiListProvider.overrideWithValue(const []),
userStatusProvider.overrideWith(() => _RecordingUserStatusNotifier()),
],
child: Builder(
builder: (context) => FilledButton(
onPressed: () => showSetStatusSheet(
context,
currentStatus: UserStatus(
text: 'Sabbatical',
emoji: '\u{1F3DD}\u{FE0F}',
updatedAt: 1,
expiresAt: expiresAt.millisecondsSinceEpoch ~/ 1000,
),
),
child: const Text('Open status editor'),
),
),
),
);
await tester.tap(find.text('Open status editor'));
await tester.pumpAndSettle();
await tester.tap(find.text('Until'));
await tester.pumpAndSettle();
final picker = tester.widget<DatePickerDialog>(
find.byType(DatePickerDialog),
);
expect(picker.initialDate, picker.lastDate);
debugDefaultTargetPlatformOverride = null;
});
testWidgets('custom duration reveals the native until picker', (
tester,
) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
addTearDown(() => debugDefaultTargetPlatformOverride = null);
final statusNotifier = _RecordingUserStatusNotifier();
await tester.pumpWidget(
WidgetHelpers.testable(
overrides: [
customEmojiListProvider.overrideWithValue(const []),
userStatusProvider.overrideWith(() => statusNotifier),
],
child: Builder(
builder: (context) => FilledButton(
onPressed: () => showSetStatusSheet(context),
child: const Text('Open status editor'),
),
),
),
);
await tester.tap(find.text('Open status editor'));
await tester.pumpAndSettle();
await tester.tap(find.text('1 day'));
await tester.pumpAndSettle();
await tester.ensureVisible(find.text('Custom'));
await tester.pumpAndSettle();
await tester.tap(find.text('Custom'));
await tester.pumpAndSettle();
expect(find.byType(CupertinoDatePicker), findsOneWidget);
await tester.tap(find.text('Done'));
await tester.pumpAndSettle();
expect(find.text('Custom'), findsOneWidget);
expect(find.text('Until'), findsOneWidget);
debugDefaultTargetPlatformOverride = null;
});
}
class _RecordingUserStatusNotifier extends UserStatusNotifier {
String? savedText;
String? savedEmoji;
DateTime? savedExpiresAt;
@override
Future<UserStatus?> build() async => null;
@override
Future<void> setStatus(
String text,
String emoji, {
DateTime? expiresAt,
}) async {
savedText = text;
savedEmoji = emoji;
savedExpiresAt = expiresAt;
}
}