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/17 12:30:25 UTC

[GitHub] [beam] alexeyinkin opened a new pull request, #25034: Test loading URLs

alexeyinkin opened a new pull request, #25034:
URL: https://github.com/apache/beam/pull/25034

   **Please** add a meaningful description for your change here
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/get-started-contributing/#make-the-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   [![Build python source distribution and wheels](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Go tests](https://github.com/apache/beam/workflows/Go%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
   


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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073283126


##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';

Review Comment:
   Used for `TextEditingValue.typed()`.



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073666242


##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';
+const _standalonePath = '/';
+const _paths = [_embeddedPath, _standalonePath];
+
+const _fullViewOptionsMap = {
+  'readonly': 'readonly1,readonly2',
+  'unfold': 'unfold1,unfold2',
+};
+final _croppedViewOptionsMap = {
+  ..._fullViewOptionsMap,
+  'show': 'show',
+};
+
+final _fullViewOptions = _mapToQueryString(_fullViewOptionsMap);
+final _croppedViewOptions = _mapToQueryString(_croppedViewOptionsMap);
+
+Future<void> _testEmbeddedRoot(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse(_embeddedPath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneRoot(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountJava.path,
+    java,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse(_standalonePath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testEmbeddedSdkOnly(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse('$_embeddedPath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneSdkOnly(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountGo.path,
+    go,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse('$_standalonePath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testCatalogDefaultExampleLoader(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountGo.path,
+    go,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse('$_standalonePath?sdk=go&default=true'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testContentExampleLoader(WidgetTester wt) async {
+  final content = await Examples.getFullTextByPath(ExampleGo.path);
+
+  for (final path in _paths) {
+    final files = jsonEncode([
+      {'content': content, 'isMain': true}
+    ]);
+    await wt.navigateAndSettle(
+      Uri.parse(
+        '$path?sdk=go&files=${Uri.encodeComponent(files)}&$_fullViewOptions',
+      ),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.fullVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testEmptyExampleLoader(WidgetTester wt) async {
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&empty=true'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, '');
+  }
+}
+
+Future<void> _testHttpExampleLoader(WidgetTester wt) async {
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_fullViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.fullVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testStandardExampleLoader(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    WordCountGo.path,
+    go,
+  );
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&path=${WordCountGo.dbPath}'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, visibleText);
+  }
+}
+
+Future<void> _testUserSharedExampleLoader(WidgetTester wt) async {
+  final template = await Examples.getFullTextByPath(ExampleGo.path);
+  final tail = '\n//${DateTime.now().millisecondsSinceEpoch}';
+  final content = '$template$tail';
+
+  final exampleCache = wt.findPlaygroundController().exampleCache;
+  final snippetId = await exampleCache.saveSnippet(
+    files: [SnippetFile(content: content, isMain: false, name: 'name')],
+    sdk: Sdk.go,
+    pipelineOptions: 'a=b',
+  );
+
+  print('Created user-shared example ID: $snippetId');
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&shared=$snippetId&$_fullViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, '${ExampleGo.fullVisibleText}$tail');
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testMultipleExamples(WidgetTester wt) async {
+  final javaVisibleText = await Examples.getVisibleTextByPath(
+    AggregationMaxJava.path,
+    java,
+  );
+  const goVisibleText = ExampleGo.fullVisibleText;
+
+  final examplesList = [
+    {
+      'sdk': Sdk.java.id,
+      'path': AggregationMaxJava.dbPath,
+      ..._fullViewOptionsMap,
+    },
+    {
+      'sdk': Sdk.go.id,
+      'url': ExampleGo.url,
+      ..._fullViewOptionsMap,
+    },
+  ];
+  final examples = jsonEncode(examplesList);
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&examples=$examples'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, goVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    final playgroundController = wt.findPlaygroundController();
+    playgroundController.setSdk(Sdk.java);
+    await wt.pumpAndSettle();
+
+    _expectSdk(wt, Sdk.java);
+    _expectText(wt, javaVisibleText);
+  }
+}
+
+void _expectSdk(WidgetTester wt, Sdk sdk) {
+  final controller = wt.findPlaygroundController();
+  expect(controller.sdk, sdk);
+}
+
+void _expectText(WidgetTester wt, String visibleText) {
+  final controller = wt.findOneCodeController();
+  expect(controller.text, visibleText);
+}
+
+/// Checks that the example contains:
+/// - at least two 'editable' substrings, and they are editable,
+/// - at least two 'readonly' substrings, and they are read-only.
+Future<void> _expectEditableAndReadOnly(WidgetTester wt) async {
+  final controller = wt.findOneCodeController();
+
+  for (int i = 0; i < 2; i++) {

Review Comment:
   Yes, it is in the doc comment.



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


[GitHub] [beam] Malarg commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
Malarg commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073112162


##########
playground/frontend/build.gradle:
##########
@@ -183,10 +183,17 @@ ext.deleteFilesByRegExp = { re ->
 }
 
 tasks.register("integrationTest") {
+  dependsOn("integrationTest_initial_urls")
   dependsOn("integrationTest_standalone_change_example_sdk_run")
   dependsOn("integrationTest_standalone_miscellaneous_ui")
 }
 
+tasks.register("integrationTest_initial_urls") {

Review Comment:
   will we add `standalone` to naming? Suggest add or remove from all tests



##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';

Review Comment:
   Suggest take from embedded playground path file



##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';
+const _standalonePath = '/';
+const _paths = [_embeddedPath, _standalonePath];
+
+const _fullViewOptionsMap = {
+  'readonly': 'readonly1,readonly2',
+  'unfold': 'unfold1,unfold2',
+};
+final _croppedViewOptionsMap = {
+  ..._fullViewOptionsMap,
+  'show': 'show',
+};
+
+final _fullViewOptions = _mapToQueryString(_fullViewOptionsMap);
+final _croppedViewOptions = _mapToQueryString(_croppedViewOptionsMap);
+
+Future<void> _testEmbeddedRoot(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse(_embeddedPath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneRoot(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountJava.path,

Review Comment:
   Would be better to generalize interface of obtaining info about examples. I suggest to make factory of examples, which will return required example by enum



##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';
+const _standalonePath = '/';
+const _paths = [_embeddedPath, _standalonePath];
+
+const _fullViewOptionsMap = {
+  'readonly': 'readonly1,readonly2',
+  'unfold': 'unfold1,unfold2',
+};
+final _croppedViewOptionsMap = {
+  ..._fullViewOptionsMap,
+  'show': 'show',
+};
+
+final _fullViewOptions = _mapToQueryString(_fullViewOptionsMap);
+final _croppedViewOptions = _mapToQueryString(_croppedViewOptionsMap);
+
+Future<void> _testEmbeddedRoot(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse(_embeddedPath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneRoot(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountJava.path,
+    java,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse(_standalonePath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testEmbeddedSdkOnly(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse('$_embeddedPath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneSdkOnly(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(

Review Comment:
   this test will be broken if default example will be changed



##########
playground/frontend/lib/main.dart:
##########
@@ -43,7 +43,7 @@ void main() async {
   // Router API specific initialization.
   final pageStack = GetIt.instance.get<PageStack>();
   final routerDelegate = BeamRouterDelegate(pageStack);
-  final routeInformationParser = PlaygroundRouteInformationParser();
+  final rip = GetIt.instance.get<PageStackRouteInformationParser>();

Review Comment:
   may be `routeParser`? My first association is rest in peace 



##########
playground/frontend/playground_components_dev/lib/src/widget_tester.dart:
##########
@@ -50,4 +52,28 @@ extension WidgetTesterExtension on WidgetTester {
     final context = element(find.codeField());
     return context.read<PlaygroundController>();
   }
+
+  Future<void> navigateAndSettle(Uri url) async {
+    print(url);
+    await _navigate(url);
+    await Future.delayed(const Duration(seconds:1));
+    await pumpAndSettle();
+
+    await Future.delayed(const Duration(seconds: 1));
+    await pumpAndSettle();
+  }
+
+  Future<void> _navigate(Uri uri) async {
+    final rip = GetIt.instance.get<PageStackRouteInformationParser>();

Review Comment:
   `routeParser`



##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';
+const _standalonePath = '/';

Review Comment:
   suggest take from standalone playground path file



##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';

Review Comment:
   unused import



##########
playground/frontend/lib/main.dart:
##########
@@ -43,7 +43,7 @@ void main() async {
   // Router API specific initialization.
   final pageStack = GetIt.instance.get<PageStack>();
   final routerDelegate = BeamRouterDelegate(pageStack);
-  final routeInformationParser = PlaygroundRouteInformationParser();
+  final rip = GetIt.instance.get<PageStackRouteInformationParser>();

Review Comment:
   also unused import on 33 row



##########
playground/frontend/lib/main.dart:
##########
@@ -43,7 +43,7 @@ void main() async {
   // Router API specific initialization.
   final pageStack = GetIt.instance.get<PageStack>();
   final routerDelegate = BeamRouterDelegate(pageStack);
-  final routeInformationParser = PlaygroundRouteInformationParser();
+  final rip = GetIt.instance.get<PageStackRouteInformationParser>();

Review Comment:
   also I think we can make extension on get it to make calls shorter



##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';
+const _standalonePath = '/';
+const _paths = [_embeddedPath, _standalonePath];
+
+const _fullViewOptionsMap = {
+  'readonly': 'readonly1,readonly2',
+  'unfold': 'unfold1,unfold2',
+};
+final _croppedViewOptionsMap = {
+  ..._fullViewOptionsMap,
+  'show': 'show',
+};
+
+final _fullViewOptions = _mapToQueryString(_fullViewOptionsMap);
+final _croppedViewOptions = _mapToQueryString(_croppedViewOptionsMap);
+
+Future<void> _testEmbeddedRoot(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse(_embeddedPath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneRoot(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountJava.path,
+    java,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse(_standalonePath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testEmbeddedSdkOnly(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse('$_embeddedPath?sdk=go'),

Review Comment:
   there are a lot of `Uri.parse` calls in the file with different params. It also could be generalized with builder.



##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';
+const _standalonePath = '/';
+const _paths = [_embeddedPath, _standalonePath];
+
+const _fullViewOptionsMap = {
+  'readonly': 'readonly1,readonly2',
+  'unfold': 'unfold1,unfold2',
+};
+final _croppedViewOptionsMap = {
+  ..._fullViewOptionsMap,
+  'show': 'show',
+};
+
+final _fullViewOptions = _mapToQueryString(_fullViewOptionsMap);
+final _croppedViewOptions = _mapToQueryString(_croppedViewOptionsMap);
+
+Future<void> _testEmbeddedRoot(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse(_embeddedPath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneRoot(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountJava.path,
+    java,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse(_standalonePath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testEmbeddedSdkOnly(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse('$_embeddedPath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneSdkOnly(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountGo.path,
+    go,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse('$_standalonePath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testCatalogDefaultExampleLoader(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountGo.path,
+    go,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse('$_standalonePath?sdk=go&default=true'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testContentExampleLoader(WidgetTester wt) async {
+  final content = await Examples.getFullTextByPath(ExampleGo.path);
+
+  for (final path in _paths) {
+    final files = jsonEncode([
+      {'content': content, 'isMain': true}
+    ]);
+    await wt.navigateAndSettle(
+      Uri.parse(
+        '$path?sdk=go&files=${Uri.encodeComponent(files)}&$_fullViewOptions',
+      ),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.fullVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testEmptyExampleLoader(WidgetTester wt) async {
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&empty=true'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, '');
+  }
+}
+
+Future<void> _testHttpExampleLoader(WidgetTester wt) async {
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_fullViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.fullVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testStandardExampleLoader(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    WordCountGo.path,
+    go,
+  );
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&path=${WordCountGo.dbPath}'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, visibleText);
+  }
+}
+
+Future<void> _testUserSharedExampleLoader(WidgetTester wt) async {
+  final template = await Examples.getFullTextByPath(ExampleGo.path);
+  final tail = '\n//${DateTime.now().millisecondsSinceEpoch}';
+  final content = '$template$tail';
+
+  final exampleCache = wt.findPlaygroundController().exampleCache;
+  final snippetId = await exampleCache.saveSnippet(
+    files: [SnippetFile(content: content, isMain: false, name: 'name')],
+    sdk: Sdk.go,
+    pipelineOptions: 'a=b',
+  );
+
+  print('Created user-shared example ID: $snippetId');
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&shared=$snippetId&$_fullViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, '${ExampleGo.fullVisibleText}$tail');
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testMultipleExamples(WidgetTester wt) async {
+  final javaVisibleText = await Examples.getVisibleTextByPath(
+    AggregationMaxJava.path,
+    java,
+  );
+  const goVisibleText = ExampleGo.fullVisibleText;
+
+  final examplesList = [
+    {
+      'sdk': Sdk.java.id,
+      'path': AggregationMaxJava.dbPath,
+      ..._fullViewOptionsMap,
+    },
+    {
+      'sdk': Sdk.go.id,
+      'url': ExampleGo.url,
+      ..._fullViewOptionsMap,
+    },
+  ];
+  final examples = jsonEncode(examplesList);
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&examples=$examples'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, goVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    final playgroundController = wt.findPlaygroundController();
+    playgroundController.setSdk(Sdk.java);
+    await wt.pumpAndSettle();
+
+    _expectSdk(wt, Sdk.java);
+    _expectText(wt, javaVisibleText);
+  }
+}
+
+void _expectSdk(WidgetTester wt, Sdk sdk) {
+  final controller = wt.findPlaygroundController();
+  expect(controller.sdk, sdk);
+}
+
+void _expectText(WidgetTester wt, String visibleText) {
+  final controller = wt.findOneCodeController();
+  expect(controller.text, visibleText);
+}
+
+/// Checks that the example contains:
+/// - at least two 'editable' substrings, and they are editable,
+/// - at least two 'readonly' substrings, and they are read-only.
+Future<void> _expectEditableAndReadOnly(WidgetTester wt) async {
+  final controller = wt.findOneCodeController();
+
+  for (int i = 0; i < 2; i++) {
+    controller.value = controller.value.select('editable')!;
+
+    final edited1 = controller.value.typed('');

Review Comment:
   edited1?



##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';
+const _standalonePath = '/';
+const _paths = [_embeddedPath, _standalonePath];
+
+const _fullViewOptionsMap = {
+  'readonly': 'readonly1,readonly2',
+  'unfold': 'unfold1,unfold2',
+};
+final _croppedViewOptionsMap = {
+  ..._fullViewOptionsMap,
+  'show': 'show',
+};
+
+final _fullViewOptions = _mapToQueryString(_fullViewOptionsMap);
+final _croppedViewOptions = _mapToQueryString(_croppedViewOptionsMap);
+
+Future<void> _testEmbeddedRoot(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse(_embeddedPath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneRoot(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountJava.path,
+    java,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse(_standalonePath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testEmbeddedSdkOnly(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse('$_embeddedPath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneSdkOnly(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountGo.path,
+    go,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse('$_standalonePath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testCatalogDefaultExampleLoader(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountGo.path,
+    go,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse('$_standalonePath?sdk=go&default=true'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testContentExampleLoader(WidgetTester wt) async {
+  final content = await Examples.getFullTextByPath(ExampleGo.path);
+
+  for (final path in _paths) {
+    final files = jsonEncode([
+      {'content': content, 'isMain': true}
+    ]);
+    await wt.navigateAndSettle(
+      Uri.parse(
+        '$path?sdk=go&files=${Uri.encodeComponent(files)}&$_fullViewOptions',
+      ),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.fullVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testEmptyExampleLoader(WidgetTester wt) async {
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&empty=true'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, '');
+  }
+}
+
+Future<void> _testHttpExampleLoader(WidgetTester wt) async {
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_fullViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.fullVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testStandardExampleLoader(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    WordCountGo.path,
+    go,
+  );
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&path=${WordCountGo.dbPath}'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, visibleText);
+  }
+}
+
+Future<void> _testUserSharedExampleLoader(WidgetTester wt) async {
+  final template = await Examples.getFullTextByPath(ExampleGo.path);
+  final tail = '\n//${DateTime.now().millisecondsSinceEpoch}';
+  final content = '$template$tail';
+
+  final exampleCache = wt.findPlaygroundController().exampleCache;
+  final snippetId = await exampleCache.saveSnippet(
+    files: [SnippetFile(content: content, isMain: false, name: 'name')],
+    sdk: Sdk.go,
+    pipelineOptions: 'a=b',
+  );
+
+  print('Created user-shared example ID: $snippetId');
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&shared=$snippetId&$_fullViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, '${ExampleGo.fullVisibleText}$tail');
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testMultipleExamples(WidgetTester wt) async {
+  final javaVisibleText = await Examples.getVisibleTextByPath(
+    AggregationMaxJava.path,
+    java,
+  );
+  const goVisibleText = ExampleGo.fullVisibleText;
+
+  final examplesList = [
+    {
+      'sdk': Sdk.java.id,
+      'path': AggregationMaxJava.dbPath,
+      ..._fullViewOptionsMap,
+    },
+    {
+      'sdk': Sdk.go.id,
+      'url': ExampleGo.url,
+      ..._fullViewOptionsMap,
+    },
+  ];
+  final examples = jsonEncode(examplesList);
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&examples=$examples'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, goVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    final playgroundController = wt.findPlaygroundController();
+    playgroundController.setSdk(Sdk.java);
+    await wt.pumpAndSettle();
+
+    _expectSdk(wt, Sdk.java);
+    _expectText(wt, javaVisibleText);
+  }
+}
+
+void _expectSdk(WidgetTester wt, Sdk sdk) {
+  final controller = wt.findPlaygroundController();
+  expect(controller.sdk, sdk);
+}
+
+void _expectText(WidgetTester wt, String visibleText) {
+  final controller = wt.findOneCodeController();
+  expect(controller.text, visibleText);
+}
+
+/// Checks that the example contains:
+/// - at least two 'editable' substrings, and they are editable,
+/// - at least two 'readonly' substrings, and they are read-only.
+Future<void> _expectEditableAndReadOnly(WidgetTester wt) async {
+  final controller = wt.findOneCodeController();
+
+  for (int i = 0; i < 2; i++) {
+    controller.value = controller.value.select('editable')!;
+
+    final edited1 = controller.value.typed('');
+    controller.value = edited1;
+    await wt.pumpAndSettle();
+    expect(controller.value, edited1, reason: 'Cannot edit an editable line');
+
+    controller.value = controller.value.select('readonly')!.typed('');
+    await wt.pumpAndSettle();
+    expect(controller.value, edited1, reason: 'Can edit a read-only line');
+  }
+}
+
+/// Checks that every character in the editor is read-only.
+void _expectReadOnly(WidgetTester wt) {
+  final controller = wt.findOneCodeController();
+  final value = controller.value;
+  final text = controller.text;
+
+  for (int i = text.length; --i >= 0;) {

Review Comment:
   better to move decrement to third part of cycle



##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';
+const _standalonePath = '/';
+const _paths = [_embeddedPath, _standalonePath];
+
+const _fullViewOptionsMap = {
+  'readonly': 'readonly1,readonly2',
+  'unfold': 'unfold1,unfold2',
+};
+final _croppedViewOptionsMap = {
+  ..._fullViewOptionsMap,
+  'show': 'show',
+};
+
+final _fullViewOptions = _mapToQueryString(_fullViewOptionsMap);
+final _croppedViewOptions = _mapToQueryString(_croppedViewOptionsMap);
+
+Future<void> _testEmbeddedRoot(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse(_embeddedPath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneRoot(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountJava.path,
+    java,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse(_standalonePath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testEmbeddedSdkOnly(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse('$_embeddedPath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneSdkOnly(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountGo.path,
+    go,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse('$_standalonePath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testCatalogDefaultExampleLoader(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountGo.path,
+    go,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse('$_standalonePath?sdk=go&default=true'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testContentExampleLoader(WidgetTester wt) async {
+  final content = await Examples.getFullTextByPath(ExampleGo.path);
+
+  for (final path in _paths) {
+    final files = jsonEncode([
+      {'content': content, 'isMain': true}
+    ]);
+    await wt.navigateAndSettle(
+      Uri.parse(
+        '$path?sdk=go&files=${Uri.encodeComponent(files)}&$_fullViewOptions',
+      ),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.fullVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testEmptyExampleLoader(WidgetTester wt) async {
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&empty=true'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, '');
+  }
+}
+
+Future<void> _testHttpExampleLoader(WidgetTester wt) async {
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_fullViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.fullVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testStandardExampleLoader(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    WordCountGo.path,
+    go,
+  );
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&path=${WordCountGo.dbPath}'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, visibleText);
+  }
+}
+
+Future<void> _testUserSharedExampleLoader(WidgetTester wt) async {
+  final template = await Examples.getFullTextByPath(ExampleGo.path);
+  final tail = '\n//${DateTime.now().millisecondsSinceEpoch}';
+  final content = '$template$tail';
+
+  final exampleCache = wt.findPlaygroundController().exampleCache;
+  final snippetId = await exampleCache.saveSnippet(
+    files: [SnippetFile(content: content, isMain: false, name: 'name')],
+    sdk: Sdk.go,
+    pipelineOptions: 'a=b',
+  );
+
+  print('Created user-shared example ID: $snippetId');
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&shared=$snippetId&$_fullViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, '${ExampleGo.fullVisibleText}$tail');
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testMultipleExamples(WidgetTester wt) async {
+  final javaVisibleText = await Examples.getVisibleTextByPath(
+    AggregationMaxJava.path,
+    java,
+  );
+  const goVisibleText = ExampleGo.fullVisibleText;
+
+  final examplesList = [
+    {
+      'sdk': Sdk.java.id,
+      'path': AggregationMaxJava.dbPath,
+      ..._fullViewOptionsMap,
+    },
+    {
+      'sdk': Sdk.go.id,
+      'url': ExampleGo.url,
+      ..._fullViewOptionsMap,
+    },
+  ];
+  final examples = jsonEncode(examplesList);
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&examples=$examples'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, goVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    final playgroundController = wt.findPlaygroundController();
+    playgroundController.setSdk(Sdk.java);
+    await wt.pumpAndSettle();
+
+    _expectSdk(wt, Sdk.java);
+    _expectText(wt, javaVisibleText);
+  }
+}
+
+void _expectSdk(WidgetTester wt, Sdk sdk) {
+  final controller = wt.findPlaygroundController();
+  expect(controller.sdk, sdk);
+}
+
+void _expectText(WidgetTester wt, String visibleText) {
+  final controller = wt.findOneCodeController();
+  expect(controller.text, visibleText);
+}
+
+/// Checks that the example contains:
+/// - at least two 'editable' substrings, and they are editable,
+/// - at least two 'readonly' substrings, and they are read-only.
+Future<void> _expectEditableAndReadOnly(WidgetTester wt) async {
+  final controller = wt.findOneCodeController();
+
+  for (int i = 0; i < 2; i++) {

Review Comment:
   2 is a magic number here



##########
playground/frontend/playground_components_dev/lib/src/widget_tester.dart:
##########
@@ -50,4 +52,28 @@ extension WidgetTesterExtension on WidgetTester {
     final context = element(find.codeField());
     return context.read<PlaygroundController>();
   }
+
+  Future<void> navigateAndSettle(Uri url) async {
+    print(url);
+    await _navigate(url);
+    await Future.delayed(const Duration(seconds:1));
+    await pumpAndSettle();
+
+    await Future.delayed(const Duration(seconds: 1));
+    await pumpAndSettle();

Review Comment:
   Explain, please. Why is it required?



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


[GitHub] [beam] alexeyinkin commented on pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on PR #25034:
URL: https://github.com/apache/beam/pull/25034#issuecomment-1396404417

   Run Whitespace PreCommit


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


[GitHub] [beam] damondouglas commented on a diff in pull request #25034: Test loading URLs

Posted by "damondouglas (via GitHub)" <gi...@apache.org>.
damondouglas commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1090863370


##########
playground/frontend/README.md:
##########
@@ -205,6 +205,143 @@ To add a new localization (using `fr` as an example):
 
 3. Add the locale to the list in `lib/l10n/l10n.dart`.
 
+## URLs and Embedding
+
+### Linking to a single example
+
+#### 1. Linking to a catalog example by path
+
+`https://play.beam.apache.org/?path=SDK_JAVA/PRECOMPILED_OBJECT_TYPE_KATA/AggregationMax&sdk=java`
+
+Handled by `StandardExampleLoader`.
+
+#### 2. Linking to the default catalog example
+
+`https://play.beam.apache.org/?sdk=python&default=true`
+
+Handled by `CatalogDefaultExampleLoader`.
+
+#### 3. Linking to a user-shared example
+
+`https://play.beam.apache.org/?sdk=java&shared=sdFdNV324HC`
+
+Handled by `UserSharedExampleLoader`.
+
+#### 4. Linking to an example by URL
+
+`https://play.beam.apache.org/?sdk=go&url=https://raw.githubusercontent.com/golang/go/master/src/fmt/format.go`
+
+Handled by `HttpExampleLoader`. The server with the example file must allow
+the cross-origin access. GitHub is known to allow it.
+Some servers may have different cross-origin policies when requested from localhost
+and other domains.
+
+#### 5. Linking to an empty editor
+
+`https://play.beam.apache.org/?sdk=go&empty=true`
+
+Handled by `EmptyExampleLoader`.
+
+### Passing view options
+
+Additional options may be passed with any of the above URL patterns.
+For them to work, the example must contain sections with the following syntax:
+
+```
+// [START section_name]
+void method() {
+...
+}
+// [END section_name]
+```
+
+See more on the syntax and limitations in the
+[README of the editor](https://pub.dev/packages/flutter_code_editor)
+that Playground uses.
+
+These options can be combined.
+
+#### Read-only sections
+
+Add `readonly` parameter with comma-separated section names:
+
+`https://play.beam.apache.org/?sdk=go&url=https://raw.githubusercontent.com/GoogleCloudPlatform/golang-samples/main/iam/snippets/roles_get.go&readonly=iam_get_role`
+
+#### Folding everything except sections
+
+Add `unfold` parameter with comma-separated section names:
+
+`https://play.beam.apache.org/?sdk=go&url=https://raw.githubusercontent.com/GoogleCloudPlatform/golang-samples/main/iam/snippets/roles_get.go&unfold=iam_get_role`
+
+This folds all foldable blocks that do not overlap with
+any of the given section.
+
+#### Hiding everything except a section
+
+Add `show` parameter with a single section name:
+
+`https://play.beam.apache.org/?sdk=go&url=https://raw.githubusercontent.com/GoogleCloudPlatform/golang-samples/main/iam/snippets/roles_get.go&show=iam_get_role`
+
+It is still the whole snippet that is sent for execution although only the given section
+is visible.
+
+This also makes the editor read-only so the user cannot add code that conflicts
+with the hidden text.
+
+### Linking to multiple examples
+
+With the above URLs, when the SDK is switched the following will be shown:
+
+- The catalog default example for the new SDK in the standalone playground.
+- The empty editor for the new SDK in the embedded playground.
+
+This can be changed by linking to multiple examples, up to one per SDK.
+
+For this purpose, make a JSON array with any combination of parameters that
+are allowed for loading single examples, for instance:
+
+```json
+[
+   {
+      "sdk": "java",
+      "path": "SDK_JAVA/PRECOMPILED_OBJECT_TYPE_KATA/AggregationMax"
+   },
+   {
+      "sdk": "go",
+      "url": "https://raw.githubusercontent.com/GoogleCloudPlatform/golang-samples/main/iam/snippets/roles_get.go",
+      "readonly": "iam_get_role"
+   }
+]
+```
+
+This starts with the Go example loaded from the URL.
+If SDK is then switched to Java, the `AggregationMax` catalog example is loaded for it.
+If SDK is switched to any other one, the default example for that SDK is loaded
+because no override was provided.
+
+`https://play.beam.apache.org/?sdk=go&examples=[{"sdk":"java","path":"SDK_JAVA/PRECOMPILED_OBJECT_TYPE_KATA/AggregationMax"},{"sdk":"go","url":"https://raw.githubusercontent.com/GoogleCloudPlatform/golang-samples/main/iam/snippets/roles_get.go","readonly":"iam_get_role"}]`

Review Comment:
   Tried this when running this branch locally and saw errors:
   ```
   The processing has started
   error: 7ac176f7-0249-4c06-86ea-c553b0a0f311.go:1:1: expected 'package', found 'EOF'
   
   output: 7ac176f7-0249-4c06-86ea-c553b0a0f311.go:1:1: expected 'package', found 'EOF'
   ```
   
   On the terminal I saw:
   ```
   Error: Assertion failed: flutter/lib/src/painting/text_painter.dart:975:12
   ```



##########
playground/frontend/build.gradle:
##########
@@ -183,16 +183,30 @@ ext.deleteFilesByRegExp = { re ->
 }
 
 tasks.register("integrationTest") {

Review Comment:
   Ran this command after following README instructions to download chromedriver.  Naturally as I was unable to run locally, the integration tests froze on the first URL.



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


[GitHub] [beam] alexeyinkin commented on pull request #25034: Test loading URLs

Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on PR #25034:
URL: https://github.com/apache/beam/pull/25034#issuecomment-1428331772

   @damondouglas Here are successful runs of this test in a GitHub workflow:
   https://github.com/apache/beam/actions/runs/4165846194/jobs/7209404002
   https://github.com/akvelon/beam/actions/runs/4165649892/jobs/7208951699
   
   We run integration tests against a deployed staging backend which currently corresponds to copying `config.example.dart`. This way there are less variables in the way.
   
   `dockerComposeLocalUp` should potentially work too, but we do not use and maintain it anymore since we have staging and the backend containers change rapidly. I have added this disclaimer to the README.
   
   In case we ever need an undeployed Python runner for local frontend development we will investigate and address this error if it persists. Otherwise please use the backend from `config.example.dart`.


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


[GitHub] [beam] pabloem commented on pull request #25034: Test loading URLs

Posted by "pabloem (via GitHub)" <gi...@apache.org>.
pabloem commented on PR #25034:
URL: https://github.com/apache/beam/pull/25034#issuecomment-1430157515

   lgtm thanks


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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073307088


##########
playground/frontend/lib/main.dart:
##########
@@ -43,7 +43,7 @@ void main() async {
   // Router API specific initialization.
   final pageStack = GetIt.instance.get<PageStack>();
   final routerDelegate = BeamRouterDelegate(pageStack);
-  final routeInformationParser = PlaygroundRouteInformationParser();
+  final rip = GetIt.instance.get<PageStackRouteInformationParser>();

Review Comment:
   `+`



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


[GitHub] [beam] alexeyinkin commented on pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on PR #25034:
URL: https://github.com/apache/beam/pull/25034#issuecomment-1396673493

   R: @damondouglas 


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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1104767884


##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;
+
+  /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`.
+  final String? croppedFoldedVisibleText;
+
+  /// Visible text when using `foldOutsideSections()`.
+  final String? foldedVisibleText;
+
+  final List<String>? outputContains;
+  final String? outputTail;
+
+  bool get hasGraphTab => !_noGraphSdks.contains(sdk);
+
+  /// The URL to view the file raw content on GitHub.
+  String get url => '$_schemaAndHost$repositoryAndRef$path';
+
+  Future<String> getVisibleText() async {
+    final content = await getFullText();
+
+    return foldLicenseAndImports(content, sdk.highlightMode!);
+  }
+
+  Future<String> getFullText() async {
+    final response = await http.get(Uri.parse(url));
+    return cutTagComments(response.body);
+  }
+
+  static String cutTagComments(String code) {

Review Comment:
   `+`



##########
playground/frontend/playground_components_dev/lib/src/examples/go/example.dart:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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:playground_components/playground_components.dart';
+
+import '../example_descriptor.dart';
+
+const goExample = ExampleDescriptor(

Review Comment:
   `+`



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073570129


##########
playground/frontend/playground_components_dev/lib/src/widget_tester.dart:
##########
@@ -50,4 +52,28 @@ extension WidgetTesterExtension on WidgetTester {
     final context = element(find.codeField());
     return context.read<PlaygroundController>();
   }
+
+  Future<void> navigateAndSettle(Uri url) async {
+    print(url);
+    await _navigate(url);
+    await Future.delayed(const Duration(seconds:1));

Review Comment:
   `+`



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073665636


##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';
+const _standalonePath = '/';
+const _paths = [_embeddedPath, _standalonePath];
+
+const _fullViewOptionsMap = {
+  'readonly': 'readonly1,readonly2',
+  'unfold': 'unfold1,unfold2',
+};
+final _croppedViewOptionsMap = {
+  ..._fullViewOptionsMap,
+  'show': 'show',
+};
+
+final _fullViewOptions = _mapToQueryString(_fullViewOptionsMap);
+final _croppedViewOptions = _mapToQueryString(_croppedViewOptionsMap);
+
+Future<void> _testEmbeddedRoot(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse(_embeddedPath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneRoot(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountJava.path,
+    java,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse(_standalonePath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testEmbeddedSdkOnly(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse('$_embeddedPath?sdk=go'),

Review Comment:
   Deleted.



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


[GitHub] [beam] alexeyinkin commented on pull request #25034: Test loading URLs

Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on PR #25034:
URL: https://github.com/apache/beam/pull/25034#issuecomment-1413202996

   Also do not upgrade to Flutter 3.7 for a while. It has breaking changes and issues.


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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073274500


##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';

Review Comment:
   I prefer two sources of truth here because the literal "/embedded" will spread over the Internet. It we change the constant in the Path class, we will not notice the regression.



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073274729


##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';

Review Comment:
   `+`



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073570670


##########
playground/frontend/playground_components_dev/lib/src/widget_tester.dart:
##########
@@ -50,4 +52,28 @@ extension WidgetTesterExtension on WidgetTester {
     final context = element(find.codeField());
     return context.read<PlaygroundController>();
   }
+
+  Future<void> navigateAndSettle(Uri url) async {
+    print(url);

Review Comment:
   Edited.



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073665331


##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';
+const _standalonePath = '/';
+const _paths = [_embeddedPath, _standalonePath];
+
+const _fullViewOptionsMap = {
+  'readonly': 'readonly1,readonly2',
+  'unfold': 'unfold1,unfold2',
+};
+final _croppedViewOptionsMap = {
+  ..._fullViewOptionsMap,
+  'show': 'show',
+};
+
+final _fullViewOptions = _mapToQueryString(_fullViewOptionsMap);
+final _croppedViewOptions = _mapToQueryString(_croppedViewOptionsMap);
+
+Future<void> _testEmbeddedRoot(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse(_embeddedPath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneRoot(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountJava.path,

Review Comment:
   I went from example constants to `ExampleDescriptor` instances. Later if we need to loop through SDKs, it will be easier this way.
   
   I do not see a room for factories because we have everything hardcoded.



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073529591


##########
playground/frontend/playground_components_dev/lib/src/widget_tester.dart:
##########
@@ -50,4 +52,28 @@ extension WidgetTesterExtension on WidgetTester {
     final context = element(find.codeField());
     return context.read<PlaygroundController>();
   }
+
+  Future<void> navigateAndSettle(Uri url) async {
+    print(url);
+    await _navigate(url);
+    await Future.delayed(const Duration(seconds:1));
+    await pumpAndSettle();
+
+    await Future.delayed(const Duration(seconds: 1));
+    await pumpAndSettle();

Review Comment:
   Happened to work with a 2-second delay and a single `pumpAndSettle()`.



##########
playground/frontend/playground_components_dev/lib/src/widget_tester.dart:
##########
@@ -50,4 +52,28 @@ extension WidgetTesterExtension on WidgetTester {
     final context = element(find.codeField());
     return context.read<PlaygroundController>();
   }
+
+  Future<void> navigateAndSettle(Uri url) async {
+    print(url);
+    await _navigate(url);
+    await Future.delayed(const Duration(seconds:1));
+    await pumpAndSettle();
+
+    await Future.delayed(const Duration(seconds: 1));
+    await pumpAndSettle();
+  }
+
+  Future<void> _navigate(Uri uri) async {
+    final rip = GetIt.instance.get<PageStackRouteInformationParser>();

Review Comment:
   `+`



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1104767317


##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;
+
+  /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`.
+  final String? croppedFoldedVisibleText;
+
+  /// Visible text when using `foldOutsideSections()`.
+  final String? foldedVisibleText;
+
+  final List<String>? outputContains;
+  final String? outputTail;

Review Comment:
   `+`



##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;
+
+  /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`.
+  final String? croppedFoldedVisibleText;
+
+  /// Visible text when using `foldOutsideSections()`.
+  final String? foldedVisibleText;
+
+  final List<String>? outputContains;
+  final String? outputTail;
+
+  bool get hasGraphTab => !_noGraphSdks.contains(sdk);

Review Comment:
   `+`



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073290684


##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';
+const _standalonePath = '/';
+const _paths = [_embeddedPath, _standalonePath];
+
+const _fullViewOptionsMap = {
+  'readonly': 'readonly1,readonly2',
+  'unfold': 'unfold1,unfold2',
+};
+final _croppedViewOptionsMap = {
+  ..._fullViewOptionsMap,
+  'show': 'show',
+};
+
+final _fullViewOptions = _mapToQueryString(_fullViewOptionsMap);
+final _croppedViewOptions = _mapToQueryString(_croppedViewOptionsMap);
+
+Future<void> _testEmbeddedRoot(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse(_embeddedPath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneRoot(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountJava.path,
+    java,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse(_standalonePath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testEmbeddedSdkOnly(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse('$_embeddedPath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneSdkOnly(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountGo.path,
+    go,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse('$_standalonePath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testCatalogDefaultExampleLoader(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountGo.path,
+    go,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse('$_standalonePath?sdk=go&default=true'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testContentExampleLoader(WidgetTester wt) async {
+  final content = await Examples.getFullTextByPath(ExampleGo.path);
+
+  for (final path in _paths) {
+    final files = jsonEncode([
+      {'content': content, 'isMain': true}
+    ]);
+    await wt.navigateAndSettle(
+      Uri.parse(
+        '$path?sdk=go&files=${Uri.encodeComponent(files)}&$_fullViewOptions',
+      ),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.fullVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testEmptyExampleLoader(WidgetTester wt) async {
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&empty=true'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, '');
+  }
+}
+
+Future<void> _testHttpExampleLoader(WidgetTester wt) async {
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_fullViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.fullVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testStandardExampleLoader(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    WordCountGo.path,
+    go,
+  );
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&path=${WordCountGo.dbPath}'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, visibleText);
+  }
+}
+
+Future<void> _testUserSharedExampleLoader(WidgetTester wt) async {
+  final template = await Examples.getFullTextByPath(ExampleGo.path);
+  final tail = '\n//${DateTime.now().millisecondsSinceEpoch}';
+  final content = '$template$tail';
+
+  final exampleCache = wt.findPlaygroundController().exampleCache;
+  final snippetId = await exampleCache.saveSnippet(
+    files: [SnippetFile(content: content, isMain: false, name: 'name')],
+    sdk: Sdk.go,
+    pipelineOptions: 'a=b',
+  );
+
+  print('Created user-shared example ID: $snippetId');
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&shared=$snippetId&$_fullViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, '${ExampleGo.fullVisibleText}$tail');
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testMultipleExamples(WidgetTester wt) async {
+  final javaVisibleText = await Examples.getVisibleTextByPath(
+    AggregationMaxJava.path,
+    java,
+  );
+  const goVisibleText = ExampleGo.fullVisibleText;
+
+  final examplesList = [
+    {
+      'sdk': Sdk.java.id,
+      'path': AggregationMaxJava.dbPath,
+      ..._fullViewOptionsMap,
+    },
+    {
+      'sdk': Sdk.go.id,
+      'url': ExampleGo.url,
+      ..._fullViewOptionsMap,
+    },
+  ];
+  final examples = jsonEncode(examplesList);
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&examples=$examples'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, goVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    final playgroundController = wt.findPlaygroundController();
+    playgroundController.setSdk(Sdk.java);
+    await wt.pumpAndSettle();
+
+    _expectSdk(wt, Sdk.java);
+    _expectText(wt, javaVisibleText);
+  }
+}
+
+void _expectSdk(WidgetTester wt, Sdk sdk) {
+  final controller = wt.findPlaygroundController();
+  expect(controller.sdk, sdk);
+}
+
+void _expectText(WidgetTester wt, String visibleText) {
+  final controller = wt.findOneCodeController();
+  expect(controller.text, visibleText);
+}
+
+/// Checks that the example contains:
+/// - at least two 'editable' substrings, and they are editable,
+/// - at least two 'readonly' substrings, and they are read-only.
+Future<void> _expectEditableAndReadOnly(WidgetTester wt) async {
+  final controller = wt.findOneCodeController();
+
+  for (int i = 0; i < 2; i++) {
+    controller.value = controller.value.select('editable')!;
+
+    final edited1 = controller.value.typed('');

Review Comment:
   Fixed.



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


[GitHub] [beam] damondouglas commented on a diff in pull request #25034: Test loading URLs

Posted by "damondouglas (via GitHub)" <gi...@apache.org>.
damondouglas commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1097934897


##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;

Review Comment:
   Comment?



##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;
+
+  /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`.
+  final String? croppedFoldedVisibleText;
+
+  /// Visible text when using `foldOutsideSections()`.
+  final String? foldedVisibleText;
+
+  final List<String>? outputContains;
+  final String? outputTail;

Review Comment:
   Comment?



##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;
+
+  /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`.
+  final String? croppedFoldedVisibleText;
+
+  /// Visible text when using `foldOutsideSections()`.
+  final String? foldedVisibleText;
+
+  final List<String>? outputContains;
+  final String? outputTail;
+
+  bool get hasGraphTab => !_noGraphSdks.contains(sdk);
+
+  /// The URL to view the file raw content on GitHub.
+  String get url => '$_schemaAndHost$repositoryAndRef$path';
+
+  Future<String> getVisibleText() async {
+    final content = await getFullText();
+
+    return foldLicenseAndImports(content, sdk.highlightMode!);
+  }
+
+  Future<String> getFullText() async {
+    final response = await http.get(Uri.parse(url));
+    return cutTagComments(response.body);
+  }
+
+  static String cutTagComments(String code) {

Review Comment:
   Comment?



##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;
+
+  /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`.
+  final String? croppedFoldedVisibleText;
+
+  /// Visible text when using `foldOutsideSections()`.
+  final String? foldedVisibleText;
+
+  final List<String>? outputContains;
+  final String? outputTail;
+
+  bool get hasGraphTab => !_noGraphSdks.contains(sdk);
+
+  /// The URL to view the file raw content on GitHub.
+  String get url => '$_schemaAndHost$repositoryAndRef$path';
+
+  Future<String> getVisibleText() async {
+    final content = await getFullText();
+
+    return foldLicenseAndImports(content, sdk.highlightMode!);
+  }
+
+  Future<String> getFullText() async {

Review Comment:
   Comment?



##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;

Review Comment:
   Comment?



##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;
+
+  /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`.
+  final String? croppedFoldedVisibleText;
+
+  /// Visible text when using `foldOutsideSections()`.
+  final String? foldedVisibleText;
+
+  final List<String>? outputContains;
+  final String? outputTail;
+
+  bool get hasGraphTab => !_noGraphSdks.contains(sdk);

Review Comment:
   Comment?



##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;
+
+  /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`.
+  final String? croppedFoldedVisibleText;
+
+  /// Visible text when using `foldOutsideSections()`.
+  final String? foldedVisibleText;
+
+  final List<String>? outputContains;

Review Comment:
   Comment?



##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;
+
+  /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`.
+  final String? croppedFoldedVisibleText;
+
+  /// Visible text when using `foldOutsideSections()`.
+  final String? foldedVisibleText;
+
+  final List<String>? outputContains;
+  final String? outputTail;
+
+  bool get hasGraphTab => !_noGraphSdks.contains(sdk);
+
+  /// The URL to view the file raw content on GitHub.
+  String get url => '$_schemaAndHost$repositoryAndRef$path';
+
+  Future<String> getVisibleText() async {

Review Comment:
   Comment?



##########
playground/frontend/playground_components_dev/lib/src/examples/go/example.dart:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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:playground_components/playground_components.dart';
+
+import '../example_descriptor.dart';
+
+const goExample = ExampleDescriptor(

Review Comment:
   What is this an example of?



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1104767636


##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;
+
+  /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`.
+  final String? croppedFoldedVisibleText;
+
+  /// Visible text when using `foldOutsideSections()`.
+  final String? foldedVisibleText;
+
+  final List<String>? outputContains;
+  final String? outputTail;
+
+  bool get hasGraphTab => !_noGraphSdks.contains(sdk);
+
+  /// The URL to view the file raw content on GitHub.
+  String get url => '$_schemaAndHost$repositoryAndRef$path';
+
+  Future<String> getVisibleText() async {

Review Comment:
   `+`



##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;
+
+  /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`.
+  final String? croppedFoldedVisibleText;
+
+  /// Visible text when using `foldOutsideSections()`.
+  final String? foldedVisibleText;
+
+  final List<String>? outputContains;
+  final String? outputTail;
+
+  bool get hasGraphTab => !_noGraphSdks.contains(sdk);
+
+  /// The URL to view the file raw content on GitHub.
+  String get url => '$_schemaAndHost$repositoryAndRef$path';
+
+  Future<String> getVisibleText() async {
+    final content = await getFullText();
+
+    return foldLicenseAndImports(content, sdk.highlightMode!);
+  }
+
+  Future<String> getFullText() async {

Review Comment:
   `+`



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073274729


##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';

Review Comment:
   `+`



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073573755


##########
playground/frontend/playground_components_dev/lib/src/examples/examples.dart:
##########
@@ -19,17 +19,24 @@
 import 'package:highlight/highlight_core.dart';
 import 'package:http/http.dart' as http;
 
-import 'code.dart';
+import '../code.dart';
 
 class Examples {
-  static const _repoAndBranch = 'apache/beam/master';
+  static const urlPrefix = '$_schemaAndHost$_repoAndBranch';
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+  static const _repoAndBranch = 'akvelon/beam/issue24959_test-loading-url';
+
+  // static const _repoAndBranch = 'apache/beam/master';

Review Comment:
   Fixed.



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


[GitHub] [beam] alexeyinkin commented on pull request #25034: Test loading URLs

Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on PR #25034:
URL: https://github.com/apache/beam/pull/25034#issuecomment-1410284312

   @damondouglas the problem was with the backend URLs. In `lib/config.example.dart' they were of the current production which does not support the recent features. I have updated them to point to the current staging. All tests passed then. Please overwrite your `lib/config.g.dart` with the content of the new `config.example.dart`. For me all tests worked after that.
   
   Note that running `MinimalWordCount` in Java currently takes a few minutes when not cached -- just in case you think the test is stuck.
   
   Also with this test I often forget to change the branch as specified in the first message here so I better mention this again.


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


[GitHub] [beam] pabloem merged pull request #25034: Test loading URLs

Posted by "pabloem (via GitHub)" <gi...@apache.org>.
pabloem merged PR #25034:
URL: https://github.com/apache/beam/pull/25034


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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1104766650


##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;

Review Comment:
   `+`



##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;

Review Comment:
   `+`



##########
playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+// ignore_for_file: prefer_interpolation_to_compose_strings
+
+import 'package:http/http.dart' as http;
+import 'package:playground_components/playground_components.dart';
+
+import '../code.dart';
+
+const _noGraphSdks = [Sdk.go, Sdk.scio];
+
+/// Describes an example for the purpose of integration tests.
+class ExampleDescriptor {
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+
+  static const _defaultRepositoryAndRef = 'apache/beam/master';
+  // If running before this is deployed, change to this:
+  // static const _defaultRepositoryAndRef =
+  //     'akvelon/beam/issue24959_test-loading-url';
+
+  const ExampleDescriptor(
+    this.name, {
+    required this.dbPath,
+    required this.path,
+    required this.sdk,
+    this.contextLine1Based,
+    this.croppedFoldedVisibleText,
+    this.foldedVisibleText,
+    this.outputContains,
+    this.outputTail,
+    this.repositoryAndRef = _defaultRepositoryAndRef,
+  });
+
+  /// 1-based line index to set cursor to.
+  final int? contextLine1Based;
+
+  /// A token to retrieve the example from server.
+  final String dbPath;
+
+  /// Name as shown in the dropdown.
+  final String name;
+
+  /// File path relative to the repository root, starting with `/`.
+  final String path;
+
+  final String repositoryAndRef;
+
+  final Sdk sdk;
+
+  /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`.
+  final String? croppedFoldedVisibleText;
+
+  /// Visible text when using `foldOutsideSections()`.
+  final String? foldedVisibleText;
+
+  final List<String>? outputContains;

Review Comment:
   `+`



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073273148


##########
playground/frontend/build.gradle:
##########
@@ -183,10 +183,17 @@ ext.deleteFilesByRegExp = { re ->
 }
 
 tasks.register("integrationTest") {
+  dependsOn("integrationTest_initial_urls")
   dependsOn("integrationTest_standalone_change_example_sdk_run")
   dependsOn("integrationTest_standalone_miscellaneous_ui")
 }
 
+tasks.register("integrationTest_initial_urls") {

Review Comment:
   `standalone` is for tests that check the standalone playground. It is also to remind to mirror them for the embedded playground. This test checks both and thus no prefix.



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073293783


##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';
+const _standalonePath = '/';
+const _paths = [_embeddedPath, _standalonePath];
+
+const _fullViewOptionsMap = {
+  'readonly': 'readonly1,readonly2',
+  'unfold': 'unfold1,unfold2',
+};
+final _croppedViewOptionsMap = {
+  ..._fullViewOptionsMap,
+  'show': 'show',
+};
+
+final _fullViewOptions = _mapToQueryString(_fullViewOptionsMap);
+final _croppedViewOptions = _mapToQueryString(_croppedViewOptionsMap);
+
+Future<void> _testEmbeddedRoot(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse(_embeddedPath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneRoot(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountJava.path,
+    java,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse(_standalonePath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testEmbeddedSdkOnly(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse('$_embeddedPath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneSdkOnly(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountGo.path,
+    go,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse('$_standalonePath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testCatalogDefaultExampleLoader(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountGo.path,
+    go,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse('$_standalonePath?sdk=go&default=true'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testContentExampleLoader(WidgetTester wt) async {
+  final content = await Examples.getFullTextByPath(ExampleGo.path);
+
+  for (final path in _paths) {
+    final files = jsonEncode([
+      {'content': content, 'isMain': true}
+    ]);
+    await wt.navigateAndSettle(
+      Uri.parse(
+        '$path?sdk=go&files=${Uri.encodeComponent(files)}&$_fullViewOptions',
+      ),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.fullVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testEmptyExampleLoader(WidgetTester wt) async {
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&empty=true'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, '');
+  }
+}
+
+Future<void> _testHttpExampleLoader(WidgetTester wt) async {
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_fullViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.fullVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testStandardExampleLoader(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    WordCountGo.path,
+    go,
+  );
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&path=${WordCountGo.dbPath}'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, visibleText);
+  }
+}
+
+Future<void> _testUserSharedExampleLoader(WidgetTester wt) async {
+  final template = await Examples.getFullTextByPath(ExampleGo.path);
+  final tail = '\n//${DateTime.now().millisecondsSinceEpoch}';
+  final content = '$template$tail';
+
+  final exampleCache = wt.findPlaygroundController().exampleCache;
+  final snippetId = await exampleCache.saveSnippet(
+    files: [SnippetFile(content: content, isMain: false, name: 'name')],
+    sdk: Sdk.go,
+    pipelineOptions: 'a=b',
+  );
+
+  print('Created user-shared example ID: $snippetId');
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&shared=$snippetId&$_fullViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, '${ExampleGo.fullVisibleText}$tail');
+    await _expectEditableAndReadOnly(wt);
+
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&url=${ExampleGo.url}&$_croppedViewOptions'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, ExampleGo.croppedVisibleText);
+    _expectReadOnly(wt);
+  }
+}
+
+Future<void> _testMultipleExamples(WidgetTester wt) async {
+  final javaVisibleText = await Examples.getVisibleTextByPath(
+    AggregationMaxJava.path,
+    java,
+  );
+  const goVisibleText = ExampleGo.fullVisibleText;
+
+  final examplesList = [
+    {
+      'sdk': Sdk.java.id,
+      'path': AggregationMaxJava.dbPath,
+      ..._fullViewOptionsMap,
+    },
+    {
+      'sdk': Sdk.go.id,
+      'url': ExampleGo.url,
+      ..._fullViewOptionsMap,
+    },
+  ];
+  final examples = jsonEncode(examplesList);
+
+  for (final path in _paths) {
+    await wt.navigateAndSettle(
+      Uri.parse('$path?sdk=go&examples=$examples'),
+    );
+    _expectSdk(wt, Sdk.go);
+    _expectText(wt, goVisibleText);
+    await _expectEditableAndReadOnly(wt);
+
+    final playgroundController = wt.findPlaygroundController();
+    playgroundController.setSdk(Sdk.java);
+    await wt.pumpAndSettle();
+
+    _expectSdk(wt, Sdk.java);
+    _expectText(wt, javaVisibleText);
+  }
+}
+
+void _expectSdk(WidgetTester wt, Sdk sdk) {
+  final controller = wt.findPlaygroundController();
+  expect(controller.sdk, sdk);
+}
+
+void _expectText(WidgetTester wt, String visibleText) {
+  final controller = wt.findOneCodeController();
+  expect(controller.text, visibleText);
+}
+
+/// Checks that the example contains:
+/// - at least two 'editable' substrings, and they are editable,
+/// - at least two 'readonly' substrings, and they are read-only.
+Future<void> _expectEditableAndReadOnly(WidgetTester wt) async {
+  final controller = wt.findOneCodeController();
+
+  for (int i = 0; i < 2; i++) {
+    controller.value = controller.value.select('editable')!;
+
+    final edited1 = controller.value.typed('');
+    controller.value = edited1;
+    await wt.pumpAndSettle();
+    expect(controller.value, edited1, reason: 'Cannot edit an editable line');
+
+    controller.value = controller.value.select('readonly')!.typed('');
+    await wt.pumpAndSettle();
+    expect(controller.value, edited1, reason: 'Can edit a read-only line');
+  }
+}
+
+/// Checks that every character in the editor is read-only.
+void _expectReadOnly(WidgetTester wt) {
+  final controller = wt.findOneCodeController();
+  final value = controller.value;
+  final text = controller.text;
+
+  for (int i = text.length; --i >= 0;) {

Review Comment:
   This is the standard form of running something `n` times backwards:
   
   ```dart
   for (int i = n; --i >= 0;) {
   }
   ```
   
   Once learned, it is very easy to recognize. Moving the decrement will require this:
   
   ```dart
   for (int i = n - 1; i >= 0; i--) {
   }
   ```
   
   which is harder to read.



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


[GitHub] [beam] nausharipov commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
nausharipov commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073335908


##########
playground/frontend/playground_components_dev/lib/src/widget_tester.dart:
##########
@@ -50,4 +52,28 @@ extension WidgetTesterExtension on WidgetTester {
     final context = element(find.codeField());
     return context.read<PlaygroundController>();
   }
+
+  Future<void> navigateAndSettle(Uri url) async {
+    print(url);

Review Comment:
   This unnamed print will be hard to find.



##########
playground/frontend/playground_components_dev/lib/src/examples/examples.dart:
##########
@@ -19,17 +19,24 @@
 import 'package:highlight/highlight_core.dart';
 import 'package:http/http.dart' as http;
 
-import 'code.dart';
+import '../code.dart';
 
 class Examples {
-  static const _repoAndBranch = 'apache/beam/master';
+  static const urlPrefix = '$_schemaAndHost$_repoAndBranch';
+  static const _schemaAndHost = 'https://raw.githubusercontent.com/';
+  static const _repoAndBranch = 'akvelon/beam/issue24959_test-loading-url';
+
+  // static const _repoAndBranch = 'apache/beam/master';

Review Comment:
   Is it commented deliberately?



##########
playground/frontend/playground_components_dev/lib/src/widget_tester.dart:
##########
@@ -50,4 +52,28 @@ extension WidgetTesterExtension on WidgetTester {
     final context = element(find.codeField());
     return context.read<PlaygroundController>();
   }
+
+  Future<void> navigateAndSettle(Uri url) async {
+    print(url);
+    await _navigate(url);
+    await Future.delayed(const Duration(seconds:1));

Review Comment:
   `seconds:1` isn't formatted.



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


[GitHub] [beam] alexeyinkin commented on a diff in pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1073286170


##########
playground/frontend/integration_test/initial_urls_test.dart:
##########
@@ -0,0 +1,315 @@
+/*
+ * 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 'dart:convert';
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_code_editor/flutter_code_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:highlight/languages/go.dart';
+import 'package:highlight/languages/java.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 'common/common.dart';
+
+// This test loads the app with most of the startup URL combinations.
+// They cannot be tested directly due to a Flutter bug:
+//     https://github.com/flutter/flutter/issues/118028
+// So the test performs in-app navigation to these URLs.
+// Many state objects are re-created this way, but not all,
+// so the test is not clean.
+
+void main() {
+  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+  testWidgets('Initial URLs', (WidgetTester wt) async {
+    await init(wt);
+
+    await _testEmbeddedRoot(wt);
+    await _testStandaloneRoot(wt);
+
+    await _testEmbeddedSdkOnly(wt);
+    await _testStandaloneSdkOnly(wt);
+
+    await _testCatalogDefaultExampleLoader(wt);
+    await _testContentExampleLoader(wt);
+    await _testEmptyExampleLoader(wt);
+    await _testHttpExampleLoader(wt);
+    await _testStandardExampleLoader(wt);
+    await _testUserSharedExampleLoader(wt);
+
+    await _testMultipleExamples(wt);
+  });
+}
+
+const _embeddedPath = '/embedded';
+const _standalonePath = '/';
+const _paths = [_embeddedPath, _standalonePath];
+
+const _fullViewOptionsMap = {
+  'readonly': 'readonly1,readonly2',
+  'unfold': 'unfold1,unfold2',
+};
+final _croppedViewOptionsMap = {
+  ..._fullViewOptionsMap,
+  'show': 'show',
+};
+
+final _fullViewOptions = _mapToQueryString(_fullViewOptionsMap);
+final _croppedViewOptions = _mapToQueryString(_croppedViewOptionsMap);
+
+Future<void> _testEmbeddedRoot(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse(_embeddedPath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneRoot(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(
+    MinimalWordCountJava.path,
+    java,
+  );
+
+  await wt.navigateAndSettle(
+    Uri.parse(_standalonePath),
+  );
+  _expectSdk(wt, Sdk.java);
+  _expectText(wt, visibleText);
+}
+
+Future<void> _testEmbeddedSdkOnly(WidgetTester wt) async {
+  await wt.navigateAndSettle(
+    Uri.parse('$_embeddedPath?sdk=go'),
+  );
+  _expectSdk(wt, Sdk.go);
+  _expectText(wt, '');
+}
+
+Future<void> _testStandaloneSdkOnly(WidgetTester wt) async {
+  final visibleText = await Examples.getVisibleTextByPath(

Review Comment:
   Which is beneficial. Any automated fetching of defaults leaves accidental changes of defaults undetected.



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


[GitHub] [beam] github-actions[bot] commented on pull request #25034: Test loading URLs

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #25034:
URL: https://github.com/apache/beam/pull/25034#issuecomment-1396676166

   Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control


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