Skip to content

Commit 821e9d0

Browse files
chrisbobbegnprice
authored andcommitted
action-sheet tests [nfc]: Move some helpers out a level
These will also be helpful for testing the upcoming "Copy to clipboard" button, which also requires fetching raw Markdown from the server.
1 parent fe84c60 commit 821e9d0

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

test/widgets/action_sheet_test.dart

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ Future<void> setupToMessageActionSheet(WidgetTester tester, {
6363
void main() {
6464
TestZulipBinding.ensureInitialized();
6565

66+
void prepareRawContentResponseSuccess(PerAccountStore store, {
67+
required Message message,
68+
required String rawContent,
69+
}) {
70+
// Prepare fetch-raw-Markdown response
71+
// TODO: Message should really only differ from `message`
72+
// in its content / content_type, not in `id` or anything else.
73+
(store.connection as FakeApiConnection).prepare(json:
74+
GetMessageResult(message: eg.streamMessage(contentMarkdown: rawContent)).toJson());
75+
}
76+
77+
void prepareRawContentResponseError(PerAccountStore store) {
78+
final fakeResponseJson = {
79+
'code': 'BAD_REQUEST',
80+
'msg': 'Invalid message(s)',
81+
'result': 'error',
82+
};
83+
(store.connection as FakeApiConnection).prepare(httpStatus: 400, json: fakeResponseJson);
84+
}
85+
6686
group('QuoteAndReplyButton', () {
6787
ComposeBoxController? findComposeBoxController(WidgetTester tester) {
6888
return tester.widget<ComposeBox>(find.byType(ComposeBox))
@@ -73,26 +93,6 @@ void main() {
7393
return tester.widgetList(find.byIcon(Icons.format_quote_outlined)).singleOrNull;
7494
}
7595

76-
void prepareRawContentResponseSuccess(PerAccountStore store, {
77-
required Message message,
78-
required String rawContent,
79-
}) {
80-
// Prepare fetch-raw-Markdown response
81-
// TODO: Message should really only differ from `message`
82-
// in its content / content_type, not in `id` or anything else.
83-
(store.connection as FakeApiConnection).prepare(json:
84-
GetMessageResult(message: eg.streamMessage(contentMarkdown: rawContent)).toJson());
85-
}
86-
87-
void prepareRawContentResponseError(PerAccountStore store) {
88-
final fakeResponseJson = {
89-
'code': 'BAD_REQUEST',
90-
'msg': 'Invalid message(s)',
91-
'result': 'error',
92-
};
93-
(store.connection as FakeApiConnection).prepare(httpStatus: 400, json: fakeResponseJson);
94-
}
95-
9696
/// Simulates tapping the quote-and-reply button in the message action sheet.
9797
///
9898
/// Checks that there is a quote-and-reply button.

0 commit comments

Comments
 (0)