loadScreen method
Future<EnsembleConfig>
loadScreen({
- required WidgetTester tester,
- required EnsembleTestCase testCase,
- EnsembleConfig? existingConfig,
- EnsembleTestContext? context,
Implementation
Future<EnsembleConfig> loadScreen({
required WidgetTester tester,
required EnsembleTestCase testCase,
EnsembleConfig? existingConfig,
EnsembleTestContext? context,
}) async {
resetTestRuntime();
ScreenTracker().clearAll();
YamlTestSession.navigationFlow.clear();
final ctx = context ?? EnsembleTestContext.fromTestCase(testCase);
var config = existingConfig ?? await buildConfig();
final bootstrapped = await tester.runAsync(() async {
return bootstrapRuntime(
config,
ctx.setup,
httpMock: ctx.mockApiProvider,
);
});
config = bootstrapped!;
final startScreen = testCase.startScreen;
if (startScreen == null || startScreen.isEmpty) {
throw EnsembleTestFailure(
'loadScreen requires startScreen on test "${testCase.id}"',
);
}
// Let EnsembleApp load the bundle through its existing config path, which
// preserves the test-installed API providers and avoids real provider init.
config.appBundle = null;
await tester.pumpWidget(
EnsembleApp(
ensembleConfig: config,
screenPayload: ScreenPayload(screenId: startScreen),
),
);
await waitForInitialWidgets(tester, testCase: testCase);
return config;
}