From 2924c6ec7f1a0a7f42502b09d1a2e0fc5d94ba14 Mon Sep 17 00:00:00 2001 From: ZhuchkaTriplesix Date: Fri, 9 Oct 2026 11:23:58 +0300 Subject: [PATCH] test(sql-workspace): run the selection through the mounted editor (#1148) The selection test was disabled: assigning the controller value hung CI, and a selection made that way is not how a user makes one. It now selects through the editor's EditableText and runs with Ctrl+Enter, the path a user takes. --- .../generic_sql_workspace_shortcuts_test.dart | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/test/features/workspace/generic_sql_workspace_shortcuts_test.dart b/test/features/workspace/generic_sql_workspace_shortcuts_test.dart index fd17517f..b2f44d8a 100644 --- a/test/features/workspace/generic_sql_workspace_shortcuts_test.dart +++ b/test/features/workspace/generic_sql_workspace_shortcuts_test.dart @@ -176,22 +176,30 @@ void main() { expect(delegate.executed, isEmpty); }); - // Disabled: this test hung CI for the full 10-minute timeout. Selecting - // text by assigning the controller value does not mimic a user selection in - // the editor. Re-enable once the selection is made through the mounted - // editor (EditableTextState.userUpdateTextEditingValue). testWidgets('only the selected text runs when there is a selection', timeout: _timeout, - skip: true, (tester) async { final delegate = FakeSqlExecutionDelegate(); - final state = await pumpWorkspace(tester, delegate); - const sql = 'SELECT 1; SELECT 2'; - state.activeSession.controller.value = const TextEditingValue( - text: sql, - selection: TextSelection(baseOffset: 10, extentOffset: 18), + final state = await pumpWorkspace(tester, delegate, initialSql: 'SELECT 1; SELECT 2'); + + // The selection is made through the mounted editor, as a user does; setting + // the controller value directly is what made the test hang before. + final editor = tester.state( + find.byType(material.EditableText).first, + ); + editor.userUpdateTextEditingValue( + const TextEditingValue( + text: 'SELECT 1; SELECT 2', + selection: TextSelection(baseOffset: 10, extentOffset: 18), + ), + null, ); + await tester.pump(); + expect(state.activeSession.controller.selection.textInside( + state.activeSession.controller.text), 'SELECT 2'); - unawaited(state.execute()); + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.enter); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); await settle(tester); expect(delegate.executed, ['SELECT 2']);