feat: add setting for auto-lock fix: fix sideswipe

This commit is contained in:
2026-08-04 01:09:01 +02:00
parent 0997d110d4
commit 812fcc892b
23 changed files with 629 additions and 28 deletions
+69
View File
@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:kooltab2/l10n/app_localizations.dart';
import 'package:kooltab2/models/bar_tab.dart';
import 'package:kooltab2/services/bar_tab_service.dart';
import 'package:kooltab2/services/product_service.dart';
import 'package:kooltab2/viewmodels/bar_screen_view_model.dart';
import 'package:kooltab2/viewmodels/inventory_view_model.dart';
import 'package:kooltab2/views/dialogs/edit_tab_dialog.dart';
import 'package:mocktail/mocktail.dart';
import 'package:provider/provider.dart';
class MockBarTabService extends Mock implements BarTabService {}
class MockProductService extends Mock implements ProductService {}
void main() {
testWidgets('edit dialog disposes its controller after closing', (
tester,
) async {
final barTabService = MockBarTabService();
final productService = MockProductService();
final viewModel = BarScreenViewModel(
barTabService: barTabService,
inventory: InventoryViewModel(productService: productService),
);
final tab = BarTab(
id: 'tab-1',
customerName: 'Before',
status: 'open',
openedAt: DateTime(2026),
items: const [],
);
when(
() => barTabService.renameTab(tabId: 'tab-1', customerName: 'After'),
).thenAnswer((_) async {});
when(() => barTabService.getOpenTabs()).thenAnswer((_) async => [tab]);
await tester.pumpWidget(
ChangeNotifierProvider<BarScreenViewModel>.value(
value: viewModel,
child: MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: Builder(
builder: (context) => Scaffold(
body: ElevatedButton(
onPressed: () => showEditTabDialog(context, tab),
child: const Text('Edit'),
),
),
),
),
),
);
await tester.tap(find.text('Edit'));
await tester.pumpAndSettle();
await tester.enterText(find.byType(TextField), 'After');
await tester.tap(find.text('Confirm'));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
verify(
() => barTabService.renameTab(tabId: 'tab-1', customerName: 'After'),
).called(1);
});
}