Skip to content

Commit

Permalink
Merge pull request #507 from GetStream/hotfix/messageText
Browse files Browse the repository at this point in the history
fix: new lines in list
  • Loading branch information
imtoori authored Jun 29, 2021
2 parents 07f3a8b + 9641926 commit 2d11044
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
2 changes: 1 addition & 1 deletion melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ scripts:
dir-exists: test

test:flutter:
run: melos exec -c 1 --fail-fast -- "flutter test --coverage"
run: melos exec -c 3 --fail-fast -- "flutter test --coverage"
description: Run Flutter tests for a specific package in this project.
select-package:
flutter: true
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_chat_flutter/lib/src/message_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MessageText extends StatelessWidget {

@override
Widget build(BuildContext context) {
final text = _replaceMentions(message.text ?? '').replaceAll('\n', '\\\n');
final text = _replaceMentions(message.text ?? '').replaceAll('\n', '\n\n');

final themeData = Theme.of(context);
return MarkdownBody(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions packages/stream_chat_flutter/test/src/message_text_test.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:mocktail/mocktail.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

import 'mocks.dart';
import 'simple_frame.dart';

void main() {
testWidgets(
Expand Down Expand Up @@ -51,4 +53,57 @@ void main() {
expect(find.byType(MarkdownBody), findsOneWidget);
},
);

testGoldens(
'control test',
(WidgetTester tester) async {
final client = MockClient();
final clientState = MockClientState();
final channel = MockChannel();
final channelState = MockChannelState();
final lastMessageAt = DateTime.parse('2020-06-22 12:00:00');
final themeData = ThemeData();
final streamTheme = StreamChatThemeData.fromTheme(themeData);

when(() => client.state).thenReturn(clientState);
when(() => clientState.user).thenReturn(OwnUser(id: 'user-id'));
when(() => channel.lastMessageAt).thenReturn(lastMessageAt);
when(() => channel.state).thenReturn(channelState);
when(() => channel.client).thenReturn(client);
when(() => channel.isMuted).thenReturn(false);
when(() => channel.isMutedStream).thenAnswer((i) => Stream.value(false));
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
'name': 'test',
}));
when(() => channel.extraData).thenReturn({
'name': 'test',
});

final messageText = '''a message.
with multiple lines
and a list:
- a. okasd
- b lllll
cool.''';

await tester.pumpWidgetBuilder(
materialAppWrapper()(SimpleFrame(
child: StreamChannel(
channel: channel,
child: Scaffold(
body: MessageText(
message: Message(
text: messageText,
),
messageTheme: streamTheme.otherMessageTheme,
),
),
),
)),
surfaceSize: const Size(500, 500),
);
await screenMatchesGolden(tester, 'message_text');
},
);
}

0 comments on commit 2d11044

Please sign in to comment.