feat(app): a file diff opens as its own page with previous and next file chevrons
This commit is contained in:
@@ -273,38 +273,59 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('a Cupertino phone dialog is inset from the screen edge', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(
|
||||
cupertinoHost(
|
||||
ChangesViewer(
|
||||
steps: [
|
||||
stepFixture(
|
||||
fileChanges: captureFixture(
|
||||
files: [
|
||||
fileChangeFixture(
|
||||
path: 'lib/feature.dart',
|
||||
patch: multiHunkPatch,
|
||||
),
|
||||
],
|
||||
),
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('a file opens as a page that steps to the previous and next '
|
||||
'file (${cupertino ? 'cupertino' : 'material'})', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final viewer = ChangesViewer(
|
||||
steps: [
|
||||
stepFixture(
|
||||
fileChanges: captureFixture(
|
||||
files: [
|
||||
fileChangeFixture(
|
||||
path: 'lib/first.dart',
|
||||
patch: multiHunkPatch,
|
||||
),
|
||||
fileChangeFixture(
|
||||
path: 'lib/second.dart',
|
||||
patch: multiHunkPatch,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.byKey(const ValueKey('change-1-lib/feature.dart')));
|
||||
await tester.pumpAndSettle();
|
||||
final rect = tester.getRect(find.byType(CupertinoPopupSurface));
|
||||
expect(rect.width, lessThanOrEqualTo(390 - 24));
|
||||
expect(rect.left, greaterThan(8));
|
||||
expect(rect.right, lessThan(382));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
),
|
||||
],
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino ? cupertinoHost(viewer) : materialHost(viewer),
|
||||
);
|
||||
await tester.tap(find.byKey(const ValueKey('change-1-lib/first.dart')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
Finder control(String label) =>
|
||||
cupertino ? find.bySemanticsLabel(label) : find.byTooltip(label);
|
||||
expect(find.byType(FileDiffPage), findsOneWidget);
|
||||
expect(find.text('first.dart'), findsOneWidget);
|
||||
expect(find.text('1 of 2'), findsOneWidget);
|
||||
// The pager sits at the bottom right.
|
||||
final pager = tester.getRect(
|
||||
find.byKey(const ValueKey('file-diff-pager')),
|
||||
);
|
||||
expect(pager.bottom, greaterThan(844 - 120));
|
||||
final next = tester.getRect(control('Next file'));
|
||||
expect(next.right, greaterThan(390 - 80));
|
||||
|
||||
await tester.tap(control('Next file'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('second.dart'), findsOneWidget);
|
||||
expect(find.text('2 of 2'), findsOneWidget);
|
||||
await tester.tap(control('Previous file'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('first.dart'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
final diffFile = FileChange(
|
||||
path: 'lib/feature.dart',
|
||||
|
||||
Reference in New Issue
Block a user