Files
pipelines/app/test/features/changes/no_patch_reason_test.dart
T
alan 87016ef5dc Engine: check stages, harness-agnostic delivery, read-only enforcement, complete captures
- New `type=check` stage: the server runs a `commands` block (sh -c, per
  command_timeout, workspace env) and routes on pass/fail; per-command status,
  exit code, duration and bounded output are recorded and the failing output is
  the handoff. With delivery=true it is the landing gate (commit leftovers,
  merge moved main, checks in a fresh candidate worktree, fast-forward main).
  Parser/registry, lint (silent guards), format docs, CLI inspect, app graph and
  run detail rendering.
- delivery=true is accepted on every harness (and on check stages).
- permissions.shell on claude stages maps to Bash(cmd) / Bash(prefix:*) rules
  instead of a bare Bash allow; stages without edit that change the workspace
  fail the visit with the changed files listed (allow_workspace_changes=true
  opts out; artifacts, public and harness state dirs are ignored).
- File-change capture: symlinks compared by target, untouched protected files no
  longer make captures partial, untracked caches/dependency/build output left
  out, lockfiles listed without patch, huge files compared by metadata, raised
  patch/line limits. Outcome repair follow-ups are logged and counted on the
  step (control.outcome_repairs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 12:52:16 +00:00

97 lines
3.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/changes/changes.dart';
import 'widget_hosts.dart';
const _legacy =
"The server truncated this file's patch at its capture limit; no diff "
'text was recorded.';
const _expected = {
'file_size': 'This file is over 1 MiB, so no diff text was recorded.',
'budget':
'The workspace snapshot ran out of text budget, so no diff text was '
'recorded.',
'lines': 'The change is over 20,000 lines, so no diff text was recorded.',
'evidence_size':
"This visit's recorded changes reached their size limit, so this patch "
'was dropped.',
'git_status':
"This change was seen only in Git status, so the file's contents weren't "
'compared.',
'baseline':
"The file's content at stage start couldn't be recovered from Git, so no "
'diff was recorded.',
'binary': 'Binary file; only its metadata was recorded.',
'symlink': 'Symbolic link; only the change to its target was recorded.',
'protected':
'A protected file (secrets, credentials or a database); its content is '
'never read, only that it changed.',
'generated':
'A lockfile, minified or generated file; it is listed without a diff.',
'large':
'This file is too large to hash, so it was compared by size and '
'modification time only.',
};
FileChange _noPatch(Object? reason, {bool binary = false}) =>
FileChange.fromJson({
'path': 'big.txt',
'kind': 'modified',
'truncated': true,
'no_patch': true,
'binary': binary,
'no_patch_reason': ?reason,
});
void main() {
test('each recorded no-patch reason has its own message', () {
for (final entry in _expected.entries) {
final file = _noPatch(entry.key, binary: entry.key == 'binary');
expect(file.noPatchReason, entry.key);
expect(patchUnavailableReason(file), entry.value, reason: entry.key);
}
});
test('no reason, a blank one or an unknown one keeps the old wording', () {
expect(patchUnavailableReason(_noPatch(null)), _legacy);
expect(patchUnavailableReason(_noPatch('')), _legacy);
expect(patchUnavailableReason(_noPatch('future_reason')), _legacy);
expect(patchUnavailableReason(_noPatch(42)), _legacy);
});
test('the reason survives aggregation across stages', () {
final file = _noPatch('budget').withSteps(const ['build']);
expect(file.noPatchReason, 'budget');
});
testWidgets('the viewer shows the reason, binary included', (tester) async {
await tester.pumpWidget(
materialHost(
Column(
children: [
Expanded(child: FileDiffViewer(file: _noPatch('lines'))),
Expanded(
child: FileDiffViewer(file: _noPatch('binary', binary: true)),
),
Expanded(
child: FileDiffViewer(
file: FileChange(
path: 'logo.bin',
kind: ChangeKind.modified,
binary: true,
),
),
),
],
),
),
);
expect(find.text(_expected['lines']!), findsOneWidget);
expect(find.text(_expected['binary']!), findsOneWidget);
expect(find.text(binaryDiffMessage), findsOneWidget);
expect(find.text(_legacy), findsNothing);
});
}