Skip to content

Commit f5a1130

Browse files
fix(cat-voices): enable unit web tests in catalyst_voices_repositories (#2374)
* fix: enable unit tests in catalyst_voices_repositories * chore: missing commas
1 parent 418c1ef commit f5a1130

File tree

18 files changed

+2744
-2348
lines changed

18 files changed

+2744
-2348
lines changed

catalyst_voices/melos.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,10 @@ scripts:
256256
melos run test:select --no-select
257257
description: Run `flutter test` for all packages.
258258

259-
# TODO(kukkok3):
260259
# catalyst_voices: this package should contain only widget tests
261-
# catalyst_voices_repositories: enable when https://github.com/input-output-hk/catalyst-voices/issues/1980 is fixed
262260
test-web:
263261
run: |
264-
melos exec -c 1 --dir-exists="test" --ignore="catalyst_voices,catalyst_voices_repositories" -- flutter test --platform chrome
262+
melos exec -c 1 --dir-exists="test" --ignore="catalyst_voices" -- flutter test --platform chrome
265263
description: Run `flutter test --platform chrome` for all packages.
266264

267265
test-report-web:

catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/database/catalyst_database_test.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import 'package:catalyst_voices_repositories/src/database/catalyst_database.dart';
2-
import 'package:drift/drift.dart';
3-
import 'package:drift/native.dart';
42
import 'package:flutter_test/flutter_test.dart';
53

64
import '../utils/test_factories.dart';
5+
import 'connection/test_connection.dart';
6+
import 'drift_test_platforms.dart';
77

88
void main() {
99
late DriftCatalystDatabase database;
1010

11-
setUp(() {
12-
final inMemory = DatabaseConnection(NativeDatabase.memory());
13-
database = DriftCatalystDatabase(inMemory);
11+
setUp(() async {
12+
final connection = await buildTestConnection();
13+
database = DriftCatalystDatabase(connection);
1414
});
1515

1616
tearDown(() async {
@@ -47,6 +47,7 @@ void main() {
4747
expect(draftsCountAfter, isZero);
4848
expect(documentsCountAfter, isZero);
4949
},
50+
onPlatform: driftOnPlatforms,
5051
);
5152
});
5253
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import 'package:drift/drift.dart';
2+
3+
import '../executor/unsupported.dart'
4+
if (dart.library.js_interop) '../executor/web.dart'
5+
if (dart.library.ffi) '../executor/native.dart';
6+
7+
Future<DatabaseConnection> buildTestConnection() async {
8+
final executor = await buildExecutor();
9+
10+
return DatabaseConnection(
11+
executor,
12+
closeStreamsSynchronously: true,
13+
);
14+
}

0 commit comments

Comments
 (0)