From 9f10d789bdcfb039b7d4ae791d48231482f0ac02 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Tue, 19 Sep 2023 18:15:48 +0200 Subject: [PATCH] test(nextcloud): Add dashboard tests Signed-off-by: jld3103 --- packages/nextcloud/test/dashboard_test.dart | 44 +++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 packages/nextcloud/test/dashboard_test.dart diff --git a/packages/nextcloud/test/dashboard_test.dart b/packages/nextcloud/test/dashboard_test.dart new file mode 100644 index 00000000000..ef7b6801425 --- /dev/null +++ b/packages/nextcloud/test/dashboard_test.dart @@ -0,0 +1,44 @@ +import 'package:test/test.dart'; + +import 'helper.dart'; + +void main() { + group( + 'dashboard', + () { + late DockerImage image; + setUpAll(() async => image = await getDockerImage()); + + late DockerContainer container; + late TestNextcloudClient client; + setUp(() async { + container = await getDockerContainer(image); + client = await getTestClient(container); + }); + tearDown(() => container.destroy()); + + test('Get widgets', () async { + final response = await client.dashboard.dashboardApi.getWidgets(); + expect(response.ocs.data.keys, equals(['activity', 'notes', 'recommendations', 'user_status'])); + }); + + group('Get widget items', () { + test('v1', () async { + final response = await client.dashboard.dashboardApi.getWidgetItems(); + expect(response.ocs.data.keys, equals(['recommendations'])); + final items = response.ocs.data['recommendations']!; + expect(items, hasLength(7)); + }); + + test('v2', () async { + final response = await client.dashboard.dashboardApi.getWidgetItemsV2(); + expect(response.ocs.data.keys, equals(['recommendations'])); + final items = response.ocs.data['recommendations']!.items; + expect(items, hasLength(7)); + }); + }); + }, + retry: retryCount, + timeout: timeout, + ); +}