mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-02 16:20:57 +02:00
fix(extensions): resume metadata after verification
This commit is contained in:
@@ -24,6 +24,51 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'retries an extension operation after successful verification',
|
||||
() async {
|
||||
var operationCalls = 0;
|
||||
var verificationCalls = 0;
|
||||
|
||||
final result = await runExtensionOperationWithVerificationRetry(
|
||||
extensionId: 'qobuz-web',
|
||||
browserMode: 'in_app_first',
|
||||
operation: () async {
|
||||
operationCalls++;
|
||||
if (operationCalls == 1) throw Exception('VERIFY_REQUIRED');
|
||||
return 'artist metadata';
|
||||
},
|
||||
verify: () async {
|
||||
verificationCalls++;
|
||||
return true;
|
||||
},
|
||||
);
|
||||
|
||||
expect(result, 'artist metadata');
|
||||
expect(operationCalls, 2);
|
||||
expect(verificationCalls, 1);
|
||||
},
|
||||
);
|
||||
|
||||
test('does not retry when extension verification is not completed', () async {
|
||||
var operationCalls = 0;
|
||||
|
||||
await expectLater(
|
||||
runExtensionOperationWithVerificationRetry(
|
||||
extensionId: 'qobuz-web',
|
||||
browserMode: 'in_app_first',
|
||||
operation: () async {
|
||||
operationCalls++;
|
||||
throw Exception('VERIFY_REQUIRED');
|
||||
},
|
||||
verify: () async => false,
|
||||
),
|
||||
throwsA(isA<Exception>()),
|
||||
);
|
||||
|
||||
expect(operationCalls, 1);
|
||||
});
|
||||
|
||||
test('verification wait can be cancelled before foreground resume', () async {
|
||||
final foreground = Completer<void>();
|
||||
final cancellation = Completer<void>();
|
||||
|
||||
Reference in New Issue
Block a user