notificationsStepAppTest function

Future<MatrixAppTest> notificationsStepAppTest({
  1. bool among(
    1. MatrixApp app
    )?,
})

The test of the step of the onboarding that asks for the permission to show notifications, which the template of the notifications role gives the onboarding screen role, that the CLI keeps in its app_tests/notifications_step, for the apps with the notifications role and the onboarding screen role, whichever modules provide them, that among accepts, or all of them. Its file runs the start-up of the app once, with bootstrap():

  • on a first launch, the condition of the step holds, so the onboarding shows it, and its action asks for the permission through the provider, whose mocks grant it; then the condition holds no more;
  • over a service of the test that scripts what a provider answers: the condition holds only while the app may not show notifications and has not asked, and reads the permission without a call of the service; the action makes one request and no other call, after a no and on a system without a question, whose request opens its settings, and while the app may show notifications it asks the user nothing; once the app asked, whatever the user answered, the condition holds no more, also at the next start;
  • the list of the steps of the onboarding of the app has the step once, with those two functions.

The page of the step is for the test of the onboarding screen role, which checks how a provider of the onboarding shows any step. The test knows only the two roles. The matrix writes the two functions of the step for it into notificationsStepFile, from the data of the onboarding screen role of the app, and the test takes the service of the test from the files of the test of the notifications role, which runs in every app that this test runs in. It has no probe for the start check: the action would show the question of the system on a device. The matrix of the fixtures runs it only in its apps with every module, which run other tests already.

Implementation

Future<MatrixAppTest> notificationsStepAppTest({
  bool Function(MatrixApp app)? among,
}) async =>
    MatrixAppTest(
      '${await appTestsDirectoryOf('smf_flutter_cli')}/notifications_step',
      appliesTo: (app) =>
          app.hook!.presentRoles
              .containsAll({notificationsRole, onboardingScreenRole}) &&
          (among?.call(app) ?? true),
      generatedFiles: _notificationsStepOf,
      roles: {notificationsRole},
    );