Browse Source

refactor(nextcloud): Group tests by tags

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/1053/head
jld3103 1 year ago
parent
commit
5c220df656
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 34
      packages/nextcloud/test/core_test.dart
  2. 13
      packages/nextcloud/test/notifications_test.dart
  3. 2
      packages/nextcloud/test/provisioning_api_test.dart
  4. 4
      packages/nextcloud/test/settings_test.dart
  5. 54
      packages/nextcloud/test/user_status_test.dart

34
packages/nextcloud/test/core_test.dart

@ -52,6 +52,7 @@ void main() {
expect(response.body.extendedSupport, isFalse); expect(response.body.extendedSupport, isFalse);
}); });
group('OCS', () {
test('Get capabilities', () async { test('Get capabilities', () async {
final response = await client.core.ocs.getCapabilities(); final response = await client.core.ocs.getCapabilities();
expect(response.statusCode, 200); expect(response.statusCode, 200);
@ -73,8 +74,10 @@ void main() {
expect(response.body.ocs.data.capabilities.userStatusCapabilities, isNotNull); expect(response.body.ocs.data.capabilities.userStatusCapabilities, isNotNull);
expect(response.body.ocs.data.capabilities.weatherStatusCapabilities, isNotNull); expect(response.body.ocs.data.capabilities.weatherStatusCapabilities, isNotNull);
}); });
});
test('Get navigation apps', () async { group('Navigation', () {
test('Get apps navigation', () async {
final response = await client.core.navigation.getAppsNavigation(); final response = await client.core.navigation.getAppsNavigation();
expect(response.statusCode, 200); expect(response.statusCode, 200);
expect(() => response.headers, isA<void>()); expect(() => response.headers, isA<void>());
@ -87,8 +90,10 @@ void main() {
expect(response.body.ocs.data[4].id, 'notes'); expect(response.body.ocs.data[4].id, 'notes');
expect(response.body.ocs.data[5].id, 'news'); expect(response.body.ocs.data[5].id, 'news');
}); });
});
test('Autocomplete', () async { group('Autocomplete', () {
test('Get', () async {
final response = await client.core.autoComplete.$get( final response = await client.core.autoComplete.$get(
search: '', search: '',
itemType: 'call', itemType: 'call',
@ -106,34 +111,42 @@ void main() {
expect(response.body.ocs.data[0].subline, ''); expect(response.body.ocs.data[0].subline, '');
expect(response.body.ocs.data[0].shareWithDisplayNameUnique, ''); expect(response.body.ocs.data[0].shareWithDisplayNameUnique, '');
}); });
});
test('Get preview', () async { group('Preview', () {
test('Get', () async {
final response = await client.core.preview.getPreview(file: 'Nextcloud.png'); final response = await client.core.preview.getPreview(file: 'Nextcloud.png');
expect(response.statusCode, 200); expect(response.statusCode, 200);
expect(() => response.headers, isA<void>()); expect(() => response.headers, isA<void>());
expect(response.body, isNotEmpty); expect(response.body, isNotEmpty);
}); });
});
test('Get avatar', () async { group('Avatar', () {
test('Get', () async {
final response = await client.core.avatar.getAvatar(userId: 'admin', size: 32); final response = await client.core.avatar.getAvatar(userId: 'admin', size: 32);
expect(response.body, isNotEmpty); expect(response.body, isNotEmpty);
}); });
test('Get dark avatar', () async { test('Get dark', () async {
final response = await client.core.avatar.getAvatarDark(userId: 'admin', size: 32); final response = await client.core.avatar.getAvatarDark(userId: 'admin', size: 32);
expect(response.body, isNotEmpty); expect(response.body, isNotEmpty);
}); });
});
test('Delete app password', () async { group('App password', () {
test('Delete', () async {
await client.core.appPassword.deleteAppPassword(); await client.core.appPassword.deleteAppPassword();
expect( expect(
() => client.core.appPassword.deleteAppPassword(), () => client.core.appPassword.deleteAppPassword(),
throwsA(predicate((final e) => (e! as DynamiteApiException).statusCode == 401)), throwsA(predicate((final e) => (e! as DynamiteApiException).statusCode == 401)),
); );
}); });
});
test('Unified search providers', () async { group('Unified search', () {
test('Get providers', () async {
final response = await client.core.unifiedSearch.getProviders(); final response = await client.core.unifiedSearch.getProviders();
expect(response.statusCode, 200); expect(response.statusCode, 200);
expect(() => response.headers, isA<void>()); expect(() => response.headers, isA<void>());
@ -141,7 +154,7 @@ void main() {
expect(response.body.ocs.data, hasLength(14)); expect(response.body.ocs.data, hasLength(14));
}); });
test('Unified search', () async { test('Search', () async {
final response = await client.core.unifiedSearch.search( final response = await client.core.unifiedSearch.search(
providerId: 'settings', providerId: 'settings',
term: 'Personal info', term: 'Personal info',
@ -161,8 +174,10 @@ void main() {
expect(response.body.ocs.data.entries.single.rounded, isFalse); expect(response.body.ocs.data.entries.single.rounded, isFalse);
expect(response.body.ocs.data.entries.single.attributes, isEmpty); expect(response.body.ocs.data.entries.single.attributes, isEmpty);
}); });
});
test('Client login flow V2', () async { group('Client login flow V2', () {
test('Init and poll', () async {
final response = await client.core.clientFlowLoginV2.init(); final response = await client.core.clientFlowLoginV2.init();
expect(response.statusCode, 200); expect(response.statusCode, 200);
expect(() => response.headers, isA<void>()); expect(() => response.headers, isA<void>());
@ -176,6 +191,7 @@ void main() {
throwsA(predicate<DynamiteApiException>((final e) => e.statusCode == 404)), throwsA(predicate<DynamiteApiException>((final e) => e.statusCode == 404)),
); );
}); });
});
}, },
retry: retryCount, retry: retryCount,
timeout: timeout, timeout: timeout,

13
packages/nextcloud/test/notifications_test.dart

@ -29,10 +29,13 @@ void main() {
); );
} }
group('API', () {
test('Send admin notification', () async { test('Send admin notification', () async {
await sendTestNotification(); await sendTestNotification();
}); });
});
group('Endpoint', () {
test('List notifications', () async { test('List notifications', () async {
await sendTestNotification(); await sendTestNotification();
@ -99,9 +102,7 @@ void main() {
}); });
}); });
group( group('Push', () {
'push notifications',
() {
late DockerImage image; late DockerImage image;
setUpAll(() async => image = await getDockerImage()); setUpAll(() async => image = await getDockerImage());
@ -139,8 +140,6 @@ void main() {
await client.notifications.push.removeDevice(); await client.notifications.push.removeDevice();
}); });
}, });
retry: retryCount, });
timeout: timeout,
);
} }

2
packages/nextcloud/test/provisioning_api_test.dart

@ -46,7 +46,7 @@ void main() {
}); });
group('Apps', () { group('Apps', () {
test('Get apps', () async { test('Get', () async {
final response = await client.provisioningApi.apps.getApps(); final response = await client.provisioningApi.apps.getApps();
expect(response.statusCode, 200); expect(response.statusCode, 200);
expect(() => response.headers, isA<void>()); expect(() => response.headers, isA<void>());

4
packages/nextcloud/test/settings_test.dart

@ -22,10 +22,12 @@ Future<void> run(final DockerImage image) async {
}); });
tearDown(() => container.destroy()); tearDown(() => container.destroy());
test('Download log file', () async { group('Logs', () {
test('Download', () async {
final response = await client.settings.logSettings.download(); final response = await client.settings.logSettings.download();
final logs = utf8.decode(response.body); final logs = utf8.decode(response.body);
expect(logs, await container.nextcloudLogs()); expect(logs, await container.nextcloudLogs());
}); });
}); });
});
} }

54
packages/nextcloud/test/user_status_test.dart

@ -18,7 +18,8 @@ void main() {
}); });
tearDown(() => container.destroy()); tearDown(() => container.destroy());
test('Find all predefined statuses', () async { group('Predefined status', () {
test('Find all', () async {
final expectedStatusIDs = ['meeting', 'commuting', 'remote-work', 'sick-leave', 'vacationing']; final expectedStatusIDs = ['meeting', 'commuting', 'remote-work', 'sick-leave', 'vacationing'];
final response = await client.userStatus.predefinedStatus.findAll(); final response = await client.userStatus.predefinedStatus.findAll();
expect(response.statusCode, 200); expect(response.statusCode, 200);
@ -51,8 +52,10 @@ void main() {
final vacationing = response.body.ocs.data.singleWhere((final s) => s.id == 'vacationing').clearAt; final vacationing = response.body.ocs.data.singleWhere((final s) => s.id == 'vacationing').clearAt;
expect(vacationing, null); expect(vacationing, null);
}); });
});
test('Set status', () async { group('User status', () {
test('Set', () async {
final response = await client.userStatus.userStatus.setStatus(statusType: 'online'); final response = await client.userStatus.userStatus.setStatus(statusType: 'online');
expect(response.statusCode, 200); expect(response.statusCode, 200);
expect(() => response.headers, isA<void>()); expect(() => response.headers, isA<void>());
@ -67,7 +70,7 @@ void main() {
expect(response.body.ocs.data.statusIsUserDefined, true); expect(response.body.ocs.data.statusIsUserDefined, true);
}); });
test('Get status', () async { test('Get', () async {
// There seems to be a bug in Nextcloud which makes getting the status fail before it has been set once. // There seems to be a bug in Nextcloud which makes getting the status fail before it has been set once.
// The error message from Nextcloud is "Could not create folder" // The error message from Nextcloud is "Could not create folder"
await client.userStatus.userStatus.setStatus(statusType: 'online'); await client.userStatus.userStatus.setStatus(statusType: 'online');
@ -86,26 +89,7 @@ void main() {
expect(response.body.ocs.data.statusIsUserDefined, true); expect(response.body.ocs.data.statusIsUserDefined, true);
}); });
test('Find all statuses', () async { test('Find', () async {
var response = await client.userStatus.statuses.findAll();
expect(response.statusCode, 200);
expect(() => response.headers, isA<void>());
expect(response.body.ocs.data, hasLength(0));
await client.userStatus.userStatus.setStatus(statusType: 'online');
response = await client.userStatus.statuses.findAll();
expect(response.statusCode, 200);
expect(() => response.headers, isA<void>());
expect(response.body.ocs.data, hasLength(1));
expect(response.body.ocs.data[0].userId, 'user1');
expect(response.body.ocs.data[0].message, null);
expect(response.body.ocs.data[0].icon, null);
expect(response.body.ocs.data[0].clearAt, null);
expect(response.body.ocs.data[0].status, 'online');
});
test('Find status', () async {
// Same as getting status // Same as getting status
await client.userStatus.userStatus.setStatus(statusType: 'online'); await client.userStatus.userStatus.setStatus(statusType: 'online');
@ -181,7 +165,30 @@ void main() {
expect(response.body.ocs.data.status, 'offline'); expect(response.body.ocs.data.status, 'offline');
expect(response.body.ocs.data.statusIsUserDefined, false); expect(response.body.ocs.data.statusIsUserDefined, false);
}); });
});
group('Statuses', () {
test('Find all', () async {
var response = await client.userStatus.statuses.findAll();
expect(response.statusCode, 200);
expect(() => response.headers, isA<void>());
expect(response.body.ocs.data, hasLength(0));
await client.userStatus.userStatus.setStatus(statusType: 'online');
response = await client.userStatus.statuses.findAll();
expect(response.statusCode, 200);
expect(() => response.headers, isA<void>());
expect(response.body.ocs.data, hasLength(1));
expect(response.body.ocs.data[0].userId, 'user1');
expect(response.body.ocs.data[0].message, null);
expect(response.body.ocs.data[0].icon, null);
expect(response.body.ocs.data[0].clearAt, null);
expect(response.body.ocs.data[0].status, 'online');
});
});
group('Heartbeat', () {
test('Heartbeat', () async { test('Heartbeat', () async {
final response = await client.userStatus.heartbeat.heartbeat(status: 'online'); final response = await client.userStatus.heartbeat.heartbeat(status: 'online');
expect(response.statusCode, 200); expect(response.statusCode, 200);
@ -196,6 +203,7 @@ void main() {
expect(response.body.ocs.data.status, 'online'); expect(response.body.ocs.data.status, 'online');
expect(response.body.ocs.data.statusIsUserDefined, false); expect(response.body.ocs.data.statusIsUserDefined, false);
}); });
});
}, },
retry: retryCount, retry: retryCount,
timeout: timeout, timeout: timeout,

Loading…
Cancel
Save