You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2023/01/18 11:34:41 UTC

[GitHub] [beam] alexeyinkin commented on a diff in pull request #25033: Playground integration test run and editing

alexeyinkin commented on code in PR #25033:
URL: https://github.com/apache/beam/pull/25033#discussion_r1073205312


##########
playground/frontend/integration_test/standalone_run_shortcuts_test.dart:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground/modules/shortcuts/constants/global_shortcuts.dart';
+import 'package:playground_components/playground_components.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+
+import 'common/common.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+  testWidgets(
+    'Shortcuts using test',
+    (WidgetTester wt) async {
+      await init(wt);
+
+      final controller = wt.findPlaygroundController();
+
+      await _checkResetShortcut(wt, controller);
+      await _checkRunShortcut(wt, controller);
+      await _checkClearOutputShortcut(wt, controller);
+    },
+  );
+}
+
+Future<void> _checkResetShortcut(
+  WidgetTester wt,
+  PlaygroundController controller,
+) async {
+  final startSource = controller.source;
+  await wt.enterText(find.codeField(), 'print("Hello World!');
+
+  expect(startSource != controller.source, true);

Review Comment:
   ```suggestion
     expect(controller.source, isNot(startSource));
   ```



##########
playground/frontend/integration_test/standalone_run_shortcuts_test.dart:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground/modules/shortcuts/constants/global_shortcuts.dart';
+import 'package:playground_components/playground_components.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+
+import 'common/common.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+  testWidgets(
+    'Shortcuts using test',
+    (WidgetTester wt) async {
+      await init(wt);
+
+      final controller = wt.findPlaygroundController();
+
+      await _checkResetShortcut(wt, controller);
+      await _checkRunShortcut(wt, controller);
+      await _checkClearOutputShortcut(wt, controller);
+    },
+  );
+}
+
+Future<void> _checkResetShortcut(
+  WidgetTester wt,
+  PlaygroundController controller,
+) async {
+  final startSource = controller.source;
+  await wt.enterText(find.codeField(), 'print("Hello World!');
+
+  expect(startSource != controller.source, true);
+
+  await wt.runShortcut(controller.resetShortcut.shortcuts.keys);

Review Comment:
   Make shortcuts OS-dependent.



##########
playground/frontend/integration_test/common/common_finders.dart:
##########
@@ -33,6 +36,13 @@ import 'package:playground_components/src/widgets/drag_handle.dart';
 import 'package:playground_components_dev/playground_components_dev.dart';
 
 extension CommonFindersExtension on CommonFinders {
+  Finder appDropdownButtonWithText(String text) {

Review Comment:
   Look for `PipelineOptionsDropdown`.



##########
playground/frontend/playground_components/lib/src/controllers/playground_controller.dart:
##########
@@ -277,6 +277,7 @@ class PlaygroundController with ChangeNotifier {
 
   void clearOutput() {
     _result = null;
+    outputResult = '';

Review Comment:
   This will conflict the timer fix.



##########
playground/frontend/integration_test/standalone_editing_test.dart:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+
+import 'common/common.dart';
+import 'common/common_finders.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+  testWidgets('Testing editing code', (WidgetTester wt) async {
+    await init(wt);
+    await _checkAutocomplete(wt);
+    await _editingAndResettingChanges(wt);
+    await _checkCodeHighlighting(wt);
+    await _codeBlockFoldingTest(wt);
+  });
+}
+
+Future<void> _checkAutocomplete(WidgetTester wt) async {
+  final codeController = wt.findOneCodeController();
+  final sSuggestions = await codeController.autocompleter.getSuggestions('sdk');
+  print(sSuggestions.map((e) => "'$e'").join(', '));
+  expect(
+    sSuggestions,
+    [
+      'sdkHttpMetadata',
+      'sdkHttpMetadataWithoutHeaders',
+      'sdkHttpResponse',
+      'sdkHttpResponseWithoutHeaders'
+    ],
+  );
+}
+
+Future<void> _editingAndResettingChanges(WidgetTester wt) async {
+  final playgroundController = wt.findPlaygroundController();
+
+  final code = playgroundController.source;
+
+  expect(code, isNotNull);
+
+  await wt.tapAndSettle(find.resetButton());
+
+  expect(playgroundController.source == code, true);

Review Comment:
   ```suggestion
     expect(playgroundController.source, code);
   ```



##########
playground/frontend/integration_test/standalone_example_selector_test.dart:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground/modules/examples/components/example_list/example_item_actions.dart';
+import 'package:playground/modules/examples/components/filter/tag_bubble.dart';
+import 'package:playground/modules/examples/components/filter/type_bubble.dart';
+import 'package:playground/modules/examples/components/search_field/search_field.dart';
+import 'package:playground/modules/examples/examples_dropdown_content.dart';
+import 'package:playground/pages/standalone_playground/notifiers/example_selector_state.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+import 'package:provider/provider.dart';
+
+import 'common/common.dart';
+import 'common/common_finders.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+  testWidgets('Example selector test', (WidgetTester wt) async {
+    await init(wt);
+    await _checkFilteringExamplesByTags(wt);
+    await _checkFilteringExamplesBySearchString(wt);

Review Comment:
   Check the actual examples before filtering and after filtering.



##########
playground/frontend/integration_test/standalone_example_selector_test.dart:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground/modules/examples/components/example_list/example_item_actions.dart';
+import 'package:playground/modules/examples/components/filter/tag_bubble.dart';
+import 'package:playground/modules/examples/components/filter/type_bubble.dart';
+import 'package:playground/modules/examples/components/search_field/search_field.dart';
+import 'package:playground/modules/examples/examples_dropdown_content.dart';
+import 'package:playground/pages/standalone_playground/notifiers/example_selector_state.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+import 'package:provider/provider.dart';
+
+import 'common/common.dart';
+import 'common/common_finders.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+  testWidgets('Example selector test', (WidgetTester wt) async {
+    await init(wt);
+    await _checkFilteringExamplesByTags(wt);
+    await _checkFilteringExamplesBySearchString(wt);
+    await _checkViewDescription(wt);
+  });
+}
+
+Future<void> _checkFilteringExamplesByTags(WidgetTester wt) async {
+  await wt.tapAndSettle(find.exampleSelector());
+  var allExamplesCount = _getExamplesCount(wt);
+  await wt.tapAndSettle(find.byType(TypeBubble).last);
+  var filteredExamplesCount = _getExamplesCount(wt);
+
+  expect(allExamplesCount != filteredExamplesCount, true);
+
+  await wt.tapAndSettle(find.exampleSelector());
+  await wt.tapAndSettle(find.exampleSelector());

Review Comment:
   Comment please.



##########
playground/frontend/playground_components_dev/lib/src/widget_tester.dart:
##########
@@ -50,4 +51,18 @@ extension WidgetTesterExtension on WidgetTester {
     final context = element(find.codeField());
     return context.read<PlaygroundController>();
   }
+
+  Future<void> runShortcut(Set<LogicalKeyboardKey> shortcut) async {
+    for (final key in shortcut) {
+      await sendKeyDownEvent(key);
+    }
+    for (final key in shortcut) {

Review Comment:
   ```suggestion
       for (final key in shortcut.reversed) {
   ```



##########
playground/frontend/integration_test/standalone_change_pipeline_options_and_run_test.dart:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown_body.dart';
+import 'package:playground/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown_input.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+
+import 'common/common.dart';
+import 'common/common_finders.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+  testWidgets(
+    'Changing pipeline options and press run',
+    (WidgetTester wt) async {
+      await init(wt);
+
+      await wt.tapAndSettle(find.appDropdownButtonWithText('Pipeline Options'));
+
+      await _addTwoOptions(wt);
+
+      await wt.tapAndSettle(find.pipelineOptionsRawTab());
+
+      _checkIfRawTextCorrect('--some test --some2 test2');
+
+      await wt.tapAndSettle(find.pipelineOptionsOptionsTab());
+
+      await wt.tap(find.byKey(const ValueKey('PipelineOptionsDelete1')));
+
+      await wt.tapAndSettle(find.pipelineOptionsRawTab());
+
+      _checkIfRawTextCorrect('--some test');
+
+      await wt.tapAndSettle(find.pipelineOptionsSaveAndCloseButton());
+
+      await wt.tap(find.runOrCancelButton());
+      await Future.delayed(const Duration(milliseconds: 300));
+
+      await wt.tapAndSettle(find.runOrCancelButton());
+
+      final playgroundController = wt.findPlaygroundController();
+      expect(playgroundController.outputResult, contains('Pipeline cancelled'));

Review Comment:
   Use a constant?



##########
playground/frontend/integration_test/standalone_change_pipeline_options_and_run_test.dart:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown_body.dart';
+import 'package:playground/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown_input.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+
+import 'common/common.dart';
+import 'common/common_finders.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+  testWidgets(
+    'Changing pipeline options and press run',
+    (WidgetTester wt) async {
+      await init(wt);
+
+      await wt.tapAndSettle(find.appDropdownButtonWithText('Pipeline Options'));
+
+      await _addTwoOptions(wt);
+
+      await wt.tapAndSettle(find.pipelineOptionsRawTab());
+
+      _checkIfRawTextCorrect('--some test --some2 test2');
+
+      await wt.tapAndSettle(find.pipelineOptionsOptionsTab());

Review Comment:
   ```suggestion
         await wt.tapAndSettle(find.pipelineOptionsListTab());
   ```



##########
playground/frontend/integration_test/standalone_change_pipeline_options_and_run_test.dart:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown_body.dart';
+import 'package:playground/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown_input.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+
+import 'common/common.dart';
+import 'common/common_finders.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+  testWidgets(
+    'Changing pipeline options and press run',
+    (WidgetTester wt) async {
+      await init(wt);
+
+      await wt.tapAndSettle(find.appDropdownButtonWithText('Pipeline Options'));
+
+      await _addTwoOptions(wt);
+
+      await wt.tapAndSettle(find.pipelineOptionsRawTab());
+
+      _checkIfRawTextCorrect('--some test --some2 test2');
+
+      await wt.tapAndSettle(find.pipelineOptionsOptionsTab());
+
+      await wt.tap(find.byKey(const ValueKey('PipelineOptionsDelete1')));
+
+      await wt.tapAndSettle(find.pipelineOptionsRawTab());
+
+      _checkIfRawTextCorrect('--some test');
+
+      await wt.tapAndSettle(find.pipelineOptionsSaveAndCloseButton());
+
+      await wt.tap(find.runOrCancelButton());
+      await Future.delayed(const Duration(milliseconds: 300));
+
+      await wt.tapAndSettle(find.runOrCancelButton());

Review Comment:
   Can we check if the options were actually sent with the run request? Maybe we can print them to the output and check.



##########
playground/frontend/integration_test/standalone_editing_test.dart:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+
+import 'common/common.dart';
+import 'common/common_finders.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+  testWidgets('Testing editing code', (WidgetTester wt) async {
+    await init(wt);
+    await _checkAutocomplete(wt);
+    await _editingAndResettingChanges(wt);
+    await _checkCodeHighlighting(wt);
+    await _codeBlockFoldingTest(wt);
+  });
+}
+
+Future<void> _checkAutocomplete(WidgetTester wt) async {
+  final codeController = wt.findOneCodeController();
+  final sSuggestions = await codeController.autocompleter.getSuggestions('sdk');
+  print(sSuggestions.map((e) => "'$e'").join(', '));
+  expect(
+    sSuggestions,
+    [
+      'sdkHttpMetadata',
+      'sdkHttpMetadataWithoutHeaders',
+      'sdkHttpResponse',
+      'sdkHttpResponseWithoutHeaders'
+    ],
+  );

Review Comment:
   1. Set the entire text to "sdk".
   2. Send a shortcut to open the suggestions box (create it).
   3. Check the content of the suggestion box.



##########
playground/frontend/integration_test/standalone_editing_test.dart:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+
+import 'common/common.dart';
+import 'common/common_finders.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+  testWidgets('Testing editing code', (WidgetTester wt) async {
+    await init(wt);
+    await _checkAutocomplete(wt);
+    await _editingAndResettingChanges(wt);
+    await _checkCodeHighlighting(wt);
+    await _codeBlockFoldingTest(wt);
+  });
+}
+
+Future<void> _checkAutocomplete(WidgetTester wt) async {
+  final codeController = wt.findOneCodeController();
+  final sSuggestions = await codeController.autocompleter.getSuggestions('sdk');
+  print(sSuggestions.map((e) => "'$e'").join(', '));
+  expect(
+    sSuggestions,
+    [
+      'sdkHttpMetadata',
+      'sdkHttpMetadataWithoutHeaders',
+      'sdkHttpResponse',
+      'sdkHttpResponseWithoutHeaders'
+    ],
+  );
+}
+
+Future<void> _editingAndResettingChanges(WidgetTester wt) async {
+  final playgroundController = wt.findPlaygroundController();
+
+  final code = playgroundController.source;
+
+  expect(code, isNotNull);
+
+  await wt.tapAndSettle(find.resetButton());
+
+  expect(playgroundController.source == code, true);
+
+  await wt.enterText(find.codeField(), 'print("Hello World!');
+  await wt.pumpAndSettle();
+
+  expect(playgroundController.source != code, true);
+
+  await wt.tapAndSettle(find.resetButton());
+
+  expect(playgroundController.source, equals(code));
+}
+
+Future<void> _checkCodeHighlighting(WidgetTester wt) async {

Review Comment:
   ```suggestion
   Future<void> _expectMoreThanOneColor(WidgetTester wt) async {
   ```



##########
playground/frontend/integration_test/standalone_editing_test.dart:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+
+import 'common/common.dart';
+import 'common/common_finders.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+  testWidgets('Testing editing code', (WidgetTester wt) async {
+    await init(wt);
+    await _checkAutocomplete(wt);
+    await _editingAndResettingChanges(wt);
+    await _checkCodeHighlighting(wt);
+    await _codeBlockFoldingTest(wt);

Review Comment:
   Unify naming.



##########
playground/frontend/integration_test/standalone_editing_test.dart:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+
+import 'common/common.dart';
+import 'common/common_finders.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+  testWidgets('Testing editing code', (WidgetTester wt) async {
+    await init(wt);
+    await _checkAutocomplete(wt);
+    await _editingAndResettingChanges(wt);
+    await _checkCodeHighlighting(wt);
+    await _codeBlockFoldingTest(wt);
+  });
+}
+
+Future<void> _checkAutocomplete(WidgetTester wt) async {
+  final codeController = wt.findOneCodeController();
+  final sSuggestions = await codeController.autocompleter.getSuggestions('sdk');
+  print(sSuggestions.map((e) => "'$e'").join(', '));
+  expect(
+    sSuggestions,
+    [
+      'sdkHttpMetadata',
+      'sdkHttpMetadataWithoutHeaders',
+      'sdkHttpResponse',
+      'sdkHttpResponseWithoutHeaders'
+    ],
+  );
+}
+
+Future<void> _editingAndResettingChanges(WidgetTester wt) async {
+  final playgroundController = wt.findPlaygroundController();
+
+  final code = playgroundController.source;
+
+  expect(code, isNotNull);
+
+  await wt.tapAndSettle(find.resetButton());
+
+  expect(playgroundController.source == code, true);
+
+  await wt.enterText(find.codeField(), 'print("Hello World!');
+  await wt.pumpAndSettle();
+
+  expect(playgroundController.source != code, true);
+
+  await wt.tapAndSettle(find.resetButton());
+
+  expect(playgroundController.source, equals(code));
+}
+
+Future<void> _checkCodeHighlighting(WidgetTester wt) async {
+  final codeController = wt.findOneCodeController();
+  final colors = <Color>{};
+  var textSpan = codeController.lastTextSpan;
+  _collectTextSpanTreeTextColors(textSpan, colors);
+
+  expect(colors.length, greaterThan(1));
+}
+
+void _collectTextSpanTreeTextColors(InlineSpan? span, Set<Color> colors) {
+  if (span is TextSpan) {
+    if (span.style?.color != null) {
+      colors.add(span.style!.color!);
+    }
+    if (span.children != null) {
+      for (final child in span.children!) {
+        _collectTextSpanTreeTextColors(child, colors);
+      }
+    }
+  }
+}
+
+Future<void> _codeBlockFoldingTest(WidgetTester wt) async {
+  const code = '''
+public class MyClass {
+  public static void main(String[] args) {
+    System.out.print("Hello World!");
+  }
+}
+''';
+
+  await wt.enterText(find.codeField(), code);
+  await wt.pumpAndSettle();
+
+  await wt.tapAndSettle(_getTopToggle(wt));
+
+  const foldedCode = '''
+public class MyClass {
+''';
+
+  expect(wt.findOneCodeController().text, equals(foldedCode));
+
+  await wt.tapAndSettle(_getFoldToggles());
+
+  expect(wt.findOneCodeController().text, equals(code));
+}
+
+Finder _getTopToggle(WidgetTester wt) {
+  Finder foldToggles = _getFoldToggles();
+
+  Finder topToggle =
+      wt.getCenter(foldToggles.at(0)).dy < wt.getCenter(foldToggles.at(1)).dy

Review Comment:
   Look for inputs the same way, comparing their centers, remove keys from inputs.



##########
playground/frontend/integration_test/standalone_editing_test.dart:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+
+import 'common/common.dart';
+import 'common/common_finders.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+  testWidgets('Testing editing code', (WidgetTester wt) async {
+    await init(wt);
+    await _checkAutocomplete(wt);
+    await _editingAndResettingChanges(wt);
+    await _checkCodeHighlighting(wt);
+    await _codeBlockFoldingTest(wt);
+  });
+}
+
+Future<void> _checkAutocomplete(WidgetTester wt) async {
+  final codeController = wt.findOneCodeController();
+  final sSuggestions = await codeController.autocompleter.getSuggestions('sdk');
+  print(sSuggestions.map((e) => "'$e'").join(', '));
+  expect(
+    sSuggestions,
+    [
+      'sdkHttpMetadata',
+      'sdkHttpMetadataWithoutHeaders',
+      'sdkHttpResponse',
+      'sdkHttpResponseWithoutHeaders'
+    ],
+  );
+}
+
+Future<void> _editingAndResettingChanges(WidgetTester wt) async {

Review Comment:
   Split to 2 methods.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org