mirror of
https://github.com/block/buzz.git
synced 2026-11-30 21:21:48 +00:00
Keep notification settings as a separate card with a single “Notifications” toggle. Remove the section heading, bell, all subtitles (including permission/capability and pending opt-out messages), and the iOS settings button. Toggle callbacks, capability visibility, persisted opt-in/out, and relay synchronization are unchanged. The disable failure is being investigated separately. This intentionally removes the pending warning rather than claiming to fix synchronization. Tom explicitly requested removal of the immediate opt-out synchronization warning and all other status text; this is an intentional exception to the pending-feedback guidance in VISION_MOBILE.md. [Codex’s finding is answered against that agreed scope](https://github.com/block/buzz/pull/8199#discussion_r4225426842). No new tests. Delete tests for the removed permission/settings UI and remove obsolete display assertions from existing recovery tests while preserving their opt-out synchronization coverage. Closest related issue: [#7826](https://github.com/block/buzz/issues/7826). No duplicate cleanup PR found. ### Validation Mobile formatting/static analysis passed. The full existing mobile suite passed (3,216 tests; 4 skipped), plus the three unconfigured-build tests and gateway recipe checks. Existing opt-out recovery tests exercised the switch, persisted tombstone, snapshot synchronization, and successful relay retry. Before/after renders use the existing Flutter widget fixture with synthetic data and mocked native navigation. No simulator or TestFlight run was performed. After merge, validate the settings row and on/off flow in the next iOS candidate; remote disable failure remains a separate investigation. GitHub CI also passed the mobile tests, unconfigured-build tests, and gateway recipe checks. The [security review](https://github.com/block/buzz/actions/runs/37863885299) completed successfully. The [Android build](https://github.com/block/buzz/actions/runs/37863554077/job/113605025305) passed. The iOS simulator build, native accessibility checks, and unsigned iOS release build passed. [All required CI checks](https://github.com/block/buzz/actions/runs/37863554077) are green. ### Before and after Headless Flutter widget fixture, with synthetic data and mocked native navigation. | Before | After | | --- | --- | |  |  | Signed-off-by: Tom Brow <tomb@block.xyz>
152 lines
5.8 KiB
Dart
152 lines
5.8 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:buzz/features/settings/settings_page.dart';
|
|
import 'package:buzz/shared/auth/auth_provider.dart';
|
|
import 'package:buzz/shared/community/community.dart';
|
|
import 'package:buzz/shared/community/community_provider.dart';
|
|
import 'package:buzz/shared/community/community_storage.dart';
|
|
import 'package:buzz/shared/push/dev_push_lease.dart';
|
|
import 'package:buzz/shared/push/push_bridge.dart';
|
|
import 'package:buzz/shared/push/push_relay_capability_provider.dart';
|
|
import 'package:buzz/shared/push/push_subscription.dart';
|
|
import 'package:buzz/shared/relay/app_lifecycle_provider.dart';
|
|
import 'package:buzz/shared/theme/theme.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import '../../shared/community/community_storage_test.dart';
|
|
|
|
void main() {
|
|
for (final outcome in ['loading', 'absent', 'error']) {
|
|
testWidgets('enabled community can turn push off with $outcome capability', (
|
|
tester,
|
|
) async {
|
|
tester.view.physicalSize = const Size(430, 1800);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
|
addTearDown(() => debugDefaultTargetPlatformOverride = null);
|
|
PackageInfo.setMockInitialValues(
|
|
appName: 'Buzz',
|
|
packageName: 'buzz',
|
|
version: '1.0.0',
|
|
buildNumber: '1',
|
|
buildSignature: '',
|
|
);
|
|
SharedPreferences.setMockInitialValues({});
|
|
final prefs = await SharedPreferences.getInstance();
|
|
final storage = CommunityStorage(secure: FakeSecureStorage());
|
|
final subscriptions = [
|
|
BuzzPushSubscription(
|
|
filter: BuzzPushFilter(kinds: const [9], pTags: ['a' * 64]),
|
|
notificationClass: 'default',
|
|
),
|
|
];
|
|
final community =
|
|
Community.create(
|
|
name: 'Team',
|
|
relayUrl: 'https://relay.example',
|
|
).copyWith(
|
|
pushNotificationsEnabled: true,
|
|
pushSubscriptionState: BuzzPushLeaseSubscriptionState.desired(
|
|
desired: subscriptions,
|
|
).withAccepted(subscriptions: subscriptions, generation: 7),
|
|
);
|
|
await storage.save(community);
|
|
await storage.saveActiveId(community.id);
|
|
final pending = Completer<BuzzPushLeaseDescriptor?>();
|
|
final snapshots = <List<Community>>[];
|
|
final tombstones = <int?>[];
|
|
var relayAvailable = false;
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
overrides: [
|
|
savedPrefsProvider.overrideWithValue(prefs),
|
|
authProvider.overrideWith(_Auth.new),
|
|
communityStorageProvider.overrideWithValue(storage),
|
|
communitySnapshotWriterProvider.overrideWithValue((
|
|
communities,
|
|
) async {
|
|
snapshots.add(List.of(communities));
|
|
}),
|
|
communityPushLeaseDeactivatorProvider.overrideWithValue((
|
|
community, {
|
|
generation,
|
|
}) async {
|
|
tombstones.add(generation);
|
|
if (!relayAvailable) throw StateError('relay unavailable');
|
|
}),
|
|
currentRelayPushDescriptorProvider.overrideWith((ref) {
|
|
if (outcome == 'loading') return pending.future;
|
|
if (outcome == 'error') throw StateError('discovery failed');
|
|
return Future.value(null);
|
|
}),
|
|
appLifecycleProvider.overrideWith(_Lifecycle.new),
|
|
buzzPushAuthorizationStatusReaderProvider.overrideWithValue(
|
|
() async => BuzzPushAuthorizationStatus.denied,
|
|
),
|
|
],
|
|
child: MaterialApp(
|
|
theme: AppTheme.light(),
|
|
home: SettingsPage(
|
|
profileHeader: const SizedBox.shrink(),
|
|
identityRecoveryPageBuilder: (_) => const SizedBox.shrink(),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
final container = ProviderScope.containerOf(
|
|
tester.element(find.byType(SettingsPage)),
|
|
);
|
|
expect(
|
|
container.read(activeCommunityProvider).value?.pushNotificationsEnabled,
|
|
isTrue,
|
|
reason:
|
|
'${container.read(activeCommunityProvider)} / ${container.read(communityListProvider)}',
|
|
);
|
|
expect(tester.widget<Switch>(find.byType(Switch)).value, isTrue);
|
|
await tester.tap(find.byType(Switch));
|
|
await tester.pumpAndSettle();
|
|
final stored = (await storage.loadAll()).single;
|
|
expect(stored.pushNotificationsEnabled, isFalse);
|
|
expect(stored.pushSubscriptionState.pendingTombstoneGeneration, 8);
|
|
expect(tombstones, [8]);
|
|
expect(snapshots.last.single.pushNotificationsEnabled, isFalse);
|
|
final offSwitch = tester.widget<Switch>(find.byType(Switch));
|
|
expect(offSwitch.value, isFalse);
|
|
expect(offSwitch.onChanged, isNull);
|
|
relayAvailable = true;
|
|
await container
|
|
.read(communityListProvider.notifier)
|
|
.retryPendingPushLeaseTombstone(community.id);
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
(await storage.loadAll())
|
|
.single
|
|
.pushSubscriptionState
|
|
.pendingTombstoneGeneration,
|
|
isNull,
|
|
);
|
|
expect(find.text('Notifications'), findsNothing);
|
|
expect(tester.takeException(), isNull);
|
|
debugDefaultTargetPlatformOverride = null;
|
|
});
|
|
}
|
|
}
|
|
|
|
class _Lifecycle extends AppLifecycleNotifier {
|
|
@override
|
|
AppLifecycleState build() => AppLifecycleState.resumed;
|
|
}
|
|
|
|
class _Auth extends AuthNotifier {
|
|
@override
|
|
Future<AuthState> build() async =>
|
|
const AuthState(status: AuthStatus.unauthenticated);
|
|
}
|