Integration Test: Show the sorting settings and view Options

Also add far more existing notes for the screenshots.
This commit is contained in:
Vishesh Handa
2020-09-28 12:11:05 +02:00
parent dfbdb5c50c
commit 75d48fbfc6
4 changed files with 129 additions and 33 deletions

View File

@ -4,6 +4,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:git_bindings/git_bindings.dart';
import 'package:provider/provider.dart';
import 'package:gitjournal/app.dart';
import 'package:gitjournal/core/md_yaml_doc_codec.dart';
import 'package:gitjournal/core/note.dart';
import 'package:gitjournal/core/notes_folder.dart';
@ -278,6 +279,7 @@ class _FolderViewState extends State<FolderView> {
},
),
RadioListTile<StandardViewHeader>(
key: const ValueKey("ShowFileNameOnly"),
title: Text(tr('widgets.FolderView.headerOptions.fileName')),
value: StandardViewHeader.FileName,
groupValue: _headerType,
@ -287,6 +289,7 @@ class _FolderViewState extends State<FolderView> {
},
),
SwitchListTile(
key: const ValueKey("SummaryToggle"),
title: Text(tr('widgets.FolderView.headerOptions.summary')),
value: _showSummary,
onChanged: (bool newVal) {
@ -299,7 +302,18 @@ class _FolderViewState extends State<FolderView> {
];
return AlertDialog(
title: Text(tr('widgets.FolderView.headerOptions.customize')),
title: GestureDetector(
key: const ValueKey("Hack_Back"),
child: Text(tr('widgets.FolderView.headerOptions.customize')),
onTap: () {
// Hack to get out of the dialog in the tests
// driver.findByType('ModalBarrier') doesn't seem to be working
if (JournalApp.isInDebugMode) {
Navigator.of(context).pop();
}
},
),
key: const ValueKey("ViewOptionsDialog"),
content: Column(
children: children,
mainAxisSize: MainAxisSize.min,
@ -375,6 +389,7 @@ class _FolderViewState extends State<FolderView> {
final settings = Provider.of<Settings>(context);
var extraActions = PopupMenuButton<DropDownChoices>(
key: const ValueKey("PopupMenu"),
onSelected: (DropDownChoices choice) {
switch (choice) {
case DropDownChoices.SortingOptions:
@ -388,11 +403,13 @@ class _FolderViewState extends State<FolderView> {
},
itemBuilder: (BuildContext context) => <PopupMenuEntry<DropDownChoices>>[
PopupMenuItem<DropDownChoices>(
key: const ValueKey("SortingOptions"),
value: DropDownChoices.SortingOptions,
child: Text(tr('widgets.FolderView.sortingOptions')),
),
if (_viewType == FolderViewType.Standard)
PopupMenuItem<DropDownChoices>(
key: const ValueKey("ViewOptions"),
value: DropDownChoices.ViewOptions,
child: Text(tr('widgets.FolderView.viewOptions')),
),

View File

@ -44,12 +44,14 @@ class _SortingModeSelectorState extends State<SortingModeSelector> {
),
actions: [
OutlineButton(
key: const ValueKey("Cancel"),
child: Text(tr('settings.cancel')),
onPressed: () {
Navigator.of(context).pop();
},
),
OutlineButton(
key: const ValueKey("Ok"),
child: Text(tr('settings.ok')),
onPressed: () {
Navigator.of(context).pop(SortingMode(field, order));

View File

@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter_driver/driver_extension.dart';
import 'package:gitjournal/app_settings.dart';
import 'package:path_provider/path_provider.dart';
import 'package:meta/meta.dart';
import 'package:gitjournal/app.dart';
import 'package:gitjournal/settings.dart';
@ -43,46 +44,86 @@ Future<void> populateWithData(SharedPreferences pref) async {
Directory(p.join(repoPath, "Journal/Personal")).createSync(recursive: true);
Directory(p.join(repoPath, "Food")).createSync();
final now = DateTime.now();
// Write notes
createChecklist(p.join(repoPath, "checklist.md"), DateTime.now());
createNoteWithTitle(
createNote(
p.join(repoPath, "note1.md"),
DateTime.now(),
"Desire",
"Haven't you always wanted such an app?",
now,
body: "Desire",
title: "Haven't you always wanted such an app?",
);
createNote(
p.join(repoPath, "note2.md"),
DateTime.now(),
"There is not a pipe",
now,
body: "There is not a pipe",
);
createNote(
p.join(repoPath, "note2.md"),
DateTime.now(),
"There is not a pipe",
p.join(repoPath, "note3.md"),
now,
body:
"What are the different models for building sustainable Open Source Software?",
);
createNote(
p.join(repoPath, "note-taking-apps.md"),
now.add(const Duration(days: -2)),
body:
"""There seems to be an explosion of Note Taking apps. Here are some of the Open Sources ones that I have found -
- Zettlr
- Foam
- Dendron
- Joplin
- SimpleNote
- Standard Notes
- TiddlyWiki
""",
);
createNote(
p.join(repoPath, "note3.md"),
now.add(const Duration(hours: -2)),
body:
"What are the different models for building sustainable Open Source Software?",
);
createNote(
p.join(repoPath, "git-analogy.md"),
now.add(const Duration(hours: -5)),
body: "Perhaps Git could be explained as a virtual usb-drive",
title: "Git Analogy",
);
createNote(
p.join(repoPath, "open-source-analytics.md"),
now.add(const Duration(hours: -5)),
body: "Research what Open Source Alternative Exist for App Analytics",
);
createNote(
p.join(repoPath, "lighting.md"),
now.add(const Duration(hours: -5)),
body: "But some lamps to make the office more cozy at night",
);
}
void createNote(String filePath, DateTime dt, String body) {
var content = """---
void createNote(String filePath, DateTime dt,
{@required String body, String title}) {
var content = "";
if (title == null) {
content = """---
modified: ${toIso8601WithTimezone(dt)}
created: ${toIso8601WithTimezone(dt)}
---
$body
""";
File(filePath).writeAsStringSync(content);
}
void createNoteWithTitle(
String filePath,
DateTime dt,
String title,
String body,
) {
var content = """---
} else {
content = """---
modified: ${toIso8601WithTimezone(dt)}
created: ${toIso8601WithTimezone(dt)}
title: $title
@ -90,6 +131,7 @@ title: $title
$body
""";
}
File(filePath).writeAsStringSync(content);
}

View File

@ -31,16 +31,6 @@ void main() {
Future _takeScreenshot() async {
screenshotNum += 1;
/*
var filePath = screenshotNum.toString() + ".png";
print("Taking screenshot $filePath");
final file = await File(filePath).create(recursive: true);
final pixels = await driver.screenshot();
await file.writeAsBytes(pixels);
*/
// Fancy Screenshot package
await screenshot(driver, config, screenshotNum.toString());
}
@ -137,9 +127,54 @@ void main() {
await Future.delayed(const Duration(milliseconds: 100));
await _takeScreenshot();
// Capture Standard View's Sorting Options
var popUpMenu = find.byValueKey("PopupMenu");
await waitFor(popUpMenu);
await driver.tap(popUpMenu);
var sortingOptions = find.byValueKey("SortingOptions");
await waitFor(sortingOptions);
await _takeScreenshot();
await driver.tap(sortingOptions);
var sortingOptionsCancel = find.byValueKey("Cancel");
await waitFor(sortingOptionsCancel);
await _takeScreenshot();
await driver.tap(sortingOptionsCancel);
// StandardView's View Settings
await waitFor(popUpMenu);
await driver.tap(popUpMenu);
var viewOptions = find.byValueKey("ViewOptions");
await waitFor(viewOptions);
await driver.tap(viewOptions);
var viewOptionsDialog = find.byValueKey("ViewOptionsDialog");
await waitFor(viewOptionsDialog);
await _takeScreenshot();
var showSummary = find.byValueKey("SummaryToggle");
await waitFor(showSummary);
await driver.tap(showSummary);
var fileNameSel = find.byValueKey("ShowFileNameOnly");
await waitFor(fileNameSel);
await _takeScreenshot();
await driver.tap(fileNameSel);
// Remove the Dialog
var barrier = find.byValueKey('Hack_Back');
await waitFor(barrier);
await driver.tap(barrier);
// Folder View Selector
print("Taking Screenshots of FolderViewSelector");
var folderViewSelector = find.byValueKey("FolderViewSelector");
await waitFor(folderViewSelector);
await _takeScreenshot();
await driver.tap(folderViewSelector);
await Future.delayed(const Duration(milliseconds: 100));
await _takeScreenshot();