-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* #57: add integration tests for notes crud operations
- Loading branch information
1 parent
9e81d01
commit d613a46
Showing
6 changed files
with
245 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import 'package:dairy_app/core/pages/home_page.dart'; | ||
import 'package:dairy_app/features/notes/presentation/pages/note_create_page.dart'; | ||
import 'package:dairy_app/features/notes/presentation/widgets/note_save_button.dart'; | ||
import 'package:dairy_app/features/notes/presentation/widgets/note_title_input_field.dart'; | ||
import 'package:dairy_app/app/view/app.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
import 'package:flutter_quill/flutter_quill.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:dairy_app/core/dependency_injection/injection_container.dart' | ||
as di; | ||
|
||
Future<void> main() async { | ||
setUpAll(() async { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
await dotenv.load(); | ||
await di.init(); | ||
}); | ||
|
||
testWidgets( | ||
'Guest login integration test,' | ||
'click on sign up button to move reveal guest login button' | ||
'click the guest login button to enter HomePage' | ||
'Click on the floating action button to move to NoteCreatePage' | ||
'Enter some text in the title field' | ||
'Enter some text in the body field' | ||
'Click on the save button to save the note' | ||
'Click on the back button to move back to HomePage' | ||
'Check if the note is saved in the HomePage', | ||
(WidgetTester tester) async { | ||
await tester.pumpWidget(const App()); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.text('Continue as guest')); | ||
await tester.pumpAndSettle(); | ||
expect(find.byType(HomePage), findsOneWidget); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.byType(FloatingActionButton)); | ||
await tester.pumpAndSettle(); | ||
await tester.enterText(find.byType(NoteTitleInputField), 'Test Title'); | ||
await tester.pumpAndSettle(); | ||
|
||
expect(find.byType(QuillEditor), findsOneWidget); | ||
|
||
expect( | ||
find.descendant( | ||
of: find.byType(QuillEditor), | ||
matching: find.byType(TextFieldTapRegion), | ||
), | ||
findsOneWidget); | ||
|
||
await tester.tap(find.byType(NoteSaveButton)); | ||
await tester.pumpAndSettle(); | ||
|
||
await Future.delayed(const Duration(seconds: 1)); | ||
await tester.pumpAndSettle(); | ||
expect(find.text('Test Title'), findsOneWidget); | ||
expect(find.byType(HomePage), findsOneWidget); | ||
expect(find.byType(NoteCreatePage), findsNothing); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import 'package:dairy_app/core/pages/home_page.dart'; | ||
import 'package:dairy_app/core/widgets/home_page_app_bar.dart'; | ||
import 'package:dairy_app/features/notes/presentation/pages/note_create_page.dart'; | ||
import 'package:dairy_app/features/notes/presentation/widgets/note_save_button.dart'; | ||
import 'package:dairy_app/features/notes/presentation/widgets/note_title_input_field.dart'; | ||
import 'package:dairy_app/app/view/app.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
import 'package:flutter_quill/flutter_quill.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:dairy_app/core/dependency_injection/injection_container.dart' | ||
as di; | ||
|
||
Future<void> main() async { | ||
setUpAll(() async { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
await dotenv.load(); | ||
await di.init(); | ||
}); | ||
|
||
testWidgets( | ||
'Run login and create note' | ||
'long press the note' | ||
'delete the note and check if the note is deleted', | ||
(WidgetTester tester) async { | ||
await tester.pumpWidget(const App()); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.text('Continue as guest')); | ||
await tester.pumpAndSettle(); | ||
expect(find.byType(HomePage), findsOneWidget); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.byType(FloatingActionButton)); | ||
await tester.pumpAndSettle(); | ||
await tester.enterText(find.byType(NoteTitleInputField), 'Test Title'); | ||
await tester.pumpAndSettle(); | ||
|
||
expect(find.byType(QuillEditor), findsOneWidget); | ||
|
||
expect( | ||
find.descendant( | ||
of: find.byType(QuillEditor), | ||
matching: find.byType(TextFieldTapRegion), | ||
), | ||
findsOneWidget); | ||
|
||
await tester.tap(find.byType(NoteSaveButton)); | ||
await tester.pumpAndSettle(); | ||
|
||
await Future.delayed(const Duration(seconds: 1)); | ||
await tester.pumpAndSettle(); | ||
expect(find.text('Test Title'), findsOneWidget); | ||
expect(find.byType(HomePage), findsOneWidget); | ||
expect(find.byType(NoteCreatePage), findsNothing); | ||
await tester.longPress(find.text('Test Title')); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.byType(DeleteIcon)); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.text('Delete')); | ||
await Future.delayed(const Duration(seconds: 1)); | ||
expect(find.text('Test Title'), findsNothing); | ||
expect(find.byType(HomePage), findsOneWidget); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import 'package:dairy_app/core/pages/home_page.dart'; | ||
import 'package:dairy_app/features/notes/presentation/pages/note_create_page.dart'; | ||
import 'package:dairy_app/features/notes/presentation/widgets/note_save_button.dart'; | ||
import 'package:dairy_app/features/notes/presentation/widgets/note_title_input_field.dart'; | ||
import 'package:dairy_app/app/view/app.dart'; | ||
import 'package:dairy_app/features/notes/presentation/widgets/toggle_read_write_button.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
import 'package:flutter_quill/flutter_quill.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:dairy_app/core/dependency_injection/injection_container.dart' | ||
as di; | ||
|
||
Future<void> main() async { | ||
setUpAll(() async { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
await dotenv.load(); | ||
await di.init(); | ||
}); | ||
|
||
testWidgets( | ||
'Run login and create note,' | ||
'update the note title and chek if the note is updated', | ||
(WidgetTester tester) async { | ||
await tester.pumpWidget(const App()); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.text('Continue as guest')); | ||
await tester.pumpAndSettle(); | ||
expect(find.byType(HomePage), findsOneWidget); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.byType(FloatingActionButton)); | ||
await tester.pumpAndSettle(); | ||
await tester.enterText(find.byType(NoteTitleInputField), 'Test Title'); | ||
await tester.pumpAndSettle(); | ||
|
||
expect(find.byType(QuillEditor), findsOneWidget); | ||
|
||
expect( | ||
find.descendant( | ||
of: find.byType(QuillEditor), | ||
matching: find.byType(TextFieldTapRegion), | ||
), | ||
findsOneWidget); | ||
|
||
await tester.tap(find.byType(NoteSaveButton)); | ||
await tester.pumpAndSettle(); | ||
|
||
await Future.delayed(const Duration(seconds: 1)); | ||
await tester.pumpAndSettle(); | ||
expect(find.text('Test Title'), findsOneWidget); | ||
expect(find.byType(HomePage), findsOneWidget); | ||
expect(find.byType(NoteCreatePage), findsNothing); | ||
await tester.tap(find.text('Test Title')); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.byType(ToggleReadWriteButton)); | ||
await tester.pumpAndSettle(); | ||
await tester.enterText( | ||
find.byType(NoteTitleInputField), 'Test Title Updated'); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.byType(NoteSaveButton)); | ||
await tester.pumpAndSettle(); | ||
|
||
await Future.delayed(const Duration(seconds: 1)); | ||
await tester.pumpAndSettle(); | ||
expect(find.text('Test Title'), findsNothing); | ||
expect(find.text('Test Title Updated'), findsOneWidget); | ||
expect(find.byType(HomePage), findsOneWidget); | ||
expect(find.byType(NoteCreatePage), findsNothing); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import 'package:integration_test/integration_test_driver.dart'; | ||
|
||
Future<void> main() => integrationDriver(); |