Browse Source

fix(app): Fix screenshots test user permissions

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/538/head
jld3103 1 year ago
parent
commit
1e0bd340c9
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 32
      packages/app/integration_test/screenshot_test.dart

32
packages/app/integration_test/screenshot_test.dart

@ -9,6 +9,7 @@ import 'package:integration_test/integration_test.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:neon/models.dart'; import 'package:neon/models.dart';
import 'package:neon/neon.dart'; import 'package:neon/neon.dart';
import 'package:neon/nextcloud.dart';
import 'package:neon_files/widgets/actions.dart'; import 'package:neon_files/widgets/actions.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -44,19 +45,34 @@ Future prepareScreenshot(final WidgetTester tester, final IntegrationTestWidgets
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
Future<Account> getAccount(final String username) async {
const host = 'http://10.0.2.2';
final appPassword = (await NextcloudClient(
host,
loginName: username,
password: username,
).core.appPassword.getAppPassword())
.ocs
.data
.apppassword;
return Account(
serverURL: host,
username: username,
password: appPassword,
);
}
Future main() async { Future main() async {
// The screenshots are pretty annoying on Android. See https://github.com/flutter/flutter/issues/92381 // The screenshots are pretty annoying on Android. See https://github.com/flutter/flutter/issues/92381
assert(Platform.isAndroid, 'Screenshots need to be taken on Android'); assert(Platform.isAndroid, 'Screenshots need to be taken on Android');
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
final account = Account(
serverURL: 'http://10.0.2.2', late Account account;
username: 'demo',
password: 'demo',
);
setUpAll(() async { setUpAll(() async {
account = await getAccount('demo');
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
}); });
@ -270,11 +286,7 @@ Future main() async {
}); });
testWidgets('notifications', (final tester) async { testWidgets('notifications', (final tester) async {
await Account( await (await getAccount('admin')).client.notifications.sendAdminNotification(
serverURL: 'http://10.0.2.2',
username: 'admin',
password: 'admin',
).client.notifications.sendAdminNotification(
userId: account.username, userId: account.username,
shortMessage: 'Notifications demo', shortMessage: 'Notifications demo',
longMessage: 'This is a notifications demo of the Neon app', longMessage: 'This is a notifications demo of the Neon app',

Loading…
Cancel
Save