mapExecutorFailure static method
Maps executor EnsembleTestFailure into structured session errors, preserving the full diagnostic message.
Tap/wait-for-id timeouts mean the widget never became available, so they classify as TestExecutionErrorCode.elementNotFound (or TestExecutionErrorCode.elementNotInteractable when it existed but was not hit-testable). Generic "timed out" is reserved for wait steps such as waitForApi / waitForNavigation.
Implementation
@visibleForTesting
static TestExecutionError mapExecutorFailure(EnsembleTestFailure error) {
final message = error.message;
final lower = message.toLowerCase();
final TestExecutionErrorCode code;
if (lower.contains('not hit-testable') ||
lower.contains('not interactable') ||
lower.contains('to become hit-testable')) {
code = TestExecutionErrorCode.elementNotInteractable;
} else if (lower.contains('not found') ||
lower.contains('could not find') ||
lower.contains('is detached') ||
lower.contains('not in the tree') ||
lower.contains('waiting for id')) {
code = TestExecutionErrorCode.elementNotFound;
} else if (lower.contains('exactly one') ||
lower.contains('ambiguous') ||
lower.contains('multiple')) {
code = TestExecutionErrorCode.ambiguousTarget;
} else if (lower.contains('timed out')) {
code = TestExecutionErrorCode.actionTimeout;
} else {
code = TestExecutionErrorCode.internalError;
}
return TestExecutionError(
code: code,
message: message,
details: const {'source': 'TestStepExecutor'},
);
}