Add utility method to fill text fields in a form
This commit is contained in:
parent
7536f2ab3e
commit
e0fe5bb635
|
|
@ -51,12 +51,11 @@ void main() {
|
|||
test('Add a new product', () async {
|
||||
await driver.tap(find.byValueKey(ProductKeys.fab));
|
||||
|
||||
await driver.tap(find.byValueKey(ProductKeys.productKey));
|
||||
await driver.enterText(productKey);
|
||||
await driver.tap(find.byValueKey(ProductKeys.notes));
|
||||
await driver.enterText(notes);
|
||||
await driver.tap(find.byValueKey(ProductKeys.cost));
|
||||
await driver.enterText(cost);
|
||||
await fillTextFields(driver, <String, dynamic>{
|
||||
ProductKeys.productKey: productKey,
|
||||
ProductKeys.notes: notes,
|
||||
ProductKeys.cost: cost,
|
||||
});
|
||||
|
||||
await driver.tap(find.byTooltip(localization.save));
|
||||
|
||||
|
|
@ -79,12 +78,11 @@ void main() {
|
|||
await driver.scrollUntilVisible(find.byType('ListView'), find.text(productKey));
|
||||
await driver.tap(find.text(productKey), timeout: Duration(seconds: 3));
|
||||
|
||||
await driver.tap(find.byValueKey(ProductKeys.productKey));
|
||||
await driver.enterText(updatedProductKey);
|
||||
await driver.tap(find.byValueKey(ProductKeys.notes));
|
||||
await driver.enterText(updatedNotes);
|
||||
await driver.tap(find.byValueKey(ProductKeys.cost));
|
||||
await driver.enterText(updatedCost);
|
||||
await fillTextFields(driver, <String, dynamic>{
|
||||
ProductKeys.productKey: updatedProductKey,
|
||||
ProductKeys.notes: updatedNotes,
|
||||
ProductKeys.cost: updatedCost,
|
||||
});
|
||||
|
||||
await driver.tap(find.byTooltip(localization.save));
|
||||
|
||||
|
|
|
|||
|
|
@ -17,16 +17,16 @@ Future<void> login(FlutterDriver driver,
|
|||
await driver.tap(find.byValueKey(LoginKeys.loginSelfHost));
|
||||
}
|
||||
|
||||
await driver.tap(find.byValueKey(LoginKeys.email));
|
||||
await driver.enterText(loginEmail);
|
||||
await driver.tap(find.byValueKey(LoginKeys.password));
|
||||
await driver.enterText(loginPassword);
|
||||
await fillTextFields(driver, <String, dynamic>{
|
||||
LoginKeys.email: loginEmail,
|
||||
LoginKeys.password: loginPassword,
|
||||
});
|
||||
|
||||
if (selfHosted) {
|
||||
await driver.tap(find.byValueKey(LoginKeys.url));
|
||||
await driver.enterText(loginUrl);
|
||||
await driver.tap(find.byValueKey(LoginKeys.secret));
|
||||
await driver.enterText(loginSecret);
|
||||
await fillTextFields(driver, <String, dynamic>{
|
||||
LoginKeys.url: loginUrl,
|
||||
LoginKeys.secret: loginSecret,
|
||||
});
|
||||
}
|
||||
|
||||
await driver.tap(find.text(LoginKeys.loginButton.toUpperCase()));
|
||||
|
|
@ -55,4 +55,19 @@ Future<void> loginAndOpenProducts(FlutterDriver driver) async {
|
|||
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.byType(AppKeys.dashboardScreen));
|
||||
await driver.tap(find.byTooltip(AppKeys.openAppDrawer));
|
||||
await driver.tap(find.byValueKey(ClientKeys.drawer));
|
||||
await driver.waitFor(find.byType(ClientKeys.screen));
|
||||
}
|
||||
|
||||
Future<void> fillTextFields(FlutterDriver driver, Map<String, dynamic> values) async {
|
||||
for (var entry in values.entries) {
|
||||
await driver.tap(find.byValueKey(entry.key));
|
||||
await driver.enterText(entry.value);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue