mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 10:17:16 +08:00
Integration Test: Make it take a few screenshots
* Default value * App Drawer * Note Editing
This commit is contained in:
@ -81,6 +81,7 @@ class JournalApp extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
|
key: ValueKey("App"),
|
||||||
title: 'GitJournal',
|
title: 'GitJournal',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
|
@ -16,6 +16,7 @@ class HomeScreen extends StatelessWidget {
|
|||||||
final appState = container.appState;
|
final appState = container.appState;
|
||||||
|
|
||||||
var createButton = FloatingActionButton(
|
var createButton = FloatingActionButton(
|
||||||
|
key: ValueKey("FAB"),
|
||||||
onPressed: () => _newPost(context),
|
onPressed: () => _newPost(context),
|
||||||
child: Icon(Icons.add),
|
child: Icon(Icons.add),
|
||||||
);
|
);
|
||||||
@ -51,6 +52,7 @@ class HomeScreen extends StatelessWidget {
|
|||||||
bool shouldShowBadge =
|
bool shouldShowBadge =
|
||||||
!appState.remoteGitRepoConfigured && appState.hasJournalEntries;
|
!appState.remoteGitRepoConfigured && appState.hasJournalEntries;
|
||||||
var appBarMenuButton = BadgeIconButton(
|
var appBarMenuButton = BadgeIconButton(
|
||||||
|
key: ValueKey("DrawerButton"),
|
||||||
icon: const Icon(Icons.menu),
|
icon: const Icon(Icons.menu),
|
||||||
itemCount: shouldShowBadge ? 1 : 0,
|
itemCount: shouldShowBadge ? 1 : 0,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
@ -5,8 +5,6 @@ import 'package:test/test.dart';
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Test', () {
|
group('Test', () {
|
||||||
final loadedFinder = find.text('Why not add your first\n Journal Entry?');
|
|
||||||
|
|
||||||
FlutterDriver driver;
|
FlutterDriver driver;
|
||||||
int screenshotNum = 0;
|
int screenshotNum = 0;
|
||||||
|
|
||||||
@ -24,14 +22,49 @@ void main() {
|
|||||||
|
|
||||||
Future _takeScreenshot() async {
|
Future _takeScreenshot() async {
|
||||||
var filePath = screenshotNum.toString() + ".png";
|
var filePath = screenshotNum.toString() + ".png";
|
||||||
|
screenshotNum += 1;
|
||||||
|
|
||||||
|
print("Taking screenshot $filePath");
|
||||||
final file = await File(filePath).create(recursive: true);
|
final file = await File(filePath).create(recursive: true);
|
||||||
final pixels = await driver.screenshot();
|
final pixels = await driver.screenshot();
|
||||||
await file.writeAsBytes(pixels);
|
await file.writeAsBytes(pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
test('Anonymous GitClone works', () async {
|
test('Anonymous GitClone works', () async {
|
||||||
|
final loadedFinder = find.text('Why not add your first\n Journal Entry?');
|
||||||
await driver.waitFor(loadedFinder, timeout: Duration(seconds: 5));
|
await driver.waitFor(loadedFinder, timeout: Duration(seconds: 5));
|
||||||
await _takeScreenshot();
|
await _takeScreenshot();
|
||||||
|
|
||||||
|
// Open the Drawer
|
||||||
|
final drawerButtonFinder = find.byValueKey("DrawerButton");
|
||||||
|
await driver.tap(drawerButtonFinder);
|
||||||
|
await Future.delayed(Duration(milliseconds: 500));
|
||||||
|
await _takeScreenshot();
|
||||||
|
|
||||||
|
// The Git Host setup screen
|
||||||
|
/*
|
||||||
|
await driver.tap(find.text("Setup Git Host"));
|
||||||
|
await driver.waitFor(find.text("GitHub"), timeout: Duration(seconds: 2));
|
||||||
|
await _takeScreenshot();
|
||||||
|
// FIXME: This doesn't seem to work!
|
||||||
|
await driver.tap(find.pageBack());
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Close the drawer
|
||||||
|
var app = find.byValueKey("App");
|
||||||
|
await driver.scroll(app, -300.0, 0.0, const Duration(milliseconds: 300));
|
||||||
|
|
||||||
|
// Create a new note
|
||||||
|
var fab = find.byValueKey("FAB");
|
||||||
|
await driver.waitFor(fab, timeout: Duration(seconds: 2));
|
||||||
|
await driver.tap(fab);
|
||||||
|
await driver.waitFor(find.text('Write here'),
|
||||||
|
timeout: Duration(seconds: 2));
|
||||||
|
await _takeScreenshot();
|
||||||
|
|
||||||
|
await driver.enterText(
|
||||||
|
"Your notes will be saved in Markdown with a YAML header for the metadata.\n\nThe writing experience is clean and distraction free");
|
||||||
|
await _takeScreenshot();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user