Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Playwright for Flutter Web #2993

Merged
merged 27 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9acb90b
create poc selenium test
tddang-linagora Jul 5, 2024
8679286
grouping parameterized for TestBase
tddang-linagora Jul 5, 2024
a079504
Create selenium-maven.yml
tddang-linagora Jul 5, 2024
543d00d
Config headless test
tddang-linagora Jul 5, 2024
a689f11
Implement robot testing pattern
tddang-linagora Jul 5, 2024
a565150
Disable log trimming
tddang-linagora Jul 5, 2024
324687a
Update Selenium CI config
tddang-linagora Jul 8, 2024
1f5ddd2
Refactored test workflow
Jul 9, 2024
787bdfc
Added local image build for integration test
Jul 10, 2024
cbe07b7
WIP Add playwright POC
tddang-linagora Jul 15, 2024
dd6dbaa
Upgrade code to Flutter 3.22.2
tddang-linagora Jul 17, 2024
f1fffae
Update maven test to Playwright
tddang-linagora Jul 18, 2024
4540ab9
Refactor Playwright test
tddang-linagora Jul 18, 2024
035c436
Update login scenario
tddang-linagora Jul 18, 2024
3a4e274
Added credentials for testing
Jul 18, 2024
d665301
Upgrade test to junit 5
tddang-linagora Jul 18, 2024
6644601
Implement parallel test
tddang-linagora Jul 18, 2024
961f7e0
Build basic auth login test
tddang-linagora Jul 19, 2024
2221601
Move setup steps to dedicated script
Jul 24, 2024
4dac747
Should throw when setup configuration wrongly
quantranhong1999 Jul 23, 2024
620dd37
Setup TestContainer for E2E testing
quantranhong1999 Jul 24, 2024
26a1a1a
Image tag should match the one built by CI
quantranhong1999 Jul 25, 2024
229bc63
Rename integration_test directory
hoangdat Aug 6, 2024
8e9a151
Update correct variable for test container
hoangdat Aug 6, 2024
3bfa649
Update working directory with new name
hoangdat Aug 6, 2024
9cf25f5
Set viewport size for web app test
hoangdat Aug 6, 2024
0895521
Disable OIDC with remote server to make test stable
hoangdat Aug 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/integration-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Integration tests

on:
workflow_dispatch:
pull_request:
paths-ignore:
- "**/*.md"

env:
JAVA_VERSION: 22

jobs:
integration_test:
name: Run integration tests
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "temurin"
cache: maven
cache-dependency-path: "tmail_integration_test/pom.xml"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build local image
uses: docker/build-push-action@v6
with:
load: true
tags: tmail-web:integration-test

- uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable
install-chromedriver: true

- uses: browser-actions/setup-firefox@v1
- uses: browser-actions/setup-geckodriver@latest

- name: Configure frontend
env:
FRONTEND_CONFIG: ${{ secrets.FRONTEND_CONFIG }}
FRONTEND_CREDS: ${{ secrets.FRONTEND_CREDS }}
run: ../scripts/setup-desktop-integration-tests.sh
working-directory: tmail_integration_test

- name: Run integration tests
run: ../scripts/run-desktop-integration-tests.sh
working-directory: tmail_integration_test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,6 @@ app.*.symbols
*.g.dart
messages_*.dart
*.mocks.dart

