diff --git a/test/widgets/previewer_test.dart b/test/widgets/previewer_test.dart index c8a33f62..3a2cbb44 100644 --- a/test/widgets/previewer_test.dart +++ b/test/widgets/previewer_test.dart @@ -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 = """ @@ -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 { diff --git a/test/widgets/response_widgets_test.dart b/test/widgets/response_widgets_test.dart index c5617035..5f437ad1 100644 --- a/test/widgets/response_widgets_test.dart +++ b/test/widgets/response_widgets_test.dart @@ -286,6 +286,8 @@ void main() { }); testWidgets('Testing Response Body for No body view', (tester) async { + String expected = + "We encountered an error rendering this Content-Type application/octet-stream.\nPlease raise an issue in API Dash GitHub repo so that we can look into this issue."; ResponseModel responseModelOctet = ResponseModel( statusCode: statusCode, body: responseBody, @@ -307,10 +309,7 @@ void main() { ), ); //await Future.delayed(const Duration(seconds: 5)); - expect( - find.text( - "${kMimeTypeRaiseIssueStart}application/octet-stream$kMimeTypeRaiseIssue"), - findsOneWidget); + expect(find.text(expected), findsOneWidget); expect(find.byIcon(Icons.download), findsOneWidget); }); @@ -339,6 +338,9 @@ void main() { }); testWidgets('Testing Body Success for ResponseBodyView.none', (tester) async { + String expected = + "Please click on 'Raw' to view the unformatted raw results as we encountered an error rendering this Content-Type application/json.\nPlease raise an issue in API Dash GitHub repo so that we can look into this issue."; + await tester.pumpWidget( MaterialApp( title: 'Body Success', @@ -358,10 +360,7 @@ void main() { ); await tester.pumpAndSettle(); - expect( - find.text( - "${kMimeTypeRawRaiseIssueStart}application/json$kMimeTypeRaiseIssue"), - findsOneWidget); + expect(find.text(expected), findsOneWidget); expect(find.byIcon(Icons.download), findsOneWidget); });