merge(app): land list-scroll-keep (run 160)
This commit is contained in:
@@ -128,6 +128,53 @@ void main() {
|
|||||||
expect(gateway.callsOf('get_pipeline').length, greaterThanOrEqualTo(2));
|
expect(gateway.callsOf('get_pipeline').length, greaterThanOrEqualTo(2));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('refresh token keeps the visible pipeline position', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final fixture = PipelineFixture();
|
||||||
|
final summaries = List.generate(
|
||||||
|
40,
|
||||||
|
(index) => pipelineSummary(id: index + 1, name: 'Pipeline ${index + 1}'),
|
||||||
|
);
|
||||||
|
final gateway = gatewayFor(fixture, summaries: summaries);
|
||||||
|
tester.view.physicalSize = const Size(500, 600);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
|
|
||||||
|
Future<void> pump(int token) => tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: PipelinesScreen(gateway: gateway, syncToken: token),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await pump(0);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.drag(
|
||||||
|
find.byKey(const Key('pipeline-list')),
|
||||||
|
const Offset(0, -600),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final list = tester.state<ScrollableState>(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byKey(const Key('pipeline-list')),
|
||||||
|
matching: find.byType(Scrollable),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final offset = list.position.pixels;
|
||||||
|
await pump(1);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
final refreshedList = tester.state<ScrollableState>(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byKey(const Key('pipeline-list')),
|
||||||
|
matching: find.byType(Scrollable),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(refreshedList.position.pixels, offset);
|
||||||
|
expect(find.byKey(const Key('pipeline-row-1')), findsNothing);
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('initial loading is shown until both list reads settle', (
|
testWidgets('initial loading is shown until both list reads settle', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
|
|||||||
@@ -67,4 +67,42 @@ void main() {
|
|||||||
expect(gateway.listRequests, hasLength(2));
|
expect(gateway.listRequests, hasLength(2));
|
||||||
expect(gateway.detailRequests, isEmpty);
|
expect(gateway.detailRequests, isEmpty);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('refresh keeps the visible run position', (tester) async {
|
||||||
|
final gateway = _Gateway();
|
||||||
|
final runs = List.generate(
|
||||||
|
40,
|
||||||
|
(index) => {
|
||||||
|
'id': index + 1,
|
||||||
|
'title': 'Run ${index + 1}',
|
||||||
|
'status': 'succeeded',
|
||||||
|
'created_at': '2026-10-20T12:00:00',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
await tester.pumpWidget(_screen(gateway, 0));
|
||||||
|
gateway.listRequests.single.complete({'runs': runs});
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.drag(find.byType(ListView), const Offset(0, -600));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final list = tester.state<ScrollableState>(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byType(ListView),
|
||||||
|
matching: find.byType(Scrollable),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final offset = list.position.pixels;
|
||||||
|
await tester.pumpWidget(_screen(gateway, 1));
|
||||||
|
gateway.listRequests.last.complete({'runs': runs});
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
final refreshedList = tester.state<ScrollableState>(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byType(ListView),
|
||||||
|
matching: find.byType(Scrollable),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(refreshedList.position.pixels, offset);
|
||||||
|
expect(find.text('Run 1'), findsNothing);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user