Skip to content

Commit f67bc03

Browse files
authored
test(cli): Refactor E2E tests (#378)
And add test for child process passed to `celest start`
1 parent 0f7ad15 commit f67bc03

14 files changed

+99
-39
lines changed

apps/cli/test/e2e/common/command.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,23 @@ final class InteractiveCommand {
302302
await [stdout.flush(), stderr.flush()].wait;
303303
}
304304

305+
Future<void> expectError([int? exitCode]) async {
306+
try {
307+
await flush().trace('expectError');
308+
await check(_process.exitCode).completes((it) {
309+
if (exitCode case final exitCode?) {
310+
it.equals(exitCode);
311+
} else {
312+
it.not((it) => it.equals(0));
313+
}
314+
});
315+
} finally {
316+
_process.kill();
317+
await _logs.cancel();
318+
await [stdout.flush(), stderr.flush()].wait;
319+
}
320+
}
321+
305322
Future<void> expectSuccess() async {
306323
try {
307324
await flush().trace('expectSuccess');

apps/cli/test/e2e/e2e_test.dart

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@ import 'package:test/test.dart';
77

88
import '../common.dart';
99
import 'common/common.dart';
10-
import 'features/bugs/add_remove_fields.dart';
11-
import 'features/create/create_project_in_dart_app.dart';
12-
import 'features/create/create_project_in_dart_app_no_deps.dart';
13-
import 'features/create/create_project_in_flutter_app.dart';
14-
import 'features/create/create_project_isolated.dart';
15-
import 'features/hot_reload/hot_reload_add_auth.dart';
16-
import 'features/hot_reload/hot_reload_add_model_after_error.dart';
17-
import 'features/init/init_project_name.dart';
18-
import 'features/init/templates/data_project.dart';
19-
import 'features/init/templates/hello_project.dart';
20-
import 'features/package_support/supports_supabase.dart';
2110
import 'targets/installed_target.dart';
2211
import 'targets/local_aot_target.dart';
2312
import 'targets/local_target.dart';
13+
import 'tests/bugs/add_remove_fields.dart';
14+
import 'tests/commands/create/create_project_in_dart_app.dart';
15+
import 'tests/commands/create/create_project_in_dart_app_no_deps.dart';
16+
import 'tests/commands/create/create_project_in_flutter_app.dart';
17+
import 'tests/commands/create/create_project_isolated.dart';
18+
import 'tests/commands/init/init_project_name.dart';
19+
import 'tests/commands/init/templates/data_project.dart';
20+
import 'tests/commands/init/templates/hello_project.dart';
21+
import 'tests/commands/start/hot_reload/hot_reload_add_auth.dart';
22+
import 'tests/commands/start/hot_reload/hot_reload_add_model_after_error.dart';
23+
import 'tests/commands/start/start_child_process.dart';
24+
import 'tests/package_support/supports_supabase.dart';
2425

2526
void main() {
2627
final targets = <TestTarget>[
@@ -30,26 +31,29 @@ void main() {
3031
];
3132

3233
final tests = <E2ETest Function(TestTarget)>[
33-
// Project templates
34-
HelloProjectTest.new,
35-
DataProjectTest.new,
34+
// // Project templates
35+
// HelloProjectTest.new,
36+
// DataProjectTest.new,
3637

37-
// Project initialization
38-
InitProjectNameTest.new,
38+
// // Init options
39+
// InitProjectNameTest.new,
3940

40-
// Project creation
41-
CreateProjectInFlutterAppTest.new,
42-
CreateProjectInDartAppTest.new,
43-
CreateProjectInDartAppNoDepsTest.new,
44-
CreateProjectIsolatedTest.new,
41+
// // Project creation
42+
// CreateProjectInFlutterAppTest.new,
43+
// CreateProjectInDartAppTest.new,
44+
// CreateProjectInDartAppNoDepsTest.new,
45+
// CreateProjectIsolatedTest.new,
46+
47+
// Start options
48+
StartChildProcessTest.new,
4549

4650
// Hot reload
47-
AddRemoveFieldsTest.new,
48-
HotReloadAddAuthTest.new,
49-
HotReloadNonExistentModel.new,
51+
// AddRemoveFieldsTest.new,
52+
// HotReloadAddAuthTest.new,
53+
// HotReloadNonExistentModel.new,
5054

51-
// Package support
52-
SupportsSupabase.new,
55+
// // Package support
56+
// SupportsSupabase.new,
5357
];
5458

5559
for (final target in targets) {
File renamed without changes.

apps/cli/test/e2e/features/create/create_project_in_dart_app.dart renamed to apps/cli/test/e2e/tests/commands/create/create_project_in_dart_app.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import '../../common/common.dart';
2-
import '../../common/test_projects.dart';
1+
import '../../../common/common.dart';
2+
import '../../../common/test_projects.dart';
33

44
final class CreateProjectInDartAppTest extends E2ETest with TestDartProject {
55
CreateProjectInDartAppTest(super.target);
66

77
@override
88
String get name => 'start (w/ Dart parent)';
9+
910
@override
1011
Future<void> run() async {
1112
await celestCommand('start')

apps/cli/test/e2e/features/create/create_project_in_dart_app_no_deps.dart renamed to apps/cli/test/e2e/tests/commands/create/create_project_in_dart_app_no_deps.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'package:celest_cli/src/pub/pub_environment.dart';
55
import 'package:checks/checks.dart';
66
import 'package:test_descriptor/test_descriptor.dart' as d;
77

8-
import '../../common/common.dart';
8+
import '../../../common/common.dart';
99

1010
final class CreateProjectInDartAppNoDepsTest extends E2ETest {
1111
CreateProjectInDartAppNoDepsTest(super.target);

apps/cli/test/e2e/features/create/create_project_in_flutter_app.dart renamed to apps/cli/test/e2e/tests/commands/create/create_project_in_flutter_app.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import '../../common/common.dart';
2-
import '../../common/test_projects.dart';
1+
import '../../../common/common.dart';
2+
import '../../../common/test_projects.dart';
33

44
final class CreateProjectInFlutterAppTest extends E2ETest
55
with TestFlutterProject {

apps/cli/test/e2e/features/create/create_project_isolated.dart renamed to apps/cli/test/e2e/tests/commands/create/create_project_isolated.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:checks/checks.dart';
22

3-
import '../../common/common.dart';
3+
import '../../../common/common.dart';
44

55
final class CreateProjectIsolatedTest extends E2ETest {
66
CreateProjectIsolatedTest(super.target);

apps/cli/test/e2e/features/init/init_project_name.dart renamed to apps/cli/test/e2e/tests/commands/init/init_project_name.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:celest_cli/src/context.dart';
22

3-
import '../../common/common.dart';
3+
import '../../../common/common.dart';
44

55
final class InitProjectNameTest extends E2ETest {
66
InitProjectNameTest(super.target);

apps/cli/test/e2e/features/init/templates/data_project.dart renamed to apps/cli/test/e2e/tests/commands/init/templates/data_project.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:celest_cli/src/context.dart';
22

3-
import '../../../common/common.dart';
3+
import '../../../../common/common.dart';
44

55
final class DataProjectTest extends E2ETest {
66
DataProjectTest(super.target);

apps/cli/test/e2e/features/init/templates/hello_project.dart renamed to apps/cli/test/e2e/tests/commands/init/templates/hello_project.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:celest_cli/src/context.dart';
22

3-
import '../../../common/common.dart';
3+
import '../../../../common/common.dart';
44

55
final class HelloProjectTest extends E2ETest {
66
HelloProjectTest(super.target);

0 commit comments

Comments
 (0)