# end-to-end test
config.properties
504 changes: 255 additions & 249 deletions lib/features/composer/presentation/widgets/recipient_composer_widget.dart

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,39 @@ class SubjectComposerWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Container(
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(
color: SubjectComposerWidgetStyle.borderColor,
width: 1
)
),
),
margin: margin,
padding: padding,
child: Row(
children: [
Text(
'${AppLocalizations.of(context).subject_email}:',
style: SubjectComposerWidgetStyle.labelTextStyle
return Semantics(
label: 'Composer:subject',
child: Container(
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(
color: SubjectComposerWidgetStyle.borderColor,
width: 1
)
),
const SizedBox(width:SubjectComposerWidgetStyle.space),
Expanded(
child: TextFieldBuilder(
cursorColor: SubjectComposerWidgetStyle.cursorColor,
focusNode: focusNode,
onTextChange: onTextChange,
maxLines: 1,
textDirection: DirectionUtils.getDirectionByLanguage(context),
textStyle: SubjectComposerWidgetStyle.inputTextStyle,
controller: textController,
),
margin: margin,
padding: padding,
child: Row(
children: [
Text(
'${AppLocalizations.of(context).subject_email}:',
style: SubjectComposerWidgetStyle.labelTextStyle
),
const SizedBox(width:SubjectComposerWidgetStyle.space),
Expanded(
child: TextFieldBuilder(
cursorColor: SubjectComposerWidgetStyle.cursorColor,
focusNode: focusNode,
onTextChange: onTextChange,
maxLines: 1,
textDirection: DirectionUtils.getDirectionByLanguage(context),
textStyle: SubjectComposerWidgetStyle.inputTextStyle,
controller: textController,
)
)
)
]
]
),
),
);
}
Expand Down
113 changes: 58 additions & 55 deletions lib/features/composer/presentation/widgets/web/web_editor_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,63 +118,66 @@ class _WebEditorState extends State<WebEditorWidget> {
return ValueListenableBuilder(
valueListenable: _htmlEditorHeight,
builder: (context, height, _) {
return HtmlEditor(
key: Key('web_editor_$height'),
controller: _editorController,
htmlEditorOptions: HtmlEditorOptions(
shouldEnsureVisible: true,
hint: '',
darkMode: false,
initialText: widget.content,
customBodyCssStyle: HtmlUtils.customCssStyleHtmlEditor(direction: widget.direction),
spellCheck: true,
disableDragAndDrop: true,
webInitialScripts: UnmodifiableListView([
WebScript(
name: HtmlUtils.lineHeight100Percent.name,
script: HtmlUtils.lineHeight100Percent.script,
),
WebScript(
name: HtmlUtils.registerDropListener.name,
script: HtmlUtils.registerDropListener.script,
return Semantics(
label: 'Composer:content',
child: HtmlEditor(
key: Key('web_editor_$height'),
controller: _editorController,
htmlEditorOptions: HtmlEditorOptions(
shouldEnsureVisible: true,
hint: '',
darkMode: false,
initialText: widget.content,
customBodyCssStyle: HtmlUtils.customCssStyleHtmlEditor(direction: widget.direction),
spellCheck: true,
disableDragAndDrop: true,
webInitialScripts: UnmodifiableListView([
WebScript(
name: HtmlUtils.lineHeight100Percent.name,
script: HtmlUtils.lineHeight100Percent.script,
),
WebScript(
name: HtmlUtils.registerDropListener.name,
script: HtmlUtils.registerDropListener.script,
),
WebScript(
name: HtmlUtils.unregisterDropListener.name,
script: HtmlUtils.unregisterDropListener.script,
)
])
),
htmlToolbarOptions: const HtmlToolbarOptions(
toolbarType: ToolbarType.hide,
defaultToolbarButtons: [],
),
otherOptions: OtherOptions(
height: height,
// dropZoneWidth: dropZoneWidth,
// dropZoneHeight: dropZoneHeight,
),
callbacks: Callbacks(
onBeforeCommand: widget.onChangeContent,
onChangeContent: widget.onChangeContent,
onInit: () {
widget.onInitial?.call(widget.content);
if (!_dropListenerRegistered) {
_editorController.evaluateJavascriptWeb(
HtmlUtils.registerDropListener.name);
_dropListenerRegistered = true;
}
},
onFocus: widget.onFocus,
onBlur: widget.onUnFocus,
onMouseDown: () => widget.onMouseDown?.call(context),
onChangeSelection: widget.onEditorSettings,
onChangeCodeview: widget.onChangeContent,
onTextFontSizeChanged: widget.onEditorTextSizeChanged,
onPaste: () => _editorController.evaluateJavascriptWeb(
HtmlUtils.lineHeight100Percent.name
),
WebScript(
name: HtmlUtils.unregisterDropListener.name,
script: HtmlUtils.unregisterDropListener.script,
)
])
),
htmlToolbarOptions: const HtmlToolbarOptions(
toolbarType: ToolbarType.hide,
defaultToolbarButtons: [],
),
otherOptions: OtherOptions(
height: height,
// dropZoneWidth: dropZoneWidth,
// dropZoneHeight: dropZoneHeight,
),
callbacks: Callbacks(
onBeforeCommand: widget.onChangeContent,
onChangeContent: widget.onChangeContent,
onInit: () {
widget.onInitial?.call(widget.content);
if (!_dropListenerRegistered) {
_editorController.evaluateJavascriptWeb(
HtmlUtils.registerDropListener.name);
_dropListenerRegistered = true;
}
},
onFocus: widget.onFocus,
onBlur: widget.onUnFocus,
onMouseDown: () => widget.onMouseDown?.call(context),
onChangeSelection: widget.onEditorSettings,
onChangeCodeview: widget.onChangeContent,
onTextFontSizeChanged: widget.onEditorTextSizeChanged,
onPaste: () => _editorController.evaluateJavascriptWeb(
HtmlUtils.lineHeight100Percent.name
onDragEnter: widget.onDragEnter,
onDragLeave: (types) {},
),
onDragEnter: widget.onDragEnter,
onDragLeave: (_) {},
),
);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/utils/app_logger.dart';
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart';
import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart';
Expand All @@ -17,6 +18,7 @@ import 'package:worker_manager/worker_manager.dart';
void main() async {
initLogger(() async {
WidgetsFlutterBinding.ensureInitialized();
SemanticsBinding.instance.ensureSemantics();
ThemeUtils.setSystemLightUIStyle();

await Future.wait([
Expand Down
4 changes: 4 additions & 0 deletions scripts/run-desktop-integration-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

# docker run -d -p 2023:80 --name tmail-web -v "$(pwd)/env.file:/usr/share/nginx/html/assets/env.file" tmail-web:integration-test
./mvnw test
5 changes: 5 additions & 0 deletions scripts/setup-desktop-integration-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh

echo "$FRONTEND_CONFIG" > env.file
mkdir -p src/main/resources
echo "$FRONTEND_CREDS" > src/main/resources/config.properties
2 changes: 2 additions & 0 deletions tmail_integration_test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Default ignored files
/target/
19 changes: 19 additions & 0 deletions tmail_integration_test/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
Loading
Loading