Add TestId helper, identifier plumbing for shared widgets, and test-key lints (#3690)
What changed, and why it matters
This is a large cleanup of how the app labels its on-screen buttons and fields for automated testing and accessibility tools. Previously, many test labels were accidentally built from private user data such as wallet names, transaction IDs, seed words, and crypto addresses. Those labels can be read by iOS/Android accessibility services and by UI-automation testing tools, so a malicious or overly curious app on the same device could have harvested them. The patch replaces those dynamic labels with fixed or index-based identifiers, adds lint rules and a CI check to stop developers from reintroducing user data into labels, and deletes an unused widget. It is a privacy improvement, not a remote hack, but it meaningfully reduces the amount of sensitive information exposed through the accessibility tree in release builds.
No immediate user action is required. For the project, ensure the new lints and CI workflow are enabled in all active branches, run the semantics_ids codemod on any remaining feature branches, and audit third-party plugins that may read accessibility identifiers. Consider documenting the policy that _key identifiers must never contain PII.
Security signals we found
Accessibility identifiers derived from PII/sensitive data (wallet names, transaction IDs, seed words, addresses) are replaced with static or index-based identifiers
New custom lint rule no_string_interpolation_in_test_key blocks string interpolation in test keys except for int indexes and enum .name
New custom lint rule require_test_key_semantics_identifier ensures framework interactive widgets with _key keys expose a Semantics identifier
New CI workflow no_user_data_in_test_keys.yaml enforces the same restriction at pull-request time
Unused ExchangeCard widget deleted because it interpolated internal card instance names into keys
Alert dialog key forwarding fixed so find.byKey resolves to a single widget instead of being dropped/duplicated
Semantics identifier plumbing added to ~125 existing Cake widgets and many framework widgets across lib/new-ui, lib/src, and lib/cake_pay
Evidence from the diff
The commit introduces a TestId helper that maps Flutter ValueKey
Changed components
lib/utils/test_id.dart (new)cw_custom_lints (new lint rules and quick fix)tool/semantics_ids/main.dart (new codemod).github/workflows/no_user_data_in_test_keys.yaml (new CI check)lib/new-ui/pages and widgets (ModalTopBar, send/receive/swap sheets, history rows, settings rows)lib/src/screens (contacts, dashboard, wallet list, seed verification, settings, new wallet)lib/cake_pay/src/cards/cake_pay_buy_card_page.dartintegration_test robots (updated to resolve list indexes)test/new-ui/widgets and test/src/widgets (new identifier tests)Inspect captured patch +2086 / −630
### .github/workflows/no_user_data_in_test_keys.yaml
@@ -0,0 +1,23 @@
+name: No user data in test keys
+
+on: [pull_request]
+
+jobs:
+ PR_test_build:
+ runs-on: puzl-ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Check that test keys under lib/ interpolate only indexes and enum names
+ run: |
+ GIT_GREP_OUT="$(git grep -nE "_key['\"]" -- lib | perl -ne '
+ next if m{^\S+?:\d+:\s*//};
+ while (/(?:Key|TestId\.(?:merge|container))\(\s*(["\x27])((?:(?!\1).)*?_key)\1/g) {
+ (my $rest = $2) =~ s/\$\{?(?:index|itemIndex|_historyKeyIndex)(?:\+\+)?\}?|\$\{[\w.]*\b(?:type|key)\.name\}|\$\{entry\.\$1\}|\$\{updatedTransactions\.length\}|\$\{date\.(?:year|month)\}|\$\{[\w.]+\.indexOf\([\w.]+\)\}//g;
+ print if $rest =~ /\$/;
+ }' || true)"
+ [[ "x$GIT_GREP_OUT" == "x" ]] && exit 0
+ echo "$GIT_GREP_OUT"
+ echo "These test keys interpolate a value that may hold user data (a seed word, address, wallet name or transaction id)."
+ echo "Keys ending in _key are published as accessibility identifiers in release builds: use a list index or an enum name."
+ exit 1
### cw_custom_lints/lib/main.dart
@@ -8,6 +8,9 @@ import "package:cw_custom_lints/money_amount_to_string/money_amount_to_string_ru
import "package:cw_custom_lints/print_verbose/print_verbose_fix.dart";
import "package:cw_custom_lints/print_verbose/print_verbose_rule.dart";
import "package:cw_custom_lints/restricted_imports/restricted_imports_rule.dart";
+import "package:cw_custom_lints/test_key_interpolation/test_key_interpolation_rule.dart";
+import "package:cw_custom_lints/test_key_semantics/test_key_semantics_fix.dart";
+import "package:cw_custom_lints/test_key_semantics/test_key_semantics_rule.dart";
import "package:cw_custom_lints/use_cake_exception/use_cake_exception_rule.dart";
final plugin = CwCustomLintsPlugin();
@@ -24,6 +27,8 @@ class CwCustomLintsPlugin extends Plugin {
registry.registerWarningRule(ModernButtonSemanticsRule());
registry.registerWarningRule(ModalTopBarSemanticsRule());
registry.registerWarningRule(MoneyAmountToStringRule());
+ registry.registerWarningRule(TestKeySemanticsRule());
+ registry.registerWarningRule(TestKeyInterpolationRule());
registry.registerWarningRule(UseCakeExceptionRule());
registry.registerFixForRule(PrintVerboseRule.code, ReplaceWithPrintV.new);
@@ -32,5 +37,6 @@ class CwCustomLintsPlugin extends Plugin {
MoneyAmountToStringRule.code,
ReplaceWithMoneyToStringInBaseUnit.new,
);
+ registry.registerFixForRule(TestKeySemanticsRule.code, WrapInTestIdMerge.new);
}
}
### cw_custom_lints/lib/test_key_interpolation/test_key_interpolation_rule.dart
@@ -0,0 +1,77 @@
+import "package:analyzer/analysis_rule/analysis_rule.dart";
+import "package:analyzer/analysis_rule/rule_context.dart";
+import "package:analyzer/analysis_rule/rule_visitor_registry.dart";
+import "package:analyzer/dart/ast/ast.dart";
+import "package:analyzer/dart/ast/visitor.dart";
+import "package:analyzer/dart/element/element.dart";
+import "package:analyzer/dart/element/type.dart";
+import "package:analyzer/error/error.dart";
+import "package:cw_custom_lints/utils/test_keys.dart";
+
+class TestKeyInterpolationRule extends AnalysisRule {
+ TestKeyInterpolationRule()
+ : super(
+ name: "no_string_interpolation_in_test_key",
+ description:
+ "Test keys become accessibility identifiers in release builds, so they must not interpolate strings that can hold user data.",
+ );
+
+ static const LintCode code = LintCode(
+ "no_string_interpolation_in_test_key",
+ "Interpolating a String into a test key would ship user data in release-build accessibility identifiers.",
+ correctionMessage: "Use an index, an enum's .name, or a static id instead.",
+ severity: DiagnosticSeverity.WARNING,
+ );
+
+ @override
+ LintCode get diagnosticCode => code;
+
+ @override
+ void registerNodeProcessors(RuleVisitorRegistry registry, RuleContext context) {
+ final filePath = context.definingUnit.file.path;
+ if (filePath.contains("/integration_test/")) {
+ return;
+ }
+
+ registry.addInstanceCreationExpression(this, _Visitor(this));
+ }
+}
+
+class _Visitor extends SimpleAstVisitor<void> {
+ _Visitor(this.rule);
+
+ final AnalysisRule rule;
+
+ @override
+ void visitInstanceCreationExpression(InstanceCreationExpression node) {
+ final literal = testKeyLiteral(node);
+ if (literal is! StringInterpolation) {
+ return;
+ }
+
+ for (final element in literal.elements.whereType<InterpolationExpression>()) {
+ if (_mayHoldUserText(element.expression)) {
+ rule.reportAtNode(element);
+ }
+ }
+ }
+
+ bool _mayHoldUserText(Expression expression) {
+ if (_isEnumName(expression)) {
+ return false;
+ }
+
+ final type = expression.staticType;
+ return type == null || type is DynamicType || type is InvalidType || type.isDartCoreString;
+ }
+
+ bool _isEnumName(Expression expression) {
+ final (target, name) = switch (expression) {
+ PrefixedIdentifier() => (expression.prefix, expression.identifier.name),
+ PropertyAccess() => (expression.target, expression.propertyName.name),
+ _ => (null, null),
+ };
+
+ return name == "name" && target?.staticType?.element is EnumElement;
+ }
+}
### cw_custom_lints/lib/test_key_semantics/test_key_semantics_fix.dart
@@ -0,0 +1,57 @@
+import "package:analysis_server_plugin/edit/dart/correction_producer.dart";
+import "package:analysis_server_plugin/edit/dart/dart_fix_kind_priority.dart";
+import "package:analyzer/dart/ast/ast.dart";
+import "package:analyzer_plugin/utilities/change_builder/change_builder_core.dart";
+import "package:analyzer_plugin/utilities/fixes/fixes.dart";
+import "package:cw_custom_lints/utils/test_keys.dart";
+import "package:cw_custom_lints/utils/widget_arguments.dart";
+
+class WrapInTestIdMerge extends ResolvedCorrectionProducer {
+ WrapInTestIdMerge({required super.context});
+
+ static const _importString = "package:cake_wallet/utils/test_id.dart";
+
+ static const _fixKind = FixKind(
+ "dart.fix.wrapInTestIdMerge",
+ DartFixKindPriority.standard,
+ "Wrap in TestId.merge() or TestId.container()",
+ );
+
+ @override
+ CorrectionApplicability get applicability => CorrectionApplicability.singleLocation;
+
+ @override
+ FixKind get fixKind => _fixKind;
+
+ @override
+ Future<void> compute(ChangeBuilder builder) async {
+ final widget = node.thisOrAncestorOfType<InstanceCreationExpression>();
+ final literal = widget == null
+ ? null
+ : testKeyLiteral(namedArgumentExpression(widget.argumentList, "key"));
+ if (widget == null || literal == null) {
+ return;
+ }
+
+ final root = widget.root;
+ final hasImport =
+ root is CompilationUnit &&
+ root.directives.whereType<ImportDirective>().any(
+ (directive) => directive.uri.stringValue == _importString,
+ );
+
+ await builder.addDartFileEdit(file, (builder) {
+ final wrapper = const {"TextField", "TextFormField"}.contains(
+ widget.constructorName.type.name.lexeme,
+ )
+ ? "container"
+ : "merge";
+ builder.addSimpleInsertion(widget.offset, "TestId.$wrapper(${literal.toSource()}, child: ");
+ builder.addSimpleInsertion(widget.end, ")");
+
+ if (!hasImport) {
+ builder.importLibrary(Uri.parse(_importString));
+ }
+ });
+ }
+}
### cw_custom_lints/lib/test_key_semantics/test_key_semantics_rule.dart
@@ -0,0 +1,98 @@
+import "package:analyzer/analysis_rule/analysis_rule.dart";
+import "package:analyzer/analysis_rule/rule_context.dart";
+import "package:analyzer/analysis_rule/rule_visitor_registry.dart";
+import "package:analyzer/dart/ast/ast.dart";
+import "package:analyzer/dart/ast/visitor.dart";
+import "package:analyzer/error/error.dart";
+import "package:cw_custom_lints/utils/test_keys.dart";
+import "package:cw_custom_lints/utils/widget_arguments.dart";
+
+class TestKeySemanticsRule extends AnalysisRule {
+ TestKeySemanticsRule()
+ : super(
+ name: "require_test_key_semantics_identifier",
+ description:
+ "A test key on a framework interactive widget needs a matching Semantics identifier so UI drivers can find it.",
+ );
+
+ static const LintCode code = LintCode(
+ "require_test_key_semantics_identifier",
+ "This test key is invisible to accessibility-tree drivers without a Semantics identifier.",
+ correctionMessage:
+ "Wrap the widget in TestId.merge with the same id, or TestId.container for a text field.",
+ severity: DiagnosticSeverity.WARNING,
+ );
+
+ static const interactiveWidgets = {
+ "GestureDetector",
+ "InkWell",
+ "TextButton",
+ "IconButton",
+ "ElevatedButton",
+ "OutlinedButton",
+ "FilledButton",
+ "TextField",
+ "TextFormField",
+ "Switch",
+ "Checkbox",
+ "Radio",
+ "ListTile",
+ "CupertinoButton",
+ };
+
+ @override
+ LintCode get diagnosticCode => code;
+
+ @override
+ void registerNodeProcessors(RuleVisitorRegistry registry, RuleContext context) =>
+ registry.addInstanceCreationExpression(this, _Visitor(this));
+}
+
+class _Visitor extends SimpleAstVisitor<void> {
+ _Visitor(this.rule);
+
+ final AnalysisRule rule;
+
+ @override
+ void visitInstanceCreationExpression(InstanceCreationExpression node) {
+ if (!isFlutterClass(node.constructorName, TestKeySemanticsRule.interactiveWidgets)) {
+ return;
+ }
+
+ if (testKeyLiteral(namedArgumentExpression(node.argumentList, "key")) == null) {
+ return;
+ }
+
+ if (_hasIdentifierAncestor(node)) {
+ return;
+ }
+
+ rule.reportAtNode(node.constructorName);
+ }
+
+ bool _hasIdentifierAncestor(AstNode node) {
+ for (AstNode? current = node.parent; current != null; current = current.parent) {
+ if (current is MethodDeclaration ||
+ current is FunctionDeclaration ||
+ current is ClassDeclaration ||
+ current is CompilationUnit) {
+ return false;
+ }
+
+ if (current is InstanceCreationExpression &&
+ current.constructorName.type.name.lexeme == "Semantics" &&
+ namedArgument(current.argumentList, "identifier") != null) {
+ return true;
+ }
+
+ if (current is MethodInvocation &&
+ current.target is SimpleIdentifier &&
+ (current.target! as SimpleIdentifier).name == "TestId" &&
+ const {"merge", "container"}.contains(current.methodName.name)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
### cw_custom_lints/lib/utils/test_keys.dart
@@ -0,0 +1,35 @@
+import "package:analyzer/dart/ast/ast.dart";
+
+bool isFlutterClass(ConstructorName constructorName, Set<String> classNames) {
+ final element = constructorName.type.element;
+ if (element == null || !classNames.contains(element.name)) {
+ return false;
+ }
+
+ final libraryUri = element.library?.uri;
+ return libraryUri != null &&
+ libraryUri.scheme == "package" &&
+ libraryUri.pathSegments.isNotEmpty &&
+ libraryUri.pathSegments.first == "flutter";
+}
+
+StringLiteral? testKeyLiteral(Expression? expression) {
+ if (expression is! InstanceCreationExpression ||
+ !isFlutterClass(expression.constructorName, const {"Key", "ValueKey"})) {
+ return null;
+ }
+
+ final arguments = expression.argumentList.arguments;
+ if (arguments.isEmpty) {
+ return null;
+ }
+
+ final literal = arguments.first;
+ final String? tail = switch (literal) {
+ SimpleStringLiteral() => literal.value,
+ StringInterpolation() => literal.lastString.value,
+ _ => null,
+ };
+
+ return tail != null && tail.endsWith("_key") ? literal as StringLiteral : null;
+}
### cw_custom_lints/test/test_key_interpolation_rule_test.dart
@@ -0,0 +1,81 @@
+import "package:analyzer_testing/analysis_rule/analysis_rule.dart";
+import "package:cw_custom_lints/test_key_interpolation/test_key_interpolation_rule.dart";
+import "package:test/test.dart";
+
+class _RuleTest extends AnalysisRuleTest {
+ @override
+ bool get addFlutterPackageDep => true;
+
+ @override
+ void setUp() {
+ rule = TestKeyInterpolationRule();
+ super.setUp();
+ }
+}
+
+void main() {
+ late _RuleTest t;
+
+ setUp(() => t = _RuleTest()..setUp());
+ tearDown(() => t.tearDown());
+
+ test("flags an interpolated String", () async {
+ const code = r"""
+import "package:flutter/foundation.dart";
+
+Key build(String word) => ValueKey("seed_verification_option_${word}_button_key");
+""";
+ await t.assertDiagnostics(code, [t.lint(code.indexOf(r"${word}"), r"${word}".length)]);
+ });
+
+ test("flags a bare String identifier", () async {
+ const code = r"""
+import "package:flutter/foundation.dart";
+
+Key build(String address) => Key("standard_list_item_$address\_key");
+""";
+ await t.assertDiagnostics(code, [t.lint(code.indexOf(r"$address"), r"$address".length)]);
+ });
+
+ test("flags dynamic", () async {
+ const code = r"""
+import "package:flutter/foundation.dart";
+
+Key build(dynamic id) => ValueKey("trade_${id}_key");
+""";
+ await t.assertDiagnostics(code, [t.lint(code.indexOf(r"${id}"), r"${id}".length)]);
+ });
+
+ test("allows int", () async {
+ await t.assertNoDiagnostics(r"""
+import "package:flutter/foundation.dart";
+
+Key build(int index) => ValueKey("home_page_transaction_${index}_key");
+""");
+ });
+
+ test("allows enums and enum .name", () async {
+ await t.assertNoDiagnostics(r"""
+import "package:flutter/foundation.dart";
+
+enum Range { day, week }
+
+Key a(Range range) => ValueKey("chart_range_${range}_key");
+Key b(Range range) => ValueKey("chart_range_${range.name}_key");
+""");
+ });
+
+ test("ignores keys that are not test keys", () async {
+ await t.assertNoDiagnostics(r"""
+import "package:flutter/foundation.dart";
+
+Key build(String name) => ValueKey("contact_$name");
+""");
+ });
+
+ test("ignores strings that are not keys", () async {
+ await t.assertNoDiagnostics(r"""
+String build(String name) => "label_${name}_key";
+""");
+ });
+}
### cw_custom_lints/test/test_key_semantics_rule_test.dart
@@ -0,0 +1,110 @@
+import "package:analyzer_testing/analysis_rule/analysis_rule.dart";
+import "package:cw_custom_lints/test_key_semantics/test_key_semantics_rule.dart";
+import "package:test/test.dart";
+
+const _fixtures = r"""
+import "package:flutter/material.dart";
+
+class Semantics extends StatelessWidget {
+ const Semantics({super.key, this.identifier, this.child});
+ final String? identifier;
+ final Widget? child;
+}
+
+abstract final class TestId {
+ static Widget merge(String? id, {required Widget child}) => child;
+ static Widget container(String? id, {required Widget child}) => child;
+}
+
+class CakeButton extends StatelessWidget {
+ const CakeButton({super.key});
+}
+""";
+
+class _RuleTest extends AnalysisRuleTest {
+ @override
+ bool get addFlutterPackageDep => true;
+
+ @override
+ void setUp() {
+ rule = TestKeySemanticsRule();
+ super.setUp();
+ }
+}
+
+void main() {
+ late _RuleTest t;
+
+ setUp(() => t = _RuleTest()..setUp());
+ tearDown(() => t.tearDown());
+
+ Future<void> expectLintAt(String code, String widget) =>
+ t.assertDiagnostics(code, [t.lint(code.indexOf("$widget(key"), widget.length)]);
+
+ test("flags a bare GestureDetector", () async {
+ await expectLintAt("""
+$_fixtures
+Widget build() => GestureDetector(key: const ValueKey("send_button_key"));
+""", "GestureDetector");
+ });
+
+ test("flags an interpolated test key", () async {
+ await expectLintAt("""
+$_fixtures
+Widget build(int i) => InkWell(key: ValueKey("row_\${i}_key"));
+""", "InkWell");
+ });
+
+ test("flags a Semantics ancestor without identifier", () async {
+ await expectLintAt("""
+$_fixtures
+Widget build() => Semantics(child: GestureDetector(key: const ValueKey("send_button_key")));
+""", "GestureDetector");
+ });
+
+ test("allows TestId.merge", () async {
+ await t.assertNoDiagnostics("""
+$_fixtures
+Widget build() =>
+ TestId.merge("send_button_key", child: GestureDetector(key: const ValueKey("send_button_key")));
+""");
+ });
+
+ test("allows Semantics(identifier:) across a builder closure", () async {
+ await t.assertNoDiagnostics("""
+$_fixtures
+Widget build() => Semantics(
+ identifier: "send_button_key",
+ child: Builder(builder: (_) => GestureDetector(key: const ValueKey("send_button_key"))),
+ );
+""");
+ });
+
+ test("ignores identity keys", () async {
+ await t.assertNoDiagnostics("""
+$_fixtures
+Widget build(String name) => GestureDetector(key: ValueKey(name));
+""");
+ });
+
+ test("ignores strings that are not test keys", () async {
+ await t.assertNoDiagnostics("""
+$_fixtures
+Widget build() => GestureDetector(key: const ValueKey("send"));
+""");
+ });
+
+ test("ignores Cake widgets", () async {
+ await t.assertNoDiagnostics("""
+$_fixtures
+Widget build() => CakeButton(key: const ValueKey("send_button_key"));
+""");
+ });
+
+ test("ignores non-interactive framework widgets", () async {
+ await t.assertNoDiagnostics("""
+$_fixtures
+Widget build() => Text("x", key: const ValueKey("title_key"));
+""");
+ });
+}
### integration_test/core/base_robot.dart
@@ -1,5 +1,6 @@
import "dart:async";
+import "package:cake_wallet/src/widgets/picker.dart";
import "package:flutter/material.dart";
import "package:flutter_test/flutter_test.dart";
import "package:integration_test/integration_test.dart";
@@ -86,6 +87,14 @@ abstract class BaseRobot {
await tester.pump(const Duration(milliseconds: 300));
}
+ Future<int> pickerIndexWhere(bool Function(dynamic item) test) async {
+ final picker = find.byWidgetPredicate((widget) => widget is Picker);
+
+ await pumpUntilFound(picker);
+
+ return tester.widget<Picker<dynamic>>(picker.last).items.indexWhere(test);
+ }
+
Future<void> tapWhenVisible(
Finder finder, {
Duration timeout = const Duration(seconds: 30),
### integration_test/flows/wallet_flows.dart
@@ -17,7 +17,7 @@ class WalletFlows {
Future<void> _expandWalletGroups({int maxGroups = 10}) async {
for (int index = 0; index < maxGroups; index++) {
- final tile = find.byKey(ValueKey("group_wallets_expansion_tile_widget_$index"));
+ final tile = find.byKey(ValueKey("wallet_list_group_${index}_key"));
if (!tester.any(tile)) {
return;
### integration_test/robots/connection_sync_page_robot.dart
@@ -16,9 +16,9 @@ class ConnectionSyncPageRobot extends BaseRobot {
Future<void> setFiatApiMode(FiatApiMode mode) async {
await tapByKey("fiat_api");
- final unselected = find.byKey(ValueKey("picker_items_index_${mode.title}_button_key"));
- final selected =
- find.byKey(ValueKey("picker_items_index_${mode.title}_selected_item_button_key"));
+ final index = await pickerIndexWhere((item) => item == mode);
+ final unselected = find.byKey(ValueKey("picker_items_index_${index}_button_key"));
+ final selected = find.byKey(ValueKey("picker_items_index_${index}_selected_item_button_key"));
await pumpUntil(() => tester.any(unselected) || tester.any(selected));
### integration_test/robots/contact_robot.dart
@@ -1,5 +1,6 @@
import "package:cake_wallet/src/screens/contact/contact_list_page.dart";
import "package:cake_wallet/src/screens/contact/contact_page.dart";
+import "package:cw_core/currency.dart";
import "package:flutter/material.dart";
import "package:flutter_test/flutter_test.dart";
@@ -26,7 +27,9 @@ class ContactRobot extends BaseRobot {
Future<void> chooseCurrency(String currencyName) async {
await tapByKey("contact_page_currency_picker_button_key");
- await tapByKey("picker_items_index_${currencyName}_button_key");
+ final index = await pickerIndexWhere((item) => item is Currency && item.name == currencyName);
+
+ await tapByKey("picker_items_index_${index}_button_key");
await settle();
}
### integration_test/robots/display_settings_page_robot.dart
@@ -21,7 +21,9 @@ class DisplaySettingsPageRobot extends BaseRobot {
}
Future<void> chooseLanguage(String code) async {
- await tapByKey("picker_items_index_${code}_button_key");
+ final index = await pickerIndexWhere((item) => item == code);
+
+ await tapByKey("picker_items_index_${index}_button_key");
await settle();
}
### integration_test/robots/home_page_robot.dart
@@ -2,6 +2,7 @@ import "package:cake_wallet/new-ui/pages/home_page.dart";
import "package:cake_wallet/new-ui/widgets/coins_page/assets_history/history_tile.dart";
import "package:cake_wallet/new-ui/widgets/coins_page/assets_history/transaction_details_modal.dart";
import "package:cake_wallet/new-ui/widgets/coins_page/top_bar_widget/sync_bar.dart";
+import "package:cake_wallet/view_model/dashboard/transaction_list_item.dart";
import "package:cw_core/sync_status.dart";
import "package:flutter/material.dart";
import "package:flutter_test/flutter_test.dart";
@@ -131,8 +132,10 @@ class HomePageRobot extends BaseRobot {
String firstTransactionIdInAllView() {
final tile = tester.widgetList<HistoryTile>(_allViewTiles).first;
final key = tile.key! as ValueKey<String>;
+ final index = key.value.substring("history_modal_transaction_".length, key.value.length - "_key".length);
+ final items = tester.widget<NewHomePage>(find.byType(NewHomePage).first).dashboardViewModel.items;
- return key.value.substring("home_page_transaction_".length, key.value.length - "_key".length);
+ return (items[int.parse(index)] as TransactionListItem).transaction.id;
}
Future<void> openFirstTransactionDetails() async {
### integration_test/robots/restore_from_seed_or_key_robot.dart
@@ -47,7 +47,9 @@ class RestoreFromSeedOrKeysPageRobot extends BaseRobot {
Future<void> chooseSeedTypeForMoneroOrWowneroWallets(MoneroSeedType selectedType) async {
await tapByKey("wallet_restore_from_seed_seedtype_picker_button_key");
- await tapByKey("picker_items_index_${selectedType.title}_button_key");
+ final index = await pickerIndexWhere((item) => item == selectedType);
+
+ await tapByKey("picker_items_index_${index}_button_key");
}
Future<void> expectRestoreRefused({Duration window = const Duration(seconds: 10)}) async {
### integration_test/robots/seed_verification_page_robot.dart
@@ -29,7 +29,9 @@ class SeedVerificationPageRobot extends BaseRobot {
hasTextAtLeastOnce(currentCorrectWord);
- await tapByKey("seed_verification_option_${currentCorrectWord}_button_key");
+ final index = walletSeedViewModel.currentOptions.indexOf(currentCorrectWord);
+
+ await tapByKey("seed_verification_option_${index}_button_key");
final hasMovedOn = await pumpUntil(
() =>
### integration_test/robots/wallet_list_page_robot.dart
@@ -15,7 +15,19 @@ class WalletListPageRobot extends BaseRobot {
}
Future<void> openEditFor(String walletName) async {
- await tapByKey("wallet_list_edit_${walletName}_button_key");
+ final viewModel = tester.widget<WalletListPage>(find.byType(WalletListPage).first).walletListViewModel;
+ final index = viewModel.singleWalletsList.indexWhere((wallet) => wallet.name == walletName);
+ if (index != -1) {
+ return tapByKey("wallet_list_single_wallet_${index}_edit_button_key");
+ }
+
+ final group = viewModel.multiWalletGroups.indexWhere((g) => g.wallets.any((w) => w.name == walletName));
+ final wallet = viewModel.multiWalletGroups[group].wallets.indexWhere((w) => w.name == walletName);
+ final key = "wallet_list_group_${group}_wallet_${wallet}_edit_button_key";
+ if (!tester.any(find.byKey(ValueKey(key)))) {
+ await tapByKey("wallet_list_group_${group}_key");
+ }
+ await tapByKey(key);
}
bool hasWallet(String walletName) => tester.any(
### lib/cake_pay/src/cards/cake_pay_buy_card_page.dart
@@ -40,6 +40,7 @@ import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart';
+import "package:cake_wallet/utils/test_id.dart";
class CakePayBuyCardPage extends BasePage {
CakePayBuyCardPage(this.cakePayBuyCardViewModel)
@@ -354,7 +355,7 @@ class CakePayBuyCardPage extends BasePage {
Observer(
builder: (_) => Padding(
padding: EdgeInsets.only(top: 10, bottom: 0, right: 20, left: 20),
- child: GestureDetector(
+ child: TestId.merge("cake_pay_buy_page_unspent_coin_button_key", child: GestureDetector(
key: ValueKey('cake_pay_buy_page_unspent_coin_button_key'),
onTap: () {
bool value = _sendViewModel.coinTypeToSpendFrom == UnspentCoinType.any;
@@ -378,7 +379,7 @@ class CakePayBuyCardPage extends BasePage {
],
),
),
- ),
+ )),
),
),
if (!_sendViewModel.isReadyForSend)
### lib/entities/new_ui_entities/list_item/list_Item_checkbox.dart
@@ -5,6 +5,7 @@ class ListItemCheckbox extends ListItem {
const ListItemCheckbox({
required super.keyValue,
required super.label,
+ super.testId,
this.subtitle,
this.subtitleColor,
this.iconPath,
### lib/entities/new_ui_entities/list_item/list_item.dart
@@ -4,12 +4,14 @@ abstract class ListItem {
const ListItem({
required this.keyValue,
required this.label,
+ this.testId,
this.isFirstInSection = false,
this.isLastInSection = false,
});
final String keyValue;
final String label;
+ final String? testId;
final bool isFirstInSection;
final bool isLastInSection;
### lib/entities/new_ui_entities/list_item/list_item_dropdown.dart
@@ -5,6 +5,7 @@ class ListItemDropdown extends ListItem {
const ListItemDropdown({
required super.keyValue,
required super.label,
+ super.testId,
this.trailingText,
required this.onTap,
});
### lib/entities/new_ui_entities/list_item/list_item_regular_row.dart
@@ -5,6 +5,7 @@ class ListItemRegularRow extends ListItem {
const ListItemRegularRow({
required super.keyValue,
required super.label,
+ super.testId,
this.subtitle,
this.trailingText,
this.iconPath,
### lib/entities/new_ui_entities/list_item/list_item_selector.dart
@@ -6,6 +6,7 @@ class ListItemSelector extends ListItem {
required this.options,
required super.keyValue,
required super.label,
+ super.testId,
this.trailingText,
this.optionImagePath,
required this.onTap,
### lib/entities/new_ui_entities/list_item/list_item_text_field.dart
@@ -5,6 +5,7 @@ class ListItemTextField extends ListItem {
const ListItemTextField(
{required super.keyValue,
required super.label,
+ super.testId,
this.initialValue,
this.validator,
this.onChanged,
### lib/entities/new_ui_entities/list_item/list_item_toggle.dart
@@ -5,6 +5,7 @@ class ListItemToggle extends ListItem {
const ListItemToggle({
required super.keyValue,
required super.label,
+ super.testId,
this.subtitle,
this.iconPath,
this.iconColor,
### lib/new-ui/pages/about_page.dart
@@ -54,6 +54,7 @@ class _AboutPageState extends State<AboutPage> {
Widget build(BuildContext context) {
return ModalPageWrapper(
topBar: ModalTopBar(
+ testId: "about_page_top_bar",
title: S.of(context).about,
leadingIcon: Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/pages/addresses_page.dart
@@ -129,6 +129,7 @@ class _NewAddressesPageState extends State<NewAddressesPage> {
spacing: 12.0,
children: [
ModalTopBar(
+ testId: "addresses_page_top_bar",
title: widget.showHidden ? S.of(context).hidden_addresses : S.of(context).addresses,
leadingIcon: Icon(Icons.arrow_back),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/pages/bridge/bridge_amount_page.dart
@@ -114,6 +114,7 @@ class _BridgeAmountPageState extends State<BridgeAmountPage> {
child: Column(
children: [
ModalTopBar(
+ testId: "bridge_amount_page_top_bar",
title: S.of(context).enter_amount,
leadingIcon: Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/pages/bridge/bridge_confirm_sheet.dart
@@ -66,6 +66,7 @@ class _BridgeConfirmSheetState extends State<BridgeConfirmSheet> {
Observer(
builder: (_) {
return ModalTopBar(
+ testId: "bridge_confirm_sheet_top_bar",
title: '',
leadingWidget: Row(
spacing: 8,
### lib/new-ui/pages/bridge/bridge_detail_page.dart
@@ -44,6 +44,7 @@ class BridgeDetailPage extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "bridge_detail_page_top_bar",
title: "Bridge Transfer Details",
leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/pages/bridge/bridge_history_page.dart
@@ -24,6 +24,7 @@ class BridgeHistoryPage extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "bridge_history_page_top_bar",
title: "Bridge history",
leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/pages/bridge/bridge_network_page.dart
@@ -29,6 +29,7 @@ class BridgeNetworkPage extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "bridge_network_page_top_bar",
title: 'Destination Network',
leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/pages/bridge/bridge_receive_address_input_page.dart
@@ -53,6 +53,7 @@ class _BridgeReceiveAddressInputPageState extends State<BridgeReceiveAddressInpu
child: Column(
children: [
ModalTopBar(
+ testId: "bridge_receive_address_input_page_top_bar",
title: 'Input Receive Address',
leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/pages/bridge/bridge_receiving_wallet_page.dart
@@ -41,6 +41,7 @@ class _BridgeReceivingWalletPageState extends State<BridgeReceivingWalletPage> {
child: Column(
children: [
ModalTopBar(
+ testId: "bridge_receiving_wallet_page_top_bar",
title: 'Receiving Wallet',
leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/pages/buy_sell/buy_sell_amount_page.dart
@@ -93,6 +93,7 @@ class _NewBuySellAmountPageState extends State<NewBuySellAmountPage> {
children: [
Observer(
builder: (_) => ModalTopBar(
+ testId: "buy_sell_amount_page_top_bar",
title: _pageTitle,
bottomText: !_customAmountMode || widget.buySellViewModel.maxFiatAmount == null
? null
### lib/new-ui/pages/buy_sell/buy_sell_confirmation_page.dart
@@ -36,6 +36,7 @@ class BuySellConfirmationPage extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "buy_sell_confirmation_page_top_bar",
title: _pageTitle,
leadingIcon: const Icon(Icons.arrow_back_ios_new),
onLeadingPressed: Navigator.of(context).pop,
### lib/new-ui/pages/buy_sell/buy_sell_payment_method_page.dart
@@ -34,6 +34,7 @@ class BuySellPaymentMethodPage extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "buy_sell_payment_method_page_top_bar",
title: S.of(context).payment_method,
leadingIcon: const Icon(Icons.arrow_back_ios_new),
onLeadingPressed: Navigator.of(context).pop,
### lib/new-ui/pages/buy_sell/buy_sell_provider_page.dart
@@ -46,6 +46,7 @@ class _BuySellProviderPageState extends State<BuySellProviderPage> {
child: Column(
children: [
ModalTopBar(
+ testId: "buy_sell_provider_page_top_bar",
title: _pageTitle,
leadingIcon: const Icon(Icons.arrow_back_ios_new),
onLeadingPressed: Navigator.of(context).pop,
### lib/new-ui/pages/card_customizer.dart
@@ -190,6 +190,7 @@ class _CardCustomizerState extends State<CardCustomizer> {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "card_customizer_top_bar",
title: _isAccount ? S.of(context).edit_account : S.of(context).edit_card,
subtitle: _isAccount ? "#${widget.account!.id + 1}" : null,
leadingIcon:
### lib/new-ui/pages/coin_control_page.dart
@@ -55,6 +55,7 @@ class _NewCoinControlPageState extends State<NewCoinControlPage> {
child: Column(
children: [
ModalTopBar(
+ testId: "coin_control_page_top_bar",
title: "",
trailingWidget: GestureDetector(
onTap: Navigator.of(context).pop,
### lib/new-ui/pages/hidden_accounts.dart
@@ -146,6 +146,7 @@ class _HiddenAccountsPageState extends State<HiddenAccountsPage> {
@override
Widget build(BuildContext context) => ModalPageWrapper(
topBar: ModalTopBar(
+ testId: "hidden_accounts_page_top_bar",
title: S.of(context).archived_accounts,
leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/pages/lightning_username_page.dart
@@ -66,6 +66,7 @@ class _LightningUsernamePageState extends State<LightningUsernamePage> {
child: Column(
children: [
ModalTopBar(
+ testId: "lightning_username_page_top_bar",
title: "Lightning ${S.of(context).username}",
leadingIcon: Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/pages/receive_page.dart
@@ -175,6 +175,7 @@ class _NewReceivePageState extends State<NewReceivePage> {
mainAxisAlignment: MainAxisAlignment.start,
children: [
ModalTopBar(
+ testId: "receive_page_top_bar",
title: _largeQrMode ? "" : S.of(context).receive,
leadingIcon: const Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
@@ -194,6 +195,9 @@ class _NewReceivePageState extends State<NewReceivePage> {
.contains("mweb")
? ModernButton(
key: ValueKey(_largeQrMode),
+ testId: _largeQrMode
+ ? "receive_page_share_button_key"
+ : "receive_page_rotate_button_key",
size: 36,
icon: _largeQrMode
? const Icon(Icons.share)
@@ -258,6 +262,7 @@ class _NewReceivePageState extends State<NewReceivePage> {
excluding: _largeQrMode || !hasLabel,
child: MergeSemantics(
child: Semantics(
+ identifier: "receive_page_label_chip_key",
button: true,
hint: S.of(context).set_label,
child: GestureDetector(
### lib/new-ui/pages/scan_page.dart
@@ -147,6 +147,7 @@ class _ScanPageState extends State<ScanPage> {
child: Column(
children: [
ModalTopBar(
+ testId: "scan_page_top_bar",
title: "",
trailingWidget: AnimatedOpacity(
duration: textModeSwitchDuration,
### lib/new-ui/pages/send_page.dart
@@ -370,6 +370,7 @@ class _NewSendPageState extends State<NewSendPage> {
mainAxisSize: MainAxisSize.max,
children: [
ModalTopBar(
+ testId: "send_page_top_bar",
title: widget.mode.title,
subtitle: widget.mode.description,
leadingIcon: const Icon(Icons.close),
@@ -607,6 +608,7 @@ class _NewSendPageState extends State<NewSendPage> {
if (widget.sendViewModel.hasFees)
ListItemRegularRowWidget(
keyValue: "",
+ testId: "send_page_fee_row_key",
label: S.of(context).fees,
subtitle:
"~${output.estimatedFee} ${widget.sendViewModel.currencySymbol} (${output.estimatedFeeFiatAmount} ${widget.sendViewModel.fiatCurrency})",
@@ -624,6 +626,7 @@ class _NewSendPageState extends State<NewSendPage> {
if (widget.sendViewModel.hasCoinControl)
ListItemRegularRowWidget(
keyValue: "",
+ testId: "send_page_coin_control_row_key",
label: S.of(context).coin_control,
onTap: () {
showCupertinoModalBottomSheet(
@@ -1344,6 +1347,7 @@ class SendHelpPage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ModalTopBar(
+ testId: "send_help_page_top_bar",
title: content.title,
leadingIcon: const Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/pages/settings_page.dart
@@ -48,6 +48,7 @@ class SettingsListItem {
this.condition = _alwaysVisible,
this.routeArgs,
this.routeArgsBuilder,
+ this.testId,
});
static bool _neverUse2fa(DashboardViewModel _) => false;
@@ -61,6 +62,7 @@ class SettingsListItem {
final bool requireAuth;
final bool Function(DashboardViewModel) use2fa;
final bool Function(DashboardViewModel) condition;
+ final String? testId;
}
class SettingsSectionData {
@@ -96,6 +98,7 @@ class WalletSettingsResolver {
"assets/new-ui/settings_row_icons/accounts.svg",
viewModel.wallet.type == WalletType.bitcoin ? S.current.accounts_onchain : S.current.accounts,
Routes.walletAccountsPage,
+ testId: "settings_page_wallet_accounts_row_key",
isCore: true,
condition: _hasAccounts,
routeArgsBuilder: (vm) => vm,
@@ -104,12 +107,14 @@ class WalletSettingsResolver {
"assets/new-ui/settings_row_icons/nodes.svg",
S.current.nodes,
Routes.manageNodes,
+ testId: "settings_page_manage_nodes_row_key",
isCore: true,
),
SettingsListItem(
"assets/new-ui/settings_row_icons/coin-control.svg",
S.current.coin_control_settings,
Routes.unspentCoinsList,
+ testId: "settings_page_unspent_coins_list_row_key",
isCore: true,
condition: _hasCoinControl,
routeArgs: const CoinControlPageArgs(canEdit: false),
@@ -118,30 +123,35 @@ class WalletSettingsResolver {
"assets/new-ui/settings_row_icons/lightning_username.svg",
"Lightning ${S.current.username}",
Routes.lightningUsernamePage,
+ testId: "settings_page_lightning_username_row_key",
condition: _hasLightning,
),
SettingsListItem(
"assets/new-ui/settings_row_icons/silent-payments.svg",
S.current.silent_payments,
Routes.silentPaymentsSettings,
+ testId: "settings_page_silent_payments_settings_row_key",
condition: _hasSilentPayments,
),
SettingsListItem(
"assets/new-ui/settings_row_icons/mweb.svg",
S.current.litecoin_mweb,
Routes.mwebSettings,
+ testId: "settings_page_mweb_settings_row_key",
condition: _hasMweb,
),
SettingsListItem(
"assets/new-ui/settings_row_icons/wc.svg",
S.current.walletConnect,
Routes.walletConnectConnectionsListing,
+ testId: "settings_page_wallet_connect_connections_listing_row_key",
condition: _hasWalletConnect,
),
SettingsListItem(
"assets/new-ui/settings_row_icons/sync-balance.svg",
S.current.resync_device,
Routes.syncKeyImagesDevices,
+ testId: "settings_page_sync_key_images_devices_row_key",
routeArgs: const {"export-outputs": "export-outputs"},
condition: _requiresKeyImageSync,
),
@@ -165,16 +175,19 @@ class SettingsPageSectionsResolver {
'assets/new-ui/settings_row_icons/privacy.svg',
strings.privacy,
Routes.privacyPage,
+ testId: "settings_page_privacy_row_key",
),
SettingsListItem(
'assets/new-ui/settings_row_icons/seed.svg',
strings.recovery_and_keys,
Routes.showKeysDisclaimer,
+ testId: "settings_page_show_keys_disclaimer_row_key",
),
SettingsListItem(
'assets/new-ui/settings_row_icons/other.svg',
strings.other,
Routes.otherSettingsPage,
+ testId: "settings_page_other_settings_row_key",
),
];
@@ -183,21 +196,25 @@ class SettingsPageSectionsResolver {
"assets/new-ui/settings_row_icons/connections.svg",
S.current.connections,
Routes.connectionSync,
+ testId: "settings_page_connection_sync_row_key",
),
SettingsListItem(
"assets/new-ui/settings_row_icons/display.svg",
S.current.display,
Routes.displaySettingsPage,
+ testId: "settings_page_display_settings_row_key",
),
SettingsListItem(
"assets/new-ui/settings_row_icons/security.svg",
S.current.security,
Routes.securityBackupPage,
+ testId: "settings_page_security_backup_row_key",
),
SettingsListItem(
"assets/new-ui/settings_row_icons/backup.svg",
S.current.backup,
Routes.backup,
+ testId: "settings_page_backup_row_key",
requireAuth: true,
use2fa: (vm) => vm.settingsStore.shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
),
@@ -208,11 +225,13 @@ class SettingsPageSectionsResolver {
'assets/new-ui/settings_row_icons/support.svg',
strings.settings_support,
Routes.support,
+ testId: "settings_page_support_row_key",
),
SettingsListItem(
'assets/new-ui/settings_row_icons/info.svg',
strings.about,
Routes.aboutPage,
+ testId: "settings_page_about_row_key",
),
];
}
@@ -258,6 +277,7 @@ class SettingsMainPage extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "settings_page_top_bar",
title: S.of(context).settings_title,
leadingIcon: const Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
@@ -300,6 +320,7 @@ class SettingsMainPage extends StatelessWidget {
"wallet_type_settings": [
ListItemRegularRow(
keyValue: "wallet_type_settings",
+ testId: "settings_page_wallet_settings_row_key",
truncateLabel: true,
label: _walletSettingsResolver.titleFor(
dashboardViewModel.wallet.type,
@@ -339,6 +360,7 @@ class SettingsMainPage extends StatelessWidget {
ListItemRegularRow _buildRow(BuildContext context, SettingsListItem item) => ListItemRegularRow(
keyValue: item.route,
+ testId: item.testId,
truncateLabel: true,
label: item.title,
iconPath: item.iconPath,
@@ -383,6 +405,7 @@ class WalletSettingsPage extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "wallet_settings_page_top_bar",
title: _resolver.titleFor(dashboardViewModel.wallet.type, strings),
titleLeadingWidget: CakeImageWidget(
imageUrl: _resolver.iconPathFor(dashboardViewModel.wallet.type),
@@ -406,6 +429,7 @@ class WalletSettingsPage extends StatelessWidget {
.map(
(item) => ListItemRegularRow(
keyValue: item.route,
+ testId: item.testId,
truncateLabel: true,
label: item.title,
iconPath: item.iconPath,
### lib/new-ui/pages/swap_page.dart
@@ -34,6 +34,7 @@ import "package:cake_wallet/src/widgets/cake_image_widget.dart";
import "package:cake_wallet/utils/list_extension.dart";
import "package:cake_wallet/utils/payment_request.dart";
import "package:cake_wallet/utils/show_pop_up.dart";
+import "package:cake_wallet/utils/test_id.dart";
import "package:cake_wallet/view_model/hardware_wallet/hardware_wallet_view_model.dart";
import "package:cw_core/amount/money.dart";
import "package:cw_core/crypto_currency.dart";
@@ -128,6 +129,7 @@ class _NewSwapPageState extends State<NewSwapPage> {
builder: (context, state) => Column(
children: [
ModalTopBar(
+ testId: "swap_page_top_bar",
title: S.of(context).swap,
leadingIcon: const Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
@@ -193,6 +195,7 @@ class _NewSwapPageState extends State<NewSwapPage> {
).colorScheme.surfaceContainerHigh,
),
ModernButton.svg(
+ testId: "swap_page_reverse_button_key",
size: 36,
iconSize: 24,
svgPath: "assets/new-ui/swap_amounts.svg",
@@ -501,7 +504,7 @@ class SwapProviderPreview extends StatelessWidget {
forcedProvider = state.forcedProvider;
}
- return GestureDetector(
+ return TestId.merge("swap_page_provider_row_key", child: GestureDetector(
onTap: () {
if (forcedProvider != null) {
bloc.add(const ForcedProviderSelected(null));
@@ -615,7 +618,7 @@ class SwapProviderPreview extends StatelessWidget {
),
),
),
- );
+ ));
},
),
);
### lib/new-ui/pages/wallet_accounts_page.dart
@@ -205,6 +205,7 @@ class _WalletAccountsPageState extends State<WalletAccountsPage> {
child: Column(
children: [
ModalTopBar(
+ testId: "wallet_accounts_page_top_bar",
title: S.of(context).accounts,
leadingIcon: const Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
### lib/new-ui/widgets/anypay/evm_address_detected_sheet.dart
@@ -35,6 +35,7 @@ class EvmAddressDetectedSheet extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "evm_address_detected_sheet_top_bar",
title: "",
trailingIcon: const Icon(Icons.close),
onTrailingPressed: () => Navigator.of(context).maybePop(),
### lib/new-ui/widgets/anypay/network_decision_page.dart
@@ -42,6 +42,7 @@ class NetworkDecisionPage extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "network_decision_page_top_bar",
title: "",
leadingIcon: const Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/widgets/anypay/select_recipient_network_sheet.dart
@@ -71,6 +71,7 @@ class SelectRecipientNetworkSheet extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "select_recipient_network_sheet_top_bar",
title: "",
trailingIcon: const Icon(Icons.close),
onTrailingPressed: () => Navigator.of(context).maybePop(),
### lib/new-ui/widgets/anypay/switch_network_wallet_page.dart
@@ -45,6 +45,7 @@ class SwitchNetworkWalletPage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
ModalTopBar(
+ testId: "switch_network_wallet_page_top_bar",
title: "",
leadingIcon: const Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/widgets/call_scam_warning_sheet.dart
@@ -37,6 +37,7 @@ class CallScamWarningSheet extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "call_scam_warning_sheet_top_bar",
title: "",
leadingIcon: const Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
### lib/new-ui/widgets/changelog_modal.dart
@@ -92,7 +92,7 @@ class _ChangelogModalState extends State<ChangelogModal> {
spacing: 12,
children: [
SizedBox(),
- ModalTopBar(title: S.of(context).whats_new),
+ ModalTopBar(title: S.of(context).whats_new, testId: "changelog_modal_top_bar"),
SizedBox(),
Flexible(
child: SingleChildScrollView(
### lib/new-ui/widgets/charts_page/chart_modal.dart
@@ -35,6 +35,7 @@ class ChartModal extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "chart_modal_top_bar",
title: "",
onLeadingPressed: Navigator.of(context).pop,
leadingIcon: const Icon(Icons.close),
### lib/new-ui/widgets/coins_page/action_row/coin_action_button.dart
@@ -3,6 +3,7 @@ import "dart:math";
import "package:auto_size_text/auto_size_text.dart";
import "package:cake_wallet/themes/core/theme_extension.dart";
+import "package:cake_wallet/utils/test_id.dart";
import "package:flutter/material.dart";
import "package:flutter/services.dart";
@@ -13,12 +14,14 @@ class CoinActionButton extends StatelessWidget {
required this.action,
super.key,
this.gradientColors,
+ this.testId,
});
final Widget icon;
final String label;
final VoidCallback action;
final List<Color>? gradientColors;
+ final String? testId;
static const sizeFactor = 0.16;
@@ -31,6 +34,7 @@ class CoinActionButton extends StatelessWidget {
// from the semantics tree to keep this a single button node.
return MergeSemantics(
child: Semantics(
+ identifier: testId ?? TestId.fromKey(key),
button: true,
label: label,
child: Column(
### lib/new-ui/widgets/coins_page/assets_history/asset_details_modal.dart
@@ -60,6 +60,7 @@ class AssetDetailsModal extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "asset_details_modal_top_bar",
title: "",
trailingIcon: Icon(Icons.close),
trailingSemanticLabel: S.of(context).close,
### lib/new-ui/widgets/coins_page/assets_history/assets_top_bar.dart
@@ -65,6 +65,7 @@ class AssetsTopBar extends StatelessWidget {
else
MergeSemantics(
child: Semantics(
+ identifier: "assets_history_action_button_key",
button: true,
child: GestureDetector(
key: const ValueKey("assets_history_action_button_key"),
### lib/new-ui/widgets/coins_page/assets_history/history_filters_page.dart
@@ -27,6 +27,7 @@ class HistoryFiltersPage extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "history_filters_page_top_bar",
title: S.of(context).filters,
leadingIcon: Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/widgets/coins_page/assets_history/history_modal.dart
@@ -25,6 +25,7 @@ class HistoryModal extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "history_modal_top_bar",
title: S.of(context).history,
leadingIcon: Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
### lib/new-ui/widgets/coins_page/assets_history/history_section.dart
@@ -8,6 +8,7 @@ import 'package:cake_wallet/new-ui/widgets/coins_page/assets_history/history_tra
import 'package:cake_wallet/new-ui/widgets/coins_page/assets_history/payjoin_history_tile.dart';
import 'package:cake_wallet/new-ui/widgets/coins_page/assets_history/transaction_details_modal.dart';
import 'package:cake_wallet/routes.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:cake_wallet/view_model/dashboard/anonpay_transaction_list_item.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
import 'package:cake_wallet/view_model/dashboard/date_section_item.dart';
@@ -41,6 +42,7 @@ class HistorySection extends StatelessWidget {
/// date, amounts) merges into one label.
Widget _historyRow({required VoidCallback onTap, required Widget child}) => MergeSemantics(
child: Semantics(
+ identifier: TestId.fromKey(child.key),
button: true,
child: GestureDetector(onTap: onTap, child: child),
),
@@ -116,7 +118,7 @@ class HistorySection extends StatelessWidget {
}
},
child: HistoryTile(
- key: ValueKey("home_page_transaction_${transaction.id}_key"),
+ key: ValueKey("${short ? "home_page" : "history_modal"}_transaction_${index}_key"),
title: item.formattedTitle + transactionType,
date: _formatTransactionDate(item.date, localeName),
amount: item.formattedCryptoAmount,
### lib/new-ui/widgets/coins_page/assets_history/history_swap_providers_page.dart
@@ -22,6 +22,7 @@ class HistorySwapProvidersPage extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "history_swap_providers_page_top_bar",
title: S.of(context).filter_swap_providers,
leadingIcon: Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/widgets/coins_page/assets_history/history_top_bar.dart
@@ -12,6 +12,7 @@ class HistoryTopBar extends StatelessWidget {
Widget build(BuildContext context) {
return SliverToBoxAdapter(
child: Semantics(
+ identifier: "history_top_bar_key",
button: true,
label: S.of(context).history,
onTap: onTap,
### lib/new-ui/widgets/coins_page/assets_history/transaction_details_modal.dart
@@ -10,6 +10,7 @@ import "package:cake_wallet/src/screens/transaction_details/confirmations_list_i
import "package:cake_wallet/src/screens/transaction_details/transaction_details_list_item.dart";
import "package:cake_wallet/src/widgets/new_list_row/new_list_section.dart";
import "package:cake_wallet/utils/address_formatter.dart";
+import "package:cake_wallet/utils/test_id.dart";
import "package:cake_wallet/view_model/transaction_details_view_model.dart";
import "package:flutter/material.dart";
import "package:flutter/services.dart";
@@ -66,6 +67,7 @@ class _TransactionDetailsModalState extends State<TransactionDetailsModal> {
child: Column(
children: [
ModalTopBar(
+ testId: "transaction_details_modal_top_bar",
title: S.of(context).transaction,
leadingIcon: const Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
@@ -126,6 +128,7 @@ class _TransactionDetailsModalState extends State<TransactionDetailsModal> {
final shouldBuildBottomWidget = item.value.length > 25;
return ListItemRegularRow(
+ testId: TestId.fromKey(item.key),
copyableText: item.value,
showArrow: false,
keyValue: ((item.key as ValueKey?)?.value as String?) ??
### lib/new-ui/widgets/coins_page/unconfirmed_balance_widget.dart
@@ -253,6 +253,7 @@ class UnconfirmedBalanceModal extends StatelessWidget {
spacing: 20,
children: [
ModalTopBar(
+ testId: "unconfirmed_balance_widget_top_bar",
title: S.of(context).balance_confirmation,
leadingIcon: Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
### lib/new-ui/widgets/coins_page/wallet_info.dart
@@ -15,6 +15,7 @@ class WalletInfoBar extends StatelessWidget {
hardwareWalletType == null ? name : "$name, ${S.of(context).hardware_wallet}";
return Semantics(
+ identifier: "home_page_wallet_name_text_key",
label: semanticsLabel,
child: ExcludeSemantics(
child: Row(
### lib/new-ui/widgets/coins_page/zcash_manual_shield_modal.dart
@@ -52,6 +52,7 @@ class ZcashManualShieldModal extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "zcash_manual_shield_modal_top_bar",
title: S.of(context).shield_device_funds,
trailingIcon: const Icon(Icons.close),
onTrailingPressed: Navigator.of(context).pop,
### lib/new-ui/widgets/coins_page/zcash_migration_modal.dart
@@ -23,6 +23,7 @@ class ZcashMigrationModal extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "zcash_migration_modal_top_bar",
title: S.of(context).zcash_network_upgrade,
trailingIcon: const Icon(Icons.close),
onTrailingPressed: Navigator.of(context).pop,
### lib/new-ui/widgets/confirm_swiper.dart
@@ -1,6 +1,7 @@
import 'dart:math';
import 'package:cake_wallet/new-ui/widgets/new_primary_button.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:flutter/material.dart';
class ConfirmSwiper extends StatefulWidget {
@@ -43,6 +44,7 @@ class _ConfirmSwiperState extends State<ConfirmSwiper> {
Widget build(BuildContext context) {
if (MediaQuery.of(context).accessibleNavigation) {
return NewPrimaryButton(
+ testId: TestId.fromKey(widget.key),
onPressed: widget.onConfirmed,
text: widget.accessibleNavigationModeButtonText ?? widget.swiperText,
color: Theme.of(context).colorScheme.primary,
@@ -124,6 +126,7 @@ class _ConfirmSwiperState extends State<ConfirmSwiper> {
// semantics action is exposed here; a screen reader gets the button
// variant above instead.
return Semantics(
+ identifier: TestId.fromKey(widget.key),
container: true,
excludeSemantics: true,
label: widget.swiperText,
### lib/new-ui/widgets/currency_picker/currency_picker_row.dart
@@ -1,6 +1,7 @@
import 'package:cake_wallet/new-ui/widgets/coins_page/token_image_widget.dart';
import "package:cake_wallet/new-ui/widgets/currency_picker/currency_picker_args.dart";
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:cw_core/crypto_currency.dart';
import 'package:flutter/material.dart';
@@ -14,6 +15,7 @@ class CurrencyPickerRow extends StatelessWidget {
this.subtitle,
this.chainPillLabel,
this.chainBadgePath,
+ this.testId,
});
final CryptoCurrency currency;
@@ -23,12 +25,14 @@ class CurrencyPickerRow extends StatelessWidget {
final String? subtitle;
final String? chainPillLabel;
final String? chainBadgePath;
+ final String? testId;
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return MergeSemantics(
child: Semantics(
+ identifier: testId ?? TestId.fromKey(key),
button: true,
selected: isSelected,
child: InkWell(
### lib/new-ui/widgets/currency_picker/currency_picker_sheet.dart
@@ -64,6 +64,7 @@ class CurrencyPickerSheet extends StatelessWidget {
mainAxisSize: MainAxisSize.max,
children: [
ModalTopBar(
+ testId: "currency_picker_sheet_top_bar",
title: S.of(context).select_asset,
leadingIcon: Icon(_isOtherAssetsPage ? Icons.arrow_back_ios_new : Icons.close),
leadingSemanticLabel:
### lib/new-ui/widgets/currency_picker/fiat_currency_picker_sheet.dart
@@ -115,6 +115,7 @@ class _FiatCurrencyPickerSheetState extends State<FiatCurrencyPickerSheet> {
mainAxisSize: MainAxisSize.max,
children: [
ModalTopBar(
+ testId: "fiat_currency_picker_sheet_top_bar",
title: S.of(context).select_fiat_currency_title,
leadingIcon: const Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
### lib/new-ui/widgets/currency_picker/select_network_page.dart
@@ -33,6 +33,7 @@ class SelectNetworkPage extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "select_network_page_top_bar",
title: S.of(context).select_network_title,
leadingIcon: const Icon(Icons.arrow_back),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/widgets/hardware_wallet/bitbox_paring_sheet.dart
@@ -20,6 +20,7 @@ class HardwareWalletBitboxParingSheet extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ModalTopBar(
+ testId: "bitbox_pairing_sheet_top_bar",
title: S.of(context).pairing_code,
onLeadingPressed: () => Navigator.of(context).pop(false),
onTrailingPressed: () {},
### lib/new-ui/widgets/hardware_wallet/proceed_on_device_sheet.dart
@@ -90,6 +90,7 @@ class _HardwareWalletProceedOnDeviceSheetState extends State<HardwareWalletProce
child: Column(
children: [
ModalTopBar(
+ testId: "proceed_on_device_sheet_top_bar",
title: "",
leadingWidget: AnimatedSwitcher(
layoutBuilder: (currentChild, previousChildren) => Stack(
### lib/new-ui/widgets/hardware_wallet/sync_key_images_sheet.dart
@@ -49,6 +49,7 @@ class _HardwareWalletProceedOnDeviceSheetState extends State<SyncKeyImagesSheet>
child: Column(
children: [
ModalTopBar(
+ testId: "sync_key_images_sheet_top_bar",
title: S.of(context).resync_device,
leadingIcon: Icon(
Icons.close,
### lib/new-ui/widgets/hardware_wallet/trezor_paring_sheet.dart
@@ -28,6 +28,7 @@ class _HardwareWalletTrezorParingSheetState extends State<HardwareWalletTrezorPa
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ModalTopBar(
+ testId: "trezor_paring_sheet_top_bar",
title: "Paring code",
onLeadingPressed: Navigator.of(context).pop,
onTrailingPressed: () {},
### lib/new-ui/widgets/line_tab_switcher.dart
@@ -8,11 +8,13 @@ class LineTabSwitcher extends StatefulWidget {
required this.tabs,
required this.onTabChange,
required this.selectedTab,
+ this.testId,
});
final List<String> tabs;
final void Function(int index) onTabChange;
final int selectedTab;
+ final String? testId;
@override
State<LineTabSwitcher> createState() => _LineTabSwitcherState();
@@ -97,6 +99,7 @@ class _LineTabSwitcherState extends State<LineTabSwitcher> {
// that also carries the selected state of this tab.
return MergeSemantics(
child: Semantics(
+ identifier: "${widget.testId ?? "line_tab_switcher"}_${index}_key",
button: true,
selected: widget.selectedTab == index,
inMutuallyExclusiveGroup: true,
### lib/new-ui/widgets/modern_button.dart
@@ -1,5 +1,6 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
@@ -17,6 +18,7 @@ class ModernButton extends StatelessWidget {
/// visible caption) when omitted, so one of the two is required. Must be
/// localized by the caller.
final String? semanticLabel;
+ final String? testId;
static const iconSvgSizeRatio = 2 / 3;
const ModernButton(
@@ -28,7 +30,8 @@ class ModernButton extends StatelessWidget {
this.iconColor,
this.backgroundColor,
this.label,
- this.semanticLabel})
+ this.semanticLabel,
+ this.testId})
: svgPath = null;
const ModernButton.svg(
@@ -40,7 +43,8 @@ class ModernButton extends StatelessWidget {
this.iconColor,
this.backgroundColor,
this.label,
- this.semanticLabel})
+ this.semanticLabel,
+ this.testId})
: icon = null;
@override
@@ -69,6 +73,7 @@ class ModernButton extends StatelessWidget {
// detached stop for screen readers.
return MergeSemantics(
child: Semantics(
+ identifier: testId ?? TestId.fromKey(key),
button: true,
label: semanticLabel ?? label,
child: Column(
### lib/new-ui/widgets/new_future_primary_button.dart
@@ -1,4 +1,5 @@
import "package:cake_wallet/new-ui/widgets/new_primary_button.dart";
+import "package:cake_wallet/utils/test_id.dart";
import "package:flutter/material.dart";
import "package:flutter_svg/flutter_svg.dart";
@@ -11,6 +12,7 @@ class NewFuturePrimaryButton extends StatefulWidget {
this.borderColor = Colors.transparent,
this.disabled = false,
this.image,
+ this.testId,
super.key,
});
@@ -21,6 +23,7 @@ class NewFuturePrimaryButton extends StatefulWidget {
final Color textColor;
final Color borderColor;
final String text;
+ final String? testId;
@override
State<StatefulWidget> createState() => _NewFuturePrimaryButtonState();
@@ -53,5 +56,6 @@ class _NewFuturePrimaryButtonState extends State<NewFuturePrimaryButton> {
isLoading: isLoading,
borderColor: widget.borderColor,
disabled: widget.disabled,
+ testId: widget.testId ?? TestId.fromKey(widget.key),
);
}
### lib/new-ui/widgets/new_primary_button.dart
@@ -1,3 +1,4 @@
+import "package:cake_wallet/utils/test_id.dart";
import "package:flutter/cupertino.dart";
import "package:flutter/material.dart";
@@ -11,6 +12,7 @@ class NewPrimaryButton extends StatelessWidget {
this.isLoading = false,
this.borderColor = Colors.transparent,
this.disabled = false,
+ this.testId,
super.key,
});
@@ -22,11 +24,12 @@ class NewPrimaryButton extends StatelessWidget {
final Color textColor;
final Color borderColor;
final String text;
+ final String? testId;
@override
Widget build(BuildContext context) => SizedBox(
height: 52,
- child: TextButton(
+ child: TestId.merge(testId ?? TestId.fromKey(key), child: TextButton(
onPressed: disabled ? null : onPressed,
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(
@@ -58,5 +61,6 @@ class NewPrimaryButton extends StatelessWidget {
),
),
),
+ ),
);
}
### lib/new-ui/widgets/picker.dart
@@ -76,6 +76,7 @@ class _NewPickerState<Item> extends State<NewPicker<Item>> {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "picker_top_bar",
title: widget.title,
leadingIcon: Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,
@@ -387,6 +388,7 @@ class _PickerSliderPageState<Item> extends State<PickerSliderPage<Item>> {
mainAxisSize: MainAxisSize.max,
children: [
ModalTopBar(
+ testId: "picker_slider_page_top_bar",
title: widget.title,
leadingIcon: Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/widgets/receive_page/payjoin_copy_modal.dart
@@ -24,6 +24,7 @@ class PayjoinCopyModal extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "payjoin_copy_modal_top_bar",
title: S.of(context).select_address_to_copy,
leadingIcon: Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
### lib/new-ui/widgets/receive_page/receive_address_type.dart
@@ -46,6 +46,7 @@ class ReceiveAddressTypeDisplay extends StatelessWidget {
// row is exposed and the chevron is treated as decoration.
return MergeSemantics(
child: Semantics(
+ identifier: "receive_page_address_type_button_key",
button: true,
label: S.of(context).address_type,
child: GestureDetector(
### lib/new-ui/widgets/receive_page/receive_address_type_selector.dart
@@ -3,6 +3,7 @@ import 'package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart';
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
import 'package:cake_wallet/src/widgets/rounded_checkbox.dart';
import 'package:cake_wallet/src/widgets/section_divider.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:cake_wallet/view_model/dashboard/receive_option_view_model.dart';
import 'package:cw_core/receive_page_option.dart';
import 'package:flutter/material.dart';
@@ -71,6 +72,7 @@ class _ReceiveAddressTypeSelectorState extends State<ReceiveAddressTypeSelector>
shrinkWrap: true,
children: [
ModalTopBar(
+ testId: "receive_address_type_selector_top_bar",
title: S.of(context).address_type,
leadingIcon: Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
@@ -93,6 +95,7 @@ class _ReceiveAddressTypeSelectorState extends State<ReceiveAddressTypeSelector>
final opt = commonOptions[index];
return ReceiveAddressTypeRow(
+ key: ValueKey("receive_address_type_common_${index}_key"),
option: opt,
roundedTop: index == 0,
roundedBottom: index == commonOptions.length - 1,
@@ -206,6 +209,7 @@ class _ReceiveAddressTypeSelectorState extends State<ReceiveAddressTypeSelector>
final opt = otherOptions[index];
return ReceiveAddressTypeRow(
+ key: ValueKey("receive_address_type_other_${index}_key"),
option: opt,
roundedTop: false,
roundedBottom: index == otherOptions.length - 1,
@@ -284,6 +288,7 @@ class ReceiveAddressTypeRow extends StatelessWidget {
// only a visual echo of it and must not be announced separately.
child: MergeSemantics(
child: Semantics(
+ identifier: TestId.fromKey(key),
selected: selected,
inMutuallyExclusiveGroup: true,
child: InkWell(
### lib/new-ui/widgets/receive_page/receive_address_widget.dart
@@ -1,4 +1,5 @@
import 'package:cake_wallet/utils/address_formatter.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
@@ -10,7 +11,7 @@ class ReceiveAddressWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return Padding(
+ return TestId.merge("receive_page_address_key", child: Padding(
key: const ValueKey("receive_page_address_key"),
padding: const EdgeInsets.symmetric(horizontal: 50.0),
child: Observer(
@@ -25,6 +26,6 @@ class ReceiveAddressWidget extends StatelessWidget {
fontFamily: "IBM Plex Mono"),
),
),
- );
+ ));
}
}
### lib/new-ui/widgets/receive_page/receive_bottom_buttons.dart
@@ -64,6 +64,7 @@ class _ReceiveBottomButtonsState extends State<ReceiveBottomButtons> {
duration: const Duration(milliseconds: 200),
child: ModernButton.svg(
key: ValueKey(copied),
+ testId: "receive_page_copy_button_key",
size: 60,
iconSize: 32,
svgPath: "assets/new-ui/copy.svg",
@@ -81,6 +82,7 @@ class _ReceiveBottomButtonsState extends State<ReceiveBottomButtons> {
),
Expanded(
child: ModernButton.svg(
+ testId: "receive_page_set_amount_button_key",
size: 60,
iconSize: 32,
svgPath: "assets/new-ui/set-amount.svg",
@@ -91,6 +93,7 @@ class _ReceiveBottomButtonsState extends State<ReceiveBottomButtons> {
if (widget.showLabelButton)
Expanded(
child: ModernButton.svg(
+ testId: "receive_page_label_button_key",
size: 60,
iconSize: 32,
svgPath: "assets/new-ui/add-label.svg",
@@ -101,6 +104,7 @@ class _ReceiveBottomButtonsState extends State<ReceiveBottomButtons> {
if (widget.showAccountsButton)
Expanded(
child: ModernButton.svg(
+ testId: "receive_page_addresses_button_key",
size: 60,
iconSize: 32,
svgPath: "assets/new-ui/addr-book.svg",
### lib/new-ui/widgets/receive_page/receive_label_modal.dart
@@ -64,6 +64,7 @@ class _ReceiveLabelModalState extends State<ReceiveLabelModal> {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "receive_label_modal_top_bar",
title: S.of(context).label_address,
leadingIcon: Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
### lib/new-ui/widgets/receive_page/receive_qr_code.dart
@@ -56,6 +56,7 @@ class ReceiveQrCode extends StatelessWidget {
// rather than each becoming a separate focus stop.
MergeSemantics(
child: Semantics(
+ identifier: "receive_page_qr_code_key",
hint: largeQrMode ? S.of(context).qr_close_fullscreen : S.of(context).qr_fullscreen,
button: true,
enabled: true,
### lib/new-ui/widgets/receive_page/receive_top_bar.dart
@@ -18,7 +18,8 @@ class ModalTopBar extends StatelessWidget {
this.trailingWidget,
this.titleLeadingWidget,
this.leadingSemanticLabel,
- this.trailingSemanticLabel}) {
+ this.trailingSemanticLabel,
+ this.testId}) {
if (leadingIcon != null && leadingWidget != null) {
throw ArgumentError("Cannot have both leadingIcon and leadingWidget");
}
@@ -49,19 +50,23 @@ class ModalTopBar extends StatelessWidget {
/// non-empty) whenever a [trailingIcon] is supplied. Must be localized by
/// the caller.
final String? trailingSemanticLabel;
+ final String? testId;
static const buttonSize = 36.0;
@override
Widget build(BuildContext context) {
final hasBottomText = bottomText != null && bottomText!.isNotEmpty;
+ final baseTestId = testId ?? "modal_top_bar";
final titleContent = Column(
mainAxisSize: MainAxisSize.min,
children: [
AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
child: Semantics(
key: ValueKey(title),
+ container: title.isNotEmpty,
+ identifier: title.isNotEmpty ? "${baseTestId}_title_key" : null,
header: title.isNotEmpty,
// Android reads the heading from headingLevel since the
// Flutter 3.41 engine; header: alone only covers iOS.
@@ -136,6 +141,7 @@ class ModalTopBar extends StatelessWidget {
onPressed: onLeadingPressed,
icon: leadingIcon!,
semanticLabel: leadingSemanticLabel,
+ testId: "${baseTestId}_leading_key",
iconColor: Theme.of(context).colorScheme.onSurfaceVariant)
: leadingWidget!
else
@@ -150,6 +156,7 @@ class ModalTopBar extends StatelessWidget {
onPressed: onTrailingPressed,
icon: trailingIcon!,
semanticLabel: trailingSemanticLabel,
+ testId: "${baseTestId}_trailing_key",
)
: trailingWidget!,
)
### lib/new-ui/widgets/scan_page/network_list.dart
@@ -34,6 +34,7 @@ class ScanPageNetworkList extends StatelessWidget {
child: Column(
children: [
ModalTopBar(
+ testId: "network_list_top_bar",
title: S.of(context).compatible_services,
leadingIcon: Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/widgets/seed/seed_checkbox_row.dart
@@ -1,5 +1,6 @@
import "package:cake_wallet/src/widgets/cake_image_widget.dart";
import "package:cake_wallet/src/widgets/new_list_row/new_simple_checkbox.dart";
+import "package:cake_wallet/utils/test_id.dart";
import "package:flutter/material.dart";
class SeedCheckboxRow extends StatelessWidget {
@@ -8,17 +9,20 @@ class SeedCheckboxRow extends StatelessWidget {
required this.text,
required this.isChecked,
required this.onChanged,
+ this.testId,
super.key,
});
final String iconPath;
final String text;
final bool isChecked;
final ValueChanged<bool> onChanged;
+ final String? testId;
@override
Widget build(BuildContext context) => MergeSemantics(
child: Semantics(
+ identifier: testId ?? TestId.fromKey(key),
checked: isChecked,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
### lib/new-ui/widgets/send_page/floating_icon_button.dart
@@ -1,4 +1,5 @@
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
@@ -8,6 +9,7 @@ class FloatingIconButton extends StatelessWidget {
required this.iconPath,
required this.onPressed,
required this.semanticLabel,
+ this.testId,
});
final String iconPath;
@@ -16,11 +18,13 @@ class FloatingIconButton extends StatelessWidget {
/// Localized accessible name for this icon-only button. The icon itself stays
/// decorative, so this is the only name a screen reader can announce.
final String semanticLabel;
+ final String? testId;
@override
Widget build(BuildContext context) {
return MergeSemantics(
child: Semantics(
+ identifier: testId ?? TestId.fromKey(key),
label: semanticLabel,
button: true,
enabled: true,
### lib/new-ui/widgets/send_page/l2_action_wallet_selector.dart
@@ -86,6 +86,7 @@ class _L2ActionWalletSelectorState extends State<L2ActionWalletSelector> {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "l2_action_wallet_selector_top_bar",
title: widget.action == L2Actions.deposit
? "${S.of(context).send_from}..."
: "${S.of(context).receive_to}...",
### lib/new-ui/widgets/send_page/l2_send_external_modal.dart
@@ -60,6 +60,7 @@ class _L2SendExternalModalState extends State<L2SendExternalModal> {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "l2_send_external_modal_top_bar",
title: "",
leadingWidget: Row(
spacing: 12,
### lib/new-ui/widgets/send_page/send_address_input.dart
@@ -4,6 +4,7 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/new-ui/widgets/send_page/floating_icon_button.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/utils/permission_handler.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:cw_core/currency.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -88,6 +89,7 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
children: [
MergeSemantics(
child: Semantics(
+ identifier: TestId.fromKey(widget.key),
label: _fieldSemanticsLabel(context),
child: TextField(
focusNode: widget.focusNode,
### lib/new-ui/widgets/send_page/send_amount_input.dart
@@ -3,6 +3,7 @@ import "package:cake_wallet/new-ui/widgets/coins_page/token_image_widget.dart";
import "package:cake_wallet/new-ui/widgets/send_page/floating_icon_button.dart";
import "package:cake_wallet/src/widgets/cake_image_widget.dart";
import "package:cake_wallet/utils/decimal_input_formatter.dart";
+import "package:cake_wallet/utils/test_id.dart";
import "package:flutter/material.dart";
import "package:flutter/services.dart";
import "package:flutter_mobx/flutter_mobx.dart";
@@ -68,7 +69,7 @@ class _NewSendAmountInputState extends State<NewSendAmountInput> {
mainAxisSize: MainAxisSize.max,
spacing: 8,
children: [
- // Deliberately unwrapped. Naming the field with
+ // Naming the field with
// MergeSemantics > Semantics(label:) made Android announce
// the amount twice: FormField's own wrapper node reflects
// its descendants' text, so the authored label came back a
@@ -77,7 +78,7 @@ class _NewSendAmountInputState extends State<NewSendAmountInput> {
// must stay in the semantics tree for this field to be
// named at all.
Expanded(
- child: TextField(
+ child: TestId.container(TestId.fromKey(widget.key), child: TextField(
keyboardType: TextInputType.numberWithOptions(
signed: false,
decimal: widget.maxDecimals > 0,
@@ -93,7 +94,7 @@ class _NewSendAmountInputState extends State<NewSendAmountInput> {
errorMaxLines: 3,
),
onChanged: state.didChange,
- ),
+ )),
),
FloatingIconButton(
iconPath: "assets/new-ui/paste.svg",
### lib/new-ui/widgets/send_page/send_confirm_sheet.dart
@@ -143,6 +143,7 @@ class SendTransactionDetails extends StatelessWidget {
mainAxisSize: isPage ? MainAxisSize.max : MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "send_confirm_sheet_top_bar",
title: "",
leadingWidget: Row(
spacing: 8,
### lib/new-ui/widgets/stacked_buttons.dart
@@ -1,4 +1,5 @@
import "package:cake_wallet/new-ui/widgets/new_primary_button.dart";
+import "package:cake_wallet/utils/test_id.dart";
import "package:flutter/material.dart";
class StackedButtons extends StatelessWidget {
@@ -34,7 +35,7 @@ class StackedButtons extends StatelessWidget {
),
if (secondaryAsLink) ...[
const SizedBox(height: 9),
- TextButton(
+ TestId.merge(TestId.fromKey(secondaryKey), child: TextButton(
key: secondaryKey,
onPressed: onSecondary,
style: TextButton.styleFrom(minimumSize: const Size(48, 48)),
@@ -46,6 +47,7 @@ class StackedButtons extends StatelessWidget {
),
),
),
+ ),
] else ...[
const SizedBox(height: 12),
NewPrimaryButton(
### lib/new-ui/widgets/swap_page/provider_options_page.dart
@@ -36,6 +36,7 @@ class ProviderOptionsPage extends StatelessWidget {
return Column(
children: [
ModalTopBar(
+ testId: "provider_options_page_top_bar",
title: S.of(context).swap_providers,
onLeadingPressed: Navigator.of(context).pop,
leadingIcon: const Icon(Icons.arrow_back_ios_new),
### lib/new-ui/widgets/swap_page/provider_selector_page.dart
@@ -36,6 +36,7 @@ class ProviderSelectorPage extends StatelessWidget {
return Column(
children: [
ModalTopBar(
+ testId: "provider_selector_page_top_bar",
title: S.of(context).change_provider,
leadingIcon: const Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,onLeadingPressed: Navigator.of(context).maybePop,
### lib/new-ui/widgets/swap_page/refund_address_modal.dart
@@ -42,6 +42,7 @@ class _RefundAddressModalState extends State<RefundAddressModal> {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "refund_address_modal_top_bar",
title: S.of(context).set_refund_address,
trailingIcon: Icon(Icons.close),
trailingSemanticLabel: S.of(context).close,
### lib/new-ui/widgets/swap_page/swap_address_selection_modal.dart
@@ -9,6 +9,7 @@ import "package:cake_wallet/new-ui/widgets/send_page/l2_action_wallet_selector.d
import "package:cake_wallet/new-ui/widgets/send_page/send_address_input.dart";
import "package:cake_wallet/src/widgets/cake_image_widget.dart";
import "package:cake_wallet/src/widgets/new_list_row/new_simple_checkbox.dart";
+import "package:cake_wallet/utils/test_id.dart";
import "package:cw_core/currency_for_wallet_type.dart";
import "package:cw_core/wallet_info.dart";
import "package:flutter/material.dart";
@@ -85,6 +86,7 @@ class _SwapAddressSelectionModalState extends State<SwapAddressSelectionModal> {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "swap_address_selection_modal_top_bar",
title: widget.isSelectingReceiver
? "${S.of(context).receive_to}..."
: "${S.of(context).send_from}...",
@@ -128,14 +130,15 @@ class _SwapAddressSelectionModalState extends State<SwapAddressSelectionModal> {
if (!widget.isSelectingReceiver) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
- child: WalletRow(
+ child: TestId.merge("swap_wallet_picker_wallet_${index}_key",
+ child: WalletRow(
currencyIconPath: currencyIconPath,
walletName: item.name,
onTap: () {
widget.bloc.add(SourceChanged(InternalSwapSource(item)));
Navigator.of(context).pop();
},
- ),
+ )),
);
}
@@ -144,6 +147,7 @@ class _SwapAddressSelectionModalState extends State<SwapAddressSelectionModal> {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: SwapAddressSelectionModalRow(
+ key: ValueKey("swap_wallet_picker_wallet_${index}_key"),
wallet: item,
iconPath: currencyIconPath,
isSelected: selected,
@@ -290,7 +294,7 @@ class _SwapAddressSelectionModalRowState extends State<SwapAddressSelectionModal
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Column(
children: [
- GestureDetector(
+ TestId.merge(TestId.fromKey(widget.key), child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (widget.accounts != null) {
@@ -327,7 +331,7 @@ class _SwapAddressSelectionModalRowState extends State<SwapAddressSelectionModal
],
),
),
- ),
+ )),
if (widget.accounts != null)
AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
### lib/new-ui/widgets/swap_page/swap_amount_box.dart
@@ -14,6 +14,7 @@ import "package:cake_wallet/src/widgets/cake_image_widget.dart";
import "package:cake_wallet/utils/decimal_input_formatter.dart";
import "package:cake_wallet/utils/payment_request.dart";
import "package:cake_wallet/utils/permission_handler.dart";
+import "package:cake_wallet/utils/test_id.dart";
import "package:cw_core/amount/money.dart";
import "package:cw_core/currency.dart";
import "package:cw_core/wallet_type.dart";
@@ -118,7 +119,11 @@ class SwapAmountBoxState extends State<SwapAmountBox> {
child: Stack(
clipBehavior: Clip.none,
children: [
- TextFormField(
+ TestId.container(
+ widget.isReceiverCard
+ ? "swap_page_receive_amount_field_key"
+ : "swap_page_deposit_amount_field_key",
+ child: TextFormField(
key: ValueKey(widget.isReceiverCard
? "swap_page_receive_amount_field_key"
: "swap_page_deposit_amount_field_key"),
@@ -158,7 +163,7 @@ class SwapAmountBoxState extends State<SwapAmountBox> {
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
),
- ),
+ )),
Positioned.fill(
child: IgnorePointer(
child: AnimatedOpacity(
@@ -200,7 +205,11 @@ class SwapAmountBoxState extends State<SwapAmountBox> {
],
),
),
- GestureDetector(
+ TestId.merge(
+ widget.isReceiverCard
+ ? "swap_amount_box_receive_currency_button_key"
+ : "swap_amount_box_deposit_currency_button_key",
+ child: GestureDetector(
key: ValueKey(widget.isReceiverCard
? "swap_amount_box_receive_currency_button_key"
: "swap_amount_box_deposit_currency_button_key"),onTap: _presentCurrencyPicker,
@@ -263,7 +272,7 @@ class SwapAmountBoxState extends State<SwapAmountBox> {
),
),
),
- ),
+ )),
],
),
),
### lib/new-ui/widgets/swap_page/swap_confirm_sheet.dart
@@ -101,6 +101,7 @@ class SwapTransactionDetails extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "swap_confirm_sheet_top_bar",
title: "",
leadingWidget: SwapModalHeader(
fromIconPath: state.depositAmount.currency.iconPath ?? "",
### lib/new-ui/widgets/swap_page/swap_options_page.dart
@@ -32,6 +32,7 @@ class SwapOptionsPage extends StatelessWidget {
builder: (context, state) => Column(
children: [
ModalTopBar(
+ testId: "swap_options_page_top_bar",
title: S.of(context).configure,
leadingIcon: const Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/widgets/swap_page/swap_provider_initial_preference_modal.dart
@@ -18,7 +18,9 @@ class SwapProviderInitialPreferenceModal extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(),
- ModalTopBar(title: S.of(context).swap_providers),
+ ModalTopBar(
+ title: S.of(context).swap_providers,
+ testId: "swap_provider_initial_preference_modal_top_bar"),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 18.0),
child: Column(
### lib/new-ui/widgets/swap_page/swap_send_external_modal.dart
@@ -59,6 +59,7 @@ class _SwapSendExternalModalState extends State<SwapSendExternalModal> {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "swap_send_external_modal_top_bar",
title: "",
leadingWidget: SwapModalHeader(
fromIconPath: widget.from.iconPath ?? "", toIconPath: widget.to.iconPath ?? ""),
### lib/new-ui/widgets/swap_page/trocador_providers_settings.dart
@@ -22,6 +22,7 @@ class TrocadorProvidersSettings extends StatelessWidget {
spacing: 24,
children: [
ModalTopBar(
+ testId: "trocador_providers_settings_top_bar",
title: "Trocador ${S.of(context).providers}",
leadingIcon: Icon(Icons.arrow_back_ios_new),
leadingSemanticLabel: S.of(context).seed_alert_back,
### lib/new-ui/widgets/wallet_deprecation_popup.dart
@@ -26,6 +26,7 @@ class WalletDeprecationPopup extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
+ testId: "wallet_deprecation_popup_top_bar",
title: "",
leadingIcon: Icon(Icons.close),
leadingSemanticLabel: S.of(context).close,
### lib/src/screens/contact/contact_list_page.dart
@@ -54,6 +54,7 @@ class ContactListPage extends BasePage implements PageOpenListener {
color: Theme.of(context).colorScheme.surfaceContainer,
),
child: Semantics(
+ identifier: "contact_list_page_add_contact_button_key",
label: S.of(context).add_contact,
button: true,
child: Stack(
### lib/src/screens/contact/contact_page.dart
@@ -81,10 +81,10 @@ class ContactPage extends BasePage {
Padding(
padding: EdgeInsets.only(top: 20),
child: Container(
- child: InkWell(
+ child: Semantics(identifier: "contact_page_currency_picker_button_key", button: true, label: S.of(context).settings_currency, value: _currencyTypeController.text.trim(), child: InkWell(
key: ValueKey("contact_page_currency_picker_button_key"),
onTap: () => _presentCurrencyPicker(context),
- child: IgnorePointer(
+ child: ExcludeSemantics(child: IgnorePointer(
child: BaseTextFormField(
controller: _currencyTypeController,
hintText: S.of(context).settings_currency,
@@ -97,8 +97,8 @@ class ContactPage extends BasePage {
],
),
),
- ),
- ),
+ )),
+ )),
),
),
if (contactViewModel.currency != null)
### lib/src/screens/dashboard/widgets/header_row.dart
@@ -3,6 +3,7 @@ import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
+import "package:cake_wallet/utils/test_id.dart";
class HeaderRow extends StatelessWidget {
HeaderRow({required this.dashboardViewModel, this.onExportCsv, super.key});
@@ -33,7 +34,7 @@ class HeaderRow extends StatelessWidget {
if (onExportCsv != null)
Padding(
padding: const EdgeInsets.only(right: 8),
- child: GestureDetector(
+ child: TestId.merge("transactions_page_header_row_export_csv_button_key", child: GestureDetector(
key: ValueKey('transactions_page_header_row_export_csv_button_key'),
onTap: onExportCsv,
child: Semantics(
@@ -54,10 +55,11 @@ class HeaderRow extends StatelessWidget {
),
),
),
- ),
+ )),
),
Semantics(
container: true,
+ identifier: "transactions_page_header_row_transaction_filter_button_key",
child: GestureDetector(
key: ValueKey('transactions_page_header_row_transaction_filter_button_key'),
onTap: () {},
### lib/src/screens/dashboard/widgets/new_main_navbar_widget.dart
@@ -2,6 +2,7 @@ import 'dart:io';
import 'dart:math';
import 'dart:ui';
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:flutter/material.dart';
import "package:flutter/services.dart";
import 'package:flutter_mobx/flutter_mobx.dart';
@@ -191,6 +192,7 @@ class _NEWNewMainNavBarState extends State<NewMainNavBar> {
: 0),
curve: Curves.easeOutCubic,
child: Semantics(
+ identifier: TestId.fromKey(visibleActions[i].key),
button: true,
selected: i == realSelectedIndex,
inMutuallyExclusiveGroup: true,
### lib/src/screens/disclaimer/disclaimer_page.dart
@@ -6,6 +6,7 @@ import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/wallet_type_utils.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
+import "package:cake_wallet/utils/test_id.dart";
class DisclaimerPage extends BasePage {
DisclaimerPage({this.isReadOnly = false});
@@ -145,7 +146,7 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
child: Container(
padding:
EdgeInsets.only(left: 24.0, top: 10.0, right: 24.0, bottom: 10.0),
- child: InkWell(
+ child: TestId.merge("disclaimer_check_key", child: InkWell(
key: ValueKey('disclaimer_check_key'),
onTap: () => setState(() => _checked = !_checked),
child: Row(
@@ -179,7 +180,7 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
)
],
),
- )),
+ ))),
),
],
),
### lib/src/screens/exchange/widgets/exchange_card.dart
@@ -1,491 +0,0 @@
-import 'package:cake_wallet/core/amount_validator.dart';
-import 'package:cake_wallet/entities/contact_base.dart';
-import 'package:cake_wallet/src/screens/receive/widgets/currency_input_field.dart';
-import 'package:cake_wallet/routes.dart';
-import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
-import 'package:cake_wallet/utils/show_bar.dart';
-import 'package:cake_wallet/utils/show_pop_up.dart';
-import 'package:cake_wallet/utils/payment_request.dart';
-import 'package:cw_core/currency.dart';
-import 'package:flutter/services.dart';
-import 'package:flutter/material.dart';
-import 'package:cake_wallet/generated/i18n.dart';
-import 'package:cake_wallet/src/widgets/address_text_field.dart';
-import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
-import 'package:cake_wallet/src/screens/exchange/widgets/currency_picker.dart';
-
-class ExchangeCard<T extends Currency> extends StatefulWidget {
- ExchangeCard({
- Key? key,
- required this.initialCurrency,
- required this.initialAddress,
- required this.initialWalletName,
- required this.initialIsAmountEditable,
- required this.isAmountEstimated,
- required this.currencies,
- required this.onCurrencySelected,
- required this.fillColor,
- this.imageArrow,
- this.currencyValueValidator,
- this.addressTextFieldValidator,
- this.title = '',
- this.initialIsAddressEditable = true,
- this.hasRefundAddress = false,
- this.isMoneroWallet = false,
- this.currencyButtonColor = Colors.transparent,
- this.addressButtonsColor = Colors.transparent,
- this.borderColor = Colors.transparent,
- this.hasAllAmount = false,
- this.isAllAmountEnabled = false,
- this.showAddressField = true,
- this.showLimitsField = true,
- this.amountFocusNode,
- this.addressFocusNode,
- this.allAmount,
- this.currencyRowPadding,
- this.addressRowPadding,
- this.onPushPasteButton,
- this.onPushAddressBookButton,
- this.onDispose,
- this.useSatoshis = false,
- this.onTapCurrencyPicker,
- required this.cardInstanceName,
- }) : super(key: key);
-
- final List<T> currencies;
- final Function(T) onCurrencySelected;
- final String title;
- final T initialCurrency;
- final String initialWalletName;
- final String initialAddress;
- final bool initialIsAmountEditable;
- final bool initialIsAddressEditable;
- final bool isAmountEstimated;
- final bool hasRefundAddress;
- final bool isMoneroWallet;
- final Image? imageArrow;
- final Color currencyButtonColor;
- final Color? addressButtonsColor;
- final Color borderColor;
- final FormFieldValidator<String>? currencyValueValidator;
- final FormFieldValidator<String>? addressTextFieldValidator;
- final FormFieldValidator<String> allAmountValidator = AllAmountValidator();
- final FocusNode? amountFocusNode;
- final FocusNode? addressFocusNode;
- final bool hasAllAmount;
- final bool showAddressField;
- final bool showLimitsField;
- final bool isAllAmountEnabled;
- final VoidCallback? allAmount;
- final EdgeInsets? currencyRowPadding;
- final EdgeInsets? addressRowPadding;
- final void Function(BuildContext context)? onPushPasteButton;
- final void Function(BuildContext context)? onPushAddressBookButton;
- final Function()? onDispose;
- final String cardInstanceName;
- final Color fillColor;
- final bool useSatoshis;
- final void Function(BuildContext context)? onTapCurrencyPicker;
-
- @override
- ExchangeCardState<T> createState() => ExchangeCardState<T>();
-}
-
-class ExchangeCardState<T extends Currency> extends State<ExchangeCard<T>> {
- ExchangeCardState()
- : _title = '',
- _min = '',
- _max = '',
- _isAmountEditable = false,
- _isAddressEditable = false,
- _walletName = '',
- _isAmountEstimated = false,
- _isMoneroWallet = false,
- _cardInstanceName = '';
-
- final addressController = TextEditingController();
- final amountController = TextEditingController();
-
- String _cardInstanceName;
- String _title;
- String? _min;
- String? _max;
- late T _selectedCurrency;
- String _walletName;
- bool _isAmountEditable;
- bool _isAddressEditable;
- bool _isAmountEstimated;
- bool _isMoneroWallet;
-
- @override
- void initState() {
- _cardInstanceName = widget.cardInstanceName;
- _title = widget.title;
- _isAmountEditable = widget.initialIsAmountEditable;
- _isAddressEditable = widget.initialIsAddressEditable;
- _walletName = widget.initialWalletName;
- _selectedCurrency = widget.initialCurrency;
- _isAmountEstimated = widget.isAmountEstimated;
- _isMoneroWallet = widget.isMoneroWallet;
- addressController.text = _normalizeAddressFormat(widget.initialAddress);
-
- super.initState();
- }
-
- @override
- void dispose() {
- widget.onDispose?.call();
-
- super.dispose();
- }
-
- void changeLimits({String? min, String? max}) {
- setState(() {
- _min = min;
- _max = max;
- });
- }
-
- void changeSelectedCurrency(T currency) {
- setState(() => _selectedCurrency = currency);
- }
-
- void changeWalletName(String walletName) {
- setState(() => _walletName = walletName);
- }
-
- void changeIsAction(bool isActive) {
- setState(() => _isAmountEditable = isActive);
- }
-
- void isAmountEditable({bool isEditable = true}) {
- setState(() => _isAmountEditable = isEditable);
- }
-
- void isAddressEditable({bool isEditable = true}) {
- setState(() => _isAddressEditable = isEditable);
- }
-
- void changeAddress({required String address}) {
- setState(() => addressController.text = _normalizeAddressFormat(address));
- }
-
- void changeAmount({required String amount}) {
- setState(() => amountController.text = amount);
- }
-
- void changeIsAmountEstimated(bool isEstimated) {
- setState(() => _isAmountEstimated = isEstimated);
- }
-
- @override
- Widget build(BuildContext context) {
- if (widget.isAllAmountEnabled) {
- WidgetsBinding.instance.addPostFrameCallback((_) {
- amountController.text = S.of(context).all;
- });
- }
-
- final copyImage = Image.asset(
- 'assets/images/copy_content.png',
- height: 16,
- width: 16,
- color: Theme.of(context).colorScheme.onSurface,
- );
-
- return Container(
- width: double.infinity,
- color: Colors.transparent,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- SizedBox(height: 10),
- Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: <Widget>[
- SizedBox(height: 40),
- Text(
- key: ValueKey('${_cardInstanceName}_title_key'),
- _title,
- style: Theme.of(context).textTheme.titleLarge!.copyWith(
- fontSize: 18,
- fontWeight: FontWeight.w600,
- color: Theme.of(context).colorScheme.onSurfaceVariant,
- ),
- )
- ],
- ),
- CurrencyAmountTextField(
- hasUnderlineBorder: true,
- borderWidth: 0.0,
- padding: EdgeInsets.zero,
- currencyPickerButtonKey: ValueKey('${_cardInstanceName}_currency_picker_button_key'),
- selectedCurrencyTextKey: ValueKey('${_cardInstanceName}_selected_currency_text_key'),
- selectedCurrencyTagTextKey:
- ValueKey('${_cardInstanceName}_selected_currency_tag_text_key'),
- amountTextfieldKey: ValueKey('${_cardInstanceName}_amount_textfield_key'),
- sendAllButtonKey: ValueKey('${_cardInstanceName}_send_all_button_key'),
- currencyAmountTextFieldWidgetKey:
- ValueKey('${_cardInstanceName}_currency_amount_textfield_widget_key'),
- imageArrow: widget.imageArrow,
- selectedCurrency: widget.useSatoshis ? "SATS" : "$_selectedCurrency",
- selectedCurrencyDecimals: widget.useSatoshis ? 0 : _selectedCurrency.decimals,
- amountFocusNode: widget.amountFocusNode,
- amountController: amountController,
- onTapPicker: () => _presentPicker(context),
- isAmountEditable: _isAmountEditable,
- isPickerEnable: true,
- allAmountButton: widget.hasAllAmount,
- currencyValueValidator: widget.currencyValueValidator,
- tag: _selectedCurrency.tag,
- allAmountCallback: widget.allAmount,
- fillColor: widget.fillColor,
- ),
- Divider(height: 1, color: Theme.of(context).colorScheme.outlineVariant),
- Padding(
- padding: EdgeInsets.only(top: 5),
- child: widget.showLimitsField
- ? Container(
- height: 15,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: <Widget>[
- _min != null
- ? Text(
- key: ValueKey('${_cardInstanceName}_min_limit_text_key'),
- S.of(context).min_value(_min ?? '', _selectedCurrency.toString()),
- style: Theme.of(context).textTheme.bodySmall!.copyWith(
- fontSize: 10,
- height: 1.2,
- color: Theme.of(context).colorScheme.onSurfaceVariant,
- ),
- )
- : Offstage(),
- _min != null ? SizedBox(width: 10) : Offstage(),
- _max != null
- ? Text(
- key: ValueKey('${_cardInstanceName}_max_limit_text_key'),
- S.of(context).max_value(_max ?? '', _selectedCurrency.toString()),
- style: Theme.of(context).textTheme.bodySmall!.copyWith(
- fontSize: 10,
- height: 1.2,
- color: Theme.of(context).colorScheme.onSurfaceVariant,
- ),
- )
- : Offstage(),
- ],
- ),
- )
- : Offstage(),
- ),
- !_isAddressEditable && widget.hasRefundAddress
- ? Padding(
- padding: EdgeInsets.only(top: 20),
- child: Text(
- S.of(context).refund_address,
- style: Theme.of(context).textTheme.bodyMedium!.copyWith(
- fontWeight: FontWeight.w500,
- color: Theme.of(context).colorScheme.onSurfaceVariant,
- ),
- ),
- )
- : Offstage(),
- _isAddressEditable
- ? widget.showAddressField
- ? FocusTraversalOrder(
- order: NumericFocusOrder(2),
- child: Padding(
- padding: widget.addressRowPadding ?? EdgeInsets.only(top: 12),
- child: AddressTextField(
- hasUnderlineBorder: true,
- borderWidth: 0.0,
- addressKey:
- ValueKey('${_cardInstanceName}_editable_address_textfield_key'),
- focusNode: widget.addressFocusNode,
- controller: addressController,
- onURIScanned: (uri) {
- final paymentRequest = PaymentRequest.fromUri(uri);
- addressController.text = paymentRequest.address;
-
- if (amountController.text.isNotEmpty &&
- paymentRequest.amount.isNotEmpty) {
- _showAmountPopup(context, paymentRequest);
- return;
- }
- widget.amountFocusNode?.requestFocus();
- amountController.text = paymentRequest.amount;
- },
- placeholder:
- widget.hasRefundAddress ? S.of(context).refund_address : null,
- options: [
- AddressTextFieldOption.paste,
- AddressTextFieldOption.qrCode,
- AddressTextFieldOption.addressBook,
- ],
- textStyle: Theme.of(context).textTheme.bodyMedium!.copyWith(
- fontSize: 16,
- fontWeight: FontWeight.w600,
- color: Theme.of(context).colorScheme.onSurface,
- ),
- hintStyle: Theme.of(context).textTheme.bodyMedium!.copyWith(
- fontSize: 16,
- fontWeight: FontWeight.w600,
- color: Theme.of(context).colorScheme.onSurfaceVariant,
- ),
- buttonColor: widget.addressButtonsColor,
- validator: widget.addressTextFieldValidator,
- onPushPasteButton: widget.onPushPasteButton,
- onPushAddressBookButton: widget.onPushAddressBookButton,
- selectedCurrency: _selectedCurrency,
- fillColor: widget.fillColor,
- iconColor: Theme.of(context).colorScheme.onSurfaceVariant,
- ),
- ),
- )
- : Offstage()
- : Padding(
- padding: EdgeInsets.only(top: 0),
- child: Builder(
- builder: (context) => Stack(
- children: <Widget>[
- FocusTraversalOrder(
- order: NumericFocusOrder(3),
- child: BaseTextFormField(
- hasUnderlineBorder: true,
- borderWidth: 0.0,
- key:
- ValueKey('${_cardInstanceName}_non_editable_address_textfield_key'),
- controller: addressController,
- suffixIcon: SizedBox(width: _isMoneroWallet ? 80 : 36),
- textStyle: Theme.of(context).textTheme.bodyMedium!.copyWith(
- fontSize: 16,
- fontWeight: FontWeight.w600,
- ),
- validator: widget.addressTextFieldValidator,
- fillColor: widget.fillColor,
- ),
- ),
- Positioned(
- top: 2,
- right: 0,
- child: SizedBox(
- width: _isMoneroWallet ? 80 : 36,
- child: Row(
- children: <Widget>[
- if (_isMoneroWallet)
- Padding(
- padding: EdgeInsets.only(left: 10),
- child: Container(
- width: 34,
- height: 34,
- padding: EdgeInsets.only(top: 0),
- child: Semantics(
- label: S.of(context).address_book,
- child: InkWell(
- key: ValueKey(
- '${_cardInstanceName}_address_book_button_key'),
- onTap: () async {
- final contact = await Navigator.of(context).pushNamed(
- Routes.pickerAddressBook,
- arguments: [widget.initialCurrency, true],
- );
-
- if (contact is ContactBase) {
- setState(
- () => addressController.text = contact.address);
- widget.onPushAddressBookButton?.call(context);
- }
- },
- child: Container(
- padding: EdgeInsets.all(8),
- decoration: BoxDecoration(
- color: widget.addressButtonsColor,
- borderRadius: BorderRadius.all(Radius.circular(6))),
- child: Image.asset(
- 'assets/images/open_book.png',
- color: Theme.of(context).colorScheme.onSurface,
- ),
- ),
- ),
- ),
- ),
- ),
- Padding(
- padding: EdgeInsets.only(left: 2),
- child: Container(
- width: 34,
- height: 34,
- padding: EdgeInsets.only(top: 0),
- child: Semantics(
- label: S.of(context).copy_address,
- child: InkWell(
- key: ValueKey(
- '${_cardInstanceName}_copy_refund_address_button_key'),
- onTap: () {
- Clipboard.setData(
- ClipboardData(text: addressController.text));
- showBar<void>(context, S.of(context).copied_to_clipboard);
- },
- child: Container(
- padding: EdgeInsets.fromLTRB(8, 8, 0, 8),
- color: Colors.transparent,
- child: copyImage,
- ),
- ),
- ),
- ),
- )
- ],
- ),
- ),
- )
- ],
- ),
- ),
- ),
- ],
- ),
- );
- }
-
- void _presentPicker(BuildContext context) {
- if (widget.onTapCurrencyPicker != null) {
- widget.onTapCurrencyPicker!(context);
- return;
- }
- showPopUp<void>(
- context: context,
- builder: (_) => CurrencyPicker(
- key: ValueKey('${_cardInstanceName}_currency_picker_dialog_button_key'),
- selectedAtIndex: widget.currencies.indexOf(_selectedCurrency),
- items: widget.currencies,
- hintText: S.of(context).search_currency,
- isConvertFrom: widget.hasRefundAddress,
- onItemSelected: (Currency item) => widget.onCurrencySelected(item as T),
- ),
- );
- }
-
- void _showAmountPopup(BuildContext context, PaymentRequest paymentRequest) {
- showPopUp<void>(
- context: context,
- builder: (dialogContext) {
- return AlertWithTwoActions(
- alertTitle: S.of(dialogContext).overwrite_amount,
- alertContent: S.of(dialogContext).qr_payment_amount,
- rightButtonText: S.of(dialogContext).ok,
- leftButtonText: S.of(dialogContext).cancel,
- actionRightButton: () {
- widget.amountFocusNode?.requestFocus();
- amountController.text = paymentRequest.amount;
- Navigator.of(dialogContext).pop();
- },
- actionLeftButton: () => Navigator.of(dialogContext).pop());
- });
- }
-
- String _normalizeAddressFormat(String address) {
- if (address.startsWith('bitcoincash:')) address = address.substring(12);
- return address;
- }
-}
### lib/src/screens/integrations/deuro/savings_page.dart
@@ -317,23 +317,23 @@ class DEuroSavingsPage extends BasePage {
context,
title: S.of(context).deuro_savings_balance,
content: S.of(context).deuro_savings_balance_tooltip,
- key: 'savings_tooltip',
+ key: _DEuroTooltip.savings,
onLearnMorePressed: () => launchUrlString("https://deuro.com/#faq", mode: LaunchMode.externalApplication),
);
void _onInterestTooltipPressed(BuildContext context) => _showTooltip(
context,
title: S.of(context).deuro_savings_collect_interest,
content: S.of(context).deuro_savings_collect_interest_tooltip,
- key: 'interest_tooltip',
+ key: _DEuroTooltip.interest,
onLearnMorePressed: () => launchUrlString("https://deuro.com/#faq", mode: LaunchMode.externalApplication),
);
void _showTooltip(
BuildContext context, {
required String title,
required String content,
- required String key,
+ required _DEuroTooltip key,
required VoidCallback onLearnMorePressed,
}) {
if (!context.mounted) return;
@@ -346,10 +346,10 @@ class DEuroSavingsPage extends BasePage {
tooltip: content,
footerType: FooterType.doubleActionButton,
doubleActionRightButtonText: S.of(context).close,
- rightActionButtonKey: ValueKey('deuro_page_tooltip_dialog_${key}_ok_button_key'),
+ rightActionButtonKey: ValueKey('deuro_page_tooltip_dialog_${key.name}_tooltip_ok_button_key'),
onRightActionButtonPressed: () => Navigator.of(bottomSheetContext).pop(),
doubleActionLeftButtonText: S.of(context).learn_more,
- leftActionButtonKey: ValueKey('deuro_page_tooltip_dialog_${key}_learn_more_button_key'),
+ leftActionButtonKey: ValueKey('deuro_page_tooltip_dialog_${key.name}_tooltip_learn_more_button_key'),
onLeftActionButtonPressed: onLearnMorePressed,
),
);
@@ -419,3 +419,5 @@ class DEuroSavingsPage extends BasePage {
);
}
}
+
+enum _DEuroTooltip { savings, interest }
### lib/src/screens/new_wallet/new_wallet_page.dart
@@ -18,6 +18,7 @@ import 'package:cake_wallet/src/widgets/seed_language_picker.dart';
import 'package:cake_wallet/src/widgets/seed_language_selector.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:cake_wallet/view_model/seed_settings_view_model.dart';
import 'package:cake_wallet/view_model/wallet_new_vm.dart';
import 'package:cw_core/wallet_type.dart';
@@ -182,7 +183,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
fontSize: 16.0,
),
hintText: S.of(context).wallet_name,
- suffixIcon: Semantics(
+ suffixIcon: TestId.merge("new_wallet_page_wallet_name_textformfield_generate_name_button_key",
label: S.of(context).generate_name,
child: IconButton(
key: ValueKey(
### lib/src/screens/new_wallet/new_wallet_type_page.dart
@@ -14,6 +14,7 @@ import 'package:cw_core/hardware/device_connection_type.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
+import "package:cake_wallet/utils/test_id.dart";
class NewWalletTypePageHeader extends StatelessWidget {
const NewWalletTypePageHeader({super.key});
@@ -159,13 +160,13 @@ class WalletTypeFormState extends State<WalletTypeForm> {
physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.zero,
itemBuilder: (context, index) {
- final item = filteredTypes[index];
+ final type = filteredTypes[index];
- return GestureDetector(
- key: ValueKey('new_wallet_type_${item.name}_button_key'),
+ return TestId.merge("new_wallet_type_${type.name}_button_key", child: GestureDetector(
+ key: ValueKey('new_wallet_type_${type.name}_button_key'),
behavior: HitTestBehavior.opaque,
onTap: () {
- onTypeSelected(item);
+ onTypeSelected(type);
},
child: SizedBox(
height: 50,
@@ -179,16 +180,16 @@ class WalletTypeFormState extends State<WalletTypeForm> {
CakeImageWidget(
height: 24,
width: 24,
- imageUrl: getCryptoCurrencyIconForWalletListItem(item),
+ imageUrl: getCryptoCurrencyIconForWalletListItem(type),
),
const SizedBox(width: 12),
Semantics(
button: true,
- child: Text(walletTypeToDisplayName(item)),
+ child: Text(walletTypeToDisplayName(type)),
),
const SizedBox(width: 4),
Text(
- walletTypeToDisplayTicker(item),
+ walletTypeToDisplayTicker(type),
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
@@ -207,7 +208,7 @@ class WalletTypeFormState extends State<WalletTypeForm> {
),
),
),
- );
+ ));
},
separatorBuilder: (context, index) => Container(
height: 1,
### lib/src/screens/new_wallet/widgets/grouped_wallet_expansion_tile.dart
@@ -1,5 +1,6 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:cw_core/currency_for_wallet_type.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
@@ -81,7 +82,7 @@ class GroupedWalletExpansionTile extends StatelessWidget {
contentPadding:
EdgeInsets.symmetric(vertical: 1, horizontal: !isCurrentlySelectedWallet ? 16 : 0),
leading: leadingWidget,
- title: Text(
+ title: Semantics(identifier: TestId.fromKey(tileKey), child: Text(
title,
semanticsLabel: isCurrentlySelectedWallet
? '${titleSemanticsLabel ?? title}$currentSuffix'
@@ -92,7 +93,7 @@ class GroupedWalletExpansionTile extends StatelessWidget {
color: effectiveTextColor,
),
textAlign: TextAlign.left,
- ),
+ )),
trailing: trailingWidget ?? const SizedBox.shrink(),
onTap: onTitleTapped,
),
@@ -117,7 +118,7 @@ class GroupedWalletExpansionTile extends StatelessWidget {
collapsedIconColor: effectiveArrowColor,
leading: leadingWidget,
trailing: trailingWidget,
- title: GestureDetector(
+ title: Semantics(identifier: TestId.fromKey(tileKey), child: GestureDetector(
onTap: onTitleTapped,
child: Text(
title,
@@ -128,13 +129,15 @@ class GroupedWalletExpansionTile extends StatelessWidget {
),
textAlign: TextAlign.left,
),
- ),
+ )),
children: childWallets.map(
(item) {
final currentColor = item.isCurrent
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.surface;
- return ListTile(
+ return TestId.container(
+ TestId.fromKey(tileKey)?.replaceFirst(RegExp(r"_key$"), "_wallet_${childWallets.indexOf(item)}_key"),
+ child: ListTile(
contentPadding: EdgeInsets.zero,
key: ValueKey(item.name),
trailing: childTrailingWidget?.call(item),
@@ -176,7 +179,7 @@ class GroupedWalletExpansionTile extends StatelessWidget {
color: effectiveTextColor,
),
),
- );
+ ));
},
).toList(),
),
### lib/src/screens/restore/wallet_restore_from_keys_form.dart
@@ -9,6 +9,7 @@ import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
import 'package:cake_wallet/core/wallet_name_validator.dart';
import 'package:cw_core/generate_name.dart';
import 'package:flutter/services.dart';
+import "package:cake_wallet/utils/test_id.dart";
class WalletRestoreFromKeysForm extends StatefulWidget {
WalletRestoreFromKeysForm({
@@ -154,7 +155,7 @@ class WalletRestoreFromKeysFormState extends State<WalletRestoreFromKeysForm> {
controller: nameTextEditingController,
hintText: S.of(context).wallet_name,
validator: WalletNameValidator(),
- suffixIcon: IconButton(
+ suffixIcon: TestId.merge("wallet_restore_from_keys_wallet_name_refresh_button_key", child: IconButton(
key: ValueKey('wallet_restore_from_keys_wallet_name_refresh_button_key'),
onPressed: () async {
final rName = await generateName();
@@ -179,7 +180,7 @@ class WalletRestoreFromKeysFormState extends State<WalletRestoreFromKeysForm> {
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
- ),
+ )),
),
if (widget.displayWalletPassword) ...[
Container(
### lib/src/screens/restore/wallet_restore_from_seed_form.dart
@@ -15,6 +15,7 @@ import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
import 'package:mobx/mobx.dart';
import 'package:polyseed/polyseed.dart';
+import "package:cake_wallet/utils/test_id.dart";
class WalletRestoreFromSeedForm extends StatefulWidget {
WalletRestoreFromSeedForm({
@@ -156,7 +157,7 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
key: ValueKey('wallet_restore_from_seed_wallet_name_textfield_key'),
controller: nameTextEditingController,
hintText: S.of(context).wallet_name,
- suffixIcon: IconButton(
+ suffixIcon: TestId.merge("wallet_restore_from_seed_wallet_name_refresh_button_key", child: IconButton(
key: ValueKey('wallet_restore_from_seed_wallet_name_refresh_button_key'),
onPressed: () async {
final rName = await generateName();
@@ -181,7 +182,7 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
- ),
+ )),
validator: WalletNameValidator(),
)),
Container(height: 20),
@@ -195,7 +196,7 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
pasteButtonKey: ValueKey('wallet_restore_from_seed_wallet_seeds_paste_button_key'),
),
if ([WalletType.monero, WalletType.wownero].contains(widget.type))
- GestureDetector(
+ TestId.merge("wallet_restore_from_seed_seedtype_picker_button_key", child: GestureDetector(
key: ValueKey('wallet_restore_from_seed_seedtype_picker_button_key'),
onTap: () async {
await showPopUp<void>(
@@ -232,7 +233,7 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
),
),
),
- ),
+ )),
if (widget.displayWalletPassword) ...[
BaseTextFormField(
key: ValueKey('password'),
### lib/src/screens/seed/seed_verification/seed_verification_step_view.dart
@@ -3,6 +3,7 @@ import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/view_model/wallet_seed_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
+import "package:cake_wallet/utils/test_id.dart";
class SeedVerificationStepView extends StatelessWidget {
const SeedVerificationStepView({
@@ -64,8 +65,9 @@ class SeedVerificationStepView extends StatelessWidget {
alignment: WrapAlignment.center,
children: walletSeedViewModel.currentOptions.map(
(option) {
- return GestureDetector(
- key: ValueKey('seed_verification_option_${option}_button_key'),
+ final index = walletSeedViewModel.currentOptions.indexOf(option);
+ return TestId.merge("seed_verification_option_${index}_button_key", child: GestureDetector(
+ key: ValueKey('seed_verification_option_${index}_button_key'),
onTap: () async {
if (walletSeedViewModel.wrongEntries > 2) return;
@@ -101,7 +103,7 @@ class SeedVerificationStepView extends StatelessWidget {
),
),
),
- );
+ ));
},
).toList(),
),
### lib/src/screens/seed/wallet_seed_page.dart
@@ -16,6 +16,7 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/view_model/wallet_seed_view_model.dart';
+import "package:cake_wallet/utils/test_id.dart";
class WalletSeedPage extends BasePage {
WalletSeedPage(this.walletSeedViewModel, {required this.isNewWalletCreated});
@@ -30,7 +31,7 @@ class WalletSeedPage extends BasePage {
@override
Widget trailing(BuildContext context) {
return isNewWalletCreated
- ? GestureDetector(
+ ? TestId.merge("wallet_seed_page_copy_seeds_button_key", child: GestureDetector(
key: ValueKey('wallet_seed_page_copy_seeds_button_key'),
onTap: () {
ClipboardUtil.setSensitiveDataToClipboard(
@@ -52,7 +53,7 @@ class WalletSeedPage extends BasePage {
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
- )
+ ))
: Offstage();
}
### lib/src/screens/settings/security_backup_page.dart
@@ -61,6 +61,7 @@ class SecurityBackupPage extends BasePage {
if (DeviceInfo.instance.isMobile || Platform.isMacOS || Platform.isLinux)
ListItemToggle(
keyValue: "security_backup_page_allow_biometrics_button_key",
+ testId: "security_backup_page_allow_biometrics_button_key",
label: S.current.settings_allow_biometrical_authentication,
value: _securitySettingsViewModel.allowBiometricalAuthentication,
onChanged: (bool value) {
@@ -96,6 +97,7 @@ class SecurityBackupPage extends BasePage {
if (FeatureFlag.duressPinEnabled)
ListItemToggle(
keyValue: "security_backup_page_duress_pin_button_key",
+ testId: "security_backup_page_duress_pin_button_key",
label: "Duress PIN",
value: _securitySettingsViewModel.enableDuressPin,
onChanged: (bool value) {
@@ -129,6 +131,7 @@ class SecurityBackupPage extends BasePage {
}),
ListItemSelector(
keyValue: "security_backup_page_require_pin_after_button_key",
+ testId: "security_backup_page_require_pin_after_button_key",
label: S.current.require_pin_after,
options: [_securitySettingsViewModel.pinCodeRequiredDuration.toString()],
onTap: () async {
@@ -164,6 +167,7 @@ class SecurityBackupPage extends BasePage {
// }),
ListItemRegularRow(
keyValue: "security_backup_page_change_pin_button_key",
+ testId: "security_backup_page_change_pin_button_key",
label: S.current.settings_change_pin,
onTap: () {
_authService.authenticateAction(
@@ -178,6 +182,7 @@ class SecurityBackupPage extends BasePage {
}),
ListItemRegularRow(
keyValue: "security_backup_page_totp_2fa_button_key",
+ testId: "security_backup_page_totp_2fa_button_key",
label: _securitySettingsViewModel.useTotp2FA
? S.current.modify_2fa
: S.current.setup_2fa,
### lib/src/screens/settings/widgets/settings_cell_with_arrow.dart
@@ -6,7 +6,8 @@ class SettingsCellWithArrow extends StandardListRow {
required String title,
required Function(BuildContext context)? handler,
Key? key,
- }) : super(title: title, isSelected: false, onTap: handler, key: key);
+ String? testId,
+ }) : super(title: title, isSelected: false, onTap: handler, key: key, testId: testId);
@override
Widget buildTrailing(BuildContext context) => Image.asset(
### lib/src/screens/settings/widgets/settings_choices_cell.dart
@@ -1,14 +1,16 @@
+import "package:cake_wallet/utils/test_id.dart";
import 'package:cake_wallet/view_model/settings/choices_list_item.dart';
import 'package:flutter/material.dart';
class SettingsChoicesCell extends StatelessWidget {
const SettingsChoicesCell(this.choicesListItem,
- {this.useGenericColor = true, this.padding, Key? key})
+ {this.useGenericColor = true, this.padding, this.testId, Key? key})
: super(key: key);
final ChoicesListItem<dynamic> choicesListItem;
final bool useGenericColor;
final EdgeInsets? padding;
+ final String? testId;
@override
Widget build(BuildContext context) {
@@ -71,7 +73,7 @@ class SettingsChoicesCell extends StatelessWidget {
children: items.map((dynamic e) {
final isSelected = choicesListItem.selectedItem == e;
return Expanded(
- child: Semantics(button: true, selected: isSelected, inMutuallyExclusiveGroup: true, child: GestureDetector(
+ child: TestId.merge(testId == null ? null : "${testId}_${items.indexOf(e)}_key", child: Semantics(button: true, selected: isSelected, inMutuallyExclusiveGroup: true, child: GestureDetector(
onTap: () => choicesListItem.onItemSelected.call(e),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 8),
@@ -93,6 +95,7 @@ class SettingsChoicesCell extends StatelessWidget {
),
),
),
+ ),
);
}).toList(),
),
### lib/src/screens/settings/widgets/settings_switcher_cell.dart
@@ -1,5 +1,6 @@
import 'package:cake_wallet/src/widgets/standard_list.dart';
import 'package:cake_wallet/src/widgets/standard_switch.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:flutter/material.dart';
class SettingsSwitcherCell extends StandardListRow {
@@ -14,7 +15,8 @@ class SettingsSwitcherCell extends StandardListRow {
this.padding,
this.switchBackgroundColor,
this.height = 56,
- }) : super(title: title, isSelected: false, decoration: decoration, onTap: onTap, key: key);
+ String? testId,
+ }) : super(title: title, isSelected: false, decoration: decoration, onTap: onTap, key: key, testId: testId);
final bool value;
final Color? switchBackgroundColor;
@@ -38,7 +40,7 @@ class SettingsSwitcherCell extends StandardListRow {
Widget build(BuildContext context) {
final leading = buildLeading(context);
final trailing = buildTrailing(context);
- final row = Container(
+ final row = TestId.merge(testId ?? TestId.fromKey(key), child: Container(
height: height,
padding: padding ?? EdgeInsets.only(left: 12, right: 12),
child: TextButton(
@@ -67,6 +69,7 @@ class SettingsSwitcherCell extends StandardListRow {
],
),
),
+ ),
);
return onTap == null ? MergeSemantics(child: row) : row;
}
### lib/src/screens/wallet_list/edit_wallet_button_widget.dart
@@ -1,4 +1,5 @@
import 'package:cake_wallet/generated/i18n.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:flutter/material.dart';
class EditWalletButtonWidget extends StatelessWidget {
@@ -21,7 +22,7 @@ class EditWalletButtonWidget extends StatelessWidget {
width: width,
child: Row(
children: [
- TextButton(
+ TestId.merge(TestId.fromKey(key), child: TextButton(
onPressed: onTap,
style: TextButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.surface, shape: CircleBorder()),
@@ -31,7 +32,7 @@ class EditWalletButtonWidget extends StatelessWidget {
color: Theme.of(context).colorScheme.onSurfaceVariant,
semanticLabel: S.of(context).edit,
),
- ),
+ )),
if (isGroup) ...{
Icon(
isExpanded ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down,
### lib/src/screens/wallet_list/wallet_list_page.dart
@@ -195,7 +195,7 @@ class WalletListBodyState extends State<WalletListBody> {
shouldShowCurrentWalletPointer: true,
borderRadius: BorderRadius.all(Radius.circular(18)),
title: groupName,
- tileKey: ValueKey('group_wallets_expansion_tile_widget_$index'),
+ tileKey: ValueKey('wallet_list_group_${index}_key'),
leadingWidget: CakeImageWidget(
imageUrl: "assets/new-ui/navbar/wallets.svg",
width: 28,
@@ -232,7 +232,8 @@ class WalletListBodyState extends State<WalletListBody> {
return item.isCurrent
? SizedBox.shrink()
: EditWalletButtonWidget(
- key: ValueKey("wallet_list_edit_${item.name}_button_key"),
+ key: ValueKey(
+ "wallet_list_group_${index}_wallet_${group.wallets.indexWhere((info) => info.name == item.name)}_edit_button_key"),
width: 64,
onTap: () => Navigator.of(context).pushNamed(
Routes.walletEdit,
@@ -278,7 +279,7 @@ class WalletListBodyState extends State<WalletListBody> {
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.surface;
return GroupedWalletExpansionTile(
- tileKey: ValueKey('single_wallets_expansion_tile_widget_$index'),
+ tileKey: ValueKey('wallet_list_single_wallet_${index}_key'),
isCurrentlySelectedWallet: wallet.isCurrent,
leadingWidget: SizedBox(
width: wallet.isCurrent ? 56 : 40,
@@ -318,7 +319,7 @@ class WalletListBodyState extends State<WalletListBody> {
trailingWidget: wallet.isCurrent
? null
: EditWalletButtonWidget(
- key: ValueKey("wallet_list_edit_${wallet.name}_button_key"),
+ key: ValueKey("wallet_list_single_wallet_${index}_edit_button_key"),
width: 64,
onTap: () {
Navigator.of(context).pushNamed(
### lib/src/widgets/alert_close_button.dart
@@ -1,4 +1,5 @@
import 'package:cake_wallet/generated/i18n.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:flutter/material.dart';
class AlertCloseButton extends StatelessWidget {
@@ -7,6 +8,7 @@ class AlertCloseButton extends StatelessWidget {
this.bottom,
this.onTap,
this.isPositioned = true,
+ this.testId,
super.key,
});
@@ -15,13 +17,15 @@ class AlertCloseButton extends StatelessWidget {
final Image? image;
final double? bottom;
final bool isPositioned;
+ final String? testId;
@override
Widget build(BuildContext context) {
final button = SafeArea(
child: GestureDetector(
onTap: onTap ?? () => Navigator.of(context).pop(),
child: Semantics(
+ identifier: testId ?? TestId.fromKey(key),
label: S.of(context).close,
button: true,
enabled: true,
### lib/src/widgets/alert_with_one_action.dart
@@ -11,7 +11,7 @@ class AlertWithOneAction extends BaseAlertDialog {
this.headerTitleText,
this.headerImageProfileUrl,
this.buttonKey,
- Key? key,
+ super.key,
});
final String alertTitle;
### lib/src/widgets/alert_with_two_actions.dart
@@ -19,7 +19,7 @@ class AlertWithTwoActions extends BaseAlertDialog {
this.alertRightActionButtonKey,
this.alertLeftActionButtonKey,
this.alertDialogKey,
- });
+ }) : super(key: alertDialogKey);
final String alertTitle;
final String alertContent;
### lib/src/widgets/base_alert_dialog.dart
@@ -3,6 +3,7 @@ import 'dart:ui';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
import 'package:cake_wallet/src/widgets/section_divider.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:flutter/material.dart';
class AlertButtonStyle {
@@ -30,6 +31,8 @@ class AlertButtonStyle {
}
class BaseAlertDialog extends StatelessWidget {
+ BaseAlertDialog({super.key});
+
String? get headerText => '';
String? get titleText => '';
@@ -127,7 +130,8 @@ class BaseAlertDialog extends StatelessWidget {
children: <Widget>[
if (showLeftButton)
Expanded(
- child: GestureDetector(
+ child: TestId.merge(TestId.fromKey(leftActionButtonKey) ?? "alert_dialog_left_button_key",
+ child: Semantics(button: true, child: GestureDetector(
key: leftActionButtonKey,
onTap: actionLeft,
child: Container(
@@ -146,9 +150,14 @@ class BaseAlertDialog extends StatelessWidget {
fontWeight: leftButtonStyle.fontWeight)),
),
)),
+ ),
+ ),
),
Expanded(
- child: GestureDetector(
+ child: TestId.merge(
+ TestId.fromKey(rightActionButtonKey) ??
+ (showLeftButton ? "alert_dialog_right_button_key" : "alert_dialog_action_button_key"),
+ child: Semantics(button: true, child: GestureDetector(
key: rightActionButtonKey,
onTap: actionRight,
child: Container(
@@ -167,6 +176,8 @@ class BaseAlertDialog extends StatelessWidget {
fontWeight: rightButtonStyle.fontWeight)),
),
)),
+ ),
+ ),
),
],
);
@@ -190,7 +201,6 @@ class BaseAlertDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GestureDetector(
- key: key,
onTap: () => barrierDismissible ? Navigator.of(context).pop() : null,
child: Container(
color: Colors.transparent,
### lib/src/widgets/base_text_form_field.dart
@@ -1,3 +1,4 @@
+import "package:cake_wallet/utils/test_id.dart";
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -49,6 +50,7 @@ class BaseTextFormField extends StatelessWidget {
this.suffixText,
this.borderRadius = const BorderRadius.all(Radius.circular(18)),
this.onEditingComplete,
+ this.testId,
});
final TextEditingController? controller;
@@ -96,10 +98,11 @@ class BaseTextFormField extends StatelessWidget {
final bool hasUnderlineBorder;
final double borderWidth;
final BorderRadius borderRadius;
+ final String? testId;
@override
Widget build(BuildContext context) {
- return TextFormField(
+ return TestId.container(testId ?? TestId.fromKey(key), child: TextFormField(
enableIMEPersonalizedLearning: enableIMEPersonalizedLearning ?? true,
cursorColor: cursorColor,
cursorWidth: cursorWidth ?? 2.0,
@@ -197,6 +200,7 @@ class BaseTextFormField extends StatelessWidget {
: OutlineInputBorder(borderRadius: borderRadius, borderSide: BorderSide.none),
),
validator: validator,
+ ),
);
}
}
### lib/src/widgets/new_list_row/list_Item_style_wrapper.dart
@@ -1,3 +1,4 @@
+import "package:cake_wallet/utils/test_id.dart";
import 'package:flutter/material.dart';
class ListItemStyleWrapper extends StatelessWidget {
@@ -11,6 +12,8 @@ class ListItemStyleWrapper extends StatelessWidget {
this.iconPath,
this.contentPadding,
this.height,
+ this.testId,
+ this.mergeTestId = true,
});
final String? iconPath;
@@ -21,6 +24,8 @@ class ListItemStyleWrapper extends StatelessWidget {
final Color? backgroundColor;
final Widget Function(BuildContext context, TextStyle textStyle, TextStyle labelStyle) builder;
final EdgeInsets? contentPadding;
+ final String? testId;
+ final bool mergeTestId;
@override
Widget build(BuildContext context) {
@@ -49,7 +54,7 @@ class ListItemStyleWrapper extends StatelessWidget {
borderRadius: radius,
child: Column(
children: [
- Container(
+ (mergeTestId ? TestId.merge : TestId.container)(testId, child: Container(
height: height,
decoration: ShapeDecoration(
shape: RoundedSuperellipseBorder(
@@ -65,6 +70,7 @@ class ListItemStyleWrapper extends StatelessWidget {
padding: EdgeInsets.symmetric(
horizontal: 12, vertical: height == null ? 11 : 0),
child: builder(context, textStyle, labelStyle))))),
+ ),
if (iconPath != null && isLastInSection == false)
Container(
color: theme.colorScheme.surfaceContainer,
### lib/src/widgets/new_list_row/list_item_checkbox_widget.dart
@@ -18,6 +18,7 @@ class ListItemCheckboxWidget extends StatefulWidget {
this.subtitle,
this.iconPath,
this.showArrow = false,
+ this.testId,
});
final String keyValue;
@@ -31,6 +32,7 @@ class ListItemCheckboxWidget extends StatefulWidget {
final ValueChanged<bool> onChanged;
final bool isFirstInSection;
final bool isLastInSection;
+ final String? testId;
@override
State<ListItemCheckboxWidget> createState() => _ListItemCheckboxWidgetState();
@@ -40,6 +42,7 @@ class _ListItemCheckboxWidgetState extends State<ListItemCheckboxWidget> {
@override
Widget build(BuildContext context) {
return ListItemStyleWrapper(
+ testId: widget.testId,
iconPath: widget.iconPath,
onTap: widget.onTap ??
() {
### lib/src/widgets/new_list_row/list_item_dropdown_widget.dart
@@ -10,6 +10,7 @@ class ListItemDropdownWidget extends StatelessWidget {
required this.onTap,
this.isFirstInSection = false,
this.isLastInSection = false,
+ this.testId,
});
final String keyValue;
@@ -18,6 +19,7 @@ class ListItemDropdownWidget extends StatelessWidget {
final VoidCallback onTap;
final bool isFirstInSection;
final bool isLastInSection;
+ final String? testId;
BorderRadius get radius => BorderRadius.vertical(
top: Radius.circular(isFirstInSection ? 16 : 0),
@@ -27,6 +29,7 @@ class ListItemDropdownWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListItemStyleWrapper(
+ testId: testId,
isFirstInSection: isFirstInSection,
isLastInSection: isLastInSection,
onTap: onTap,
### lib/src/widgets/new_list_row/list_item_regular_row_widget.dart
@@ -31,7 +31,8 @@ class ListItemRegularRowWidget extends StatelessWidget {
this.leadingIconSize,
this.badgeIconSize,
this.iconColor,
- this.secondaryLabel});
+ this.secondaryLabel,
+ this.testId});
final String keyValue;
final String label;
@@ -57,6 +58,7 @@ class ListItemRegularRowWidget extends StatelessWidget {
final double? leadingIconSize;
final double? badgeIconSize;
final Color? iconColor;
+ final String? testId;
@override
Widget build(BuildContext context) {
@@ -72,6 +74,8 @@ class ListItemRegularRowWidget extends StatelessWidget {
duration: Duration(milliseconds: 150),
child: ListItemStyleWrapper(
key: ValueKey(copied),
+ testId: testId,
+ mergeTestId: trailingWidget == null && bottomWidget == null,
backgroundColor: copied ? Theme.of(context).colorScheme.surfaceContainerHigh : null,
onTap: onTap,
iconPath: iconPath,
### lib/src/widgets/new_list_row/list_item_selector_widget.dart
@@ -14,6 +14,7 @@ class ListItemSelectorWidget extends StatelessWidget {
this.isFirstInSection = false,
this.isLastInSection = false,
this.onTap,
+ this.testId,
this.optionImagePath,
});
@@ -26,11 +27,13 @@ class ListItemSelectorWidget extends StatelessWidget {
final bool isFirstInSection;
final bool isLastInSection;
final VoidCallback? onTap;
+ final String? testId;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return ListItemStyleWrapper(
+ testId: testId,
onTap: onTap,
isFirstInSection: isFirstInSection,
isLastInSection: isLastInSection,
### lib/src/widgets/new_list_row/list_item_text_field_widget.dart
@@ -1,4 +1,5 @@
import 'package:cake_wallet/src/widgets/new_list_row/list_Item_style_wrapper.dart';
+import 'package:cake_wallet/utils/test_id.dart';
import 'package:flutter/material.dart';
class ListItemTextFieldWidget extends StatefulWidget {
@@ -13,6 +14,7 @@ class ListItemTextFieldWidget extends StatefulWidget {
this.focusNode,
this.isFirstInSection = false,
this.isLastInSection = false,
+ this.testId,
});
final String keyValue;
@@ -24,6 +26,7 @@ class ListItemTextFieldWidget extends StatefulWidget {
final FocusNode? focusNode;
final bool isFirstInSection;
final bool isLastInSection;
+ final String? testId;
@override
State<ListItemTextFieldWidget> createState() => _ListItemTextFieldWidgetState();
@@ -40,7 +43,7 @@ class _ListItemTextFieldWidgetState extends State<ListItemTextFieldWidget> {
return Row(
children: [
Expanded(
- child: TextFormField(
+ child: TestId.container(widget.testId, child: TextFormField(
controller: widget.controller,
validator: widget.validator,
onChanged: widget.onChanged,
@@ -57,7 +60,7 @@ class _ListItemTextFieldWidgetState extends State<ListItemTextFieldWidget> {
isDense: true,
contentPadding: const EdgeInsets.symmetric(vertical: 7),
),
- ),
+ )),
),
],
);
### lib/src/widgets/new_list_row/list_item_toggle_widget.dart
@@ -16,6 +16,7 @@ class ListItemToggleWidget extends StatefulWidget {
this.leadingEndWidget,
this.isFirstInSection = false,
this.isLastInSection = false,
+ this.testId,
});
final String keyValue;
@@ -28,6 +29,7 @@ class ListItemToggleWidget extends StatefulWidget {
final Widget? leadingEndWidget;
final bool isFirstInSection;
final bool isLastInSection;
+ final String? testId;
@override
State<ListItemToggleWidget> createState() => _ListItemToggleWidgetState();
@@ -42,6 +44,7 @@ class _ListItemToggleWidgetState extends State<ListItemToggleWidget> {
@override
Widget build(BuildContext context) {
return MergeSemantics(child: ListItemStyleWrapper(
+ testId: widget.testId,
isFirstInSection: widget.isFirstInSection,
isLastInSection: widget.isLastInSection,
iconPath: widget.iconPath,
### lib/src/widgets/new_list_row/new_list_section.dart
@@ -76,6 +76,7 @@ class NewListSections extends StatelessWidget {
'Please provide a TextEditingController for this key.');
return ListItemTextFieldWidget(
+ testId: item.testId,
keyValue: item.keyValue,
label: item.label,
controller: controllers[item.keyValue]!,
@@ -90,6 +91,7 @@ class NewListSections extends StatelessWidget {
if (item is ListItemRegularRow) {
return ListItemRegularRowWidget(
+ testId: item.testId,
key: ValueKey(item.keyValue),
keyValue: item.keyValue,
label: item.label,
@@ -120,6 +122,7 @@ class NewListSections extends StatelessWidget {
if (item is ListItemToggle) {
return ListItemToggleWidget(
+ testId: item.testId,
key: ValueKey(item.keyValue),
keyValue: item.keyValue,
label: item.label,
@@ -136,6 +139,7 @@ class NewListSections extends StatelessWidget {
if (item is ListItemCheckbox) {
return ListItemCheckboxWidget(
+ testId: item.testId,
key: ValueKey(item.keyValue),
keyValue: item.keyValue,
label: item.label,
@@ -153,6 +157,7 @@ class NewListSections extends StatelessWidget {
if (item is ListItemDropdown) {
return ListItemDropdownWidget(
+ testId: item.testId,
key: ValueKey(item.keyValue),
keyValue: item.keyValue,
label: item.label,
@@ -165,6 +170,7 @@ class NewListSections extends StatelessWidget {
if (item is ListItemSelector) {
return ListItemSelectorWidget(
+ testId: item.testId,
key: ValueKey(item.keyValue),
keyValue: item.keyValue,
label: item.label,
### lib/src/widgets/option_tile.dart
@@ -1,4 +1,5 @@
import 'package:cake_wallet/themes/core/theme_extension.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:flutter/material.dart';
class OptionTile extends StatelessWidget {
@@ -9,6 +10,7 @@ class OptionTile extends StatelessWidget {
required this.title,
required this.description,
this.tag,
+ this.testId,
super.key,
}) : assert(image != null || icon != null);
@@ -18,10 +20,11 @@ class OptionTile extends StatelessWidget {
final String title;
final String description;
final String? tag;
+ final String? testId;
@override
Widget build(BuildContext context) {
- return Container(
+ return TestId.merge(testId ?? TestId.fromKey(key), child: Container(
width: double.infinity,
alignment: Alignment.center,
decoration: ShapeDecoration(
@@ -95,6 +98,7 @@ class OptionTile extends StatelessWidget {
],
),
),
+ ),
);
}
}
### lib/src/widgets/picker.dart
@@ -10,6 +10,7 @@ import 'package:cw_core/crypto_currency.dart';
import 'package:flutter/material.dart';
import 'package:cw_core/currency.dart';
import 'package:cake_wallet/src/widgets/picker_wrapper_widget.dart';
+import "package:cake_wallet/utils/test_id.dart";
class Picker<Item> extends StatefulWidget {
Picker({
@@ -304,13 +305,11 @@ class _PickerState<Item> extends State<Picker<Item>> {
);
}
- String _getItemName(Item item) => item is Currency ? item.name : item.toString();
-
Widget buildItem(int index) {
final item = widget.headerEnabled ? filteredItems[index] : items[index];
final tag = item is Currency ? item.tag : null;
- final itemName = _getItemName(item);
+ final itemIndex = items.indexOf(item);
final icon = _getItemIcon(item);
@@ -338,7 +337,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
children: [
Flexible(
child: Text(
- key: ValueKey('picker_items_index_${itemName}_text_key'),
+ key: ValueKey('picker_items_index_${itemIndex}_text_key'),
widget.displayItem?.call(item) ??
(item == CryptoCurrency.btcln ? "BTC (LN)" : item.toString()),
softWrap: true,
@@ -379,8 +378,8 @@ class _PickerState<Item> extends State<Picker<Item>> {
],
);
- return Semantics(button: true, selected: false, inMutuallyExclusiveGroup: true, child: GestureDetector(
- key: ValueKey('picker_items_index_${itemName}_button_key'),
+ return TestId.merge("picker_items_index_${itemIndex}_button_key", child: Semantics(button: true, selected: false, inMutuallyExclusiveGroup: true, child: GestureDetector(
+ key: ValueKey('picker_items_index_${itemIndex}_button_key'),
onTap: () {
if (widget.closeOnItemSelected) Navigator.of(context).pop();
onItemSelected(item!);
@@ -399,14 +398,14 @@ class _PickerState<Item> extends State<Picker<Item>> {
)
: itemContent,
),
- ));
+ )));
}
Widget buildSelectedItem(int index) {
final item = items[index];
final tag = item is Currency ? item.tag : null;
- final itemName = _getItemName(item);
+ final itemIndex = items.indexOf(item);
final icon = _getItemIcon(item);
final image = images.isNotEmpty ? images[index] : icon;
@@ -434,7 +433,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
children: [
Flexible(
child: Text(
- key: ValueKey('picker_items_index_${itemName}_selected_item_text_key'),
+ key: ValueKey('picker_items_index_${itemIndex}_selected_item_text_key'),
widget.displayItem?.call(item) ?? item.toString(),
softWrap: true,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
@@ -475,8 +474,8 @@ class _PickerState<Item> extends State<Picker<Item>> {
],
);
- return Semantics(button: true, selected: true, inMutuallyExclusiveGroup: true, child: GestureDetector(
- key: ValueKey('picker_items_index_${itemName}_selected_item_button_key'),
+ return TestId.merge("picker_items_index_${itemIndex}_selected_item_button_key", child: Semantics(button: true, selected: true, inMutuallyExclusiveGroup: true, child: GestureDetector(
+ key: ValueKey('picker_items_index_${itemIndex}_selected_item_button_key'),
onTap: () {
if (widget.closeOnItemSelected) Navigator.of(context).pop();
},
@@ -494,7 +493,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
)
: itemContent,
),
- ));
+ )));
}
Widget? _getItemIcon(Item item) {
### lib/src/widgets/primary_button.dart
@@ -1,5 +1,6 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -15,6 +16,7 @@ class PrimaryButton extends StatelessWidget {
this.borderColor = Colors.black,
this.onDisabledPressed,
this.borderRadius,
+ this.testId,
super.key,
});
@@ -27,10 +29,11 @@ class PrimaryButton extends StatelessWidget {
final bool isDisabled;
final bool isDottedBorder;
final BorderRadius? borderRadius;
+ final String? testId;
@override
Widget build(BuildContext context) {
- final content = ConstrainedBox(
+ final content = TestId.merge(testId ?? TestId.fromKey(key), child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtilBase.kDesktopMaxWidthConstraint),
child: SizedBox(
width: double.infinity,
@@ -59,6 +62,7 @@ class PrimaryButton extends StatelessWidget {
),
),
),
+ ),
);
return isDottedBorder
@@ -81,6 +85,7 @@ class LoadingPrimaryButton extends StatelessWidget {
required this.textColor,
this.isDisabled = false,
this.isLoading = false,
+ this.testId,
super.key,
});
@@ -90,6 +95,7 @@ class LoadingPrimaryButton extends StatelessWidget {
final bool isLoading;
final bool isDisabled;
final String text;
+ final String? testId;
@override
Widget build(BuildContext context) {
@@ -98,6 +104,7 @@ class LoadingPrimaryButton extends StatelessWidget {
// The spinner replaces the label while loading, so the name is kept on a single
// semantics node that also reports the loading and disabled states.
return Semantics(
+ identifier: testId ?? TestId.fromKey(key),
button: true,
enabled: isEnabled,
label: text,
@@ -230,6 +237,7 @@ class PrimaryImageButton extends StatelessWidget {
required this.color,
required this.textColor,
this.borderColor = Colors.transparent,
+ this.testId,
super.key});
final VoidCallback onPressed;
@@ -238,10 +246,11 @@ class PrimaryImageButton extends StatelessWidget {
final Color textColor;
final Color borderColor;
final String text;
+ final String? testId;
@override
Widget build(BuildContext context) {
- return ConstrainedBox(
+ return TestId.merge(testId ?? TestId.fromKey(key), child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtilBase.kDesktopMaxWidthConstraint),
child: SizedBox(
width: double.infinity,
@@ -274,6 +283,7 @@ class PrimaryImageButton extends StatelessWidget {
),
),
),
+ ),
);
}
}
### lib/src/widgets/standard_list.dart
@@ -1,5 +1,6 @@
import 'package:cake_wallet/src/widgets/standard_list_card.dart';
import 'package:cake_wallet/src/widgets/standard_list_status_row.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:flutter/material.dart';
class StandardListRow extends StatelessWidget {
@@ -9,6 +10,7 @@ class StandardListRow extends StatelessWidget {
this.subtitle,
this.onTap,
this.decoration,
+ this.testId,
super.key,
});
@@ -17,12 +19,13 @@ class StandardListRow extends StatelessWidget {
final bool isSelected;
final void Function(BuildContext context)? onTap;
final Decoration? decoration;
+ final String? testId;
@override
Widget build(BuildContext context) {
final leading = buildLeading(context);
final trailing = buildTrailing(context);
- return Container(
+ return TestId.merge(testId ?? TestId.fromKey(key), child: Container(
height: 56,
padding: EdgeInsets.only(left: 12, right: 12),
child: TextButton(
@@ -44,6 +47,7 @@ class StandardListRow extends StatelessWidget {
],
),
),
+ ),
);
}
### lib/src/widgets/standard_slide_button_widget.dart
@@ -1,6 +1,7 @@
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/themes/core/theme_extension.dart';
import 'package:flutter/material.dart';
+import "package:cake_wallet/utils/test_id.dart";
class StandardSlideButton extends StatefulWidget {
const StandardSlideButton({
@@ -79,7 +80,7 @@ class StandardSlideButtonState extends State<StandardSlideButton> {
),
Positioned(
left: sideMargin + _dragPosition,
- child: GestureDetector(
+ child: TestId.merge("standard_slide_button_widget_slider_key", child: GestureDetector(
key: ValueKey('standard_slide_button_widget_slider_key'),
onHorizontalDragUpdate: widget.isDisabled
? null
@@ -118,7 +119,7 @@ class StandardSlideButtonState extends State<StandardSlideButton> {
: Theme.of(context).colorScheme.onSurface,
),
),
- ),
+ )),
)
],
),
### lib/src/widgets/standard_switch.dart
@@ -1,16 +1,20 @@
import 'package:cake_wallet/themes/core/theme_extension.dart';
+import "package:cake_wallet/utils/test_id.dart";
import 'package:flutter/material.dart';
class StandardSwitch extends StatefulWidget {
const StandardSwitch({
required this.value,
required this.onTapped,
this.backgroundColor,
+ this.testId,
+ super.key,
});
final bool value;
final Color? backgroundColor;
final VoidCallback onTapped;
+ final String? testId;
@override
StandardSwitchState createState() => StandardSwitchState();
}
@@ -19,6 +23,7 @@ class StandardSwitchState extends State<StandardSwitch> {
@override
Widget build(BuildContext context) {
return Semantics(
+ identifier: widget.testId ?? TestId.fromKey(widget.key),
toggled: widget.value,
child: GestureDetector(
onTap: widget.onTapped,
### lib/store/anonpay/anonpay_transactions_store.dart
@@ -26,11 +26,12 @@ abstract class AnonpayTransactionsStoreBase with Store {
@action
Future<void> updateTransactionList() async {
+ var index = 0;
transactions = anonpayInvoiceInfoSource.values
.map(
(transaction) => AnonpayTransactionListItem(
transaction: transaction,
- key: ValueKey('anonpay_invoice_transaction_list_item_${transaction.invoiceId}_key'),
+ key: ValueKey('anonpay_invoice_transaction_list_item_${index++}_key'),
),
)
.toList();
### lib/store/dashboard/orders_store.dart
@@ -38,10 +38,10 @@ abstract class OrdersStoreBase with Store {
@action
Future updateOrderList() async => orders = ordersSource.values
- .map((order) => OrderListItem(
- order: order,
+ .indexed.map((entry) => OrderListItem(
+ order: entry.$2,
settingsStore: settingsStore,
- key: ValueKey('order_list_item_${order.id}_key'),
+ key: ValueKey('order_list_item_${entry.$1}_key'),
))
.toList();
}
### lib/store/dashboard/payjoin_transactions_store.dart
@@ -36,7 +36,7 @@ abstract class PayjoinTransactionsStoreBase with Store {
updatedTransactions.add(PayjoinTransactionListItem(
sessionId: key as String,
session: session,
- key: ValueKey('payjoin_transaction_list_item_${key}_key'),
+ key: ValueKey('payjoin_transaction_list_item_${updatedTransactions.length}_key'),
));
}
});
### lib/store/dashboard/trades_store.dart
@@ -23,12 +23,13 @@ abstract class TradesStoreBase with Store {
Future<void> updateTradeList() async {
try {
final allTrades = await Trade.getAll();
+ var index = 0;
runInAction(() {
trades = allTrades
.map((trade) => TradeListItem(
trade: trade,
appStore: appStore,
- key: ValueKey('trade_list_item_${trade.id}_key'),
+ key: ValueKey('trade_list_item_${index++}_key'),
))
.toList();
});
### lib/utils/test_id.dart
@@ -0,0 +1,22 @@
+import "package:flutter/widgets.dart";
+
+abstract final class TestId {
+ static final RegExp _testKeyPattern = RegExp(r"^[a-z0-9_]+_key$");
+
+ static Widget merge(String? id, {required Widget child, String? label}) => id == null
+ ? child
+ : MergeSemantics(child: Semantics(identifier: id, label: label, child: child));
+
+ static Widget container(String? id, {required Widget child, bool explicitChildNodes = false}) =>
+ id == null
+ ? child
+ : Semantics(
+ container: true,
+ explicitChildNodes: explicitChildNodes,
+ identifier: id,
+ child: child,
+ );
+
+ static String? fromKey(Key? key) =>
+ key is ValueKey<String> && _testKeyPattern.hasMatch(key.value) ? key.value : null;
+}
### lib/view_model/dashboard/dashboard_view_model.dart
@@ -152,7 +152,7 @@ abstract class DashboardViewModelBase with Store {
transaction: transaction,
balanceViewModel: balanceViewModel,
appStore: appStore,
- key: ValueKey('monero_transaction_history_item_${transaction.id}_key'),
+ key: ValueKey('monero_transaction_history_item_${_historyKeyIndex++}_key'),
),
),
);
@@ -182,7 +182,7 @@ abstract class DashboardViewModelBase with Store {
transaction: transaction,
balanceViewModel: balanceViewModel,
appStore: appStore,
- key: ValueKey('wownero_transaction_history_item_${transaction.id}_key'),
+ key: ValueKey('wownero_transaction_history_item_${_historyKeyIndex++}_key'),
),
),
);
@@ -367,6 +367,7 @@ abstract class DashboardViewModelBase with Store {
}
transactions.clear();
+ _historyKeyIndex = 0;
final filteredTransactions = wallet.type == WalletType.bitcoin
? bitcoin!.getCurrentAccountBitcoinTransactions(wallet)
@@ -380,7 +381,7 @@ abstract class DashboardViewModelBase with Store {
transaction: transaction,
balanceViewModel: balanceViewModel,
appStore: appStore,
- key: ValueKey('${wallet.type.name}_transaction_history_item_${transaction.id}_key'),
+ key: ValueKey('${wallet.type.name}_transaction_history_item_${_historyKeyIndex++}_key'),
),
),
);
@@ -574,7 +575,7 @@ abstract class DashboardViewModelBase with Store {
transaction: tx,
balanceViewModel: balanceViewModel,
appStore: appStore,
- key: ValueKey('${wallet.type.name}_transaction_history_item_${tx.id}_key'),
+ key: ValueKey('${wallet.type.name}_transaction_history_item_${_historyKeyIndex++}_key'),
))
.toList();
@@ -795,6 +796,8 @@ abstract class DashboardViewModelBase with Store {
return formattedItemsList(_items);
}
+ int _historyKeyIndex = 0;
+
static const shortHistoryLength = 3;
@computed
@@ -1527,6 +1530,7 @@ abstract class DashboardViewModelBase with Store {
@action
void _onMoneroTransactionsUpdate(WalletBase wallet) {
transactions.clear();
+ _historyKeyIndex = 0;
if (wallet.type == WalletType.monero) {
final _accountTransactions = monero!
.getTransactionHistory(wallet)
@@ -1542,7 +1546,7 @@ abstract class DashboardViewModelBase with Store {
transaction: transaction,
balanceViewModel: balanceViewModel,
appStore: appStore,
- key: ValueKey('monero_transaction_history_item_${transaction.id}_key'),
+ key: ValueKey('monero_transaction_history_item_${_historyKeyIndex++}_key'),
),
),
);
@@ -1562,7 +1566,7 @@ abstract class DashboardViewModelBase with Store {
transaction: transaction,
balanceViewModel: balanceViewModel,
appStore: appStore,
- key: ValueKey('wownero_transaction_history_item_${transaction.id}_key'),
+ key: ValueKey('wownero_transaction_history_item_${_historyKeyIndex++}_key'),
),
),
);
### lib/view_model/transaction_details_view_model.dart
@@ -188,7 +188,7 @@ class TxDetailRowDefinition {
applicable: (vm) => vm.wallet.type == WalletType.monero,
),
TxDetailRowDefinition(
- keyString: "standard_list_item_lightning_preimage",
+ keyString: "standard_list_item_lightning_preimage_key",
title: S.current.transaction_preimage,
valueGetter: (vm) => vm.transactionInfo.additionalInfo["preimage"] as String? ?? "",
applicable: (vm) =>
@@ -277,7 +277,7 @@ abstract class TransactionDetailsViewModelBase with Store {
AddressListItem(
title: S.current.transaction_details_recipient_address,
value: recipientAddressForDisplay,
- key: ValueKey("standard_list_item_${recipientAddressForDisplay}_key"),
+ key: ValueKey("standard_list_item_transaction_details_saved_recipient_address_key"),
),
);
}
### lib/view_model/wallet_keys_view_model.dart
@@ -24,7 +24,6 @@ class WalletKeysViewModel = WalletKeysViewModelBase with _$WalletKeysViewModel;
abstract class WalletKeysViewModelBase with Store {
WalletKeysViewModelBase(this._appStore)
: _wallet = _appStore.wallet!,
- _walletName = _appStore.wallet!.type.name,
_restoreHeight = _appStore.wallet!.walletInfo.restoreHeight,
_restoreHeightByTransactions = 0,
items = ObservableList<StandartListItem>(),
@@ -94,7 +93,6 @@ abstract class WalletKeysViewModelBase with Store {
String get title => _title;
final WalletBase _wallet;
- final String _walletName;
final AppStore _appStore;
final int _restoreHeight;
@@ -178,7 +176,7 @@ abstract class WalletKeysViewModelBase with Store {
items.addAll([
if (_wallet.privateKey != null)
StandartListItem(
- key: ValueKey('${_walletName}_wallet_private_key_item_key'),
+ key: ValueKey('${_wallet.type.name}_wallet_private_key_item_key'),
title: S.current.private_key,
value: _wallet.privateKey!,
),
@@ -190,13 +188,13 @@ abstract class WalletKeysViewModelBase with Store {
items.addAll([
if (_wallet.hexSeed != null)
StandartListItem(
- key: ValueKey('${_walletName}_wallet_hex_seed_key'),
+ key: ValueKey('${_wallet.type.name}_wallet_hex_seed_key'),
title: S.current.seed_hex_form,
value: _wallet.hexSeed!,
),
if (_wallet.privateKey != null)
StandartListItem(
- key: ValueKey('${_walletName}_wallet_private_key_item_key'),
+ key: ValueKey('${_wallet.type.name}_wallet_private_key_item_key'),
title: S.current.private_key,
value: _wallet.privateKey!,
),
@@ -242,42 +240,42 @@ abstract class WalletKeysViewModelBase with Store {
keysList.addAll([
if ((keys['primaryAddress'] ?? '').isNotEmpty)
StandartListItem(
- key: ValueKey('${_walletName}_wallet_primary_address_item_key'),
+ key: ValueKey('${_wallet.type.name}_wallet_primary_address_item_key'),
title: S.current.primary_address,
value: keys['primaryAddress']!),
if ((keys['publicSpendKey'] ?? '').isNotEmpty)
StandartListItem(
- key: ValueKey('${_walletName}_wallet_public_spend_key_item_key'),
+ key: ValueKey('${_wallet.type.name}_wallet_public_spend_key_item_key'),
title: S.current.spend_key_public,
value: keys['publicSpendKey']!,
),
if ((keys['privateSpendKey'] ?? '').isNotEmpty)
StandartListItem(
- key: ValueKey('${_walletName}_wallet_private_spend_key_item_key'),
+ key: ValueKey('${_wallet.type.name}_wallet_private_spend_key_item_key'),
title: S.current.spend_key_private,
value: keys['privateSpendKey']!,
),
if ((keys['publicViewKey'] ?? '').isNotEmpty)
StandartListItem(
- key: ValueKey('${_walletName}_wallet_public_view_key_item_key'),
+ key: ValueKey('${_wallet.type.name}_wallet_public_view_key_item_key'),
title: S.current.view_key_public,
value: keys['publicViewKey']!,
),
if ((keys['privateViewKey'] ?? '').isNotEmpty)
StandartListItem(
- key: ValueKey('${_walletName}_wallet_private_view_key_item_key'),
+ key: ValueKey('${_wallet.type.name}_wallet_private_view_key_item_key'),
title: S.current.view_key_private,
value: keys['privateViewKey']!,
),
if ((keys['tsk'] ?? '').isNotEmpty)
StandartListItem(
- key: ValueKey('${_walletName}_wallet_transparent_secret_key_item_key'),
+ key: ValueKey('${_wallet.type.name}_wallet_transparent_secret_key_item_key'),
title: S.current.transparent_secret_key,
value: keys['tsk']!,
),
if ((keys['uvk'] ?? '').isNotEmpty)
StandartListItem(
- key: ValueKey('${_walletName}_wallet_unified_view_key_item_key'),
+ key: ValueKey('${_wallet.type.name}_wallet_unified_view_key_item_key'),
title: S.current.unified_view_key,
value: keys['uvk']!,
),
### test/new-ui/widgets/newui_identifiers_test.dart
@@ -0,0 +1,152 @@
+import "package:cake_wallet/core/auth_service.dart";
+import "package:cake_wallet/generated/i18n.dart";
+import "package:cake_wallet/locales/locale.dart";
+import "package:cake_wallet/new-ui/pages/settings_page.dart";
+import "package:cake_wallet/new-ui/widgets/confirm_swiper.dart";
+import "package:cake_wallet/new-ui/widgets/receive_page/receive_bottom_buttons.dart";
+import "package:cake_wallet/new-ui/widgets/send_page/send_amount_input.dart";
+import "package:cake_wallet/view_model/dashboard/dashboard_view_model.dart";
+import "package:cw_core/balance.dart";
+import "package:cw_core/transaction_history.dart";
+import "package:cw_core/transaction_info.dart";
+import "package:cw_core/wallet_base.dart";
+import "package:cw_core/wallet_type.dart";
+import "package:flutter/material.dart";
+import "package:flutter/services.dart";
+import "package:flutter_test/flutter_test.dart";
+import "package:mocktail/mocktail.dart";
+
+import "../../utils/semantics_helpers.dart";
+
+class _MockDashboardViewModel extends Mock implements DashboardViewModel {}
+
+class _MockAuthService extends Mock implements AuthService {}
+
+class _MockWallet extends Mock
+ implements WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> {}
+
+void main() {
+ setUpAll(() => S.delegate.load(const Locale("en")));
+
+ Widget wrap(Widget child) => MaterialApp(
+ localizationsDelegates: localizationDelegates,
+ supportedLocales: S.delegate.supportedLocales,
+ home: Scaffold(body: child),
+ );
+
+ testWidgets("settings rows and top bar carry settings_page ids", (tester) async {
+ final handle = tester.ensureSemantics();
+ final dashboardViewModel = _MockDashboardViewModel();
+ final wallet = _MockWallet();
+ when(() => dashboardViewModel.wallet).thenReturn(wallet);
+ when(() => dashboardViewModel.hasLightning).thenReturn(false);
+ when(() => dashboardViewModel.hasWalletConnect).thenReturn(false);
+ when(() => wallet.type).thenReturn(WalletType.monero);
+ when(() => wallet.hardwareWalletType).thenReturn(null);
+ when(() => wallet.hasAccountsSupport).thenReturn(true);
+ when(() => wallet.name).thenReturn("Main");
+
+ await tester.pumpWidget(
+ wrap(SettingsMainPage(dashboardViewModel: dashboardViewModel, authService: _MockAuthService())),
+ );
+ await tester.pumpAndSettle();
+
+ for (final (id, label) in [
+ ("settings_page_privacy_row_key", S.current.privacy),
+ ("settings_page_display_settings_row_key", S.current.display),
+ ("settings_page_security_backup_row_key", S.current.security),
+ ("settings_page_about_row_key", S.current.about),
+ ]) {
+ expect(
+ platformNodesWithId(tester, id).single,
+ isSemantics(label: label, hasTapAction: true),
+ reason: id,
+ );
+ }
+ expect(
+ platformNodesWithId(tester, "settings_page_wallet_settings_row_key").single,
+ isSemantics(hasTapAction: true),
+ );
+ expect(platformNodesWithId(tester, "settings_page_top_bar_title_key"), hasLength(1));
+ expect(platformNodesWithId(tester, "settings_page_top_bar_leading_key"), hasLength(1));
+ expect(find.bySemanticsIdentifier(RegExp("lightning_username")), findsNothing);
+ handle.dispose();
+ });
+
+ testWidgets("send amount field keeps its own text-field node with the id", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ NewSendAmountInput(
+ key: const ValueKey("send_page_amount_input_key"),
+ currency: "XMR",
+ maxDecimals: 12,
+ hasPicker: false,
+ onPickerClicked: () {},
+ currencyIconPath: "",
+ amountController: TextEditingController(),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+
+ expect(
+ platformNodesWithId(tester, "send_page_amount_input_key").single,
+ isSemantics(isTextField: true),
+ );
+ handle.dispose();
+ });
+
+ testWidgets("confirm swiper exposes its key as the identifier", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ ConfirmSwiper(
+ key: const ValueKey("send_page_confirm_swiper_key"),
+ onConfirmed: () {},
+ swiperText: "Swipe to send",
+ ),
+ ),
+ );
+ await tester.pump();
+
+ expect(
+ platformNodesWithId(tester, "send_page_confirm_swiper_key").single,
+ isSemantics(label: "Swipe to send"),
+ );
+ handle.dispose();
+ });
+
+ testWidgets("receive bottom buttons carry receive_page ids", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ ReceiveBottomButtons(
+ largeQrMode: false,
+ onCopyButtonPressed: () {},
+ onAccountsButtonPressed: () {},
+ onAmountButtonPressed: () {},
+ onLabelButtonPressed: () {},
+ showLabelButton: true,
+ showAccountsButton: true,
+ copyData: const ClipboardData(text: "address"),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+
+ for (final (id, label) in [
+ ("receive_page_copy_button_key", S.current.copy),
+ ("receive_page_set_amount_button_key", S.current.set_amount),
+ ("receive_page_label_button_key", S.current.label),
+ ("receive_page_addresses_button_key", S.current.addresses),
+ ]) {
+ expect(
+ platformNodesWithId(tester, id).single,
+ isSemantics(label: label, isButton: true, hasTapAction: true),
+ reason: id,
+ );
+ }
+ handle.dispose();
+ });
+}
### test/new-ui/widgets/testid_plumbing_test.dart
@@ -0,0 +1,483 @@
+import "package:cake_wallet/di.dart";
+import "package:cake_wallet/entities/new_ui_entities/list_item/list_item_regular_row.dart";
+import "package:cake_wallet/entities/new_ui_entities/list_item/list_item_toggle.dart";
+import "package:cake_wallet/generated/i18n.dart";
+import "package:cake_wallet/locales/locale.dart";
+import "package:cake_wallet/new-ui/widgets/line_tab_switcher.dart";
+import "package:cake_wallet/new-ui/widgets/modern_button.dart";
+import "package:cake_wallet/new-ui/widgets/new_primary_button.dart";
+import "package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart";
+import "package:cake_wallet/new-ui/widgets/stacked_buttons.dart";
+import "package:cake_wallet/src/screens/settings/widgets/settings_cell_with_arrow.dart";
+import "package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart";
+import "package:cake_wallet/src/widgets/alert_with_one_action.dart";
+import "package:cake_wallet/src/widgets/alert_with_two_actions.dart";
+import "package:cake_wallet/src/widgets/base_text_form_field.dart";
+import "package:cake_wallet/src/widgets/new_list_row/list_item_toggle_widget.dart";
+import "package:cake_wallet/src/widgets/new_list_row/new_list_section.dart";
+import "package:cake_wallet/src/widgets/primary_button.dart";
+import "package:cake_wallet/themes/core/theme_store.dart";
+import "package:flutter/material.dart";
+import "package:flutter/semantics.dart";
+import "package:flutter_test/flutter_test.dart";
+
+import "../../utils/semantics_helpers.dart";
+
+void main() {
+ late bool registeredThemeStore;
+
+ setUpAll(() {
+ registeredThemeStore = !getIt.isRegistered<ThemeStore>();
+ if (registeredThemeStore) {
+ getIt.registerSingleton(ThemeStore());
+ }
+ });
+
+ tearDownAll(() async {
+ if (registeredThemeStore) {
+ await getIt.unregister<ThemeStore>();
+ }
+ });
+
+ Widget wrap(Widget child) => MaterialApp(
+ localizationsDelegates: localizationDelegates,
+ supportedLocales: S.delegate.supportedLocales,
+ home: Scaffold(body: Center(child: child)),
+ );
+
+ Future<SemanticsNode> pumpAndFindOne(WidgetTester tester, Widget widget, String id) async {
+ await tester.pumpWidget(wrap(widget));
+ await tester.pumpAndSettle();
+ final nodes = platformNodesWithId(tester, id);
+ expect(nodes, hasLength(1), reason: "exactly one platform node should carry '$id'");
+ expect(find.bySemanticsIdentifier(id), findsOneWidget);
+ return nodes.single;
+ }
+
+ group("ModernButton", () {
+ testWidgets("a test key becomes the identifier of its one button node", (tester) async {
+ final handle = tester.ensureSemantics();
+ final node = await pumpAndFindOne(
+ tester,
+ ModernButton(
+ key: const ValueKey("x_button_key"),
+ size: 40,
+ icon: const Icon(Icons.close),
+ onPressed: () {},
+ semanticLabel: "Close",
+ ),
+ "x_button_key",
+ );
+
+ expect(
+ node,
+ isSemantics(identifier: "x_button_key", label: "Close", isButton: true, hasTapAction: true),
+ );
+ expect(find.byKey(const ValueKey("x_button_key")), findsOneWidget);
+ handle.dispose();
+ });
+
+ testWidgets("an explicit testId wins over the key", (tester) async {
+ final handle = tester.ensureSemantics();
+ await pumpAndFindOne(
+ tester,
+ ModernButton(
+ key: const ValueKey("x_button_key"),
+ testId: "explicit_button_key",
+ size: 40,
+ icon: const Icon(Icons.close),
+ onPressed: () {},
+ label: "Close",
+ ),
+ "explicit_button_key",
+ );
+ expect(find.bySemanticsIdentifier("x_button_key"), findsNothing);
+ handle.dispose();
+ });
+
+ testWidgets("a non-test key does not become an identifier", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ ModernButton(
+ key: const ValueKey("Satoshi's wallet"),
+ size: 40,
+ icon: const Icon(Icons.close),
+ onPressed: () {},
+ label: "Close",
+ ),
+ ),
+ );
+ expect(find.bySemanticsIdentifier(RegExp(".")), findsNothing);
+ handle.dispose();
+ });
+ });
+
+ group("ModalTopBar", () {
+ testWidgets("title is its own header node and chrome buttons get stable ids", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ ModalTopBar(
+ testId: "receive_amount_modal",
+ title: "Set amount",
+ leadingIcon: const Icon(Icons.arrow_back),
+ leadingSemanticLabel: "Back",
+ trailingIcon: const Icon(Icons.close),
+ trailingSemanticLabel: "Close",
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+
+ expect(
+ platformNodesWithId(tester, "receive_amount_modal_title_key").single,
+ isSemantics(label: "Set amount", isHeader: true),
+ );
+ expect(
+ platformNodesWithId(tester, "receive_amount_modal_leading_key").single,
+ isSemantics(label: "Back", isButton: true),
+ );
+ expect(
+ platformNodesWithId(tester, "receive_amount_modal_trailing_key").single,
+ isSemantics(label: "Close", isButton: true),
+ );
+ handle.dispose();
+ });
+
+ testWidgets("falls back to modal_top_bar ids", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(wrap(ModalTopBar(title: "Receive")));
+ await tester.pumpAndSettle();
+ expect(platformNodesWithId(tester, "modal_top_bar_title_key"), hasLength(1));
+ handle.dispose();
+ });
+ });
+
+ group("primary buttons", () {
+ testWidgets("NewPrimaryButton", (tester) async {
+ final handle = tester.ensureSemantics();
+ final node = await pumpAndFindOne(
+ tester,
+ NewPrimaryButton(
+ key: const ValueKey("new_wallet_continue_button_key"),
+ onPressed: () {},
+ text: "Continue",
+ color: Colors.blue,
+ textColor: Colors.white,
+ ),
+ "new_wallet_continue_button_key",
+ );
+ expect(node, isSemantics(label: "Continue", isButton: true, hasTapAction: true));
+ handle.dispose();
+ });
+
+ testWidgets("PrimaryButton and LoadingPrimaryButton", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ PrimaryButton(
+ key: const ValueKey("primary_button_key"),
+ onPressed: () {},
+ text: "Next",
+ color: Colors.blue,
+ textColor: Colors.white,
+ ),
+ LoadingPrimaryButton(
+ key: const ValueKey("loading_primary_button_key"),
+ onPressed: () {},
+ text: "Send",
+ color: Colors.blue,
+ textColor: Colors.white,
+ ),
+ ],
+ ),
+ ),
+ );
+
+ expect(
+ platformNodesWithId(tester, "primary_button_key").single,
+ isSemantics(label: "Next", isButton: true, hasTapAction: true),
+ );
+ expect(
+ platformNodesWithId(tester, "loading_primary_button_key").single,
+ isSemantics(label: "Send", isButton: true, hasTapAction: true),
+ );
+ handle.dispose();
+ });
+
+ testWidgets("StackedButtons link-style secondary button", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ StackedButtons(
+ primaryText: "Create",
+ onPrimary: () {},
+ secondaryText: "Restore",
+ onSecondary: () {},
+ secondaryAsLink: true,
+ primaryKey: const ValueKey("welcome_create_button_key"),
+ secondaryKey: const ValueKey("welcome_restore_button_key"),
+ ),
+ ),
+ );
+
+ expect(
+ platformNodesWithId(tester, "welcome_create_button_key").single,
+ isSemantics(label: "Create", isButton: true),
+ );
+ expect(
+ platformNodesWithId(tester, "welcome_restore_button_key").single,
+ isSemantics(label: "Restore", isButton: true),
+ );
+ handle.dispose();
+ });
+ });
+
+ group("alert dialogs", () {
+ testWidgets("two-action buttons get default ids and a button role", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ AlertWithTwoActions(
+ alertTitle: "Title",
+ alertContent: "Content",
+ leftButtonText: "Cancel",
+ rightButtonText: "OK",
+ actionLeftButton: () {},
+ actionRightButton: () {},
+ ),
+ ),
+ );
+
+ expect(
+ platformNodesWithId(tester, "alert_dialog_left_button_key").single,
+ isSemantics(label: "Cancel", isButton: true, hasTapAction: true),
+ );
+ expect(
+ platformNodesWithId(tester, "alert_dialog_right_button_key").single,
+ isSemantics(label: "OK", isButton: true, hasTapAction: true),
+ );
+ handle.dispose();
+ });
+
+ testWidgets("a button test key overrides the default id", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ AlertWithOneAction(
+ alertTitle: "Title",
+ alertContent: "Content",
+ buttonText: "OK",
+ buttonAction: () {},
+ buttonKey: const ValueKey("send_page_confirm_ok_button_key"),
+ ),
+ ),
+ );
+
+ expect(
+ platformNodesWithId(tester, "send_page_confirm_ok_button_key").single,
+ isSemantics(label: "OK", isButton: true),
+ );
+ expect(find.byKey(const ValueKey("send_page_confirm_ok_button_key")), findsOneWidget);
+ expect(find.bySemanticsIdentifier("alert_dialog_action_button_key"), findsNothing);
+ handle.dispose();
+ });
+
+ testWidgets("a single action falls back to alert_dialog_action_button_key", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ AlertWithOneAction(
+ alertTitle: "Title",
+ alertContent: "Content",
+ buttonText: "OK",
+ buttonAction: () {},
+ ),
+ ),
+ );
+ expect(platformNodesWithId(tester, "alert_dialog_action_button_key"), hasLength(1));
+ handle.dispose();
+ });
+ });
+
+ group("BaseTextFormField", () {
+ testWidgets("a keyed field is a distinct text-field node with the identifier", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const Text("Header"),
+ BaseTextFormField(
+ key: const ValueKey("wallet_name_textfield_key"),
+ hintText: "Wallet name",
+ ),
+ ],
+ ),
+ ),
+ );
+
+ final node = platformNodesWithId(tester, "wallet_name_textfield_key").single;
+ expect(node, isSemantics(isTextField: true, label: "Wallet name"));
+ expect(find.byKey(const ValueKey("wallet_name_textfield_key")), findsOneWidget);
+ handle.dispose();
+ });
+
+ testWidgets("suffix buttons stay separate nodes next to the field", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ BaseTextFormField(
+ key: const ValueKey("send_page_address_textfield_key"),
+ hintText: "Address",
+ suffixIcon: IconButton(
+ onPressed: () {},
+ tooltip: "Paste",
+ icon: const Icon(Icons.paste),
+ ),
+ ),
+ ),
+ );
+
+ final field = platformNodesWithId(tester, "send_page_address_textfield_key").single;
+ expect(field, isSemantics(isTextField: true, label: "Address"));
+ final paste = tester.getSemantics(find.byTooltip("Paste"));
+ expect(paste.isMergedIntoParent, isFalse);
+ expect(paste, isSemantics(isButton: true, tooltip: "Paste"));
+ handle.dispose();
+ });
+
+ testWidgets("a field without a hint still carries the identifier", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(BaseTextFormField(key: const ValueKey("nameless_textfield_key"))),
+ );
+ expect(platformNodesWithId(tester, "nameless_textfield_key").single, isSemantics(isTextField: true));
+ handle.dispose();
+ });
+ });
+
+ group("toggle rows", () {
+ testWidgets("ListItemToggleWidget is one node with label, toggled and id", (tester) async {
+ final handle = tester.ensureSemantics();
+ final node = await pumpAndFindOne(
+ tester,
+ ListItemToggleWidget(
+ key: const ValueKey("settings_tor_toggle_key"),
+ testId: "settings_tor_toggle_key",
+ keyValue: "settings_tor_toggle_key",
+ label: "Use Tor",
+ value: true,
+ onChanged: (_) {},
+ ),
+ "settings_tor_toggle_key",
+ );
+ expect(
+ node,
+ isSemantics(label: "Use Tor", hasToggledState: true, isToggled: true, hasTapAction: true),
+ );
+ handle.dispose();
+ });
+
+ testWidgets("SettingsSwitcherCell is one node with label, toggled and id", (tester) async {
+ final handle = tester.ensureSemantics();
+ final node = await pumpAndFindOne(
+ tester,
+ SettingsSwitcherCell(
+ key: const ValueKey("privacy_settings_fiat_api_toggle_key"),
+ title: "Disable fiat API",
+ value: false,
+ onValueChange: (_, __) {},
+ ),
+ "privacy_settings_fiat_api_toggle_key",
+ );
+ expect(node, isSemantics(label: "Disable fiat API", hasToggledState: true, isToggled: false));
+ handle.dispose();
+ });
+ });
+
+ group("list rows", () {
+ testWidgets("SettingsCellWithArrow", (tester) async {
+ final handle = tester.ensureSemantics();
+ final node = await pumpAndFindOne(
+ tester,
+ SettingsCellWithArrow(
+ testId: "settings_page_display_row_key",
+ title: "Display settings",
+ handler: (_) {},
+ ),
+ "settings_page_display_row_key",
+ );
+ expect(node, isSemantics(label: "Display settings", isButton: true, hasTapAction: true));
+ handle.dispose();
+ });
+
+ testWidgets("NewListSections applies ListItem.testId and never a keyValue", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ NewListSections(
+ sections: {
+ "": [
+ ListItemRegularRow(
+ keyValue: "/settings/display",
+ testId: "settings_page_display_row_key",
+ label: "Display",
+ onTap: () {},
+ ),
+ ListItemRegularRow(
+ keyValue: "/settings/security",
+ label: "Security",
+ onTap: () {},
+ ),
+ ListItemToggle(
+ keyValue: "settings_page_tor_toggle_key",
+ testId: "settings_page_tor_toggle_key",
+ label: "Tor",
+ value: false,
+ onChanged: (_) {},
+ ),
+ ListItemRegularRow(keyValue: "savings_key", label: "savings_key", onTap: () {}),
+ ],
+ },
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+
+ expect(
+ platformNodesWithId(tester, "settings_page_display_row_key").single,
+ isSemantics(label: "Display", hasTapAction: true),
+ );
+ expect(
+ platformNodesWithId(tester, "settings_page_tor_toggle_key").single,
+ isSemantics(label: "Tor", hasToggledState: true),
+ );
+ expect(find.bySemanticsIdentifier(RegExp("security")), findsNothing);
+ expect(find.bySemanticsIdentifier(RegExp("savings")), findsNothing);
+ handle.dispose();
+ });
+ });
+
+ group("LineTabSwitcher", () {
+ testWidgets("tabs get index-based ids on their existing button nodes", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(LineTabSwitcher(tabs: const ["Send", "Receive"], selectedTab: 1, onTabChange: (_) {})),
+ );
+ await tester.pumpAndSettle();
+
+ expect(
+ platformNodesWithId(tester, "line_tab_switcher_1_key").single,
+ isSemantics(label: "Receive", isButton: true, isSelected: true),
+ );
+ expect(platformNodesWithId(tester, "line_tab_switcher_0_key"), hasLength(1));
+ handle.dispose();
+ });
+ });
+}
### test/new-ui/widgets/transaction_details_modal_test.dart
@@ -0,0 +1,61 @@
+import "package:cake_wallet/generated/i18n.dart";
+import "package:cake_wallet/locales/locale.dart";
+import "package:cake_wallet/new-ui/widgets/coins_page/assets_history/transaction_details_modal.dart";
+import "package:cake_wallet/src/screens/transaction_details/standart_list_item.dart";
+import "package:cake_wallet/view_model/transaction_details_view_model.dart";
+import "package:cw_core/crypto_currency.dart";
+import "package:flutter/material.dart";
+import "package:flutter_test/flutter_test.dart";
+import "package:mocktail/mocktail.dart";
+
+import "../../utils/semantics_helpers.dart";
+
+class _MockTransactionDetailsViewModel extends Mock implements TransactionDetailsViewModel {}
+
+void main() {
+ testWidgets("detail rows publish only their static model keys as identifiers", (tester) async {
+ final handle = tester.ensureSemantics();
+ final viewModel = _MockTransactionDetailsViewModel();
+ when(() => viewModel.items).thenReturn([
+ StandartListItem(
+ title: "Transaction ID",
+ value: "e0007f02252bf58b591ec3251790690d6db5c38889990f1d4f7b43d1ffebc163",
+ key: const ValueKey("standard_list_item_transaction_details_id_key"),
+ ),
+ StandartListItem(
+ title: "Recipient address",
+ value: "bc1q70vr0t3yrnztt3sd68sradq4elkd9pa2m9yl82",
+ key: const ValueKey("standard_list_item_transaction_details_recipient_address_key"),
+ ),
+ StandartListItem(title: "Date", value: "2026-10-08"),
+ ]);
+ when(() => viewModel.note).thenReturn("");
+ when(() => viewModel.transactionAsset).thenReturn(CryptoCurrency.btc);
+ when(() => viewModel.formattedTitle).thenReturn("Sent");
+ when(() => viewModel.formattedStatus).thenReturn("");
+ when(() => viewModel.transactionAmount).thenReturn("0.001 BTC");
+ when(() => viewModel.transactionCopyAmount).thenReturn("0.001");
+ when(() => viewModel.explorerDescription).thenReturn("View on explorer");
+ when(() => viewModel.canReplaceByFee).thenReturn(false);
+ when(() => viewModel.rawTransaction).thenReturn(null);
+
+ await tester.pumpWidget(
+ MaterialApp(
+ localizationsDelegates: localizationDelegates,
+ supportedLocales: S.delegate.supportedLocales,
+ home: Scaffold(body: TransactionDetailsModal(transactionDetailsViewModel: viewModel)),
+ ),
+ );
+ await tester.pumpAndSettle();
+
+ for (final id in [
+ "standard_list_item_transaction_details_id_key",
+ "standard_list_item_transaction_details_recipient_address_key",
+ ]) {
+ expect(platformNodesWithId(tester, id), hasLength(1), reason: id);
+ expect(find.byKey(ValueKey(id)), findsOneWidget);
+ }
+ expect(find.bySemanticsIdentifier(RegExp("Date|2026|bc1q|e0007f")), findsNothing);
+ handle.dispose();
+ });
+}
### test/src/widgets/legacy_identifiers_test.dart
@@ -0,0 +1,152 @@
+import "package:cake_wallet/core/auth_service.dart";
+import "package:cake_wallet/di.dart";
+import "package:cake_wallet/generated/i18n.dart";
+import "package:cake_wallet/locales/locale.dart";
+import "package:cake_wallet/src/screens/seed/seed_verification/seed_verification_step_view.dart";
+import "package:cake_wallet/src/screens/wallet_list/wallet_list_page.dart";
+import "package:cake_wallet/src/widgets/alert_with_one_action.dart";
+import "package:cake_wallet/src/widgets/alert_with_two_actions.dart";
+import "package:cake_wallet/themes/core/theme_store.dart";
+import "package:cake_wallet/view_model/wallet_list/wallet_list_item.dart";
+import "package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart";
+import "package:cake_wallet/view_model/wallet_seed_view_model.dart";
+import "package:cw_core/wallet_type.dart";
+import "package:flutter/material.dart";
+import "package:flutter/semantics.dart";
+import "package:flutter_test/flutter_test.dart";
+import "package:mobx/mobx.dart" show ObservableList;
+import "package:mocktail/mocktail.dart";
+
+import "../../utils/semantics_helpers.dart";
+
+class _MockWalletListViewModel extends Mock implements WalletListViewModel {}
+
+class _MockWalletSeedViewModel extends Mock implements WalletSeedViewModel {}
+
+class _MockAuthService extends Mock implements AuthService {}
+
+List<String> _allIdentifiers(WidgetTester tester) {
+ final ids = <String>[];
+
+ void visit(SemanticsNode node) {
+ final id = node.getSemanticsData().identifier;
+ if (id.isNotEmpty) {
+ ids.add(id);
+ }
+ node.visitChildren((child) {
+ visit(child);
+ return true;
+ });
+ }
+
+ visit(tester.binding.pipelineOwner.semanticsOwner!.rootSemanticsNode!);
+ return ids;
+}
+
+void main() {
+ late bool registeredThemeStore;
+
+ setUpAll(() async {
+ await S.delegate.load(const Locale("en"));
+ registeredThemeStore = !getIt.isRegistered<ThemeStore>();
+ if (registeredThemeStore) {
+ getIt.registerSingleton(ThemeStore());
+ }
+ });
+
+ tearDownAll(() async {
+ if (registeredThemeStore) {
+ await getIt.unregister<ThemeStore>();
+ }
+ });
+
+ Widget wrap(Widget child) => MaterialApp(
+ localizationsDelegates: localizationDelegates,
+ supportedLocales: S.delegate.supportedLocales,
+ home: Scaffold(body: child),
+ );
+
+ testWidgets("wallet list rows use index ids and never the wallet name", (tester) async {
+ final handle = tester.ensureSemantics();
+ final viewModel = _MockWalletListViewModel();
+ when(() => viewModel.multiWalletGroups).thenReturn(ObservableList());
+ when(() => viewModel.singleWalletsList).thenReturn(
+ ObservableList.of(const [
+ WalletListItem(name: "Alice Savings", type: WalletType.bitcoin, key: 0, isHardware: false, isCurrent: true),
+ WalletListItem(name: "Bob Spending", type: WalletType.litecoin, key: 1, isHardware: false),
+ ]),
+ );
+
+ await tester.pumpWidget(
+ wrap(
+ WalletListBody(
+ walletListViewModel: viewModel,
+ authService: _MockAuthService(),
+ onWalletLoaded: (_) {},
+ ),
+ ),
+ );
+ await tester.pump();
+
+ expect(
+ platformNodesWithId(tester, "wallet_list_single_wallet_0_key").single,
+ isSemantics(label: "Alice Savings, Bitcoin, Current wallet"),
+ );
+ expect(
+ platformNodesWithId(tester, "wallet_list_single_wallet_1_key").single,
+ isSemantics(label: "Bob Spending, Litecoin", hasTapAction: true),
+ );
+ expect(
+ platformNodesWithId(tester, "wallet_list_single_wallet_1_edit_button_key").single,
+ isSemantics(isButton: true, hasTapAction: true),
+ );
+ expect(find.byKey(const ValueKey("wallet_list_single_wallet_1_edit_button_key")), findsOneWidget);
+ expect(_allIdentifiers(tester).where((id) => id.contains("alice") || id.contains("bob")), isEmpty);
+ handle.dispose();
+ });
+
+ testWidgets("seed verification options use index ids and never the seed word", (tester) async {
+ final handle = tester.ensureSemantics();
+ const words = ["abandon", "zebra", "orbit", "lunar"];
+ final viewModel = _MockWalletSeedViewModel();
+ when(() => viewModel.currentOptions).thenReturn(ObservableList.of(words));
+ when(() => viewModel.currentWordIndex).thenReturn(2);
+
+ await tester.pumpWidget(
+ wrap(SeedVerificationStepView(walletSeedViewModel: viewModel, questionTextColor: Colors.black)),
+ );
+
+ for (final (index, word) in words.indexed) {
+ expect(
+ platformNodesWithId(tester, "seed_verification_option_${index}_button_key").single,
+ isSemantics(label: word, hasTapAction: true),
+ );
+ }
+ expect(_allIdentifiers(tester).where((id) => words.any(id.contains)), isEmpty);
+ handle.dispose();
+ });
+
+ testWidgets("an alert's own key lands on exactly one widget", (tester) async {
+ const oneKey = ValueKey("one_action_dialog_key");
+ await tester.pumpWidget(
+ wrap(AlertWithOneAction(key: oneKey, alertTitle: "T", alertContent: "C", buttonText: "OK", buttonAction: () {})),
+ );
+ expect(find.byKey(oneKey), findsOneWidget);
+
+ const twoKey = ValueKey("two_actions_dialog_key");
+ await tester.pumpWidget(
+ wrap(
+ AlertWithTwoActions(
+ alertDialogKey: twoKey,
+ alertTitle: "T",
+ alertContent: "C",
+ leftButtonText: "No",
+ rightButtonText: "Yes",
+ actionLeftButton: () {},
+ actionRightButton: () {},
+ ),
+ ),
+ );
+ expect(find.byKey(twoKey), findsOneWidget);
+ });
+}
### test/utils/semantics_helpers.dart
@@ -0,0 +1,19 @@
+import "package:flutter/semantics.dart";
+import "package:flutter_test/flutter_test.dart";
+
+List<SemanticsNode> platformNodesWithId(WidgetTester tester, String identifier) {
+ final result = <SemanticsNode>[];
+
+ void visit(SemanticsNode node) {
+ if (!node.isMergedIntoParent && node.getSemanticsData().identifier == identifier) {
+ result.add(node);
+ }
+ node.visitChildren((child) {
+ visit(child);
+ return true;
+ });
+ }
+
+ visit(tester.binding.pipelineOwner.semanticsOwner!.rootSemanticsNode!);
+ return result;
+}
### test/utils/test_id_test.dart
@@ -0,0 +1,108 @@
+import "package:cake_wallet/utils/test_id.dart";
+import "package:flutter/material.dart";
+import "package:flutter_test/flutter_test.dart";
+
+import "semantics_helpers.dart";
+
+void main() {
+ Widget wrap(Widget child) => MaterialApp(home: Scaffold(body: Center(child: child)));
+
+ group("TestId.fromKey", () {
+ test("accepts ValueKey<String> test keys", () {
+ expect(
+ TestId.fromKey(const ValueKey("home_page_receive_button_key")),
+ "home_page_receive_button_key",
+ );
+ expect(TestId.fromKey(const Key("line_tab_switcher_0_key")), "line_tab_switcher_0_key");
+ });
+
+ test("rejects keys that are not test keys", () {
+ expect(TestId.fromKey(null), isNull);
+ expect(TestId.fromKey(const ValueKey(42)), isNull);
+ expect(TestId.fromKey(UniqueKey()), isNull);
+ expect(TestId.fromKey(GlobalKey()), isNull);
+ expect(TestId.fromKey(const ValueKey("0.00012 BTC 1")), isNull);
+ expect(TestId.fromKey(const ValueKey("Satoshi")), isNull);
+ expect(TestId.fromKey(const ValueKey("/settings/display")), isNull);
+ expect(TestId.fromKey(const ValueKey("home_page_receive_button")), isNull);
+ expect(TestId.fromKey(const ValueKey("Home_page_receive_button_key")), isNull);
+ expect(TestId.fromKey(const ValueKey("home page_key")), isNull);
+ });
+
+ test("accepts a lowercase seed word, so only the lint keeps user data out", () {
+ const seedWord = "abandon";
+ expect(
+ TestId.fromKey(const ValueKey("seed_verification_option_${seedWord}_button_key")),
+ "seed_verification_option_abandon_button_key",
+ );
+ });
+ });
+
+ group("TestId.merge", () {
+ test("returns the child unchanged without an id", () {
+ const child = SizedBox();
+ expect(TestId.merge(null, child: child), same(child));
+ expect(TestId.container(null, child: child), same(child));
+ });
+
+ testWidgets("folds a framework button into one node with id, label and role", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ TestId.merge(
+ "merge_button_key",
+ child: TextButton(onPressed: () {}, child: const Text("Go")),
+ ),
+ ),
+ );
+
+ expect(find.bySemanticsIdentifier("merge_button_key"), findsOneWidget);
+ expect(
+ platformNodesWithId(tester, "merge_button_key").single,
+ isSemantics(label: "Go", isButton: true, hasTapAction: true),
+ );
+ handle.dispose();
+ });
+
+ testWidgets("an identifier inside ExcludeSemantics is dropped", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(ExcludeSemantics(child: TestId.merge("excluded_key", child: const Text("hidden")))),
+ );
+
+ expect(find.bySemanticsIdentifier("excluded_key"), findsNothing);
+ handle.dispose();
+ });
+ });
+
+ group("TestId.container", () {
+ testWidgets("keeps explicit children as their own nodes", (tester) async {
+ final handle = tester.ensureSemantics();
+ await tester.pumpWidget(
+ wrap(
+ TestId.container(
+ "card_key",
+ explicitChildNodes: true,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const Text("Savings"),
+ TestId.merge(
+ "card_send_button_key",
+ child: TextButton(onPressed: () {}, child: const Text("Send")),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+
+ expect(platformNodesWithId(tester, "card_key"), hasLength(1));
+ expect(
+ platformNodesWithId(tester, "card_send_button_key").single,
+ isSemantics(label: "Send", isButton: true),
+ );
+ handle.dispose();
+ });
+ });
+}
### tool/semantics_ids/main.dart
@@ -0,0 +1,140 @@
+import "dart:io";
+
+import "package:analyzer/dart/analysis/utilities.dart";
+import "package:analyzer/dart/ast/ast.dart";
+import "package:analyzer/dart/ast/visitor.dart";
+
+const _testIdImport = "package:cake_wallet/utils/test_id.dart";
+
+const _interactiveWidgets = {
+ "GestureDetector",
+ "InkWell",
+ "TextButton",
+ "IconButton",
+ "ElevatedButton",
+ "OutlinedButton",
+ "FilledButton",
+ "TextField",
+ "TextFormField",
+ "Switch",
+ "Checkbox",
+ "Radio",
+ "ListTile",
+ "CupertinoButton",
+};
+
+void main(List<String> args) {
+ final apply = args.contains("--apply");
+ final paths = args.where((arg) => arg != "--apply").toList();
+ var total = 0;
+
+ for (final path in (paths.isEmpty ? ["lib"] : paths).expand(_dartFiles)) {
+ final source = File(path).readAsStringSync();
+ final unit = parseString(content: source, path: path, throwIfDiagnostics: false).unit;
+ final finder = _Finder();
+ unit.accept(finder);
+
+ for (final (widget, id) in finder.hits) {
+ stdout.writeln("$path:${unit.lineInfo.getLocation(widget.offset).lineNumber} $id");
+ }
+
+ total += finder.hits.length;
+ if (apply && finder.hits.isNotEmpty) {
+ File(path).writeAsStringSync(_wrap(source, unit, finder.hits));
+ }
+ }
+
+ stdout.writeln("$total hit(s)");
+}
+
+Iterable<String> _dartFiles(String path) => FileSystemEntity.isDirectorySync(path)
+ ? Directory(path)
+ .listSync(recursive: true)
+ .whereType<File>()
+ .map((file) => file.path)
+ .where((path) => path.endsWith(".dart") && !path.endsWith(".g.dart"))
+ : [path];
+
+String _wrap(String source, CompilationUnit unit, List<(AstNode, String)> hits) {
+ final edits = [
+ for (final (widget, id) in hits) ...[
+ (
+ widget.offset,
+ "TestId.${const {"TextField", "TextFormField"}.contains(_name(widget)) ? "container" : "merge"}($id, child: ",
+ ),
+ (widget.end, ")"),
+ ],
+ ];
+
+ final imports = unit.directives.whereType<ImportDirective>();
+ if (!imports.any((directive) => directive.uri.stringValue == _testIdImport)) {
+ final quote = imports.isEmpty ? '"' : imports.last.uri.toSource()[0];
+ final line = "import $quote$_testIdImport$quote;";
+ edits.add(imports.isEmpty ? (0, "$line\n") : (imports.last.end, "\n$line"));
+ }
+
+ edits.sort((a, b) => b.$1.compareTo(a.$1));
+ return edits.fold(source, (text, edit) => text.replaceRange(edit.$1, edit.$1, edit.$2));
+}
+
+String? _name(AstNode node) => switch (node) {
+ InstanceCreationExpression(:final constructorName) => constructorName.type.name.lexeme,
+ MethodInvocation(target: null, :final methodName) => methodName.name,
+ MethodInvocation(target: SimpleIdentifier(:final name)) => name,
+ _ => null,
+};
+
+NodeList<Expression>? _arguments(AstNode node) => switch (node) {
+ InstanceCreationExpression(:final argumentList) => argumentList.arguments,
+ MethodInvocation(:final argumentList) => argumentList.arguments,
+ _ => null,
+};
+
+Expression? _named(AstNode node, String name) => _arguments(node)
+ ?.whereType<NamedExpression>()
+ .where((argument) => argument.name.label.name == name)
+ .firstOrNull
+ ?.expression;
+
+class _Finder extends GeneralizingAstVisitor<void> {
+ final hits = <(AstNode, String)>[];
+
+ @override
+ void visitNode(AstNode node) {
+ final id = _interactiveWidgets.contains(_name(node)) ? _testKey(_named(node, "key")) : null;
+ if (id != null && !_hasIdentifierAncestor(node)) {
+ hits.add((node, id));
+ }
+
+ super.visitNode(node);
+ }
+
+ String? _testKey(Expression? key) {
+ final literal = key != null && const {"Key", "ValueKey"}.contains(_name(key))
+ ? _arguments(key)?.firstOrNull
+ : null;
+ return literal is SimpleStringLiteral && literal.value.endsWith("_key")
+ ? literal.toSource()
+ : null;
+ }
+
+ bool _hasIdentifierAncestor(AstNode node) {
+ for (var current = node.parent; current != null; current = current.parent) {
+ if (current is MethodDeclaration ||
+ current is FunctionDeclaration ||
+ current is ClassDeclaration ||
+ current is CompilationUnit) {
+ return false;
+ }
+
+ if ((_name(current) == "Semantics" && _named(current, "identifier") != null) ||
+ (current is MethodInvocation &&
+ _name(current) == "TestId" &&
+ const {"merge", "container"}.contains(current.methodName.name))) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}Why this scored 30/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.