Skip to content

Commit 86440a9

Browse files
KrumTypd-redisdantovskaKIvanowclaude
authored
[RI-7280] resolve redux store circular dependencies during tests (#4809)
* add redis-ui * add forms/button * run format * add icons * add general export * re-export icons from ui-icons * add theme config in themeContext.tsx * make SecondaryButton.tsx outlined by default * add EmptyButton.tsx * add key panels * icon button added * edit json icons * analysis page * update font size * DatetimeForm.tsx * CloudSettings.tsx * add play and play filled icons * QueryCardHeader.tsx * QueryActions.tsx * InternalPage.tsx * move all icon imports * checkpoint * add db dialog * notifications * remove unused imports * fix ZSetDetails.tsx overflow * command helper * refactor window controls * checkpoint * stream * monitor, browser search, connection * InstanceHeader.tsx, WbNoResultsMessage.tsx * rdi * InlineItemEditor.tsx * rdi * NotFoundErrorPage.tsx * update to public packages * ensure color is supported * connectivity screens * ConnectivityOptions.tsx * Recommendations.tsx * update vite config * update jest config * OnboardingStartPopover.tsx * CodeButtonBlock.tsx * RunConfirmationPopover.tsx * UploadTutorialForm.tsx * RedisUploadButton.tsx * BulkUpload.tsx * FilterNotAvailable.tsx * ModuleNotLoadedButton.tsx * ModuleNotLoadedMinimalized.tsx * MonacoEditor.tsx * CloudCapiUnAuthorizedErrorContent.tsx * InfiniteMessages.tsx * OAuthConnectFreeDb.tsx, RdiDeployErrorContent.tsx, Link.tsx * OAuthSelectAccountDialog.tsx * OAuthSelectPlan.tsx * OAuthSignInButton.tsx * OAuthAutodiscovery.tsx * OAuthCreateDb.tsx * OAuthSsoForm.tsx * InternalLink.tsx, OnboardingTour.tsx * VoteOption.tsx * ScanMore.tsx * ChatForm.tsx, ErrorMessage.tsx, ExpertChatHeader.tsx * RestartChat.tsx * DeleteTutorialButton.tsx * PopoverRunAnalyze.tsx * CopilotTrigger.tsx * RedisCloudDatabasesResult.tsx * RedisCloudDatabases.tsx * RedisCloudSubscriptions.tsx * SentinelDatabasesResult.tsx, SentinelDatabasesResultPage.tsx * SentinelDatabases.tsx * BulkDeleteFooter.tsx * BulkDeleteSummaryButton.tsx * CreateRedisearchIndex.tsx * RI-7051: Replace EuiFieldPassword with PasswordInput (#4552) * RI-7051: add PasswordInput component * RI-7051: replace EuiFieldPassword with PasswordInput * RI-7051: remove euiFieldPassword styles * RI-7051: adjust info icon in rdi form * RI-7051: change PasswordInput import path * remove leftover * RI-7051: move PasswordInput a folder level up * RI-7051: PasswordInput leftover * fix Config.spec.tsx * fic AddKeyList.spec.tsx, AddKeyList.tsx, RdiDeployErrorContent.tsx, RdiDeployErrorContent.spec.tsx * fic SentinelDatabasesResultPage.tsx * RI-7053: replace EuiFlyout with Drawer (#4582) * RI-7053: use Drawer for ShortcutsFlyout * RI-7053: remove EuiFlyout styles * RI-7053: remove EuiFlyoutHeader reference * RI-7054: replace EuiFormRow with FormField (#4585) * RI-7052: replace EuiFieldSearch with SearchInput (#4586) * RI-7054: replace EuiFormRow with FormField * RI-7052 remove leftover * RI-7052: expose and use KeyboardKeys enum * RI-7056 replace eui health (#4593) * Add Health.tsx * Replace EuiHealth * RI-7045: replace EuiCallOut * replace EuiCallOut * RI-7044 , RI-7043: EuiButtonEmpty, EuiButtonIcon * RI-7046: replace EuiCheckbox * add Checkbox.tsx replace EuiCheckbox * RI-7047: replace eui combo box * add AutoTag component * update CreateRedisearchIndex.tsx * update KeyTreeSettings.tsx * update tests * RI-7041: replace eui badge * add RiBadge.tsx * replace EuiBadge with RiBadge * RI-7055: replace eui global toast * add RiToast.tsx, RiToaster.tsx * update notifications components, fix types in notifications.ts * update Notifications.tsx, error-messages.tsx to use RiToast components * RI-7070: RI-7072 replace eui text, eui colortext * add/refactor text components * replace EuiText, EuiTextColor * RI-7050 replace EUI field number with NumericInput (#4607) * export redis ui numeric input * replace eui field number with numeric input * remove no longer used validators * add better test names and some more tests for the numeric input behavior when strings are provided * RI-7048, RI-7049: replace eui menu with redis menu (#4611) * export menu components * replace in Pagination component and delete bunch of styles * RI-7071: Replace EuiTextArea with TextArea (#4619) * RI-7071: Replace EuiTextArea with TextArea * RI-7071: remove .euiTextArea class styles * fix label * replace euitext with colortext * RI-7073 replace eui title * Add Title.tsx * "Refactor: Replace EuiTitle with a custom Title component * RI-7068: replace EuiSwitch with SwitchInput (#4622) * RI-7068: replace EuiSwitch for AutoRefresh * update AutoRefresh * SwitchInput for WorkbenchSettings * SwitchInput for ConsentOptions * SwitchInput for Monitor * SwitchInput for Graph * SwitchInput for MessageClaimPopover * SwitchInput for db analytics * remove euiSwitch styles * SwitchInput for redistimeseries-app * fix failing unit tests * refactor userEvent imports * update SwitchInput props signature * RI-7068: update SwitchInput props * update SwitchInput import path * [RI-7069]: Replace EuiTabs with Tabs (#4625) * RI-7069: use Tabs for HomeTabs * RI-7069: use Tabs for InstancesNavigationPopover * fix unit tests * use Tabs for InsightsPanel * Tabs for DatabaseAnalysis * fix tests * Tabs for AnalyticsTabs * Tabs for ChatsWrapper * Tabs for BulkActionsTabs * Tabs for Panel * Tabs for StreamTabs * Tabs for ManualConnectionForm * drop euiTab styles * temp: skip manual connection tests * fix failing tests * update tests * cleanup tests * update import path * update test selector * RI-7059: Replace EUI Link with Redis Link (#4620) * replace eui link with redis link everywhere * fix profile badge styling for cloud * create use profile link component and replace * remove custom styles --------- Co-authored-by: pd-redis <[email protected]> * RI-7060: Replace EUI Loading Spinner with Redis Loader (#4631) * export the loader * replace everywhere * add support for t shirt sizing for redis ui loader and conversion to pixels * [RI-7058] Replace EuiInMemoryTable with Table (#4640) * RI-7058: expose redis ui Table component * update Table for TopKeys * use Table for TopNamespaces * use Table for UserApiKeysTable * use Table for TestConnectionsTable * use Table for TableResult * use Table for ClusterNodesTable * update Table for TableInfoResult * use Table for TableResult * use Table for ShortcutsTable * use Table for RedisClusterDatabasesPage * use Table for SentinelDatabasesResultPage * use Table for SentinelDatabasesPage * use Table for RedisCloudSubscriptionsPage * use Table for RedisCloudDatabasesResultPage * use Table for RedisCloudDatabasesPage * use Table for redisgraph * use Table for TableView * use Table for rdi tables * RI-7179: replace eui tour step * replace eui tour step * RI-7063: replace EuiPanel with Card (#4655) * RI-7063: replace EuiPanel with Card * revert test ids * RI-7066: replace eui radio group and eui SuperSelect, RI-7067 (#4645) * add RadioGroup.tsx * replace EuiRadioGroup with RiRadioGroup * add redis-ui select * replace in EuiSuperSelect with RiSelect * remove cx * [RI-7074] Replace EuiToolTip with RiTooltip (#4659) * RI-7074: init RiTooltip * RI-7074: replace EuiTooltip with RITooltip * update unit tests * remove euiTooltip styles * fix failing tests * cleanup TODOs * resolve comments * remove EuiTooltip * expose TOOLTIP_DELAY_LONG constant * fix errors after main merge * RI-7040: replace eui accordion Replace EuiAccordion with RiAccordion * [RI-7064] Replace EuiPopover with RiPopover (#4671) * RI-7064: replace EuiPopup init * replace EuiPopup with RiPopup * fix some unit tests * skip some unit tests * remove EuiPopover reference * fix tests * fix onboarding popover * [RI-7074] revert anchorClassName prop usage for RiTooltip (#4710) * RI-7074: expose anchorClassName for RiTooltip * revert anchorClassName prop usage for RiTooltip * revert missing styles * fix missing import * RI-7065: Replace EUI Progress with custom Progress Bar Loader (#4663) * create progress bar loader component * replace EuiProgress with ProgressBarLoader * apply the background color logic; this will be extracted and reused at a later point * RI-7062: Replace EUI sidebar with Redis SideBar (#4660) * Export the sidebar component * Use SideBarItem for the existing menu items * add width and height props to side bar icon * remove the logo component - wasn't flexible enough to use in this case * remove the navigation item wrapper * fix the icon naming to be consistent, remove unneeded icons, make them work for both light and dark themes * wrap the create cloud component inside sidebar when rendering * change getIconType function to just iconType * remove leafIcon, which is a leftover of a previous UI redesign - #2706, Node.tsx file * Fe/feature/ri 7039 replace eui build fix 2 (#4721) * fix for the builds failing with redis ui * fix for the builds failing with redis ui * RI-7040: replace eui icon * replace EuiIcon * [RI-7040] RiIcon refactor (#4727) * replace EuiIcon in ExternalLink.tsx * remove console.log * temp * update Icon.tsx, RiIcon.tsx * add isSvg prop * replace EuiIcon * add some icons * refactor icons * replace icons * replace icons * replace icons * replace icons * remove icon files * fix SlowLogTable.spec.tsx matcher * move sidebar icons * move options icons * move modules icons * replace Icon with RiIcon * remove todo comment * remove todo comment * add back icons * fix issues after rebase * remove usage of htmlIdGenerator * remove unused files, fix tests * RI-7040: refactor icons to reduce technical debt * include missing icon --------- Co-authored-by: pd-redis <[email protected]> * RI-7226: fix RiTooltip when content is empty (#4742) * RI-7226: fix RiTooltip when content is empty * add unit tests for RiTooltip * electron upgraded from 33.* to 36.* (#4740) * Update Electron from 33.2.0 to 36.4.0 and related dependencies - Update electron from EOL version 33.2.0 to supported 36.4.0 - Update electron-builder from 24.13.3 to 26.0.12 - Update electron-updater from 6.3.9 to 6.6.2 - Add node-abi 4.12.0 for better Electron version support - Update yarn.lock files with new dependency versions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * rolled back local changes * rolled back local changes * Update Node.js version from 22.11.0 to 22.12.0 for node-abi compatibility The [email protected] package requires Node.js >=22.12.0 but CI was using 22.11.0. This update ensures compatibility with the upgraded Electron dependencies. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Testing slightly different config to fix the resolutions after install * Fix electron-builder 26.0.12 configuration compatibility - Update Linux desktop configuration to use desktop.entry structure - Change Mac notarize from object to boolean (temporarily disabled) - Replace Windows publisherName with legalTrademarks - Remove electron-builder install-app-deps from postinstall script These changes address breaking changes in electron-builder 26.0.12. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Restore Mac notarization and disable native module rebuilding - Restore Mac notarization with teamId configuration (good security practice) - Add npmRebuild: false, nodeGypRebuild: false, buildDependenciesFromSource: false to disable native module rebuilding which fails due to ABI compatibility issues - This allows electron-builder to proceed without trying to rebuild native modules like keytar and sqlite3 that cause ABI detection errors with Electron 36 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Update Mac notarize configuration to boolean for electron-builder 26.0.12 In electron-builder 26.0.12, notarize must be a boolean value. The actual notarization configuration (teamId, etc.) is now handled via environment variables such as APPLE_TEAM_ID=UUK47G4BAZ instead of in the config file. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Reverting unneeded changes * Reverting unneeded changes * reverting yarn.lock in the api folder for testing --------- Co-authored-by: Claude <[email protected]> * RI-7212: replace EuiFormFieldset with FormFieldset (#4739) * RI-7212: replace EuiFormFieldset with FormFieldset * update display legend logic * add FormFieldset unit tests * RI-7226: fix RiTooltip when title/content is empty (#4747) * RI-7226: fix RiTooltip when title/content is empty * update test name * RI-7236 replace settings icon (#4745) * Remove settings icons * fix keys summary alignment * entirely remove settings svgs * RI-7211: replace eui form * replace EuiForm with form, replace eui/keys with uiSrc/constants/keys * RI-7208 replace eui collapsible nav group * add RICollapsibleNavGroup * replace EuiCollapsibleNavGroup * Remove unused PageBreadcrumbs component (#4746) * RI-7228 - key details - space is missing between Add / Cancel (#4761) * RI-7228 - key details - space is missing between Add / Cancel * RI-7228 - key details - space is missing between Add / Cancel * RI-7228 - key details - space is missing between Add / Cancel - returned classnames for test purposes * RI-7239 - Workbench results - the execution time has a broken layout (#4763) * RI-7030 - on workbench page, the text in the executing queries has broken styles and has blue square all over the screen (#4764) * RI-7210 replace eui file picker * add RiFilePicker.tsx * replace EuiFilePicker * Fe/feature/ri 7233 key details on web and full screen do not expand to the width of the container and do not have space between each other (#4762) * RI-7233 - key details on web and full screen do not expand to the width of the container and do not have space between each other - fixed spacing between name and ttl, and below the same row * RI-7233 - key details on web and full screen do not expand to the width of the container and do not have space between each other - fixed spacing between different input components * RI-7233 - key details on web and full screen do not expand to the width of the container and do not have space between each other - fixed styles to stretch from one end to the other * RI-7224 - in messages - ACK / CLAIM buttons need space between (#4769) * RI-7213: replace EuiImage with img tag (#4760) * replace Eui Image with RiImage * RI-7209 - Replace EuiFieldText with Input (#4775) * RI-7209 - Replace EuiFieldText with Input * Update redisinsight/ui/src/pages/home/components/database-manage-tags-modal/TagInputField.tsx Co-authored-by: Copilot <[email protected]> * Update redisinsight/ui/src/pages/browser/modules/key-details/components/stream-details/add-stream-entity/StreamEntryFields/StreamEntryFields.tsx Co-authored-by: Copilot <[email protected]> * Update redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/components/add-item/AddItem.tsx Co-authored-by: Copilot <[email protected]> * Update redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/components/add-item/AddItem.tsx Co-authored-by: Copilot <[email protected]> * Update redisinsight/ui/src/components/inline-item-editor/InlineItemEditor.tsx Co-authored-by: Copilot <[email protected]> * redisinsight/ui/src/components/multi-search/MultiSearch.tsx * RI-7209 - Replace EuiFieldText with Input - fixed tests (some?), added tooltip provider for the tooltip * RI-7209 - Replace EuiFieldText with Input - fixed tests * RI-7209 - Replace EuiFieldText with Input - fixed tests * RI-7209 - Replace EuiFieldText with Input - fixed tests * RI-7209 - Replace EuiFieldText with Input - fixed tests * Update redisinsight/ui/src/components/instance-header/components/instances-navigation-popover/InstancesNavigationPopover.tsx Co-authored-by: pd-redis <[email protected]> * Update redisinsight/ui/src/components/multi-search/MultiSearch.tsx Co-authored-by: pd-redis <[email protected]> * Update redisinsight/ui/src/components/input-field-sentinel/InputFieldSentinel.tsx Co-authored-by: pd-redis <[email protected]> * Update redisinsight/ui/src/pages/browser/components/create-redisearch-index/CreateRedisearchIndex.tsx Co-authored-by: pd-redis <[email protected]> * Update redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/components/add-item/AddItem.tsx Co-authored-by: pd-redis <[email protected]> * Update redisinsight/ui/src/pages/browser/components/add-key/AddKeyCommonFields/AddKeyCommonFields.tsx Co-authored-by: pd-redis <[email protected]> * RI-7209 - Replace EuiFieldText with Input - fixed tests --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: pd-redis <[email protected]> * RI-7214: Replace EUI loading logo with custom bouncing logo component (#4768) * create loading logo component * add sizing to the component * RI-7235 new navigation (#4777) * add AppNavigation.tsx * add useNavigation.ts, move AppNavigation to InstancePageTemplate.tsx * RI-7207: Replace RUI Button Group with Redis Button Group (#4773) * replace the accordion component; change some styling to look nice with the accordion * replace button group component * RI-7061: Replace EUI Modal (#4749) * import the modal components * apply the form dialog; vefiry for the database connection form; delete unneeded styles * replace filter key type modal * remove filter key type eui styles * replace browser search panel / module not loaded * replace consents settings popup modal * replace rdi import modal(s) * add ids to buttons * replace the start rdi pipeline modal * remove background colors * remove :global styling * remove the advantages background * replace select account dialog modal * replace select plan modal * replace oauth sso dialog modal * finalize form dialog and manage tags modal * round up the width, set too 601 for no reason (: * format form dialog file * use width modal prop instead of as part of the class * fix the rebase issues - use the propper RI file picker * and fix the upload warning container * refactor size capital to small letter; format * change rdi error configuration file icon and add color; align items * return the exported type and format file * use cx when multiple classes applied * fix some of the tests failing due to issues with the modal header; skip the ones that are tied directly to the header as the header is set to null * fix upload dialog tests * fix database panel dialog * change oauth sso dialog and browser search panel dialog to null * fix width * remove duplicate styling * remove not needed code * fix oauth select account dialog * fix all tests regarding the buggy modal title * reverting changes to the features config.json --------- Co-authored-by: Kristiyan Ivanov <[email protected]> * Fe/feature/ri 7269 fix major discrepancies between the ds previews and the implementation around the main content under the new navigation (#4784) * RI-7269 - Fix major discrepancies between the DS previews and the implementation around the main content under the new navigation - added border above the new navigation * RI-7269 - Fix major discrepancies between the DS previews and the implementation around the main content under the new navigation - updated main content brackgrounds to use the proper colors * RI-7269 - Fix major discrepancies between the DS previews and the implementation around the main content under the new navigation - added borders to the keys list and key details to mimic the new DS * RI-7269 - Fix major discrepancies between the DS previews and the implementation around the main content under the new navigation - removed background for the bottom buttons (add, cancel, save, etc). In the new DS there is no different BG and it only makes it mroe complciated to keep track * RI-7269 - Fix major discrepancies between the DS previews and the implementation around the main content under the new navigation - add padding on top of the search bar to distance it from the new navigation * RI-7269 - Fix major discrepancies between the DS previews and the implementation around the main content under the new navigation - updated the cli row to look like the previews * RI-7269 - Fix major discrepancies between the DS previews and the implementation around the main content under the new navigation - updated spacing under the navigation to be handled in one place * RI-7269 - Fix major discrepancies between the DS previews and the implementation around the main content under the new navigation - fixed paddings for the CLI row * RI-7269 - Fix major discrepancies between the DS previews and the implementation around the main content under the new navigation - Updated uses of theme to be through useTheme, instead of a direct import * RI-7263: Replace EUI empty prompt (#4778) * create loading logo component * move import from layout to display * add sizing to the component * use $ for size and bounceSpeed instead of Omit * implement redis theme sizing * Rename folder logo-loading -> loading-logo * create and export RiEmptyPrompt component * replace the eui component with the new one * Include the ...rest in the empty prompt component * Extended spacer to support theme sizes --------- Co-authored-by: Kristiyan Ivanov <[email protected]> * RI-7252 - RDI-empty-screen-is-missaligned (#4792) * RI-7250 - RDI---the-loading-message-is-not-aligned (#4791) * RI-7249 - RDI---Connection-test-results-are-broken (#4790) * RI-7248 - RDI---deploy-button-has-broken-styles (#4787) * RI-7244 -Edit-and-remove-buttons-are-not-aligned (#4786) * RI-7244 -Edit-and-remove-buttons-are-not-aligned * Update redisinsight/ui/src/components/base/forms/buttons/EmptyButton.tsx Co-authored-by: pd-redis <[email protected]> * Update redisinsight/ui/src/components/base/forms/buttons/EmptyButton.tsx Co-authored-by: pd-redis <[email protected]> --------- Co-authored-by: pd-redis <[email protected]> * RI-7243 capabilities not displayed * provide actual icon element to IconButton * set LikeIcon as default for VoteOption.tsx * RI-7223 links should have underline only on hover * reverse link behavior * Fe/feature/ri 7252 rdi broken layout for the list of jobs (#4797) * RI-7252 - RDI---Broken-layout-for-the-list-of-jobs - added size props for the inline item editor's action section * RI-7252 - RDI---Broken-layout-for-the-list-of-jobs - added size props for the inline item editor's action section * RI-7253: make delete buttons same size * RI-7240 - White-area-below-the-tooltip-in-connection-forms (#4798) * RI-7247: older notifications are displayed * Fe/feature/ri 7278 and ri 7279 (#4802) * RI-7279 - "test" element is visible on top of the db keys list * RI-7278 - Remove the old navigation for DBs * RI-7278 - Remove the old navigation for DBs - removed unused variables and updated tests * fix: resolve redux store circular dependencies * update svg mock * fix store reference * update svg mock * update test-utils tyes * simplify test store solution * cleanup not needed changes * add store subscribe method --------- Co-authored-by: pd-redis <[email protected]> Co-authored-by: dantovska <[email protected]> Co-authored-by: Kristiyan Ivanov <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Kristiyan Ivanov <[email protected]>
1 parent 0d636c0 commit 86440a9

File tree

9 files changed

+94
-28
lines changed

9 files changed

+94
-28
lines changed

jest.config.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
'\\.svg': '<rootDir>/redisinsight/__mocks__/svg.js',
1212
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
1313
'\\.scss\\?inline$': '<rootDir>/redisinsight/__mocks__/scssRaw.js',
14+
'uiSrc/slices/store$': '<rootDir>/redisinsight/ui/src/utils/test-store.ts',
1415
'uiSrc/(.*)': '<rootDir>/redisinsight/ui/src/$1',
1516
'@redislabsdev/redis-ui-components': '@redis-ui/components',
1617
'@redislabsdev/redis-ui-styles': '@redis-ui/styles',

redisinsight/__mocks__/svg.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1-
export default 'SvgrURL';
2-
export const ReactComponent = 'div';
1+
import React from 'react';
2+
3+
// Mock SVG component for Jest tests
4+
const SvgMock = React.forwardRef((props, ref) => <svg ref={ref} {...props} />);
5+
6+
SvgMock.displayName = 'SvgMock';
7+
8+
export default SvgMock;
9+
export const ReactComponent = SvgMock;

redisinsight/ui/src/components/database-list-modules/DatabaseListModules.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const DatabaseListModules = React.memo((props: Props) => {
4949
const newModules: IDatabaseModule[] = sortModules(
5050
modules?.map(({ name: propName, semanticVersion = '', version = '' }) => {
5151
const isValidModuleKey = Object.values(RedisDefaultModules).includes(propName as RedisDefaultModules)
52-
53-
const module: ModuleInfo | undefined = isValidModuleKey
52+
53+
const module: ModuleInfo | undefined = isValidModuleKey
5454
? DEFAULT_MODULES_INFO[propName as RedisDefaultModules]
5555
: undefined
5656
const moduleName = module?.text || propName

redisinsight/ui/src/slices/store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,6 @@ const store = configureStore({
151151

152152
export { store }
153153

154+
export type ReduxStore = typeof store
154155
export type RootState = ReturnType<typeof rootReducer>
155156
export type AppDispatch = typeof store.dispatch

redisinsight/ui/src/slices/tests/browser/keys.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
setBrowserSelectedKey,
3232
} from 'uiSrc/slices/app/context'
3333
import { MOCK_TIMESTAMP } from 'uiSrc/mocks/data/dateNow'
34-
import { rootReducer } from 'uiSrc/slices/store'
3534
import {
3635
setEditorType,
3736
setIsWithinThreshold,
@@ -46,6 +45,7 @@ import { CreateRejsonRlWithExpireDto } from 'apiSrc/modules/browser/rejson-rl/dt
4645
import { CreateSetWithExpireDto } from 'apiSrc/modules/browser/set/dto'
4746
import { CreateZSetWithExpireDto } from 'apiSrc/modules/browser/z-set/dto'
4847
import { SetStringWithExpireDto } from 'apiSrc/modules/browser/string/dto'
48+
import { rootReducer } from '../../store'
4949
import { getString, getStringSuccess } from '../../browser/string'
5050
import reducer, {
5151
addHashKey,

redisinsight/ui/src/slices/tests/browser/rejson.setJsonDataAction.spec.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,6 @@ import { EditorType } from 'uiSrc/slices/interfaces'
44

55
const mockStore = configureStore([thunk])
66

7-
const originalConsoleError = console.error
8-
9-
// Suppress Redux warnings about missing reducers
10-
beforeAll(() => {
11-
console.error = (...args: any[]) => {
12-
const message = args[0]
13-
if (
14-
typeof message === 'string' &&
15-
message.includes('No reducer provided for key')
16-
) {
17-
return
18-
}
19-
20-
originalConsoleError(...args)
21-
}
22-
})
23-
24-
afterAll(() => {
25-
console.error = originalConsoleError
26-
})
27-
287
describe('setReJSONDataAction', () => {
298
let store: any
309
let sendEventTelemetryMock: jest.Mock
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { createBrowserHistory } from 'history'
2+
3+
import type { ReduxStore } from 'uiSrc/slices/store'
4+
5+
// Re-export all types and exports from the real store to avoid circular dependencies during tests
6+
7+
export type { RootState, AppDispatch, ReduxStore } from 'uiSrc/slices/store'
8+
export const history = createBrowserHistory()
9+
10+
// Lazy reference to avoid circular dependencies
11+
// The store will be set by the store module itself after it's created
12+
let storeRef: ReduxStore | null = null
13+
14+
// This function will be called by the store modules to set the reference
15+
export const setStoreRef = (store: ReduxStore) => {
16+
storeRef = store
17+
}
18+
19+
const getState: ReduxStore['getState'] = () => {
20+
if (!storeRef) {
21+
throw new Error(
22+
'Store not initialized. Make sure store-dynamic is imported after store creation.',
23+
)
24+
}
25+
return storeRef.getState()
26+
}
27+
28+
const dispatch: ReduxStore['dispatch'] = (action: any) => {
29+
if (!storeRef) {
30+
throw new Error(
31+
'Store not initialized. Make sure store-dynamic is imported after store creation.',
32+
)
33+
}
34+
return storeRef.dispatch(action)
35+
}
36+
37+
const subscribe: ReduxStore['subscribe'] = (listener: () => void) => {
38+
if (!storeRef) {
39+
throw new Error(
40+
'Store not initialized. Make sure store-dynamic is imported after store creation.',
41+
)
42+
}
43+
return storeRef.subscribe(listener)
44+
}
45+
46+
// Export store object that matches the real store interface
47+
export const store = {
48+
getState,
49+
dispatch,
50+
subscribe,
51+
}

redisinsight/ui/src/utils/test-utils.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import { ThemeProvider } from 'styled-components'
1616
import { themeLight } from '@redis-ui/styles'
1717
import userEvent from '@testing-library/user-event'
18-
import { RootState, store as rootStore } from 'uiSrc/slices/store'
18+
import type { RootState, ReduxStore } from 'uiSrc/slices/store'
1919
import { initialState as initialStateInstances } from 'uiSrc/slices/instances/instances'
2020
import { initialState as initialStateTags } from 'uiSrc/slices/instances/tags'
2121
import { initialState as initialStateCaCerts } from 'uiSrc/slices/instances/caCerts'
@@ -70,12 +70,14 @@ import { initialState as initialStateAiAssistant } from 'uiSrc/slices/panels/aiA
7070
import { RESOURCES_BASE_URL } from 'uiSrc/services/resourcesService'
7171
import { apiService } from 'uiSrc/services'
7272
import { initialState as initialStateAppConnectivity } from 'uiSrc/slices/app/connectivity'
73+
import { initialState as initialStateAppDbSettings } from 'uiSrc/slices/app/db-settings'
7374
import { initialState as initialStateAppInit } from 'uiSrc/slices/app/init'
7475
import * as appFeaturesSlice from 'uiSrc/slices/app/features'
76+
import { setStoreRef } from './test-store'
7577

7678
interface Options {
7779
initialState?: RootState
78-
store?: typeof rootStore
80+
store?: ReduxStore
7981
withRouter?: boolean
8082
[property: string]: any
8183
}
@@ -94,6 +96,7 @@ const initialStateDefault: RootState = {
9496
csrf: cloneDeep(initialStateAppCsrfReducer),
9597
init: cloneDeep(initialStateAppInit),
9698
connectivity: cloneDeep(initialStateAppConnectivity),
99+
dbSettings: cloneDeep(initialStateAppDbSettings),
97100
},
98101
connections: {
99102
instances: cloneDeep(initialStateInstances),
@@ -166,6 +169,10 @@ export const mockStore = configureMockStore<RootState>([thunk])
166169
export const mockedStore = mockStore(initialStateDefault)
167170
export const mockedStoreFn = () => mockStore(initialStateDefault)
168171

172+
// Set the mock store reference for the dynamic store wrapper
173+
// This ensures that store-dynamic works correctly in tests
174+
setStoreRef(mockedStore)
175+
169176
// insert root state to the render Component
170177
const render = (
171178
ui: JSX.Element,
@@ -176,6 +183,10 @@ const render = (
176183
...renderOptions
177184
}: Options = initialStateDefault,
178185
) => {
186+
if (store !== mockedStore) {
187+
setStoreRef(store)
188+
}
189+
179190
const Wrapper = ({ children }: { children: JSX.Element }) => (
180191
<ThemeProvider theme={themeLight}>
181192
<Provider store={store}>{children}</Provider>
@@ -196,6 +207,10 @@ const renderHook = (
196207
...renderOptions
197208
}: Options = initialStateDefault,
198209
) => {
210+
if (store !== mockedStore) {
211+
setStoreRef(store)
212+
}
213+
199214
const Wrapper = ({ children }: { children: JSX.Element }) => (
200215
<Provider store={store}>{children}</Provider>
201216
)

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,18 @@
15481548
dependencies:
15491549
"@isaacs/balanced-match" "^4.0.1"
15501550

1551+
"@isaacs/balanced-match@^4.0.1":
1552+
version "4.0.1"
1553+
resolved "https://registry.yarnpkg.com/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz#3081dadbc3460661b751e7591d7faea5df39dd29"
1554+
integrity sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==
1555+
1556+
"@isaacs/brace-expansion@^5.0.0":
1557+
version "5.0.0"
1558+
resolved "https://registry.yarnpkg.com/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz#4b3dabab7d8e75a429414a96bd67bf4c1d13e0f3"
1559+
integrity sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==
1560+
dependencies:
1561+
"@isaacs/balanced-match" "^4.0.1"
1562+
15511563
"@isaacs/cliui@^8.0.2":
15521564
version "8.0.2"
15531565
resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550"

0 commit comments

Comments
 (0)