Update tests for previewers

This commit is contained in:
Ankit Mahato
2024-04-10 10:17:23 +05:30
parent c5bfd168d9
commit 0ae20e3233
2 changed files with 28 additions and 20 deletions

View File

@ -11,6 +11,9 @@ import '../test_consts.dart';
void main() {
Uint8List bytes1 = Uint8List.fromList([20, 8]);
testWidgets('Testing when type/subtype is application/pdf', (tester) async {
String expected =
"We encountered an error rendering this pdf.\nPlease raise an issue in API Dash GitHub repo so that we can look into this issue.";
await tester.pumpWidget(
MaterialApp(
title: 'Previewer',
@ -25,10 +28,7 @@ void main() {
),
);
expect(
find.text(
"${kMimeTypeRaiseIssueStart}application/pdf$kMimeTypeRaiseIssue"),
findsNothing);
expect(find.text(expected), findsNothing);
expect(find.byType(PdfPreview), findsOneWidget);
});
@ -68,6 +68,9 @@ void main() {
});
testWidgets('Testing when type/subtype is model/step+xml', (tester) async {
String expected =
"Please click on 'Raw' to view the unformatted raw results as we encountered an error rendering this Content-Type model/step+xml.\nPlease raise an issue in API Dash GitHub repo so that we can look into this issue.";
await tester.pumpWidget(
MaterialApp(
title: 'Previewer',
@ -77,15 +80,13 @@ void main() {
subtype: 'step+xml',
bytes: bytes1,
body: "",
hasRaw: true,
),
),
),
);
expect(
find.text(
"${kMimeTypeRaiseIssueStart}model/step+xml$kMimeTypeRaiseIssue"),
findsOneWidget);
expect(find.text(expected), findsOneWidget);
});
testWidgets('Testing when type/subtype is image/jpeg', (tester) async {
@ -110,6 +111,8 @@ void main() {
testWidgets('Testing when type/subtype is image/jpeg corrupted',
(tester) async {
String expected =
"We encountered an error rendering this image.\nPlease raise an issue in API Dash GitHub repo so that we can look into this issue.";
Uint8List bytesJpegCorrupt = Uint8List.fromList([
255,
216,
@ -145,11 +148,13 @@ void main() {
),
);
await tester.pumpAndSettle();
expect(find.text(kImageError), findsOneWidget);
expect(find.text(expected), findsOneWidget);
});
testWidgets('Testing when type/subtype is audio/mpeg corrupted',
(tester) async {
String expected =
"We encountered an error rendering this audio.\nPlease raise an issue in API Dash GitHub repo so that we can look into this issue.";
Uint8List bytesAudioCorrupt =
Uint8List.fromList(List.generate(100, (index) => index));
await tester.pumpWidget(
@ -166,10 +171,12 @@ void main() {
),
);
await tester.pumpAndSettle();
expect(find.text(kAudioError), findsOneWidget);
expect(find.text(expected), findsOneWidget);
});
testWidgets('Testing when type/subtype is image/svg+xml', (tester) async {
String expected =
"Please click on 'Raw' to view the unformatted raw results as we encountered an error rendering this svg.\nPlease raise an issue in API Dash GitHub repo so that we can look into this issue.";
String rawSvg =
"""<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 166 202">
<defs>
@ -206,12 +213,14 @@ void main() {
),
);
await tester.pumpAndSettle();
expect(find.text(kSvgError), findsNothing);
expect(find.text(expected), findsNothing);
expect(find.byType(SvgPicture), findsOneWidget);
});
testWidgets('Testing when type/subtype is image/svg+xml corrupted',
(tester) async {
String expected =
"Please click on 'Raw' to view the unformatted raw results as we encountered an error rendering this svg.\nPlease raise an issue in API Dash GitHub repo so that we can look into this issue.";
String rawSvg = "rwsjhdws";
await tester.pumpWidget(
MaterialApp(
@ -227,7 +236,7 @@ void main() {
),
);
await tester.pumpAndSettle();
expect(find.text(kSvgError), findsOneWidget);
expect(find.text(expected), findsOneWidget);
});
testWidgets('Testing when type/subtype is text/csv', (tester) async {