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

test: MM-59420 unit test for app/actions/remote/integrations.ts #8305

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Prathamesh010
Copy link

@Prathamesh010 Prathamesh010 commented Oct 31, 2024

Summary

Fixes: #2766

Ticket Link

Checklist

  • Added or updated unit tests (required for all new features)
  • Has UI changes
  • Includes text changes and localization file updates
  • Have tested against the 5 core themes to ensure consistency between them.
  • Have run E2E tests by adding label E2E iOS tests for PR.

Screenshots

image

Release Note

unit test for app/actions/remote/integrations.ts

@mm-cloud-bot mm-cloud-bot added the kind/testing Categorizes issue or PR as related to addition or refactoring of tests. label Oct 31, 2024
@mattermost-build
Copy link
Contributor

Hello @Prathamesh010,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

Per the Mattermost Contribution Guide, we need to add you to the list of approved contributors for the Mattermost project.

Please help complete the Mattermost contribution license agreement?
Once you have signed the CLA, please comment with /check-cla and confirm that the CLA check is green.

This is a standard procedure for many open source projects.

Please let us know if you have any questions.

We are very happy to have you join our growing community! If you're not yet a member, please consider joining our Contributors community channel to meet other contributors and discuss new opportunities with the core team.

@Prathamesh010
Copy link
Author

/check-cla

@mattermost-build
Copy link
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@marianunez marianunez added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester and removed Lifecycle/1:stale labels Nov 25, 2024
@marianunez marianunez requested a review from larkox November 25, 2024 01:11
Comment on lines +33 to +37
beforeAll(() => {
// eslint-disable-next-line
// @ts-ignore
NetworkManager.getClient = () => mockClient;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I know part of the codebase do it this way, but I feel it is a better test if we follow what is done in app/managers/draft_upload_manager with something like this:

const mockClient = TestHelper.createClient();

jest.mock('@managers/network_manager', () => {
    const original = jest.requireActual('@managers/network_manager');
    return {
        ...original,
        getClient: (serverUrl: string) => {
            if (serverUrl === url) {
                return mockClient;
            }

            throw new Error('client not found');
        },
    };
});

Among other things, this helps verify that we are getting the correct client. Not a huge deal, because there would be little chance we are doing that wrong, but makes the test more correct with not much more effort (and less ts-ignore comments :P).

@mattermost-build
Copy link
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester Contributor Hacktoberfest kind/testing Categorizes issue or PR as related to addition or refactoring of tests. Lifecycle/1:stale release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add unit test cases for integrations.ts
6 participants