Tests
This commit is contained in:
parent
34e56f95b1
commit
83b377f7a2
|
|
@ -49,7 +49,6 @@ import 'package:invoiceninja_flutter/redux/quote/quote_middleware.dart';
|
|||
// STARTER: import - do not remove comment
|
||||
|
||||
void main({bool isTesting = false}) async {
|
||||
|
||||
final SentryClient _sentry = Config.SENTRY_DNS.isEmpty
|
||||
? null
|
||||
: SentryClient(
|
||||
|
|
@ -87,11 +86,13 @@ void main({bool isTesting = false}) async {
|
|||
..addAll(createStoreQuotesMiddleware())
|
||||
..addAll(createStoreSettingsMiddleware())
|
||||
// STARTER: middleware - do not remove comment
|
||||
..addAll([
|
||||
LoggingMiddleware<dynamic>.printer(
|
||||
formatter: LoggingMiddleware.multiLineFormatter,
|
||||
),
|
||||
]));
|
||||
..addAll(isTesting
|
||||
? []
|
||||
: [
|
||||
LoggingMiddleware<dynamic>.printer(
|
||||
formatter: LoggingMiddleware.multiLineFormatter,
|
||||
),
|
||||
]));
|
||||
|
||||
Future<void> _reportError(dynamic error, dynamic stackTrace) async {
|
||||
print('Caught error: $error');
|
||||
|
|
|
|||
|
|
@ -1,12 +1,3 @@
|
|||
class AppKeys {
|
||||
static const String openAppDrawer = 'Open navigation menu';
|
||||
}
|
||||
|
||||
class AppTooltips {
|
||||
static const String save = 'Save';
|
||||
static const String back = 'Back';
|
||||
}
|
||||
|
||||
class ProductKeys {
|
||||
static const String screen = 'ProductScreen';
|
||||
static const String drawer = 'productDrawer';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// Import Flutter Driver API
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:invoiceninja_flutter/utils/keys.dart';
|
||||
|
||||
import 'utils/common_actions.dart';
|
||||
import 'utils/localizations.dart';
|
||||
|
|
@ -35,11 +34,6 @@ void main() {
|
|||
|
||||
test('Details filled by user and login', () async {
|
||||
await login(driver, retype: true);
|
||||
|
||||
await driver.waitFor(
|
||||
find.byTooltip(AppKeys.openAppDrawer),
|
||||
timeout: new Duration(seconds: 60),
|
||||
);
|
||||
});
|
||||
|
||||
test('Logout from a logged in user', () async {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import 'utils/localizations.dart';
|
|||
|
||||
void main() {
|
||||
group('PRODUCTS TEST', () {
|
||||
|
||||
TestLocalization localization;
|
||||
FlutterDriver driver;
|
||||
|
||||
|
|
@ -18,14 +17,16 @@ void main() {
|
|||
|
||||
final updatedProductKey = faker.food.cuisine();
|
||||
final updatedNotes = faker.food.dish();
|
||||
final updatedCost = faker.randomGenerator.decimal(min: 50).toStringAsFixed(2);
|
||||
final updatedCost =
|
||||
faker.randomGenerator.decimal(min: 50).toStringAsFixed(2);
|
||||
|
||||
setUpAll(() async {
|
||||
localization = TestLocalization('en');
|
||||
|
||||
driver = await FlutterDriver.connect();
|
||||
|
||||
await loginAndOpenProducts(driver);
|
||||
await login(driver);
|
||||
await driver.tap(find.byTooltip(Keys.openAppDrawer));
|
||||
await driver.tap(find.byTooltip(localization.products));
|
||||
});
|
||||
|
||||
tearDownAll(() async {
|
||||
|
|
@ -63,7 +64,8 @@ void main() {
|
|||
|
||||
await driver.tap(find.pageBack());
|
||||
|
||||
await driver.scrollUntilVisible(find.byType('ListView'), find.text(productKey));
|
||||
await driver.scrollUntilVisible(
|
||||
find.byType('ListView'), find.text(productKey));
|
||||
await driver.tap(find.text(productKey));
|
||||
await driver.waitFor(find.text(productKey));
|
||||
await driver.waitFor(find.text(notes));
|
||||
|
|
@ -72,10 +74,10 @@ void main() {
|
|||
await driver.tap(find.pageBack());
|
||||
});
|
||||
|
||||
|
||||
// Edit the newly created product
|
||||
test('Edit an existing product', () async {
|
||||
await driver.scrollUntilVisible(find.byType('ListView'), find.text(productKey));
|
||||
await driver.scrollUntilVisible(
|
||||
find.byType('ListView'), find.text(productKey));
|
||||
await driver.tap(find.text(productKey), timeout: Duration(seconds: 3));
|
||||
|
||||
await fillTextFields(driver, <String, dynamic>{
|
||||
|
|
@ -91,7 +93,7 @@ void main() {
|
|||
|
||||
await driver.tap(find.pageBack());
|
||||
|
||||
// verify updated values while editing existing product
|
||||
// verify updated values while editing existing product
|
||||
await driver.tap(find.text(updatedProductKey));
|
||||
await driver.waitFor(find.text(updatedProductKey));
|
||||
await driver.waitFor(find.text(updatedNotes));
|
||||
|
|
@ -154,7 +156,6 @@ void main() {
|
|||
|
||||
// Delete the edited product
|
||||
test('Deleteing a product test', () async {
|
||||
|
||||
await driver.tap(find.text(updatedProductKey));
|
||||
|
||||
await driver.tap(find.byType('ActionMenuButton'));
|
||||
|
|
@ -163,6 +164,5 @@ void main() {
|
|||
// verify not in list
|
||||
await driver.waitForAbsent(find.text(updatedProductKey));
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ import 'package:invoiceninja_flutter/utils/keys.dart';
|
|||
|
||||
import 'localizations.dart';
|
||||
|
||||
class Keys {
|
||||
static const String openAppDrawer = 'Open navigation menu';
|
||||
}
|
||||
|
||||
Future<void> login(FlutterDriver driver,
|
||||
{bool selfHosted = true,
|
||||
bool retype = false,
|
||||
|
|
@ -11,7 +15,6 @@ Future<void> login(FlutterDriver driver,
|
|||
String loginPassword = Config.TEST_PASSWORD,
|
||||
String loginUrl = Config.TEST_URL,
|
||||
String loginSecret = Config.TEST_SECRET}) async {
|
||||
|
||||
final localization = TestLocalization('en');
|
||||
|
||||
await fillTextFields(driver, <String, dynamic>{
|
||||
|
|
@ -27,11 +30,16 @@ Future<void> login(FlutterDriver driver,
|
|||
}
|
||||
|
||||
await driver.tap(find.text(localization.login.toUpperCase()));
|
||||
|
||||
await driver.waitFor(
|
||||
find.byTooltip(Keys.openAppDrawer),
|
||||
timeout: new Duration(seconds: 60),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> logout(FlutterDriver driver, TestLocalization localization) async {
|
||||
// Go to Settings Screen
|
||||
await driver.tap(find.byTooltip(AppKeys.openAppDrawer));
|
||||
await driver.tap(find.byTooltip(Keys.openAppDrawer));
|
||||
//await driver.scrollUntilVisible(find.byType('Drawer'), find.byValueKey(SettingsKeys.drawer));
|
||||
//await driver.tap(find.byValueKey(SettingsKeys.drawer));
|
||||
await driver.tap(find.byTooltip(localization.settings));
|
||||
|
|
@ -47,18 +55,10 @@ Future<void> logout(FlutterDriver driver, TestLocalization localization) async {
|
|||
await driver.waitFor(find.text(localization.login.toUpperCase()));
|
||||
}
|
||||
|
||||
Future<void> loginAndOpenProducts(FlutterDriver driver) async {
|
||||
login(driver);
|
||||
await driver.waitFor(find.byTooltip(AppKeys.openAppDrawer));
|
||||
await driver.tap(find.byTooltip(AppKeys.openAppDrawer));
|
||||
await driver.tap(find.byValueKey(ProductKeys.drawer));
|
||||
await driver.waitFor(find.byType(ProductKeys.screen));
|
||||
}
|
||||
|
||||
Future<void> loginAndOpenClients(FlutterDriver driver) async {
|
||||
login(driver);
|
||||
await driver.waitFor(find.byTooltip(AppKeys.openAppDrawer));
|
||||
await driver.tap(find.byTooltip(AppKeys.openAppDrawer));
|
||||
await driver.waitFor(find.byTooltip(Keys.openAppDrawer));
|
||||
await driver.tap(find.byTooltip(Keys.openAppDrawer));
|
||||
await driver.tap(find.byValueKey(ClientKeys.drawer));
|
||||
await driver.waitFor(find.byType(ClientKeys.screen));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue