fix(extensions): resume metadata after verification

This commit is contained in:
zarzet
2026-08-27 13:08:44 +07:00
parent 9bbfee25d0
commit 47deb9f34e
4 changed files with 99 additions and 12 deletions
+45
View File
@@ -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>();