test: remove redundant coverage and shorten timers

This commit is contained in:
edde746
2026-07-13 02:15:03 +02:00
parent c4e9fa1650
commit e6e7d8cdfd
63 changed files with 90 additions and 1760 deletions
-4
View File
@@ -23,10 +23,6 @@ void main() {
expect(resolveActiveClientScopeId(serverId: serverId, cacheServerId: 'other-machine/user-a'), isNull);
});
test('resolves a compound user scope', () {
expect(resolveActiveClientScopeId(serverId: serverId, cacheServerId: 'jf-machine/user-a'), 'jf-machine/user-a');
});
test('keeps users on the same server in distinct active scopes', () {
expect(resolveActiveClientScopeId(serverId: serverId, cacheServerId: 'jf-machine/user-a'), 'jf-machine/user-a');
expect(resolveActiveClientScopeId(serverId: serverId, cacheServerId: 'jf-machine/user-b'), 'jf-machine/user-b');
-15
View File
@@ -7,21 +7,6 @@ class _IntNotifier extends BaseNotifier<int> {}
void main() {
group('BaseNotifier', () {
test('single listener receives events', () async {
final n = _IntNotifier();
final received = <int>[];
final sub = n.stream.listen(received.add);
n.notify(1);
n.notify(2);
n.notify(3);
await Future<void>.delayed(Duration.zero);
expect(received, [1, 2, 3]);
await sub.cancel();
n.dispose();
});
test('broadcasts to multiple listeners', () async {
final n = _IntNotifier();
final a = <int>[];
-15
View File
@@ -40,21 +40,6 @@ void main() {
expect(CodecUtils.getSubtitleExtension('dvb_subtitle'), 'sub');
});
test('every image subtitle codec maps to a non-srt extension', () {
for (final codec in [
'pgs',
'pgssub',
'hdmv_pgs_subtitle',
'dvd_subtitle',
'dvdsub',
'vobsub',
'dvb_sub',
'dvb_subtitle',
]) {
expect(CodecUtils.getSubtitleExtension(codec), isNot('srt'), reason: codec);
}
});
test('defaults to srt for unknown codec', () {
expect(CodecUtils.getSubtitleExtension('weirdcodec'), 'srt');
expect(CodecUtils.getSubtitleExtension(''), 'srt');
@@ -2,18 +2,6 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:plezy/utils/external_ids.dart';
void main() {
group('ExternalIds.intersects with Plex Guid arrays', () {
test('verifies a raw Plex Guid array against target ids', () {
final candidate = ExternalIds.fromGuids(const [
{'id': 'imdb://tt15398776'},
{'id': 'tmdb://872585'},
{'id': 'tvdb://287533'},
]);
expect(const ExternalIds(tmdb: 872585).intersects(candidate), isTrue);
expect(const ExternalIds(imdb: 'tt0000001').intersects(candidate), isFalse);
});
});
group('ExternalIds.intersects', () {
test('matches when any shared id form is equal', () {
const trakt = ExternalIds(imdb: 'tt0133093', tmdb: 603);
-6
View File
@@ -175,11 +175,5 @@ void main() {
expect(formatFullDate('not-a-date'), 'not-a-date');
expect(formatFullDate(''), '');
});
test('does not throw for a valid ISO date', () {
// DateFormat may fall back to raw input if intl date symbols aren't
// initialised in the test runner — just verify no crash and string output.
expect(formatFullDate('2024-01-15'), isA<String>());
});
});
}
-14
View File
@@ -11,10 +11,6 @@ void main() {
test('allows empty ratingKey', () {
expect(buildGlobalKey(ServerId('server'), ''), 'server:');
});
test('rejects empty serverId', () {
expect(() => ServerId(''), throwsArgumentError);
});
});
group('parseGlobalKey', () {
@@ -48,14 +44,4 @@ void main() {
expect(result.ratingKey, '');
});
});
test('round-trip build → parse returns original components', () {
for (final pair in const [('s1', '42'), ('serverXYZ', '/library/metadata/123'), ('s', '')]) {
final built = buildGlobalKey(ServerId(pair.$1), pair.$2);
final parsed = parseGlobalKey(built);
expect(parsed, isNotNull);
expect(parsed!.serverId, pair.$1);
expect(parsed.ratingKey, pair.$2);
}
});
}
-24
View File
@@ -3,7 +3,6 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:plezy/services/settings_service.dart' show LibraryDensity;
import 'package:plezy/utils/grid_size_calculator.dart';
import 'package:plezy/utils/layout_constants.dart';
/// Column count the stock [SliverGridDelegateWithMaxCrossAxisExtent] renders for
/// [crossAxisExtent]. This is the source of truth that the navigation column
@@ -39,13 +38,6 @@ void main() {
group('GridSizeCalculator.getColumnCount', () {
// crossAxisSpacing is 0 in the current layout constants, so the formula
// reduces to ceil(crossAxisExtent / maxCrossAxisExtent).
test('returns 1 when extent equals maxCrossAxisExtent', () {
expect(GridSizeCalculator.getColumnCount(200, 200), 1);
});
test('returns 2 when extent slightly exceeds maxCrossAxisExtent', () {
expect(GridSizeCalculator.getColumnCount(201, 200), 2);
});
test('rounds up partial columns', () {
// 600 / 200 = 3 exactly
@@ -63,15 +55,6 @@ void main() {
// 100000 / 100 = 1000 -> clamped to 100
expect(GridSizeCalculator.getColumnCount(100000, 100), 100);
});
test('uses GridLayoutConstants.crossAxisSpacing in the formula', () {
// The formula adds crossAxisSpacing to the denominator only (matching the
// stock grid delegate), and that constant is currently 0. If it ever
// becomes non-zero, this test forces a rethink.
expect(GridLayoutConstants.crossAxisSpacing, 0);
// Identity-ish: extent = max -> 1 column.
expect(GridSizeCalculator.getColumnCount(200, 200), 1);
});
});
group('GridSizeCalculator.getColumnCount matches the rendered grid', () {
@@ -93,13 +76,6 @@ void main() {
}
});
}
test('regression: #1288 diagonal case (200px cells, 8px spacing, 1040px wide)', () {
// The old formula gave ceil((1040 + 8) / 208) = 6, but the grid renders
// ceil(1040 / 208) = 5, so "down" jumped a column right. Must be 5.
expect(GridSizeCalculator.getColumnCount(1040, 200, crossAxisSpacing: 8), 5);
expect(_renderedColumnCount(1040, 200, 8), 5);
});
});
group('GridSizeCalculator.isFirstRow / isFirstColumn', () {
-12
View File
@@ -57,17 +57,5 @@ void main() {
expect(ScreenBreakpoints.desktop, 1200);
expect(ScreenBreakpoints.largeDesktop, 1600);
});
test('partitioning: every width matches exactly one of mobile/tablet/desktop/largeDesktop', () {
for (final w in const [0.0, 300, 599.9, 600, 899.9, 1199.9, 1200, 1599.9, 1600, 2500]) {
final matches = [
ScreenBreakpoints.isMobile(w.toDouble()),
ScreenBreakpoints.isTablet(w.toDouble()) && !ScreenBreakpoints.isDesktopOrLarger(w.toDouble()),
ScreenBreakpoints.isDesktop(w.toDouble()),
ScreenBreakpoints.isLargeDesktop(w.toDouble()),
].where((b) => b).length;
expect(matches, 1, reason: 'width $w should match exactly one tier');
}
});
});
}
-12
View File
@@ -93,18 +93,6 @@ void main() {
expect(url, contains('h=240'));
});
test('near-minimum slots request a sized transcode', () {
final url = MediaImageHelper.getOptimizedImageUrl(
client: client,
thumbPath: '/library/metadata/1/thumb/2',
maxWidth: 96,
maxHeight: 144,
devicePixelRatio: 1,
);
expect(url, startsWith('sized:'));
});
test('regular slots request DPR-scaled dimensions', () {
final url = MediaImageHelper.getOptimizedImageUrl(
client: client,
@@ -143,23 +143,6 @@ void main() {
);
});
test('preserves 500 status and raw body when JSON decoding fails', () async {
final client = MediaServerHttpClient(
baseUrl: 'https://example.test',
client: MockClient((_) async => http.Response('{bad json', 500, headers: {'content-type': 'application/json'})),
);
addTearDown(client.close);
await expectLater(
client.get('/System/Info'),
throwsA(
isA<MediaServerHttpException>()
.having((e) => e.statusCode, 'statusCode', 500)
.having((e) => e.responseData, 'responseData', '{bad json'),
),
);
});
test('preserves 200 status when successful JSON response is malformed', () async {
final client = MediaServerHttpClient(
baseUrl: 'https://example.test',
-22
View File
@@ -91,17 +91,6 @@ void main() {
);
});
test('uses native seek near the start of a buffer range', () {
expect(
resolvePlexTranscodeSeekAction(
currentPosition: const Duration(seconds: 30),
target: const Duration(milliseconds: 29500),
bufferRanges: const [BufferRange(start: Duration(seconds: 30), end: Duration(seconds: 50))],
),
PlexTranscodeSeekAction.nativeSeek,
);
});
test('restarts near the tail of a buffer range to avoid optimistic cache edges', () {
expect(
resolvePlexTranscodeSeekAction(
@@ -152,17 +141,6 @@ void main() {
);
});
test('does not treat a flat buffer end as a local seekable range', () {
expect(
resolvePlexTranscodeSeekAction(
currentPosition: const Duration(seconds: 30),
target: const Duration(seconds: 45),
bufferRanges: const [],
),
PlexTranscodeSeekAction.restartTranscode,
);
});
test('restarts large seeks when no buffer information exists', () {
expect(
resolvePlexTranscodeSeekAction(
-5
View File
@@ -59,11 +59,6 @@ void main() {
expect(info!.assetPath, 'assets/rating_icons/imdb.svg');
expect(info.formattedValue, '7.5');
});
test('formats to one decimal (truncation follows toStringAsFixed semantics)', () {
final info = parseRatingImage('imdb://title', 7.25);
expect(info!.formattedValue, anyOf('7.2', '7.3'));
});
});
group('parseRatingImage - TMDB', () {