mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
fix(mobile): retry diagnostics teardown
Co-authored-by: npub1ft62tztwwm2x9xamk25smmuaj4sfckdkldksruf2x2jwqalffkrq0g7arr <4af4a5896e76d4629bbbb2a90def9d95609c59b6fb6d01f12a32a4e077e94d86@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub1ft62tztwwm2x9xamk25smmuaj4sfckdkldksruf2x2jwqalffkrq0g7arr <4af4a5896e76d4629bbbb2a90def9d95609c59b6fb6d01f12a32a4e077e94d86@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
parent
a072957adb
commit
e73f3c2288
@@ -61,6 +61,12 @@ class DiagnosticsController extends ChangeNotifier {
|
||||
Future<void> setConsent(bool granted) {
|
||||
return _serialize(() async {
|
||||
if (_consentGranted == granted) {
|
||||
// A failed close keeps the runtime initialized even though the
|
||||
// persisted preference and visible control are already off. Allow the
|
||||
// same revocation to retry teardown until it succeeds.
|
||||
if (!granted && _initialized) {
|
||||
await _applyCurrentConsent();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ void main() {
|
||||
expect(reporter.initializeCalls, 1);
|
||||
});
|
||||
|
||||
test('close failure preserves persisted revocation', () async {
|
||||
test('close failure preserves revocation and retries teardown', () async {
|
||||
final controller = await createController(
|
||||
storedValues: {diagnosticsConsentPreferenceKey: true},
|
||||
);
|
||||
@@ -219,6 +219,17 @@ void main() {
|
||||
expect(controller.consentGranted, isFalse);
|
||||
expect(preferences.getBool(diagnosticsConsentPreferenceKey), isFalse);
|
||||
expect(reporter.closeCalls, 1);
|
||||
|
||||
reporter.closeError = null;
|
||||
await controller.setConsent(false);
|
||||
|
||||
expect(controller.consentGranted, isFalse);
|
||||
expect(preferences.getBool(diagnosticsConsentPreferenceKey), isFalse);
|
||||
expect(reporter.closeCalls, 2);
|
||||
expect(
|
||||
logs,
|
||||
contains('Diagnostics disabled: user consent is off; Sentry closed.'),
|
||||
);
|
||||
});
|
||||
|
||||
test('continues accepting changes after a failed operation', () async {
|
||||
|
||||
Reference in New Issue
Block a user