Skip to content

Conversation

@arhtudormorar
Copy link
Contributor

@arhtudormorar arhtudormorar commented Nov 26, 2025

Summary by CodeRabbit

  • Tests

    • Added comprehensive test coverage for authentication and transaction signing workflows.
    • Expanded mock server coverage for transaction-related operations.
    • Enhanced test environment compatibility across platforms.
  • Chores

    • Improved code coverage metrics to 87.98%.
    • Updated changelog with recent testing improvements.

✏️ Tip: You can customize this high-level summary in your review settings.

* Add integraiton test

* Passing

* Passing

* Update tests

* Update CHANGELOG

* Update CHANGELOG.md
* Passing

* Added IframeProviderStrategy tests

* Update CHANGELOG

* Update CHANGELOG.md
@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

This PR adds comprehensive unit test suites for ExtensionProviderStrategy and IframeProviderStrategy covering initialization, authentication, and transaction/message signing flows. It updates the mock server with a new transactions endpoint, adds test environment polyfills for setImmediate/clearImmediate compatibility, and updates the changelog and coverage metrics.

Changes

Cohort / File(s) Summary
Documentation & Metrics
CHANGELOG.md, coverage-total.json
Added two unreleased entries linking to provider strategy test PRs; updated test coverage badge from 85.10% to 87.98%
Mock Server Updates
src/__mocks__/server.ts
Added GET handler for /transactions/ppu/0 endpoint returning lastBlock, fast, and faster fields
Provider Strategy Tests
src/providers/strategies/ExtensionProviderStrategy/tests/ExtensionProviderStrategy.test.ts, src/providers/strategies/IframeProviderStrategy/tests/IframeProviderStrategy.test.ts
Comprehensive unit test suites covering provider initialization, login/logout, transaction signing, message signing, utility methods, error handling, and mocked dependencies
Test Infrastructure
src/setupTests.js
Added polyfill for setImmediate and clearImmediate, mapping to setTimeout/clearTimeout for environments without native support

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • ExtensionProviderStrategy test file — Verify test mocking strategy, nonce computation mocks, and assertion coverage for login, transaction signing, and message signing flows
  • IframeProviderStrategy test file — Review comprehensive test coverage including initialization error paths, UI handling in transaction signing, and cancellation behaviors
  • Mock server endpoint — Confirm new endpoint structure matches expected transaction PPU data format
  • Test polyfill — Ensure setImmediate/clearImmediate mapping is compatible with existing test environment

Poem

🐰 Tests multiply like carrots in spring,
IframeStrategy and Extension take wing,
Coverage climbs from eighty-five high,
To eighty-seven-point-nine, reaching sky!
With mocks and polyfills, the suite's now complete,
Quality assurance—a testing retreat! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided by the author; the required template sections (Issue/Feature, Root cause, Fix, etc.) are completely missing. Add a comprehensive pull request description following the template, including Issue/Feature, Root cause, Fix, and explanations of the changes made.
Title check ❓ Inconclusive The title 'Test review' is vague and generic; it does not clearly convey the specific changes being made, such as adding unit tests for provider strategies or updating coverage metrics. Provide a more descriptive title that captures the main changes, such as 'Add unit tests for ExtensionProviderStrategy and IframeProviderStrategy' or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch development

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @arhtudormorar, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the test coverage and reliability of the provider strategies within the application. It introduces dedicated unit tests for the ExtensionProviderStrategy and IframeProviderStrategy, ensuring robust functionality for user authentication and transaction handling. Additionally, it includes minor updates to the changelog and test setup to reflect these improvements.

Highlights

  • New Unit Tests: Comprehensive unit tests have been added for both the ExtensionProviderStrategy and IframeProviderStrategy, covering their core functionalities like login, logout, transaction signing, and message signing.
  • Code Coverage Increase: The overall code coverage has increased from 85.10% to 87.98%, reflecting the addition of new test cases.
  • Test Environment Enhancements: A new mock API endpoint for '/transactions/ppu/0' has been introduced to support specific testing scenarios, and a polyfill for 'global.setImmediate' was added to 'src/setupTests.js' for improved test environment compatibility.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds tests for IframeProviderStrategy and ExtensionProviderStrategy, which significantly increases test coverage. The changes are well-implemented. I've added a few suggestions to improve code quality and maintainability, focusing on a potentially confusing type name, improving type safety in tests by avoiding as any, and a minor formatting fix in the changelog.

Copy link

@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: 1

🧹 Nitpick comments (2)
src/providers/strategies/ExtensionProviderStrategy/tests/ExtensionProviderStrategy.test.ts (1)

