yubioath-flutter/integration_test/keyless_test.dart

154 lines
5.9 KiB
Dart
Raw Permalink Normal View History

/*
2023-12-04 17:28:07 +03:00
* Copyright (C) 2023 Yubico.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2023-11-28 18:51:44 +03:00
@Tags(['desktop', 'android'])
2024-07-03 13:44:20 +03:00
library;
2023-11-28 18:51:44 +03:00
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:yubico_authenticator/app/views/keys.dart';
2023-11-24 14:18:30 +03:00
import 'package:yubico_authenticator/core/state.dart';
import 'utils/keyless_test_util.dart';
2023-11-24 14:18:30 +03:00
import 'utils/test_util.dart';
void main() {
var binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
2023-11-28 18:51:44 +03:00
group('Startup', () {
appTestKeyless('App starts', (WidgetTester tester) async {},
tags: 'minimal');
});
group('Settings', () {
appTestKeyless('Click through all Themes', (WidgetTester tester) async {
2024-04-15 13:06:10 +03:00
await tester.tap(find.byKey(actionsIconButtonKey).hitTestable());
await tester.shortWait();
await tester.tap(find.byKey(settingDrawerIcon).hitTestable());
await tester.shortWait();
await tester.tap(find.byKey(themeModeSetting));
2024-04-15 13:06:10 +03:00
await tester.shortWait();
await tester
.tap(find.byKey(themeModeOption(ThemeMode.light)).hitTestable());
await tester.longWait();
await tester.tap(find.byKey(themeModeSetting));
2024-04-15 13:06:10 +03:00
await tester.shortWait();
await tester
.tap(find.byKey(themeModeOption(ThemeMode.dark)).hitTestable());
await tester.longWait();
await tester.tap(find.byKey(themeModeSetting));
2024-04-15 13:06:10 +03:00
await tester.shortWait();
await tester
.tap(find.byKey(themeModeOption(ThemeMode.system)).hitTestable());
await tester.longWait();
});
});
group('Help and about', () {
var helpDrawerButton = find.byKey(helpDrawerIcon).hitTestable();
appTestKeyless('Check Licenses view', (WidgetTester tester) async {
2024-04-15 13:06:10 +03:00
await tester.tap(find.byKey(actionsIconButtonKey).hitTestable());
await tester.shortWait();
await tester.tap(helpDrawerButton);
await tester.shortWait();
var licensesButtonText = find.byKey(licensesButton).hitTestable();
await tester.tap(licensesButtonText);
await tester.shortWait();
/// TODO: do want to click all licenses and see that they show?
});
group('Opening of URLs', () {
appTestKeyless('TOS link', (WidgetTester tester) async {
2024-04-15 13:06:10 +03:00
await tester.tap(find.byKey(actionsIconButtonKey).hitTestable());
await tester.shortWait();
await tester.tap(helpDrawerButton);
2024-04-15 13:06:10 +03:00
await tester.shortWait();
2023-11-28 18:51:44 +03:00
if (isAndroid) {
expect(find.byKey(tosButton).hitTestable(), findsOneWidget);
} else {
await tester.tap(find.byKey(tosButton).hitTestable());
await tester.longWait();
}
});
appTestKeyless('Privacy link', (WidgetTester tester) async {
2024-04-15 13:06:10 +03:00
await tester.tap(find.byKey(actionsIconButtonKey).hitTestable());
await tester.shortWait();
await tester.tap(helpDrawerButton);
2024-04-15 13:06:10 +03:00
await tester.shortWait();
2023-11-28 18:51:44 +03:00
if (isAndroid) {
expect(find.byKey(privacyButton).hitTestable(), findsOneWidget);
} else {
await tester.tap(find.byKey(privacyButton).hitTestable());
await tester.longWait();
}
});
appTestKeyless('Feedback link', (WidgetTester tester) async {
2024-04-15 13:06:10 +03:00
await tester.tap(find.byKey(actionsIconButtonKey).hitTestable());
await tester.shortWait();
await tester.tap(helpDrawerButton);
2024-04-15 13:06:10 +03:00
await tester.shortWait();
2023-11-28 18:51:44 +03:00
if (isAndroid) {
2024-04-11 15:24:50 +03:00
expect(find.byKey(userGuideButton).hitTestable(), findsOneWidget);
2023-11-28 18:51:44 +03:00
} else {
2024-04-11 15:24:50 +03:00
await tester.tap(find.byKey(userGuideButton).hitTestable());
2023-11-28 18:51:44 +03:00
await tester.longWait();
}
});
appTestKeyless('Help link', (WidgetTester tester) async {
2024-04-15 13:06:10 +03:00
await tester.tap(find.byKey(actionsIconButtonKey).hitTestable());
await tester.shortWait();
await tester.tap(helpDrawerButton);
await tester.longWait();
2023-11-28 18:51:44 +03:00
if (isAndroid) {
expect(find.byKey(helpButton).hitTestable(), findsOneWidget);
} else {
await tester.tap(find.byKey(helpButton).hitTestable());
await tester.longWait();
}
});
});
group('Troubleshooting', () {
2023-11-24 14:18:30 +03:00
appTestKeyless('Diagnostics Button', skip: isAndroid,
(WidgetTester tester) async {
2024-04-15 13:06:10 +03:00
await tester.tap(find.byKey(actionsIconButtonKey).hitTestable());
await tester.shortWait();
await tester.tap(helpDrawerButton);
2024-04-15 13:06:10 +03:00
await tester.shortWait();
await tester.tap(find.byKey(diagnosticsChip).hitTestable());
await tester.longWait();
});
appTestKeyless('Log button', (WidgetTester tester) async {
2024-04-15 13:06:10 +03:00
await tester.tap(find.byKey(actionsIconButtonKey).hitTestable());
await tester.shortWait();
await tester.tap(helpDrawerButton);
2024-04-15 13:06:10 +03:00
await tester.shortWait();
await tester.tap(find.byKey(logChip).hitTestable());
await tester.longWait();
});
// appTestKeyless('Allow screenshots', (WidgetTester tester) async {
// /// Pausing test until we have Android CI.
// await tester.tap(helpDrawerButton);
// await tester.shortWait();
// await tester.tap(find.byKey(screenshotChip).hitTestable());
// await tester.longWait();
// await tester.tap(find.byKey(screenshotChip).hitTestable());
// await tester.shortWait();
// });
});
});
}