Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from deprecated uni_links to app_links package #2708

Closed

Conversation

may-tas
Copy link
Contributor

@may-tas may-tas commented Jan 16, 2025

What kind of change does this PR introduce?

  • This PR migrates our deep linking implementation from the deprecated uni_links package to the actively maintained app_links package.

Issue Number:

Did you add tests for your changes?

  • Yes

  • Tests are written for all changes made in this PR.

  • Test coverage meets or exceeds the current coverage (~90/95%).

Summary

  • Updated pubspec.yaml dependencies
  • Refactored deep link handlers to use app_links API
  • Maintained existing deep linking behavior and user flow
  • No changes to Android/iOS configurations required

Does this PR introduce a breaking change?

  • No

Checklist for Repository Standards

  • Have you reviewed and implemented all applicable coderaabbitai review suggestions?
  • Have you ensured that the PR aligns with the repository’s contribution guidelines?

Have you read the contributing guide?

  • Yes

Summary by CodeRabbit

  • Dependencies

    • Updated SDK version compatibility
    • Replaced uni_links package with app_links
    • Added new dependencies: video_player_android and win32
  • Deep Link Handling

    • Migrated deep link functionality to use app_links package
    • Updated URI link stream and initial link retrieval methods
  • Testing

    • Updated test cases to support new deep link package
    • Enhanced test coverage for splash screen URI handling

Copy link
Contributor

coderabbitai bot commented Jan 16, 2025

Walkthrough

This pull request focuses on migrating the deep linking functionality from the discontinued uni_links package to the actively maintained app_links package. The changes involve updating the splash_screen.dart file to use the new package, modifying the pubspec.yaml to update dependencies and SDK constraints, and corresponding updates to the test file to ensure compatibility with the new deep linking implementation.

Changes

File Change Summary
lib/splash_screen.dart Replaced uni_links import with app_links, updated URI handling method to use AppLinks class
pubspec.yaml Updated SDK version to >=2.17.0 <=3.6.0, removed uni_links dependencies, added app_links, app_links_platform_interface, video_player_android, and win32 packages
test/widget_tests/pre_auth_screens/splash_screen_test.dart Updated import to app_links, modified test cases to use AppLinks instance

Sequence Diagram

sequenceDiagram
    participant App
    participant AppLinks
    participant URIHandler
    
    App->>AppLinks: Create AppLinks instance
    App->>AppLinks: Get initial link
    AppLinks-->>App: Return initial URI
    App->>URIHandler: Process initial URI
    App->>AppLinks: Listen to URI link stream
    AppLinks-->>App: Notify of new URIs
Loading

Assessment against linked issues

