routerWalkAppTest function
The test of the router role that the CLI keeps in its
app_tests/router_walk, for the apps with the role, whichever module
provides it, that among accepts, or all of them: it starts the app
with main() and goes to each location of the app that needs no
values, at most routerWalkLimit, with go() of the navigator of the
role. Each must show the page named after its route on top of the
innermost navigator on the screen, and the screen of the route, without
an ErrorWidget on the screen or an error that Flutter reports.
In an app with guards of the routes, the walk expects what the role
says. For a location that a guard keeps the user from, that is the page
and the screen of the target of that guard (redirectOf() of the
role): every location outside the flow of a gate, and for a guard that
stands for a condition, only the locations of the routes that ask for
the condition. The target of a gate takes the place of the stack, and
that of a guard of a condition opens over the page that the walk is on:
either way it is the page on top, which the walk looks at. For any other
location in a flow that is over, it is the screen that the app starts on
(flowIsOver() of the role). So its probe, probeRoutes(), which the
start check runs on a device, holds whichever guards allow there, where
no test can open one, such as a guard that asks for a signed-in user.
The test itself first fails on each guard that does not allow, by its
name, a guard of a condition too: under flutter test, the module of a
guard opens it for the tests of the app, in the mocks of its app test
(MatrixAppTest.mocks), so that the walk reaches every route outside
the flows and the tests of the other modules see the screens that they
expect. The screens of a flow are then for the tests of its module,
since the router shows them only while the guard does not allow.
The test knows only the role. The matrix writes the locations of each
app for it, from the routes and the guards of its router role, into
routerWalkFile, next to the walk in
integration_test/router_walk/walk.dart. The matrix of the fixtures
runs it too, only in the apps with every module, which run other tests
already.
Implementation
Future<MatrixAppTest> routerWalkAppTest({
bool Function(MatrixApp app)? among,
}) async =>
MatrixAppTest(
'${await appTestsDirectoryOf('smf_flutter_cli')}/router_walk',
appliesTo: (app) =>
app.hook!.presentRoles.contains(routerRole) &&
(among?.call(app) ?? true),
generatedFiles: _walkedLocationsOf,
roles: {routerRole},
startProbe: const MatrixStartProbe(
'integration_test/router_walk/walk.dart',
'probeRoutes',
),
);