Skip to content

Commit 761ba96

Browse files
committed
refactor: replace endpoint mock with QueryClient for enterprise feature testing
1 parent 1895d59 commit 761ba96

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

apps/meteor/client/sidebar/RoomMenu.spec.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { RoomType } from '@rocket.chat/core-typings';
22
import { mockAppRoot } from '@rocket.chat/mock-providers';
3+
import { QueryClient } from '@tanstack/react-query';
34
import { render, screen } from '@testing-library/react';
45
import '@testing-library/jest-dom';
56
import userEvent from '@testing-library/user-event';
@@ -52,13 +53,16 @@ const renderOptions = {
5253
wrapper: buildBase().build(),
5354
};
5455

56+
const buildEnterpriseQueryClient = () => {
57+
const client = new QueryClient({ defaultOptions: { queries: { retry: false }, mutations: { retry: false } } });
58+
client.setQueryData(['licenses', 'getLicenses', undefined], {
59+
license: createFakeLicenseInfo({ hasValidLicense: true, activeModules: ['experimental-enterprise-features'] }),
60+
});
61+
return client;
62+
};
63+
5564
const enterpriseRenderOptions = {
56-
wrapper: buildBase()
57-
.withJohnDoe()
58-
.withEndpoint('GET', '/v1/licenses.info', async () => ({
59-
license: createFakeLicenseInfo({ hasValidLicense: true, activeModules: ['experimental-enterprise-features'] }),
60-
}))
61-
.build(),
65+
wrapper: buildBase().withJohnDoe().withQueryClient(buildEnterpriseQueryClient()).build(),
6266
};
6367

6468
it('should display Hide, Mark Unread, Leave and Favorite toggle for regular rooms without enterprise', async () => {
@@ -98,19 +102,15 @@ it('should reveal Favorites and New category inside the "Move to" submenu for en
98102
const enterpriseFavoriteRenderOptions = {
99103
wrapper: buildBase()
100104
.withJohnDoe()
101-
.withEndpoint('GET', '/v1/licenses.info', async () => ({
102-
license: createFakeLicenseInfo({ hasValidLicense: true, activeModules: ['experimental-enterprise-features'] }),
103-
}))
105+
.withQueryClient(buildEnterpriseQueryClient())
104106
.withSubscription(createFakeSubscription({ rid: 'roomId', f: true, t: 'c' }))
105107
.build(),
106108
};
107109

108110
const enterpriseCategoryRenderOptions = {
109111
wrapper: buildBase()
110112
.withJohnDoe()
111-
.withEndpoint('GET', '/v1/licenses.info', async () => ({
112-
license: createFakeLicenseInfo({ hasValidLicense: true, activeModules: ['experimental-enterprise-features'] }),
113-
}))
113+
.withQueryClient(buildEnterpriseQueryClient())
114114
.withSubscription(createFakeSubscription({ rid: 'roomId', f: false, t: 'c' }))
115115
.withUserPreference('sidebarCustomCategories', [{ _id: 'cat-design', name: 'Design', rooms: ['roomId'], showUnreads: true }])
116116
.build(),

0 commit comments

Comments
 (0)