diff --git a/lib/screens/channel/video/video_store.dart b/lib/screens/channel/video/video_store.dart index c9b2aaae..a91fe6d2 100644 --- a/lib/screens/channel/video/video_store.dart +++ b/lib/screens/channel/video/video_store.dart @@ -782,7 +782,7 @@ abstract class VideoStoreBase with Store { // Convert to abbreviated unit: "4.69 sec." -> "4.69s" const match = latencyText.match(/([0-9.]+)\s*sec/i); if (match) { - latencyText = Math.round(parseFloat(match[1])) + 's'; + latencyText = parseFloat(match[1]).toFixed(2) + 's'; this.hasInitialLatency = true; } diff --git a/test/screens/channel/video/video_store_latency_js_test.dart b/test/screens/channel/video/video_store_latency_js_test.dart new file mode 100644 index 00000000..67cb7bf8 --- /dev/null +++ b/test/screens/channel/video/video_store_latency_js_test.dart @@ -0,0 +1,17 @@ +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test( + 'webview latency tracker keeps two decimal places in overlay labels', + () { + final source = File( + 'lib/screens/channel/video/video_store.dart', + ).readAsStringSync(); + + expect(source, contains("parseFloat(match[1]).toFixed(2) + 's'")); + expect(source, isNot(contains("Math.round(parseFloat(match[1])) + 's'"))); + }, + ); +}