71-75: Avoid leaking the initSignState spy into future tests

jest.spyOn(ExtensionProviderStrategy.prototype as any, 'initSignState') permanently replaces the implementation for the rest of this file. That’s fine today, but could surprise future tests that rely on the real initSignState. Consider restoring it after the assertion:

const initSignStateSpy = jest
  .spyOn(ExtensionProviderStrategy.prototype as any, 'initSignState')
  .mockResolvedValue({ manager: { closeUI: jest.fn() } });

try {
  // test body
} finally {
  initSignStateSpy.mockRestore();
}

This keeps the test self‑contained.

src/providers/strategies/IframeProviderStrategy/tests/IframeProviderStrategy.test.ts (1)

167-177: Align test name with assertions for the sign‑error path

The "cancels action and rethrows on sign error" test currently only asserts that signTransactions rejects with 'sign error'; it doesn’t check that cancelAction, onClose, or closeUI were invoked.

Either:

  • Add expectations for these side‑effects (e.g., expect(mockIframeProvider.cancelAction).toHaveBeenCalled() / expect(handlers.manager.closeUI).toHaveBeenCalled()), or
  • Rename the test to focus solely on the rethrow behavior.

That will keep the spec and behavior in sync.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 298a708 and 9342812.

📒 Files selected for processing (6)
  • CHANGELOG.md (1 hunks)
  • coverage-total.json (1 hunks)
  • src/__mocks__/server.ts (1 hunks)
  • src/providers/strategies/ExtensionProviderStrategy/tests/ExtensionProviderStrategy.test.ts (1 hunks)
  • src/providers/strategies/IframeProviderStrategy/tests/IframeProviderStrategy.test.ts (1 hunks)
  • src/setupTests.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/__mocks__/server.ts (1)
src/__mocks__/accountConfig.ts (1)
  • testNetwork (7-8)
src/providers/strategies/IframeProviderStrategy/tests/IframeProviderStrategy.test.ts (4)
src/__mocks__/data/storeData/network.ts (1)
  • network (1-20)
src/__mocks__/data/storeData/account.ts (1)
  • account (4-27)
src/providers/types/providerFactory.types.ts (1)
  • ProviderTypeEnum (26-35)
src/__mocks__/accountConfig.ts (1)
  • testAddress (4-5)
src/providers/strategies/ExtensionProviderStrategy/tests/ExtensionProviderStrategy.test.ts (5)
src/__mocks__/accountConfig.ts (1)
  • testAddress (4-5)
src/providers/ProviderFactory.ts (1)
  • ProviderFactory (31-149)
src/providers/strategies/ExtensionProviderStrategy/ExtensionProviderStrategy.ts (1)
  • ExtensionProviderStrategy (13-95)
src/lib/sdkCore.ts (3)
  • Transaction (7-7)
  • Message (12-12)
  • Address (10-10)
src/__mocks__/data/mockPendingTransaction.ts (1)
  • mockPendingTransaction (3-23)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: run_template_dapps_integration_script
🔇 Additional comments (4)
coverage-total.json (1)

4-4: Coverage badge update looks good

The new 87.98% value is a straightforward metadata update; no issues from a code perspective.

CHANGELOG.md (1)

8-10: Changelog entries match the test additions

The new “Unreleased” items correctly reference the Iframe and Extension provider test PRs and keep the history consistent.

src/__mocks__/server.ts (1)

57-60: PPU mock endpoint is consistent and scoped

The new /transactions/ppu/0 MSW handler has the expected shape (lastBlock, fast, faster) and uses testNetwork.apiAddress, so it should integrate cleanly with tests that rely on gas-station metadata.

src/setupTests.js (1)

23-26: setImmediate/clearImmediate polyfill is safe for the test env

Conditionally mapping setImmediate/clearImmediate to setTimeout/clearTimeout when missing is a pragmatic fix for Jest/JS DOM environments and won’t affect Node where setImmediate already exists.

arhtudormorar and others added 3 commits November 27, 2025 18:00
* Add getTransactionsHistory tests

* Added handleSignError tests

* Partially working

* update

* Passing

* Passing

* Passing

* Passing

* Passing

* Passing

* Update CHANGELOG

* Update CHANGELOG

* Update coverage
Signed-off-by: bigmoonbit <bigmoonbit@outlook.com>
Co-authored-by: Tudor Morar <tudor.morar@multiversx.com>
* Extend tests

* Add DappProvider tests

* Extend tests

* Add CONTRIBUTING.md
@arhtudormorar arhtudormorar merged commit 79e4f74 into main Nov 28, 2025
3 checks passed
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.

6 participants