document method

Future<void> document(
  1. String name,
  2. List<int> bytes, {
  3. String? fileName,
  4. String? mimeType,
  5. List<String> tags = const [],
})

A beat of the flow that is not a screen: the PDF it just generated, the email body it queued, the payload it posted.

A step like any other — named, positioned, carrying the events that led to it — whose picture is the document rather than the app:

await s.tap('Export');
var bytes = await s.runAsync(() => report.generatePdf());
await s.document('receipt', bytes!, fileName: 'receipt.pdf',
    mimeType: 'application/pdf');

A flow that exists to produce a document was otherwise a scenario that stopped one step short: you could screenshot the button and prove nothing about what it made. Deliberately one verb rather than one per format — the format is mimeType's job, and a viewer shows what it can and offers the rest as a download.

It renders nothing, so it costs no capture: there is no screen here to photograph, which is why it is its own kind of step rather than a file attached to another one.

Implementation

Future<void> document(
  String name,
  List<int> bytes, {
  String? fileName,
  String? mimeType,
  List<String> tags = const [],
}) => _beat(
  kind: ScenarioCaptureKind.document,
  verb: 'document',
  name: name,
  tags: tags,
  payload: bytes is Uint8List ? bytes : Uint8List.fromList(bytes),
  fileName: fileName,
  mimeType: mimeType,
);