You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "alexeyinkin (via GitHub)" <gi...@apache.org> on 2023/03/22 11:35:29 UTC

[GitHub] [beam] alexeyinkin commented on a diff in pull request #25925: Issue25640 tour of beam integration tests

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


##########
.github/workflows/tour_of_beam_frontend_test.yml:
##########
@@ -0,0 +1,85 @@
+# 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.
+
+name: Tour Of Beam Fronend Test
+
+on:
+  push:
+    paths: ['learning/tour-of-beam/frontend/**', 'playground/frontend/playground_components']
+    branches: ['**']
+  pull_request:
+    paths: ['learning/tour-of-beam/frontend/**', 'playground/frontend/playground_components']
+    branches: ['**']
+  workflow_dispatch:

Review Comment:
   Delete.



##########
playground/frontend/playground_components_dev/lib/src/common_tests/toggle_brightness_mode_test.dart:
##########
@@ -18,7 +18,8 @@
 
 import 'package:flutter/material.dart';
 import 'package:flutter_test/flutter_test.dart';
-import 'package:playground_components_dev/playground_components_dev.dart';
+
+import '../../playground_components_dev.dart';

Review Comment:
   Please import specific files.



##########
learning/tour-of-beam/frontend/integration_test/tour_page_test.dart:
##########
@@ -0,0 +1,208 @@
+/*
+ * 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:get_it/get_it.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:playground_components/playground_components.dart';
+import 'package:playground_components_dev/playground_components_dev.dart';
+import 'package:tour_of_beam/cache/content_tree.dart';
+import 'package:tour_of_beam/components/builders/content_tree.dart';
+import 'package:tour_of_beam/models/group.dart';
+import 'package:tour_of_beam/models/module.dart';
+import 'package:tour_of_beam/models/node.dart';
+import 'package:tour_of_beam/models/unit.dart';
+import 'package:tour_of_beam/pages/tour/screen.dart';
+import 'package:tour_of_beam/pages/tour/widgets/unit.dart';
+import 'package:tour_of_beam/pages/tour/widgets/unit_content.dart';
+
+import 'common/common.dart';
+import 'common/common_finders.dart';
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets(
+    'ToB miscellaneous ui',
+    (wt) async {
+      await init(wt);
+      await wt.tapAndSettle(find.text(Sdk.java.title));
+      await wt.tapAndSettle(find.startTourButton());
+
+      await _checkContentTreeBuildsProperly(wt);
+      await _checkUnitContentLoadsProperly(wt);
+      await _checkContentTreeScrollsProperly(wt);
+      await _checkHighlightsSelectedUnit(wt);
+      await _checkRunCodeWorks(wt);
+      await _checkResizeUnitContent(wt);
+    },
+  );
+}
+
+Future<void> _checkContentTreeBuildsProperly(WidgetTester wt) async {
+  final modules = _getModules(wt);
+
+  for (final module in modules) {
+    await _checkModule(module, wt);
+  }
+}
+
+List<ModuleModel> _getModules(WidgetTester wt) {
+  final contentTreeCache = GetIt.instance.get<ContentTreeCache>();
+  final controller = getContentTreeController(wt);
+  final contentTree = contentTreeCache.getContentTree(controller.sdkId);
+  return contentTree?.modules ?? (throw Exception('Can not load moduled'));
+}
+
+Future<void> _checkModule(ModuleModel module, WidgetTester wt) async {
+  for (final node in module.nodes) {
+    if (node is UnitModel) {
+      _checkNode(node);
+    }
+    if (node is GroupModel) {
+      await _checkGroup(node, wt);
+    }
+  }
+}
+
+void _checkNode(NodeModel node) {
+  expect(
+    find.descendant(
+      of: find.byType(ContentTreeBuilder),
+      matching: find.text(node.title),
+    ),
+    findsAtLeastNWidgets(1),
+  );
+}
+
+Future<void> _checkGroup(GroupModel group, WidgetTester wt) async {
+  final contentTreeController = getContentTreeController(wt);
+  contentTreeController.expandGroup(group);

Review Comment:
   Can you mimic a click on it?



-- 
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