@@ -219,6 +219,52 @@ void main() {
219219 });
220220 });
221221
222+ group ('topic not yet chosen, tap content input -> topic input focused' , () {
223+ void checkFocused ({required bool topic, required bool content}) {
224+ assert (! (topic && content), "Topic and content inputs can't both have focus!" );
225+
226+ check (controller).isA <StreamComposeBoxController >()
227+ ..topicFocusNode.hasFocus.equals (topic)
228+ ..contentFocusNode.hasFocus.equals (content);
229+ }
230+
231+ Future <void > prepareAndTapContentInput (WidgetTester tester) async {
232+ final channel = eg.stream ();
233+ await prepareComposeBox (tester,
234+ narrow: ChannelNarrow (channel.streamId),
235+ subscriptions: [eg.subscription (channel)]);
236+ checkFocused (topic: false , content: false );
237+
238+ // Prepare a response for a getChannelTopics request triggered by the
239+ // the topic input being focused.
240+ connection.prepare (json: GetChannelTopicsResult (topics: []).toJson ());
241+ await tester.tap (contentInputFinder);
242+ await tester.pump (Duration .zero);
243+ }
244+
245+ testWidgets ('basic' , (tester) async {
246+ await prepareAndTapContentInput (tester);
247+ checkFocused (topic: true , content: false );
248+ });
249+
250+ testWidgets ('choose topic, tap content input -> content input focused' , (tester) async {
251+ await prepareAndTapContentInput (tester);
252+ checkFocused (topic: true , content: false );
253+
254+ await tester.enterText (topicInputFinder, 'topic' );
255+ await tester.tap (contentInputFinder);
256+ checkFocused (topic: false , content: true );
257+ });
258+
259+ testWidgets ('skip topic, tap content input -> content input focused' , (tester) async {
260+ await prepareAndTapContentInput (tester);
261+ checkFocused (topic: true , content: false );
262+
263+ await tester.tap (contentInputFinder);
264+ checkFocused (topic: false , content: true );
265+ });
266+ });
267+
222268 group ('ComposeBoxTheme' , () {
223269 test ('lerp light to dark, no crash' , () {
224270 final a = ComposeBoxTheme .light;
0 commit comments