Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
enm10k committed Jun 20, 2024
1 parent f0c31fa commit 77e1395
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 20 deletions.
13 changes: 5 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
fix:
dart fix --apply lib
run_integration_test rit:
flutter run -t integration_test/hello_test.dart

fmt:
dart format lib
dart fix --apply lib
dart fix --apply integration_test
dart format lib integration_test

build-runner-watch watch:
# flutter pub run build_runner build -d -v
Expand Down Expand Up @@ -36,8 +38,3 @@ cloc:

run-web:
CHROME_EXECUTABLE="./scripts/google-chrome-unsafe.sh" flutter run -d chrome

integration_test it:
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/hello_test.dart
56 changes: 53 additions & 3 deletions integration_test/hello_test.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,60 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:nocodb/main.dart';

// https://github.com/flutter/flutter/issues/88765#issuecomment-1113140289
Future<void> waitFor(
final WidgetTester tester,
final Finder finder, {
final Duration timeout = const Duration(seconds: 20),
}) async {
final end = DateTime.now().add(timeout);

do {
if (DateTime.now().isAfter(end)) {
throw Exception('Timed out waiting for $finder');
}

await tester.pumpAndSettle();
await Future.delayed(const Duration(milliseconds: 100));
} while (finder.evaluate().isEmpty);
}

void main() {
HttpOverrides.global = null;
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

testWidgets('failing test example', (WidgetTester tester) async {
expect(2 + 2, equals(5));
testWidgets('sign in', (final WidgetTester tester) async {
await tester.pumpWidget(
const ProviderScope(
child: App(),
),
);
await waitFor(tester, find.text('SIGN IN'));

await tester.enterText(
find.byKey(const ValueKey('email')),
'enm10k@gmail.com',
);
await tester.enterText(
find.byKey(const ValueKey('password')),
'hogehoge',
);
await tester.enterText(
find.byKey(const ValueKey('endpoint')),
'http://10.0.2.2:8080',
);
await tester.tap(
find.byKey(const ValueKey('sign_in_button')),
);

await tester.pumpAndSettle();

await waitFor(tester, find.text('Projects'));
// expect(2 + 2, equals(5));
});
}
}
4 changes: 1 addition & 3 deletions lib/features/core/components/dialog/fields_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ class FieldsDialog extends HookConsumerWidget {
),
InkWell(
onTap: () {
ref
.read(viewProvider.notifier)
.showSystemFields();
ref.read(viewProvider.notifier).showSystemFields();
},
child: Row(
children: [
Expand Down
3 changes: 2 additions & 1 deletion lib/features/core/providers/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class View extends _$View {
data: {
'show_system_fields': !state!.showSystemFields,
},
), serializer: (final ok) => state = ok,
),
serializer: (final ok) => state = ok,
);
}

Expand Down
6 changes: 5 additions & 1 deletion lib/features/sign_in/pages/sign_in.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class SignInPage extends HookConsumerWidget {
child: Column(
children: [
TextField(
key: const ValueKey('email'),
autofillHints: const [
AutofillHints.email,
AutofillHints.username,
Expand All @@ -72,6 +73,7 @@ class SignInPage extends HookConsumerWidget {
),
),
TextField(
key: const ValueKey('password'),
autofillHints: const [
AutofillHints.password,
],
Expand All @@ -92,9 +94,10 @@ class SignInPage extends HookConsumerWidget {
obscureText: !showPassword.value,
),
TextField(
key: const ValueKey('endpoint'),
onChanged: (final value) {
EasyDebounce.debounce(
'sign_in_password',
'api_endpoint',
const Duration(seconds: 1),
() async {
await api
Expand Down Expand Up @@ -138,6 +141,7 @@ class SignInPage extends HookConsumerWidget {
),
actions: [
TextButton(
key: const ValueKey('sign_in_button'),
child: const Text('SIGN IN'),
onPressed: () async {
api.init(apiUrlController.text);
Expand Down
1 change: 0 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ void main() async {
return stack;
};

// WidgetsFlutterBinding.ensureInitialized();
runApp(
const ProviderScope(
child: App(),
Expand Down
5 changes: 5 additions & 0 deletions scripts/run_android_emulator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

cd ~/Library/Android/sdk/emulator
./emulator -avd $(emulator -list-avds | head -n 1) &

3 changes: 0 additions & 3 deletions test_driver/integration_test.dart

This file was deleted.

0 comments on commit 77e1395

Please sign in to comment.