Clients Tests
This commit is contained in:
parent
9c794f2596
commit
096855bb45
|
|
@ -632,6 +632,7 @@ const kPageSizes = [
|
|||
];
|
||||
|
||||
const String kDrawerKey = 'drawer_key';
|
||||
const String kSelectCompanyDropdownKey = 'select_company_dropdown_key';
|
||||
|
||||
const String kActivityCreateClient = '1';
|
||||
const String kActivityArchiveClient = '2';
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
|
|||
|
||||
class AppDropdownButton<T> extends StatelessWidget {
|
||||
const AppDropdownButton({
|
||||
Key key,
|
||||
@required this.value,
|
||||
@required this.onChanged,
|
||||
@required this.items,
|
||||
|
|
@ -13,7 +14,7 @@ class AppDropdownButton<T> extends StatelessWidget {
|
|||
this.blankValue = '',
|
||||
this.enabled = true,
|
||||
this.showUseDefault = false,
|
||||
});
|
||||
}) : super(key: key);
|
||||
|
||||
final String labelText;
|
||||
final dynamic value;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import 'package:material_design_icons_flutter/material_design_icons_flutter.dart
|
|||
|
||||
class DecoratedFormField extends StatelessWidget {
|
||||
const DecoratedFormField({
|
||||
Key key,
|
||||
this.formKey,
|
||||
this.controller,
|
||||
this.label,
|
||||
this.onSavePressed,
|
||||
|
|
@ -36,8 +36,9 @@ class DecoratedFormField extends StatelessWidget {
|
|||
this.isPercent = false,
|
||||
this.showClear = true,
|
||||
this.inputFormatters,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
final Key formKey;
|
||||
final TextEditingController controller;
|
||||
final String label;
|
||||
final String hint;
|
||||
|
|
@ -118,7 +119,7 @@ class DecoratedFormField extends StatelessWidget {
|
|||
}
|
||||
|
||||
return TextFormField(
|
||||
key: key ?? ValueKey(label),
|
||||
key: formKey ?? ValueKey(label),
|
||||
focusNode: focusNode,
|
||||
controller: controller,
|
||||
autofocus: autofocus,
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class _GrowableFormFieldState extends State<GrowableFormField> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DecoratedFormField(
|
||||
key: widget.key,
|
||||
formKey: widget.key,
|
||||
focusNode: _focusNode,
|
||||
initialValue: widget.initialValue,
|
||||
onChanged: widget.onChanged,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class _PasswordFormFieldState extends State<PasswordFormField> {
|
|||
final localization = AppLocalization.of(context);
|
||||
|
||||
return DecoratedFormField(
|
||||
formKey: ValueKey(widget.labelText ?? localization.password),
|
||||
controller: widget.controller,
|
||||
onSavePressed: widget.onSavePressed,
|
||||
autocorrect: false,
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ class MenuDrawer extends StatelessWidget {
|
|||
final _expandedCompanySelector = state.companies.isEmpty
|
||||
? SizedBox()
|
||||
: AppDropdownButton<String>(
|
||||
key: ValueKey(kSelectCompanyDropdownKey),
|
||||
value: viewModel.selectedCompanyIndex,
|
||||
items: [
|
||||
...state.companies
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ class ClientEditDetailsState extends State<ClientEditDetails> {
|
|||
FormCard(
|
||||
children: <Widget>[
|
||||
DecoratedFormField(
|
||||
formKey: ValueKey(localization.name),
|
||||
autofocus: true,
|
||||
controller: _nameController,
|
||||
validator: (String val) => !viewModel.client.hasNameSet
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ class ExpenseEditSettingsState extends State<ExpenseEditSettings> {
|
|||
_setCurrency(currency),
|
||||
),
|
||||
DecoratedFormField(
|
||||
key: ValueKey('__${expense.invoiceCurrencyId}__'),
|
||||
formKey: ValueKey('__${expense.invoiceCurrencyId}__'),
|
||||
controller: _exchangeRateController,
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(decimal: true),
|
||||
|
|
|
|||
|
|
@ -633,7 +633,7 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
children: [
|
||||
Expanded(
|
||||
child: DecoratedFormField(
|
||||
key: ValueKey(
|
||||
formKey: ValueKey(
|
||||
'__exchange_rate_${invoice.clientId}__'),
|
||||
label: localization.exchangeRate,
|
||||
initialValue: formatNumber(
|
||||
|
|
|
|||
|
|
@ -389,7 +389,7 @@ class InvoiceEditDetailsState extends State<InvoiceEditDetails> {
|
|||
.onChanged(invoice.rebuild((b) => b..designId = value?.id)),
|
||||
),
|
||||
DecoratedFormField(
|
||||
key: ValueKey('__exchange_rate_${invoice.clientId}__'),
|
||||
formKey: ValueKey('__exchange_rate_${invoice.clientId}__'),
|
||||
label: localization.exchangeRate,
|
||||
initialValue: formatNumber(invoice.exchangeRate, context,
|
||||
formatNumberType: FormatNumberType.inputAmount),
|
||||
|
|
|
|||
|
|
@ -517,7 +517,7 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
Padding(
|
||||
padding: const EdgeInsets.only(right: kTableColumnGap),
|
||||
child: DecoratedFormField(
|
||||
key: ValueKey('__line_item_${index}_cost__'),
|
||||
formKey: ValueKey('__line_item_${index}_cost__'),
|
||||
textAlign: TextAlign.right,
|
||||
initialValue: formatNumber(
|
||||
lineItems[index].cost, context,
|
||||
|
|
@ -536,7 +536,7 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
Padding(
|
||||
padding: const EdgeInsets.only(right: kTableColumnGap),
|
||||
child: DecoratedFormField(
|
||||
key: ValueKey('__line_item_${index}_quantity__'),
|
||||
formKey: ValueKey('__line_item_${index}_quantity__'),
|
||||
textAlign: TextAlign.right,
|
||||
initialValue: formatNumber(
|
||||
lineItems[index].quantity, context,
|
||||
|
|
@ -555,7 +555,7 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
Padding(
|
||||
padding: const EdgeInsets.only(right: kTableColumnGap),
|
||||
child: DecoratedFormField(
|
||||
key: ValueKey('__line_item_${index}_discount__'),
|
||||
formKey: ValueKey('__line_item_${index}_discount__'),
|
||||
textAlign: TextAlign.right,
|
||||
initialValue: formatNumber(
|
||||
lineItems[index].discount, context,
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ class _FileImportState extends State<_FileImport> {
|
|||
|
||||
final field = DecoratedFormField(
|
||||
enabled: false,
|
||||
key: ValueKey(uploadPart.key +
|
||||
formKey: ValueKey(uploadPart.key +
|
||||
(multipartFile != null ? multipartFile.filename : '')),
|
||||
label: localization.lookup(uploadPart.value),
|
||||
initialValue: !_multipartFiles.containsKey(uploadPart.key)
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ class _TaskEditDesktopState extends State<TaskEditDesktop> {
|
|||
isMoney: false,
|
||||
),
|
||||
DecoratedFormField(
|
||||
key: ValueKey('__rate__'),
|
||||
formKey: ValueKey('__rate__'),
|
||||
controller: _rateController,
|
||||
label: rateLabel,
|
||||
keyboardType: TextInputType.numberWithOptions(
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ class _TaskEditDetailsState extends State<TaskEditDetails> {
|
|||
autocorrect: false,
|
||||
),
|
||||
DecoratedFormField(
|
||||
key: ValueKey('__rate__'),
|
||||
formKey: ValueKey('__rate__'),
|
||||
controller: _rateController,
|
||||
label: rateLabel,
|
||||
keyboardType:
|
||||
|
|
|
|||
46
pubspec.lock
46
pubspec.lock
|
|
@ -267,6 +267,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.1"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fake_async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
faker:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
|
|
@ -287,7 +294,7 @@ packages:
|
|||
name: file
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.2.1"
|
||||
version: "6.0.0"
|
||||
file_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -377,6 +384,11 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.5"
|
||||
flutter_driver:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_json_widget:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -438,6 +450,11 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.1+1"
|
||||
flutter_test:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_typeahead:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -452,6 +469,11 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
fuchsia_remote_debug_protocol:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -660,7 +682,7 @@ packages:
|
|||
name: node_io
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.1.1"
|
||||
node_preamble:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -800,7 +822,7 @@ packages:
|
|||
name: process
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.13"
|
||||
version: "4.0.0"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -987,7 +1009,7 @@ packages:
|
|||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
version: "1.8.0"
|
||||
sqflite:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -1030,6 +1052,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
sync_http:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sync_http
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
synchronized:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -1162,7 +1191,7 @@ packages:
|
|||
name: vm_service
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.2.0"
|
||||
version: "5.5.0"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -1177,6 +1206,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
webdriver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webdriver
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
webkit_inspection_protocol:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ dependency_overrides:
|
|||
path: packages/google_sign_in/google_sign_in_platform_interface
|
||||
|
||||
dev_dependencies:
|
||||
#flutter_driver: # TODO Re-enable
|
||||
# sdk: flutter
|
||||
flutter_driver:
|
||||
sdk: flutter
|
||||
test: ^1.6.3
|
||||
#flutter_test:
|
||||
# sdk: flutter
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
/*
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:invoiceninja_flutter/main.dart' as app;
|
||||
|
||||
|
|
@ -6,4 +5,3 @@ void main() {
|
|||
enableFlutterDriverExtension();
|
||||
app.main(isTesting: true);
|
||||
}
|
||||
*/
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
/*
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:invoiceninja_flutter/main.dart' as app;
|
||||
|
||||
|
|
@ -7,4 +6,3 @@ void main() {
|
|||
enableFlutterDriverExtension();
|
||||
app.main(isTesting: true);
|
||||
}
|
||||
*/
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
/*
|
||||
import 'package:faker/faker.dart';
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
|
@ -96,9 +95,10 @@ void runTestSuite({bool batchMode = false}) {
|
|||
});
|
||||
|
||||
// Archive the edited client
|
||||
test('Archieve/delete client test', () async {
|
||||
test('Archive/delete client test', () async {
|
||||
await testArchiveAndDelete(
|
||||
driver: driver,
|
||||
name: updatedName,
|
||||
archivedMessage: localization.archivedClient,
|
||||
deletedMessage: localization.deletedClient,
|
||||
restoredMessage: localization.restoredClient);
|
||||
|
|
@ -109,4 +109,3 @@ void runTestSuite({bool batchMode = false}) {
|
|||
});
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:faker/faker.dart';
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
import 'package:invoiceninja_flutter/.env.dart';
|
||||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
|
||||
import 'localizations.dart';
|
||||
|
||||
|
|
@ -54,10 +54,11 @@ Future<void> login(FlutterDriver driver,
|
|||
if (selfHosted) {
|
||||
await fillTextFields(driver, <String, dynamic>{
|
||||
localization.url: loginUrl,
|
||||
localization.secret: loginSecret,
|
||||
'${localization.secret} (${localization.optional})': loginSecret,
|
||||
});
|
||||
}
|
||||
|
||||
print(localization.emailSignIn);
|
||||
await driver.tap(find.text(localization.emailSignIn));
|
||||
|
||||
if (loginEmail.isNotEmpty) {
|
||||
|
|
@ -75,8 +76,10 @@ Future<void> logout(FlutterDriver driver, TestLocalization localization,
|
|||
}
|
||||
|
||||
//await driver.scrollUntilVisible(find.byType('Drawer'), find.text(localization.settings));
|
||||
await driver.tap(find.text(localization.settings));
|
||||
await driver.tap(find.text(localization.deviceSettings));
|
||||
//await driver.tap(find.text(localization.settings));
|
||||
//await driver.tap(find.text(localization.deviceSettings));
|
||||
|
||||
await driver.tap(find.byValueKey(kSelectCompanyDropdownKey));
|
||||
|
||||
// Tap on Log Out
|
||||
await driver.tap(find.text(localization.logout));
|
||||
|
|
@ -129,7 +132,7 @@ Future<void> fillAndSaveForm(FlutterDriver driver, Map<String, dynamic> values,
|
|||
await fillTextFields(driver, values);
|
||||
|
||||
// Await for Debouncer
|
||||
await Future<dynamic>.delayed(Duration(milliseconds: 400));
|
||||
await Future<dynamic>.delayed(Duration(milliseconds: 1000));
|
||||
|
||||
print('Check for updated values');
|
||||
await checkTextFields(driver, values, except: skipCheckFor);
|
||||
|
|
@ -145,6 +148,7 @@ Future<void> fillAndSaveForm(FlutterDriver driver, Map<String, dynamic> values,
|
|||
Future<void> testArchiveAndDelete(
|
||||
{FlutterDriver driver,
|
||||
String archivedMessage,
|
||||
String name,
|
||||
String deletedMessage,
|
||||
String restoredMessage}) async {
|
||||
final localization = TestLocalization('en');
|
||||
|
|
@ -164,6 +168,7 @@ Future<void> testArchiveAndDelete(
|
|||
//await driver.waitFor(find.text(localization.archived));
|
||||
|
||||
print('Restore record');
|
||||
await driver.tap(find.text(name));
|
||||
await selectAction(driver, localization.restore);
|
||||
await driver.waitFor(find.text(restoredMessage));
|
||||
await driver.waitForAbsent(find.byType('Snackbar'));
|
||||
|
|
@ -174,6 +179,7 @@ Future<void> testArchiveAndDelete(
|
|||
//await driver.waitFor(find.text(localization.deleted));
|
||||
|
||||
print('Restore record');
|
||||
await driver.tap(find.text(name));
|
||||
await selectAction(driver, localization.restore);
|
||||
await driver.waitFor(find.text(restoredMessage));
|
||||
await driver.waitForAbsent(find.byType('Snackbar'));
|
||||
|
|
@ -189,4 +195,3 @@ String makeUnique(String value) =>
|
|||
|
||||
String getLineItemKey(String key, int index) =>
|
||||
'${Keys.invoiceLineItemBaseKey}_${index}_${key}__';
|
||||
*/
|
||||
Loading…
Reference in New Issue