mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Changing pages in the notifications or devices list gave no cue that the next page was loading. Render an indeterminate progress bar at the shell level, pinned flush against the bottom of the page body (above the nav bar on phones, the screen bottom on wide layouts), driven by a shared paginationLoading notifier the lists set while fetching. The pagination bar keeps disabling its buttons during the fetch. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
51 lines
1.3 KiB
Dart
51 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:frontend/theme/gruvbox_theme.dart';
|
|
import 'package:frontend/widgets/pagination_bar.dart';
|
|
|
|
void main() {
|
|
Widget wrap(Widget child) => MaterialApp(
|
|
theme: gruvboxDarkTheme,
|
|
home: Scaffold(body: child),
|
|
);
|
|
|
|
testWidgets('disables every navigation button while loading', (tester) async {
|
|
var changedTo = -1;
|
|
await tester.pumpWidget(
|
|
wrap(
|
|
PaginationBar(
|
|
currentPage: 1,
|
|
hasNextPage: true,
|
|
isLoading: true,
|
|
onPageChanged: (page) => changedTo = page,
|
|
),
|
|
),
|
|
);
|
|
|
|
await tester.tap(find.byTooltip('Next page'));
|
|
await tester.tap(find.byTooltip('Previous page'));
|
|
await tester.tap(find.byTooltip('First page'));
|
|
expect(changedTo, -1);
|
|
});
|
|
|
|
testWidgets('enables navigation when idle', (tester) async {
|
|
var changedTo = -1;
|
|
await tester.pumpWidget(
|
|
wrap(
|
|
PaginationBar(
|
|
currentPage: 1,
|
|
hasNextPage: true,
|
|
isLoading: false,
|
|
onPageChanged: (page) => changedTo = page,
|
|
),
|
|
),
|
|
);
|
|
|
|
await tester.tap(find.byTooltip('Next page'));
|
|
expect(changedTo, 2);
|
|
|
|
await tester.tap(find.byTooltip('Previous page'));
|
|
expect(changedTo, 0);
|
|
});
|
|
}
|