mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-27 19:04:25 +01:00
This commit introduces the UserMessageTile widget, designed to display user messages in the chat interface. The widget includes the following features: - Proper alignment based on available screen width - A predefined minimum height with flexible expansion for longer messages - Styling including a white background, thin black border, and small corner radius Alongside the widget, this commit also includes comprehensive widget tests to ensure the correct rendering and functionality of the UserMessageTile. The tests cover: - Rendering without errors - Displaying the correct user message - Showing the "User" title as expected These implementations improve the structure and readability of the user messages within the chat view, ensuring a consistent and user-friendly experience.
43 lines
1.3 KiB
Dart
43 lines
1.3 KiB
Dart
import 'package:auto_gpt_flutter_client/views/chat/user_message_tile.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
// Test group for UserMessageTile widget
|
|
group('UserMessageTile', () {
|
|
// Test to check if the widget renders without error
|
|
testWidgets('renders without error', (WidgetTester tester) async {
|
|
await tester.pumpWidget(const MaterialApp(
|
|
home: Scaffold(
|
|
body: UserMessageTile(message: 'Hello, User!'),
|
|
),
|
|
));
|
|
expect(find.byType(UserMessageTile), findsOneWidget);
|
|
});
|
|
|
|
// Test to check if the widget displays the correct user message
|
|
testWidgets('displays the correct user message',
|
|
(WidgetTester tester) async {
|
|
const testMessage = 'Test Message';
|
|
await tester.pumpWidget(const MaterialApp(
|
|
home: Scaffold(
|
|
body: UserMessageTile(message: testMessage),
|
|
),
|
|
));
|
|
|
|
expect(find.text(testMessage), findsOneWidget);
|
|
});
|
|
|
|
// Test to check if the widget displays the "User" title
|
|
testWidgets('displays the "User" title', (WidgetTester tester) async {
|
|
await tester.pumpWidget(const MaterialApp(
|
|
home: Scaffold(
|
|
body: UserMessageTile(message: 'Any Message'),
|
|
),
|
|
));
|
|
|
|
expect(find.text('User'), findsOneWidget);
|
|
});
|
|
});
|
|
}
|