diff --git a/mobile/test/features/onboarding/community_link_input_test.dart b/mobile/test/features/onboarding/community_link_input_test.dart index 12d8c1f2df..ad783d9c65 100644 --- a/mobile/test/features/onboarding/community_link_input_test.dart +++ b/mobile/test/features/onboarding/community_link_input_test.dart @@ -4,24 +4,26 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('normalizes addresses through the existing community parser', () { - for (final value in [ - ' team.communities.buzz.xyz ', - 'https://team.communities.buzz.xyz/', - 'wss://team.communities.buzz.xyz', + for (final (value, relay) in [ + (' team.communities.buzz.xyz ', 'wss://team.communities.buzz.xyz'), + ('https://team.communities.buzz.xyz/', 'wss://team.communities.buzz.xyz'), + ('wss://team.communities.buzz.xyz', 'wss://team.communities.buzz.xyz'), + ('secondary.example', 'wss://secondary.example'), + ('relay.example.com:8443', 'wss://relay.example.com:8443'), ]) { final uri = parseCommunityLinkInput(value)!; final link = parseBuzzDeepLink(uri) as AddCommunityDeepLink; - expect(link.relayUrl, 'wss://team.communities.buzz.xyz'); + expect(link.relayUrl, relay, reason: value); } }); test('preserves the invite and its destination', () { final uri = parseCommunityLinkInput( - 'https://community.example.com/invite/abc123', + 'https://primary.example/invite/fixture', )!; final link = parseBuzzDeepLink(uri) as InviteDeepLink; - expect(link.code, 'abc123'); - expect(link.relayUrl, 'wss://community.example.com'); + expect(link.code, 'fixture'); + expect(link.relayUrl, 'wss://primary.example'); }); test('rejects unrelated actions and unsafe or incomplete addresses', () { @@ -29,9 +31,11 @@ void main() { '', 'not a link', 'http://community.example.com', + 'ws://secondary.example', 'https://user:secret@community.example.com', 'https://community.example.com/other', 'https://community.example.com/invite/', + 'https://primary.example/invite/fixture/', 'https://community.example.com#secret', 'https://community.example.com?token=secret', 'https://127.0.0.1', diff --git a/mobile/test/features/onboarding/onboarding_entry_routes_test.dart b/mobile/test/features/onboarding/onboarding_entry_routes_test.dart index 93bb638ce2..38053c5724 100644 --- a/mobile/test/features/onboarding/onboarding_entry_routes_test.dart +++ b/mobile/test/features/onboarding/onboarding_entry_routes_test.dart @@ -5,6 +5,8 @@ import 'dart:convert'; import 'package:buzz/features/channels/channel.dart'; import 'package:buzz/features/channels/channels_provider.dart'; +import 'package:buzz/features/invites/invite_join_provider.dart'; +import 'package:buzz/features/invites/invite_join_sheet.dart'; import 'package:buzz/features/onboarding/hosted_connect_page.dart'; import 'package:buzz/features/onboarding/self_hosted_entry_sheet.dart'; import 'package:buzz/hosted_app_gate.dart'; @@ -243,6 +245,25 @@ void main() { find.text('Enter a valid community address or invite link.'), findsOneWidget, ); + // A pasted invite-page link keeps its code through to the join sheet. + await tester.enterText( + find.byKey(const Key('community-link-input')).hitTestable(), + 'https://primary.example/invite/fixture', + ); + await tester.tap(find.text('Continue').hitTestable()); + await tester.pumpAndSettle(); + expect(find.byType(InviteJoinSheet), findsOneWidget); + expect( + find.descendant( + of: find.byType(InviteJoinSheet), + matching: find.text('primary.example'), + ), + findsOneWidget, + ); + expect(container.read(inviteJoinProvider).invite?.code, 'fixture'); + await tester.tap(find.text('Cancel').hitTestable()); + await tester.pumpAndSettle(); + expect(find.byType(InviteJoinSheet), findsNothing); // Drive the real deep-link dispatcher, sheet, service and auth persistence. await tester.enterText( find.byKey(const Key('community-link-input')).hitTestable(),