mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: bloc test errors
This commit is contained in:
parent
54826da701
commit
1af6c5eadc
2
.github/workflows/dart_lint.yml
vendored
2
.github/workflows/dart_lint.yml
vendored
@ -73,7 +73,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cargo make --profile development-linux-x86_64 flowy-sdk-dev
|
cargo make --profile development-linux-x86_64 flowy-sdk-dev
|
||||||
|
|
||||||
- name: Code Generation
|
- name: Flutter Code Generation
|
||||||
working-directory: frontend/app_flowy
|
working-directory: frontend/app_flowy
|
||||||
run: |
|
run: |
|
||||||
flutter packages pub run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations -s en.json
|
flutter packages pub run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations -s en.json
|
||||||
|
11
.github/workflows/dart_test.yml
vendored
11
.github/workflows/dart_test.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: Unit test(Flutter)
|
name: Frontend test
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@ -21,7 +21,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: "stable-2022-04-07"
|
toolchain: "stable-2022-04-07"
|
||||||
@ -53,10 +52,6 @@ jobs:
|
|||||||
working-directory: frontend
|
working-directory: frontend
|
||||||
run: |
|
run: |
|
||||||
cargo install cargo-make
|
cargo install cargo-make
|
||||||
|
|
||||||
- name: Cargo make flowy dev
|
|
||||||
working-directory: frontend
|
|
||||||
run: |
|
|
||||||
cargo make flowy_dev
|
cargo make flowy_dev
|
||||||
|
|
||||||
- name: Flutter Deps
|
- name: Flutter Deps
|
||||||
@ -64,12 +59,12 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
flutter config --enable-linux-desktop
|
flutter config --enable-linux-desktop
|
||||||
|
|
||||||
- name: Build FlowySDK
|
- name: Build Test lib
|
||||||
working-directory: frontend
|
working-directory: frontend
|
||||||
run: |
|
run: |
|
||||||
cargo make --profile test-linux build-test-lib
|
cargo make --profile test-linux build-test-lib
|
||||||
|
|
||||||
- name: Code Generation
|
- name: Flutter Code Generation
|
||||||
working-directory: frontend/app_flowy
|
working-directory: frontend/app_flowy
|
||||||
run: |
|
run: |
|
||||||
flutter packages pub get
|
flutter packages pub get
|
||||||
|
2
.github/workflows/rust_test.yml
vendored
2
.github/workflows/rust_test.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: Unit test(Rust)
|
name: Backend test
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
|
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
|
||||||
import 'package:flowy_infra/notifier.dart';
|
import 'package:flowy_infra/notifier.dart';
|
||||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart';
|
||||||
import 'package:app_flowy/plugins/grid/application/field/field_service.dart';
|
import 'package:app_flowy/plugins/grid/application/field/field_service.dart';
|
||||||
|
@ -79,8 +79,8 @@ class GridDataController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createRow() {
|
Future<void> createRow() async {
|
||||||
_gridFFIService.createRow();
|
await _gridFFIService.createRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> dispose() async {
|
Future<void> dispose() async {
|
||||||
|
@ -7,6 +7,7 @@ void main() {
|
|||||||
late AppFlowyGridTest gridTest;
|
late AppFlowyGridTest gridTest;
|
||||||
setUpAll(() async {
|
setUpAll(() async {
|
||||||
gridTest = await AppFlowyGridTest.ensureInitialized();
|
gridTest = await AppFlowyGridTest.ensureInitialized();
|
||||||
|
await gridTest.createTestGrid();
|
||||||
});
|
});
|
||||||
|
|
||||||
group('GridBloc', () {
|
group('GridBloc', () {
|
||||||
|
@ -17,8 +17,11 @@ void main() {
|
|||||||
group('SingleSelectOptionBloc', () {
|
group('SingleSelectOptionBloc', () {
|
||||||
late GridSelectOptionCellController cellController;
|
late GridSelectOptionCellController cellController;
|
||||||
setUp(() async {
|
setUp(() async {
|
||||||
cellController =
|
await cellTest.createTestGrid();
|
||||||
await cellTest.makeCellController(FieldType.SingleSelect);
|
await cellTest.createTestRow();
|
||||||
|
cellController = await cellTest.makeCellController(
|
||||||
|
FieldType.SingleSelect,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
blocTest<SelectOptionCellEditorBloc, SelectOptionEditorState>(
|
blocTest<SelectOptionCellEditorBloc, SelectOptionEditorState>(
|
||||||
|
@ -19,12 +19,10 @@ class AppFlowyGridTest {
|
|||||||
|
|
||||||
static Future<AppFlowyGridTest> ensureInitialized() async {
|
static Future<AppFlowyGridTest> ensureInitialized() async {
|
||||||
final inner = await AppFlowyUnitTest.ensureInitialized();
|
final inner = await AppFlowyUnitTest.ensureInitialized();
|
||||||
final test = AppFlowyGridTest(inner);
|
return AppFlowyGridTest(inner);
|
||||||
await test._createTestGrid();
|
|
||||||
return test;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _createTestGrid() async {
|
Future<void> createTestGrid() async {
|
||||||
final app = await _inner.createTestApp();
|
final app = await _inner.createTestApp();
|
||||||
final builder = GridPluginBuilder();
|
final builder = GridPluginBuilder();
|
||||||
final result = await AppService().createView(
|
final result = await AppService().createView(
|
||||||
@ -42,56 +40,65 @@ class AppFlowyGridTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AppFlowyGridSelectOptionCellTest {
|
class AppFlowyGridSelectOptionCellTest {
|
||||||
final AppFlowyGridCellTest _cellTest;
|
final AppFlowyGridCellTest _gridCellTest;
|
||||||
|
|
||||||
AppFlowyGridSelectOptionCellTest(AppFlowyGridCellTest cellTest)
|
AppFlowyGridSelectOptionCellTest(AppFlowyGridCellTest cellTest)
|
||||||
: _cellTest = cellTest;
|
: _gridCellTest = cellTest;
|
||||||
|
|
||||||
static Future<AppFlowyGridSelectOptionCellTest> ensureInitialized() async {
|
static Future<AppFlowyGridSelectOptionCellTest> ensureInitialized() async {
|
||||||
final cellTest = await AppFlowyGridCellTest.ensureInitialized();
|
final gridTest = await AppFlowyGridCellTest.ensureInitialized();
|
||||||
final test = AppFlowyGridSelectOptionCellTest(cellTest);
|
return AppFlowyGridSelectOptionCellTest(gridTest);
|
||||||
return test;
|
}
|
||||||
|
|
||||||
|
Future<void> createTestGrid() async {
|
||||||
|
await _gridCellTest.createTestGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> createTestRow() async {
|
||||||
|
await _gridCellTest.createTestRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For the moment, just edit the first row of the grid.
|
|
||||||
Future<GridSelectOptionCellController> makeCellController(
|
Future<GridSelectOptionCellController> makeCellController(
|
||||||
FieldType fieldType) async {
|
FieldType fieldType) async {
|
||||||
assert(fieldType == FieldType.SingleSelect ||
|
assert(fieldType == FieldType.SingleSelect ||
|
||||||
fieldType == FieldType.MultiSelect);
|
fieldType == FieldType.MultiSelect);
|
||||||
|
|
||||||
final fieldContexts =
|
final fieldContexts =
|
||||||
_cellTest._dataController.fieldController.fieldContexts;
|
_gridCellTest._dataController.fieldController.fieldContexts;
|
||||||
final field =
|
final field =
|
||||||
fieldContexts.firstWhere((element) => element.fieldType == fieldType);
|
fieldContexts.firstWhere((element) => element.fieldType == fieldType);
|
||||||
final builder = await _cellTest.cellControllerBuilder(0, field.id);
|
final builder = await _gridCellTest.cellControllerBuilder(field.id);
|
||||||
final cellController = builder.build() as GridSelectOptionCellController;
|
final cellController = builder.build() as GridSelectOptionCellController;
|
||||||
return cellController;
|
return cellController;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a new Grid for cell test
|
||||||
class AppFlowyGridCellTest {
|
class AppFlowyGridCellTest {
|
||||||
// ignore: unused_field
|
|
||||||
final AppFlowyGridTest _gridTest;
|
final AppFlowyGridTest _gridTest;
|
||||||
final GridDataController _dataController;
|
late GridDataController _dataController;
|
||||||
AppFlowyGridCellTest(AppFlowyGridTest gridTest)
|
AppFlowyGridCellTest(AppFlowyGridTest gridTest) : _gridTest = gridTest;
|
||||||
: _gridTest = gridTest,
|
|
||||||
_dataController = GridDataController(view: gridTest.gridView);
|
|
||||||
|
|
||||||
static Future<AppFlowyGridCellTest> ensureInitialized() async {
|
static Future<AppFlowyGridCellTest> ensureInitialized() async {
|
||||||
final gridTest = await AppFlowyGridTest.ensureInitialized();
|
final gridTest = await AppFlowyGridTest.ensureInitialized();
|
||||||
final test = AppFlowyGridCellTest(gridTest);
|
return AppFlowyGridCellTest(gridTest);
|
||||||
await test._loadGridData();
|
|
||||||
return test;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadGridData() async {
|
Future<void> createTestRow() async {
|
||||||
|
await _dataController.createRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> createTestGrid() async {
|
||||||
|
await _gridTest.createTestGrid();
|
||||||
|
_dataController = GridDataController(view: _gridTest.gridView);
|
||||||
final result = await _dataController.loadData();
|
final result = await _dataController.loadData();
|
||||||
result.fold((l) => null, (r) => throw Exception(r));
|
result.fold((l) => null, (r) => throw Exception(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<GridCellControllerBuilder> cellControllerBuilder(
|
Future<GridCellControllerBuilder> cellControllerBuilder(
|
||||||
int rowIndex, String fieldId) async {
|
String fieldId,
|
||||||
final RowInfo rowInfo = _dataController.rowInfos[rowIndex];
|
) async {
|
||||||
|
final RowInfo rowInfo = _dataController.rowInfos.last;
|
||||||
final blockCache = _dataController.blocks[rowInfo.rowPB.blockId];
|
final blockCache = _dataController.blocks[rowInfo.rowPB.blockId];
|
||||||
final rowCache = blockCache?.rowCache;
|
final rowCache = blockCache?.rowCache;
|
||||||
|
|
||||||
@ -116,9 +123,9 @@ class AppFlowyGridCellTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> gridResponseFuture() {
|
Future<void> gridResponseFuture() {
|
||||||
return Future.delayed(gridResponseDuration(milliseconds: 500));
|
return Future.delayed(gridResponseDuration(milliseconds: 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
Duration gridResponseDuration({int milliseconds = 500}) {
|
Duration gridResponseDuration({int milliseconds = 200}) {
|
||||||
return Duration(milliseconds: milliseconds);
|
return Duration(milliseconds: milliseconds);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user