mirror of
https://github.com/block/buzz.git
synced 2026-11-24 10:12:19 +00:00
Uploaded images on the mobile Agents page now crop to fill the avatar squircle, matching desktop. Animated avatars and bundled character posters retain their existing sizing. Validation: `just mobile-check mobile-test` passed (4,050 Flutter tests; 34 skipped), plus before/after rendering of the production card. Regression coverage checks uploaded, preset and animated images. Snapshots use a sample rectangular PNG in a local Flutter widget preview, not an installed build. | Before | After | | --- | --- | |  |  | Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
171 lines
5.3 KiB
Dart
171 lines
5.3 KiB
Dart
import 'dart:ui' show SemanticsAction;
|
|
|
|
import 'package:buzz/features/agents/agent_card.dart';
|
|
import 'package:buzz/features/agents/agent_card_grid.dart';
|
|
import 'package:buzz/shared/theme/theme.dart';
|
|
import 'package:buzz/shared/widgets/avatar_image.dart';
|
|
import 'package:buzz/shared/widgets/avatar_shape.dart';
|
|
import 'package:buzz/shared/widgets/progressive_animated_avatar.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
void main() {
|
|
testWidgets(
|
|
'uploaded portraits cover the frame while character artwork stays contained',
|
|
(tester) async {
|
|
for (final (url, expectedFit) in [
|
|
('https://example.com/portrait.png', BoxFit.cover),
|
|
(
|
|
'https://dwwgwmfqqjotj.cloudfront.net/avatars/20260925T154625166Z/poster/pollies/pollies-10.png',
|
|
BoxFit.contain,
|
|
),
|
|
(
|
|
'https://example.com/portrait.png#buzz-anim=https%3A%2F%2Fexample.com%2Fanimated.png',
|
|
BoxFit.contain,
|
|
),
|
|
]) {
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
child: MaterialApp(
|
|
theme: AppTheme.light(),
|
|
home: Center(
|
|
child: SizedBox(
|
|
width: 180,
|
|
height: 240,
|
|
child: AgentCard(
|
|
name: 'Portrait',
|
|
imageUrl: url,
|
|
onOpen: () {},
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
final portrait = find.descendant(
|
|
of: find.byType(AvatarClip),
|
|
matching: find.byType(AvatarImageContent),
|
|
);
|
|
expect(portrait, findsOneWidget);
|
|
expect(tester.widget<AvatarImageContent>(portrait).fit, expectedFit);
|
|
final animation = find.byType(ProgressiveAnimatedAvatar);
|
|
if (animation.evaluate().isNotEmpty) {
|
|
expect(
|
|
tester.widget<ProgressiveAnimatedAvatar>(animation).fit,
|
|
expectedFit,
|
|
);
|
|
}
|
|
expect(tester.takeException(), isNull);
|
|
}
|
|
},
|
|
);
|
|
|
|
testWidgets('whole card opens profile without stealing footer taps', (
|
|
tester,
|
|
) async {
|
|
var opens = 0;
|
|
var selections = 0;
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
child: MaterialApp(
|
|
theme: AppTheme.light(),
|
|
home: Scaffold(
|
|
body: Center(
|
|
child: SizedBox(
|
|
width: 180,
|
|
height: 240,
|
|
child: AgentCard(
|
|
name: 'Cloud assistant',
|
|
onOpen: () => opens++,
|
|
footer: TextButton(
|
|
onPressed: () => selections++,
|
|
child: const Text('Model'),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
final bounds = tester.getRect(find.byType(AgentCard));
|
|
await tester.tapAt(Offset(bounds.left + 2, bounds.center.dy));
|
|
await tester.tapAt(Offset(bounds.center.dx, bounds.bottom - 2));
|
|
expect(opens, 2);
|
|
await tester.tap(find.text('Model'));
|
|
expect(selections, 1);
|
|
expect(opens, 2);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
|
|
testWidgets('agent grid keeps cards readable and actionable at large text', (
|
|
tester,
|
|
) async {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
final semantics = tester.ensureSemantics();
|
|
try {
|
|
String? opened;
|
|
|
|
Future<void> render(double scale) async {
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
child: MaterialApp(
|
|
theme: AppTheme.light(),
|
|
home: MediaQuery(
|
|
data: MediaQueryData(
|
|
size: const Size(390, 844),
|
|
textScaler: TextScaler.linear(scale),
|
|
disableAnimations: true,
|
|
),
|
|
child: Scaffold(
|
|
body: CustomScrollView(
|
|
slivers: [
|
|
AgentCardGrid(
|
|
itemCount: 6,
|
|
itemBuilder: (_, index) => AgentCard(
|
|
name: 'Research assistant $index',
|
|
location: 'Remote',
|
|
onOpen: () => opened = '$index',
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
await render(1);
|
|
expect(
|
|
tester.getTopLeft(find.byType(AgentCard).at(0)).dy,
|
|
tester.getTopLeft(find.byType(AgentCard).at(1)).dy,
|
|
);
|
|
await render(2);
|
|
expect(
|
|
tester.getTopLeft(find.byType(AgentCard).at(1)).dy,
|
|
greaterThan(tester.getTopLeft(find.byType(AgentCard).at(0)).dy),
|
|
);
|
|
final first = find.bySemanticsLabel(RegExp('Open Research assistant 0'));
|
|
expect(
|
|
tester
|
|
.getSemantics(first)
|
|
.getSemanticsData()
|
|
.hasAction(SemanticsAction.tap),
|
|
isTrue,
|
|
);
|
|
await tester.tap(first);
|
|
expect(opened, '0');
|
|
expect(tester.takeException(), isNull);
|
|
} finally {
|
|
semantics.dispose();
|
|
}
|
|
});
|
|
}
|