Skip to content

Commit

Permalink
tour of beam integration tests (apache#25925)
Browse files Browse the repository at this point in the history
* Integration test to load the default example of the default SDK and change the example (apache#24730) (apache#24729)

* Fix formatting and README (apache#24730)

* Support collection v1.17.0 (apache#24730)

* LoadingIndicator on chaning examples, remove duplicating licenses (apache#24730)

* Add a missing license header (apache#24730)

* Integration test for changing SDK and running code (apache#24779) (apache#382)

* Integration test for changing SDK and running code (apache#24779)

* Rename an integration test (apache#24779)

* Use enum to switch SDK in integration test (apache#24779)

* Find SDK in a dropdown by key (apache#24779)

* Add a TODO (apache#24779)

* Fix exports (apache#24779)

* Issue24779 integration changing sdk from 24370 (apache#387)

* Integration test for changing SDK and running code (apache#24779)

* Rename an integration test (apache#24779)

* Use enum to switch SDK in integration test (apache#24779)

* Find SDK in a dropdown by key (apache#24779)

* Add a TODO (apache#24779)

* Fix exports (apache#24779)

* Integration tests miscellaneous UI (apache#383)

* miscellaneous ui integration tests

* reverted pubspec.lock

* gradle tasks ordered alhpabetically

* integration tests refactoring

* clean code

* integration tests miscellaneous ui fix pr

* rename method

* added layout adaptivity

* A minor cleanup (apache#24779)

Co-authored-by: Dmitry Repin <[email protected]>

* integration tests run and editing

* example selector test

* minor fixes

* rat

* fix pr

* minor

* minor

* rat

* integration test finder written

* integration test minor fixes

* minor fixes

* removed comment

* minor fixes

* playground integration tests minor fixes

* integration test pumpAnSettleNoException

* integration test shortcut refactor

* integration test another changing shortcuts running

* upgrade to flutter 3.7.1

* workaround comment

* playground frontend updated major versions

* issues 25329 25331 25336

* 25329 extract connectivity extension to separate file

* Upgrade Flutter to 3.7.3 in integration tests (apache#24730)

* Fix integration test (apache#24730)

* fix cors issue and added mouse scroll to tags

* Upgrade Flutter in Dockerfile (apache#24720)

* sorting moved to model

* sorting moved to model

* sorting moved to model

* bugs fix

* issue 25278

* fix pr

* quites fix in en.yaml

* Fix not loading default example (apache#25528)

* fix compile error

* Refactor output tabs, test embedded playground (apache#25136) (apache#439)

* Refactor output tabs, test embedded playground (apache#25136)

* Clean up (apache#25136)

* Change example paths to IDs in integration tests

* issue25640 tob ci

* fix tob ci

* rename ci process

* test add new line to main

* test add new line to main

* commented unit test run

* issue25640 changed server path

* issue25640 tests on welcome page

* deleted config.g.dart

* issue25640 pr fixes

* Update .github/workflows/tour_of_beam_frontend_test.yml

Co-authored-by: alexeyinkin <[email protected]>

* Update learning/tour-of-beam/frontend/integration_test/welcome_page_test.dart

Co-authored-by: alexeyinkin <[email protected]>

* Improve tests (apache#25640)

* issue25640 tour page tests

* pr fix

* removed import

* pr fix

* fix test

* 25640 fixed pubspec.lock

* issue25640 fix readme

* updated readme

* issue25640 fixed after master merge

* issue25483 ToB pipeline options

* removed unnecesary variable

* pr fix

* Update learning/tour-of-beam/frontend/assets/translations/en.yaml

Co-authored-by: alexeyinkin <[email protected]>

* playground hides when snippet does not exists

* pipeline options extracted to playground components

* issue25483 pipeline options

* added errors handling, fix pr

* refactoring

* Revert "refactoring"

This reverts commit 1540961.

* removed unnecessary constants

* playground controller in tour notifier becomes nullable

* playground controller returned to non nullable in tour notifier

* playground controller actions

* removed unnecessary code

* tob scaffold wrapped with animated builder

* minor fixes

* partially fixed tests

* Upgrade flutter_code_editor to v0.2.19 (apache#25640)

* Replace output SelectableText with a CodeField instance (apache#25640)

* Trigger ToB integration tests (apache#25640)

* Clean up (apache#25640)

* Enable manual workflow runs for Playground and ToB integration tests (apache#25640)

---------

Co-authored-by: Alexey Inkin <[email protected]>
Co-authored-by: alexeyinkin <[email protected]>
  • Loading branch information
3 people authored and lostluck committed May 1, 2023
1 parent db2163c commit 5303eac
Show file tree
Hide file tree
Showing 67 changed files with 1,020 additions and 292 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/playground_frontend_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ name: Playground Frontend Test

on:
push:
paths: ['playground/frontend/**']
paths:
- 'playground/frontend/**'
branches: ['**']
pull_request:
paths: ['playground/frontend/**']
paths:
- 'playground/frontend/**'
branches: ['**']
workflow_dispatch:

Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/tour_of_beam_frontend_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Tour Of Beam Frontend Test

on:
push:
paths:
- 'learning/tour-of-beam/frontend/**'
- 'playground/frontend/playground_components'
branches: ['**']
pull_request:
paths:
- 'learning/tour-of-beam/frontend/**'
- 'playground/frontend/playground_components'
branches: ['**']
workflow_dispatch:

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
tour_of_beam_test:
name: Tour of Beam Test
runs-on: ubuntu-latest

env:
FLUTTER_VERSION: '3.7.3'

steps:
- uses: actions/checkout@v3

- name: 'Cache Flutter Dependencies'
uses: actions/cache@v3
with:
path: /opt/hostedtoolcache/flutter
key: ${{ runner.OS }}-flutter-install-cache-${{ env.FLUTTER_VERSION }}
restore-keys: ${{ runner.OS }}-flutter-install-cache

- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'

- name: 'Install Dependencies'
run: |
cd playground/frontend/playground_components && flutter pub get && cd -
cd playground/frontend/playground_components_dev && flutter pub get && cd -
cd learning/tour-of-beam/frontend && flutter pub get && cd -
- uses: nanasess/setup-chromedriver@v1

- name: 'Integration tests'
run: |
chromedriver --port=4444 &
./gradlew :learning:tour-of-beam:frontend:integrationTest -PdeviceId=web-server
37 changes: 29 additions & 8 deletions learning/tour-of-beam/frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,35 @@ To change the Google Project that is used as the backend:

# Deployment

# Tests

Install ChromeDriver to run integration tests in a browser: https://docs.flutter.dev/testing/integration-tests#running-in-a-browser
Run integration tests:
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/counter_test.dart \
-d web-server
# Integration Tests

## Prerequisites

1. Install Google Chrome: https://www.google.com/chrome/
2. Install Chrome Driver: https://chromedriver.chromium.org/downloads
- Note: This GitHub action installs both Chrome and Chrome Driver:
https://github.com/nanasess/setup-chromedriver/blob/a249caaaad10fd12103028fd509853c2229eb6e6/lib/setup-chromedriver.sh
3. Retrieve the required dependencies for each project subdirectory by running the following commands:

```bash
cd playground/frontend/playground_components && flutter pub get && cd -
cd playground/frontend/playground_components_dev && flutter pub get && cd -
cd learning/tour-of-beam/frontend && flutter pub get && cd -
```

## Running Tests

1. Run the Chrome Driver on port 4444: `chromedriver --port=4444`
2. Run the integration tests:

```bash
# To run in a visible Chrome window:
./gradlew :learning:tour-of-beam:frontend:integrationTest

# Headless run without a browser window:
./gradlew :learning:tour-of-beam:frontend:integrationTest -PdeviceId=web-server
```


# Packages

Expand Down
4 changes: 4 additions & 0 deletions learning/tour-of-beam/frontend/assets/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ ui:
signOut: Sign out
toWebsite: To Apache Beam website

errors:
toastTitle: Error

pages:
welcome:
ifSaveProgress: Your journey is broken down into learning modules. If you would like to save your progress and track completed modules, please
Expand All @@ -51,6 +54,7 @@ pages:
playground: Playground
saving: Saving...
summaryTitle: Table of Contents
pipelineOptionsButtonTitle: 'Pipeline Options ({count})'

dialogs:
signInIf: If you would like to save your progress and track completed modules
Expand Down
33 changes: 33 additions & 0 deletions learning/tour-of-beam/frontend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,36 @@ val deleteFilesByRegExp: (String) -> Unit = { re ->
args("assets", "lib", "test", "-regex", re, "-delete")
}
}

tasks.register("integrationTest") {
dependsOn("integrationTest_tour_page")
dependsOn("integrationTest_welcome_page")
}

tasks.register("integrationTest_tour_page") {
doLast {
runIntegrationTest("tour_page", "/")
}
}

tasks.register("integrationTest_welcome_page") {
doLast {
runIntegrationTest("welcome_page", "/")
}
}

fun runIntegrationTest(path: String, url: String) {
// Run with -PdeviceId=web-server for headless tests.
val deviceId: String = if (project.hasProperty("deviceId")) project.property("deviceId") as String else "chrome"

exec {
executable = "flutter"
args(
"drive",
"--driver=test_driver/integration_test.dart",
"--target=integration_test/${path}_test.dart",
"--web-launch-url='$url'",
"--device-id=$deviceId",
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,17 @@
* limitations under the License.
*/

import 'package:easy_localization/easy_localization.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:playground_components/playground_components.dart';
import 'package:tour_of_beam/main.dart' as app;
import 'package:tour_of_beam/pages/tour/controllers/content_tree.dart';
import 'package:tour_of_beam/pages/tour/widgets/content_tree.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
Future<void> init(WidgetTester wt) async {
await app.main();
await wt.pumpAndSettle();
}

group('theme', () {
testWidgets('mode toggle', (tester) async {
app.main();
await tester.pumpAndSettle();
final Finder switchToDarkModeButton =
find.widgetWithText(ToggleThemeButton, 'ui.darkMode'.tr());
expect(switchToDarkModeButton, findsOneWidget);
await tester.tap(switchToDarkModeButton);
await tester.pumpAndSettle();
expect(
find.widgetWithText(ToggleThemeButton, 'ui.lightMode'.tr()),
findsOneWidget,
);
});
});
ContentTreeController getContentTreeController(WidgetTester wt) {
return (wt.widget(find.byType(ContentTreeWidget)) as ContentTreeWidget)
.controller;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
* limitations under the License.
*/

import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:playground/constants/sizes.dart';
import 'package:playground_components/playground_components.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:tour_of_beam/components/sdk_dropdown.dart';

class PipelineOptionsDropdownSeparator extends StatelessWidget {
const PipelineOptionsDropdownSeparator({Key? key}) : super(key: key);
extension CommonFindersExtension on CommonFinders {
Finder sdkDropdown() {
return byType(SdkDropdown);
}

@override
Widget build(BuildContext context) {
return Container(
height: kDividerHeight,
decoration: BoxDecoration(
color: Theme.of(context).extension<BeamThemeExtension>()?.borderColor,
),
Finder startTourButton() {
return find.ancestor(
of: find.text('pages.welcome.startTour'.tr()),
matching: find.byType(ElevatedButton),
);
}
}
Loading

0 comments on commit 5303eac

Please sign in to comment.