afterStep method

Future<List<PlaybookShot>> afterStep(
  1. PlaybookStep step,
  2. PlaybookActor actor, {
  3. required bool everyStep,
})

Takes the shot for step, which actor just performed, when this run captures it. everyStep is false for a playbook with screenshot() steps. The shot waits for running animations to finish, so a tap that opens a page shows the page.

A screenshot() step takes one shot for each of its locales and themes, switching the app in place and back again. When one can't be captured the step fails. Other captures are best effort.

Implementation

Future<List<PlaybookShot>> afterStep(
  PlaybookStep step,
  PlaybookActor actor, {
  required bool everyStep,
}) async {
  if (step is PlaybookScreenshotStep) {
    if (mode == PlaybookScreenshots.off ||
        mode == PlaybookScreenshots.failures) {
      return const [];
    }
    final List<String?> locales = await _cells(
      step.locales,
      matrix?.locale,
      () async => (await _looks()).locales,
    );
    final List<String?> themes = await _cells(
      step.themes,
      matrix?.theme,
      () async => (await _looks()).themes,
    );
    return [
      for (final String? locale in locales)
        for (final String? theme in themes)
          await _marked(step, actor, locale: locale, theme: theme),
    ];
  }
  final bool capture = switch (mode) {
    PlaybookScreenshots.all => true,
    PlaybookScreenshots.auto => everyStep,
    _ => false,
  };
  if (!capture) return const [];
  await actor.settleAnimations();
  final PlaybookShot? shot = await _bestEffort(PlaybookShotKind.step);
  return [?shot];
}