|
1 | 1 | import type { RoomType } from '@rocket.chat/core-typings'; |
2 | 2 | import { mockAppRoot } from '@rocket.chat/mock-providers'; |
| 3 | +import { QueryClient } from '@tanstack/react-query'; |
3 | 4 | import { render, screen } from '@testing-library/react'; |
4 | 5 | import '@testing-library/jest-dom'; |
5 | 6 | import userEvent from '@testing-library/user-event'; |
@@ -52,13 +53,16 @@ const renderOptions = { |
52 | 53 | wrapper: buildBase().build(), |
53 | 54 | }; |
54 | 55 |
|
| 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 | + |
55 | 64 | 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(), |
62 | 66 | }; |
63 | 67 |
|
64 | 68 | 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 |
98 | 102 | const enterpriseFavoriteRenderOptions = { |
99 | 103 | wrapper: buildBase() |
100 | 104 | .withJohnDoe() |
101 | | - .withEndpoint('GET', '/v1/licenses.info', async () => ({ |
102 | | - license: createFakeLicenseInfo({ hasValidLicense: true, activeModules: ['experimental-enterprise-features'] }), |
103 | | - })) |
| 105 | + .withQueryClient(buildEnterpriseQueryClient()) |
104 | 106 | .withSubscription(createFakeSubscription({ rid: 'roomId', f: true, t: 'c' })) |
105 | 107 | .build(), |
106 | 108 | }; |
107 | 109 |
|
108 | 110 | const enterpriseCategoryRenderOptions = { |
109 | 111 | wrapper: buildBase() |
110 | 112 | .withJohnDoe() |
111 | | - .withEndpoint('GET', '/v1/licenses.info', async () => ({ |
112 | | - license: createFakeLicenseInfo({ hasValidLicense: true, activeModules: ['experimental-enterprise-features'] }), |
113 | | - })) |
| 113 | + .withQueryClient(buildEnterpriseQueryClient()) |
114 | 114 | .withSubscription(createFakeSubscription({ rid: 'roomId', f: false, t: 'c' })) |
115 | 115 | .withUserPreference('sidebarCustomCategories', [{ _id: 'cat-design', name: 'Design', rooms: ['roomId'], showUnreads: true }]) |
116 | 116 | .build(), |
|
0 commit comments