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

Unit test ci #16

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 3 additions & 8 deletions .github/workflows/flutter_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
path: appflowy_flutter.tar.gz

unit_test:
needs: [prepare]
# needs: [prepare]
if: github.event.pull_request.draft != true
strategy:
fail-fast: false
Expand Down Expand Up @@ -181,17 +181,12 @@ jobs:
fi
shell: bash

- uses: actions/download-artifact@v3
with:
name: ${{ github.run_id }}-${{ matrix.os }}

- name: Uncompress appflowy_flutter
run: tar -xf appflowy_flutter.tar.gz

- name: Run Flutter unit tests
working-directory: frontend
run: |
if [ "$RUNNER_OS" == "macOS" ]; then
flutter config --enable-macos-desktop
cargo make --profile ${{ matrix.flutter_profile }} appflowy-dev
cargo make dart_unit_test
else
cargo make dart_unit_test_no_build
Expand Down
2 changes: 1 addition & 1 deletion frontend/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
{
"label": "AF: Generate Env File",
"type": "shell",
"command": "dart run build_runner clean && dart run build_runner build --delete-conflicting-outputs ",
"command": "dart run build_runner clean && flutter packages pub get && dart run build_runner build --delete-conflicting-outputs ",
"options": {
"cwd": "${workspaceFolder}/appflowy_flutter"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:appflowy/mobile/presentation/bottom_sheet/mobile_bottom_sheet_body.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/mobile_bottom_sheet_rename_widget.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/mobile_bottom_sheet_view_item_header.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_drag_handler.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_rename_widget.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_view_item_body.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_view_item_header.dart';
import 'package:appflowy/workspace/application/favorite/favorite_bloc.dart';
import 'package:appflowy/workspace/application/view/view_bloc.dart';
import 'package:appflowy_backend/protobuf/flowy-folder2/protobuf.dart';
Expand Down Expand Up @@ -36,11 +37,11 @@ enum MobileBottomSheetType {
class MobileViewItemBottomSheet extends StatefulWidget {
const MobileViewItemBottomSheet({
super.key,
this.view,
required this.view,
this.defaultType = MobileBottomSheetType.view,
});

final ViewPB? view;
final ViewPB view;
final MobileBottomSheetType defaultType;

@override
Expand All @@ -56,11 +57,6 @@ class _MobileViewItemBottomSheetState extends State<MobileViewItemBottomSheet> {
super.initState();

type = widget.defaultType;

if ([MobileBottomSheetType.view, MobileBottomSheetType.rename]
.contains(type)) {
assert(widget.view != null);
}
}

@override
Expand All @@ -69,17 +65,7 @@ class _MobileViewItemBottomSheetState extends State<MobileViewItemBottomSheet> {
mainAxisSize: MainAxisSize.min,
children: [
// drag handler
Padding(
padding: const EdgeInsets.only(top: 12, bottom: 12.0),
child: Container(
width: 64,
height: 4,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2.0),
color: Colors.grey,
),
),
),
const MobileBottomSheetDragHandler(),

// header
_buildHeader(),
Expand All @@ -100,7 +86,7 @@ class _MobileViewItemBottomSheetState extends State<MobileViewItemBottomSheet> {
// header
return MobileViewItemBottomSheetHeader(
showBackButton: type != MobileBottomSheetType.view,
view: widget.view!,
view: widget.view,
onBack: () {
setState(() {
type = MobileBottomSheetType.view;
Expand All @@ -114,7 +100,7 @@ class _MobileViewItemBottomSheetState extends State<MobileViewItemBottomSheet> {
switch (type) {
case MobileBottomSheetType.view:
return MobileViewItemBottomSheetBody(
isFavorite: widget.view!.isFavorite,
isFavorite: widget.view.isFavorite,
onAction: (action) {
switch (action) {
case MobileViewItemBottomSheetBodyAction.rename:
Expand All @@ -138,17 +124,17 @@ class _MobileViewItemBottomSheetState extends State<MobileViewItemBottomSheet> {
case MobileViewItemBottomSheetBodyAction.removeFromFavorites:
context
.read<FavoriteBloc>()
.add(FavoriteEvent.toggle(widget.view!));
.add(FavoriteEvent.toggle(widget.view));
context.pop();
break;
}
},
);
case MobileBottomSheetType.rename:
return MobileBottomSheetRenameWidget(
name: widget.view!.name,
name: widget.view.name,
onRename: (name) {
if (name != widget.view!.name) {
if (name != widget.view.name) {
context.read<ViewBloc>().add(ViewEvent.rename(name));
}
context.pop();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_action_widget.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_drag_handler.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_view_item_header.dart';
import 'package:appflowy_backend/protobuf/flowy-folder2/protobuf.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';

class AddNewPageWidgetBottomSheet extends StatelessWidget {
const AddNewPageWidgetBottomSheet({
super.key,
required this.view,
required this.onAction,
});

final ViewPB view;
final void Function(ViewLayoutPB layout) onAction;

@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
// drag handler
const MobileBottomSheetDragHandler(),

// header
MobileViewItemBottomSheetHeader(
showBackButton: false,
view: view,
onBack: () {},
),
const VSpace(8.0),
const Divider(),

// body
_AddNewPageBody(
onAction: onAction,
),
const VSpace(24.0),
],
);
}
}

class _AddNewPageBody extends StatelessWidget {
const _AddNewPageBody({
required this.onAction,
});

final void Function(ViewLayoutPB layout) onAction;

@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// rename, duplicate
Row(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: BottomSheetActionWidget(
svg: FlowySvgs.documents_s,
text: LocaleKeys.newDocumentText.tr(),
onTap: () => onAction(ViewLayoutPB.Document),
),
),
Expanded(
child: BottomSheetActionWidget(
svg: FlowySvgs.grid_s,
text: LocaleKeys.newGridText.tr(),
onTap: () => onAction(ViewLayoutPB.Grid),
),
),
],
),

// share, delete
Row(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: BottomSheetActionWidget(
svg: FlowySvgs.board_s,
text: LocaleKeys.newBoardText.tr(),
onTap: () => onAction(ViewLayoutPB.Board),
),
),
Expanded(
child: BottomSheetActionWidget(
svg: FlowySvgs.date_s,
text: LocaleKeys.newCalendarText.tr(),
onTap: () => onAction(ViewLayoutPB.Calendar),
),
),
],
),
],
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:flutter/material.dart';

class MobileBottomSheetDragHandler extends StatelessWidget {
const MobileBottomSheetDragHandler({super.key});

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(top: 12, bottom: 12.0),
child: Container(
width: 64,
height: 4,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2.0),
color: Colors.grey,
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_drag_handler.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_rename_widget.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_view_item_body.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_view_item_header.dart';
import 'package:appflowy/workspace/application/favorite/favorite_bloc.dart';
import 'package:appflowy/workspace/application/view/view_bloc.dart';
import 'package:appflowy_backend/protobuf/flowy-folder2/protobuf.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart' hide WidgetBuilder;
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';

enum MobileBottomSheetType {
view,
rename,
}

class MobileViewItemBottomSheet extends StatefulWidget {
const MobileViewItemBottomSheet({
super.key,
required this.view,
this.defaultType = MobileBottomSheetType.view,
});

final ViewPB view;
final MobileBottomSheetType defaultType;

@override
State<MobileViewItemBottomSheet> createState() =>
_MobileViewItemBottomSheetState();
}

class _MobileViewItemBottomSheetState extends State<MobileViewItemBottomSheet> {
MobileBottomSheetType type = MobileBottomSheetType.view;

@override
initState() {
super.initState();

type = widget.defaultType;
}

@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
// drag handler
const MobileBottomSheetDragHandler(),

// header
_buildHeader(),
const VSpace(8.0),
const Divider(),

// body
_buildBody(),
const VSpace(24.0),
],
);
}

Widget _buildHeader() {
switch (type) {
case MobileBottomSheetType.view:
case MobileBottomSheetType.rename:
// header
return MobileViewItemBottomSheetHeader(
showBackButton: type != MobileBottomSheetType.view,
view: widget.view,
onBack: () {
setState(() {
type = MobileBottomSheetType.view;
});
},
);
}
}

Widget _buildBody() {
switch (type) {
case MobileBottomSheetType.view:
return MobileViewItemBottomSheetBody(
isFavorite: widget.view.isFavorite,
onAction: (action) {
switch (action) {
case MobileViewItemBottomSheetBodyAction.rename:
setState(() {
type = MobileBottomSheetType.rename;
});
break;
case MobileViewItemBottomSheetBodyAction.duplicate:
context.read<ViewBloc>().add(const ViewEvent.duplicate());
context.pop();
break;
case MobileViewItemBottomSheetBodyAction.share:
// unimplemented
context.pop();
break;
case MobileViewItemBottomSheetBodyAction.delete:
context.read<ViewBloc>().add(const ViewEvent.delete());
context.pop();
break;
case MobileViewItemBottomSheetBodyAction.addToFavorites:
case MobileViewItemBottomSheetBodyAction.removeFromFavorites:
context
.read<FavoriteBloc>()
.add(FavoriteEvent.toggle(widget.view));
context.pop();
break;
}
},
);
case MobileBottomSheetType.rename:
return MobileBottomSheetRenameWidget(
name: widget.view.name,
onRename: (name) {
if (name != widget.view.name) {
context.read<ViewBloc>().add(ViewEvent.rename(name));
}
context.pop();
},
);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/mobile_bottom_sheet_action_widget.dart';
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_action_widget.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';

Expand Down
Loading