Objective Addressed Explanation
Migrate from uni_links to app_links [#2706]
Update dependencies in pubspec.yaml [#2706]
Modify deep linking code to use new package [#2706]

Possibly related PRs

Suggested labels

ignore-sensitive-files-pr

Suggested reviewers

  • noman2002

Poem

🐰 Deep links dance, a package's new song,
From uni_links to app_links, we've moved along!
Migrations spark joy, code leaps with grace,
Updating our path at a rabbit's swift pace! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Our Pull Request Approval Process

Thanks for contributing!

Testing Your Code

Remember, your PRs won't be reviewed until these criteria are met:

  1. We don't merge PRs with poor code quality.
    1. Follow coding best practices such that CodeRabbit.ai approves your PR.
  2. We don't merge PRs with failed tests.
    1. When tests fail, click on the Details link to learn more.
    2. Write sufficient tests for your changes (CodeCov Patch Test). Your testing level must be better than the target threshold of the repository
    3. Tests may fail if you edit sensitive files. Ask to add the ignore-sensitive-files-pr label if the edits are necessary.
  3. We cannot merge PRs with conflicting files. These must be fixed.

Our policies make our code better.

Reviewers

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

Other

🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🔭 Outside diff range comments (1)
test/widget_tests/pre_auth_screens/splash_screen_test.dart (1)

Line range hint 231-310: Restructure test cases for better organization.

The test cases should be:

  1. Organized within descriptive test groups
  2. Have clear test names
  3. Use proper setUp and tearDown

Would you like me to provide a complete restructured version of these test cases?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b237153 and e33f13c.

⛔ Files ignored due to path filters (1)
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • lib/splash_screen.dart (3 hunks)
  • pubspec.yaml (2 hunks)
  • test/widget_tests/pre_auth_screens/splash_screen_test.dart (4 hunks)
🧰 Additional context used
🪛 GitHub Actions: PR Workflow
pubspec.yaml

[error] Unauthorized modification or deletion of sensitive file. Apply 'ignore-sensitive-files-pr' label to override.

🔇 Additional comments (6)
pubspec.yaml (3)

13-13: LGTM: SDK version update is reasonable.

The SDK version update to ">=2.17.0 <=3.6.0" allows for newer Dart versions while maintaining backward compatibility.

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Unauthorized modification or deletion of sensitive file. Apply 'ignore-sensitive-files-pr' label to override.


21-22: LGTM: Core package migration looks good.

The replacement of uni_links with app_links and its platform interface is aligned with the PR objective.

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Unauthorized modification or deletion of sensitive file. Apply 'ignore-sensitive-files-pr' label to override.


Line range hint 1-120: Address pipeline failure for sensitive file modification.

The pipeline indicates unauthorized modification of a sensitive file. Please request the 'ignore-sensitive-files-pr' label from repository maintainers to proceed.

✅ Verification successful

Sensitive file modification confirmed - 'ignore-sensitive-files-pr' label required

The verification confirms that pubspec.yaml is indeed a protected sensitive file. The pipeline correctly enforces this protection. Request the 'ignore-sensitive-files-pr' label from repository maintainers to proceed with the changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if pubspec.yaml is marked as sensitive
gh api repos/:owner/:repo/contents/.github/sensitive-files.txt --raw | grep -q "pubspec.yaml" && echo "pubspec.yaml is marked as sensitive"

Length of output: 1457


Script:

#!/bin/bash
# Check multiple potential locations for sensitive files configuration
echo "Checking .github directory for sensitive files configuration..."
fd -t f "sensitive.*\.(txt|ya?ml|json)$" .github/

echo -e "\nSearching for files containing 'pubspec.yaml' as sensitive..."
rg -l "pubspec\.ya?ml" .github/ || true

echo -e "\nChecking workflow files for sensitive file patterns..."
fd -e yml -e yaml . .github/workflows/ --exec cat {} \; | rg "sensitive.*files?" -C 2 || true

Length of output: 1774


Script:

#!/bin/bash
# Extract the sensitive files check implementation
echo "Checking pull-request.yml for sensitive files definition..."
rg -A 10 "Check-Sensitive-Files" .github/workflows/pull-request.yml

Length of output: 664


Script:

#!/bin/bash
# Get the complete workflow file content
echo "Getting complete pull-request.yml content..."
cat .github/workflows/pull-request.yml

Length of output: 11994

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Unauthorized modification or deletion of sensitive file. Apply 'ignore-sensitive-files-pr' label to override.

lib/splash_screen.dart (3)

46-47: LGTM: Clean initialization of AppLinks.

The AppLinks instance is properly initialized at the start of the method.


Line range hint 48-65: LGTM: Stream subscription handling looks good.

The implementation correctly:

  • Subscribes to URI link stream
  • Handles mounted state
  • Updates state appropriately
  • Handles errors

Line range hint 66-75: LGTM: Initial link handling is properly implemented.

The migration maintains the same error handling and state management while using the new app_links API.

Comment on lines +79 to +81
video_player_android: ^2.7.16
visibility_detector: ^0.4.0+2
win32: ^5.10.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove unrelated package additions.

The following packages seem unrelated to the uni_links to app_links migration:

  • video_player_android
  • win32

Please remove these additions or create a separate PR for them.

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Unauthorized modification or deletion of sensitive file. Apply 'ignore-sensitive-files-pr' label to override.

@@ -267,7 +267,7 @@ Future<void> testWidgets3(WidgetTester tester) async {

// Mock the uriLinkStream to emit a test URI
final testUri = Uri.parse("https://example.com");
uriLinkStream.any(testUri as bool Function(Uri? element));
appLinks.uriLinkStream.any(testUri as bool Function(Uri? element));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix stream and future mocking in tests.

The tests incorrectly use the real AppLinks instance. Mock the dependencies and their responses.

-appLinks.uriLinkStream.any(testUri as bool Function(Uri? element));
+when(mockAppLinks.uriLinkStream)
+    .thenAnswer((_) => Stream.fromIterable([testUri]));

-when(appLinks.getInitialLink()).thenAnswer((_) async => testUri);
+when(mockAppLinks.getInitialLink())
+    .thenAnswer((_) async => testUri);

Also applies to: 302-302

Comment on lines +231 to +238
final appLinks = AppLinks();
Future<void> testWidgets1(WidgetTester tester) async {
await tester.pumpWidget(createSplashScreenLight());
await tester.pumpAndSettle();

// Mock the uriLinkStream to emit a test URI
final testUri = Uri.parse("https://example.com");
uriLinkStream.any(testUri as bool Function(Uri? element));
appLinks.uriLinkStream.any(testUri as bool Function(Uri? element));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix incorrect stream testing implementation.

The current implementation has several issues:

  1. appLinks should be mocked
  2. Stream.any() is incorrectly used with a URI directly
  3. Test is not properly structured within a test group
-final appLinks = AppLinks();
+// Mock AppLinks
+final mockAppLinks = MockAppLinks();
+
+group('URI Link Handling', () {
+  setUp(() {
+    when(mockAppLinks.uriLinkStream)
+        .thenAnswer((_) => Stream.fromIterable([Uri.parse("https://example.com")]));
+  });
+
+  testWidgets('handles incoming URI correctly', (tester) async {
     // ... test implementation
+  });
+});

Committable suggestion skipped: line range outside the PR's diff.

@may-tas may-tas closed this Jan 16, 2025
@may-tas may-tas deleted the app-links branch January 16, 2025 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant