-
Notifications
You must be signed in to change notification settings - Fork 421
[RI-7280] resolve redux store circular dependencies during tests #4809
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
Merged
Merged
Changes from all commits
Commits
Show all changes
163 commits
Select commit
Hold shift + click to select a range
d377072
add redis-ui
pd-redis 3a3696b
add forms/button
pd-redis ba385ab
run format
pd-redis 049a991
add icons
pd-redis 3c3b65f
add general export
pd-redis 1832c1a
re-export icons from ui-icons
pd-redis e5ed77b
add theme config in themeContext.tsx
pd-redis 8026a6c
make SecondaryButton.tsx outlined by default
pd-redis 36e23a1
add EmptyButton.tsx
pd-redis e2a9bfe
add key panels
pd-redis f580b98
icon button added
pd-redis 192aa1f
edit json icons
pd-redis e9358e0
analysis page
pd-redis f1051e2
update font size
pd-redis 31da78e
DatetimeForm.tsx
pd-redis 40cbb55
CloudSettings.tsx
pd-redis 75db002
add play and play filled icons
pd-redis 52771a4
QueryCardHeader.tsx
pd-redis d07d5d2
QueryActions.tsx
pd-redis eee47b2
InternalPage.tsx
pd-redis aaaa43b
Merge branch 'main' into fe/feature/RI-7039-replace-eui
pd-redis 6301a55
move all icon imports
pd-redis 05ef986
checkpoint
pd-redis 88bfbe9
add db dialog
pd-redis 4966145
notifications
pd-redis 226baf2
remove unused imports
pd-redis 1acb93a
fix ZSetDetails.tsx overflow
pd-redis e836924
command helper
pd-redis f744afc
refactor window controls
pd-redis 0f0e74f
checkpoint
pd-redis a02015d
stream
pd-redis 5c04afc
monitor, browser search, connection
pd-redis 321112b
InstanceHeader.tsx, WbNoResultsMessage.tsx
pd-redis 735ad96
rdi
pd-redis 42a16fb
InlineItemEditor.tsx
pd-redis 6803376
rdi
pd-redis 4e1f2d3
Merge branch 'main' into fe/feature/RI-7039-replace-eui
pd-redis c4045c9
NotFoundErrorPage.tsx
pd-redis 4937213
update to public packages
pd-redis f33e3da
ensure color is supported
pd-redis d4ef6ef
connectivity screens
pd-redis 85ab56d
ConnectivityOptions.tsx
pd-redis 47ab453
Recommendations.tsx
pd-redis 0d1e8ee
update vite config
KrumTy 38a54bb
update jest config
KrumTy 88c342b
OnboardingStartPopover.tsx
pd-redis 5775639
CodeButtonBlock.tsx
pd-redis b58bb78
RunConfirmationPopover.tsx
pd-redis b916a2a
UploadTutorialForm.tsx
pd-redis 03855eb
RedisUploadButton.tsx
pd-redis eaa652e
BulkUpload.tsx
pd-redis e78731f
FilterNotAvailable.tsx
pd-redis e098586
ModuleNotLoadedButton.tsx
pd-redis 12f628a
ModuleNotLoadedMinimalized.tsx
pd-redis f976c0c
MonacoEditor.tsx
pd-redis 8c831cb
CloudCapiUnAuthorizedErrorContent.tsx
pd-redis 822c0e9
InfiniteMessages.tsx
pd-redis d24f422
OAuthConnectFreeDb.tsx, RdiDeployErrorContent.tsx, Link.tsx
pd-redis 78f808d
OAuthSelectAccountDialog.tsx
pd-redis 51a6f74
OAuthSelectPlan.tsx
pd-redis c311f89
OAuthSignInButton.tsx
pd-redis 12a402b
OAuthAutodiscovery.tsx
pd-redis 02aa2aa
OAuthCreateDb.tsx
pd-redis 4893c44
OAuthSsoForm.tsx
pd-redis 355db6c
InternalLink.tsx, OnboardingTour.tsx
pd-redis 96a592a
VoteOption.tsx
pd-redis f043f43
ScanMore.tsx
pd-redis 4817dfc
ChatForm.tsx, ErrorMessage.tsx, ExpertChatHeader.tsx
pd-redis 1d6d38a
RestartChat.tsx
pd-redis 7ef621e
DeleteTutorialButton.tsx
pd-redis 3b897fa
PopoverRunAnalyze.tsx
pd-redis ba26fac
CopilotTrigger.tsx
pd-redis 6db7083
RedisCloudDatabasesResult.tsx
pd-redis 960bcc9
RedisCloudDatabases.tsx
pd-redis ba662a9
RedisCloudSubscriptions.tsx
pd-redis ee882ea
SentinelDatabasesResult.tsx, SentinelDatabasesResultPage.tsx
pd-redis 79e5e29
SentinelDatabases.tsx
pd-redis ecefce7
BulkDeleteFooter.tsx
pd-redis 93c5de6
BulkDeleteSummaryButton.tsx
pd-redis c9aeaf9
CreateRedisearchIndex.tsx
pd-redis c2df435
RI-7051: Replace EuiFieldPassword with PasswordInput (#4552)
KrumTy 97b2d46
fix Config.spec.tsx
pd-redis 901d5ec
fic AddKeyList.spec.tsx, AddKeyList.tsx, RdiDeployErrorContent.tsx, R…
pd-redis 7de2983
fic SentinelDatabasesResultPage.tsx
pd-redis 6553188
RI-7053: replace EuiFlyout with Drawer (#4582)
KrumTy ffda0f7
RI-7054: replace EuiFormRow with FormField (#4585)
KrumTy 839830c
RI-7052: replace EuiFieldSearch with SearchInput (#4586)
KrumTy 66a4de2
RI-7056 replace eui health (#4593)
pd-redis 4f09c94
RI-7045: replace EuiCallOut
pd-redis b3ba28e
RI-7044 , RI-7043: EuiButtonEmpty, EuiButtonIcon
pd-redis a4ca899
RI-7046: replace EuiCheckbox
pd-redis 5f12ecf
RI-7047: replace eui combo box
pd-redis 0c385bd
RI-7041: replace eui badge
pd-redis e98b604
RI-7055: replace eui global toast
pd-redis 5fc5800
RI-7070: RI-7072 replace eui text, eui colortext
pd-redis 84a3d21
RI-7050 replace EUI field number with NumericInput (#4607)
dantovska 0b87f59
RI-7048, RI-7049: replace eui menu with redis menu (#4611)
dantovska 4cb33d0
RI-7071: Replace EuiTextArea with TextArea (#4619)
KrumTy 1469bda
replace euitext with colortext
pd-redis 662ee58
RI-7073 replace eui title
pd-redis bf3ddfe
RI-7068: replace EuiSwitch with SwitchInput (#4622)
KrumTy 384bdff
[RI-7069]: Replace EuiTabs with Tabs (#4625)
KrumTy 62f8a72
RI-7059: Replace EUI Link with Redis Link (#4620)
dantovska 01d6ef4
RI-7060: Replace EUI Loading Spinner with Redis Loader (#4631)
dantovska debba5d
[RI-7058] Replace EuiInMemoryTable with Table (#4640)
KrumTy face974
RI-7179: replace eui tour step
pd-redis 1320c70
RI-7063: replace EuiPanel with Card (#4655)
KrumTy e075507
RI-7066: replace eui radio group and eui SuperSelect, RI-7067 (#4645)
pd-redis 7f0bbd4
remove cx
pd-redis bd05295
[RI-7074] Replace EuiToolTip with RiTooltip (#4659)
KrumTy c7bb583
Merge branch 'main' into fe/feature/RI-7039-replace-eui
pd-redis 59650e0
fix errors after main merge
pd-redis 6d9f45f
RI-7040: replace eui accordion
pd-redis f93a9a7
[RI-7064] Replace EuiPopover with RiPopover (#4671)
KrumTy e3f0b73
[RI-7074] revert anchorClassName prop usage for RiTooltip (#4710)
KrumTy 0dd6e01
RI-7065: Replace EUI Progress with custom Progress Bar Loader (#4663)
dantovska 483390b
RI-7062: Replace EUI sidebar with Redis SideBar (#4660)
dantovska 4c6983b
Fe/feature/ri 7039 replace eui build fix 2 (#4721)
a7f885d
RI-7040: replace eui icon
pd-redis b993a06
[RI-7040] RiIcon refactor (#4727)
KrumTy 9508198
RI-7226: fix RiTooltip when content is empty (#4742)
KrumTy 65736aa
electron upgraded from 33.* to 36.* (#4740)
2e64134
RI-7212: replace EuiFormFieldset with FormFieldset (#4739)
KrumTy f08ae61
RI-7226: fix RiTooltip when title/content is empty (#4747)
KrumTy 8416742
RI-7236 replace settings icon (#4745)
dantovska 5c86907
RI-7211: replace eui form
pd-redis 030f3f0
RI-7208 replace eui collapsible nav group
pd-redis 907799f
Remove unused PageBreadcrumbs component (#4746)
pd-redis a061b08
RI-7228 - key details - space is missing between Add / Cancel (#4761)
c14102f
RI-7239 - Workbench results - the execution time has a broken layout …
f1d8528
RI-7030 - on workbench page, the text in the executing queries has br…
1ccfce9
RI-7210 replace eui file picker
pd-redis 7d34422
Fe/feature/ri 7233 key details on web and full screen do not expand…
d0997b0
RI-7224 - in messages - ACK / CLAIM buttons need space between (#4769)
16e5768
RI-7213: replace EuiImage with img tag (#4760)
dantovska 7d4f6bc
RI-7209 - Replace EuiFieldText with Input (#4775)
3016ee7
RI-7214: Replace EUI loading logo with custom bouncing logo component…
dantovska 31b21bb
RI-7235 new navigation (#4777)
pd-redis 37686f6
RI-7207: Replace RUI Button Group with Redis Button Group (#4773)
dantovska 510f314
RI-7061: Replace EUI Modal (#4749)
dantovska 8bcb187
Fe/feature/ri 7269 fix major discrepancies between the ds previews …
06e6020
RI-7263: Replace EUI empty prompt (#4778)
dantovska 1e70c67
RI-7252 - RDI-empty-screen-is-missaligned (#4792)
c355c70
RI-7250 - RDI---the-loading-message-is-not-aligned (#4791)
36a272b
RI-7249 - RDI---Connection-test-results-are-broken (#4790)
22d55f1
RI-7248 - RDI---deploy-button-has-broken-styles (#4787)
579b31c
RI-7244 -Edit-and-remove-buttons-are-not-aligned (#4786)
bcc8946
RI-7243 capabilities not displayed
pd-redis a9db370
RI-7223 links should have underline only on hover
pd-redis 8138740
Fe/feature/ri 7252 rdi broken layout for the list of jobs (#4797)
93ab1e1
RI-7253: make delete buttons same size
pd-redis bf5aa14
RI-7240 - White-area-below-the-tooltip-in-connection-forms (#4798)
ed3b7bd
RI-7247: older notifications are displayed
pd-redis 83f64a6
Fe/feature/ri 7278 and ri 7279 (#4802)
fea64c3
fix: resolve redux store circular dependencies
KrumTy 8640a2b
update svg mock
KrumTy 129548a
fix store reference
KrumTy adaa0d2
update svg mock
KrumTy 0f4e53e
update test-utils tyes
KrumTy a88564e
simplify test store solution
KrumTy 2ac2737
cleanup not needed changes
KrumTy 82adae0
add store subscribe method
KrumTy ad2fa5f
Merge remote-tracking branch 'origin/main' into bugfix/redux-store-ci…
KrumTy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,9 @@ | ||
| export default 'SvgrURL'; | ||
| export const ReactComponent = 'div'; | ||
| import React from 'react'; | ||
|
|
||
| // Mock SVG component for Jest tests | ||
| const SvgMock = React.forwardRef((props, ref) => <svg ref={ref} {...props} />); | ||
|
|
||
| SvgMock.displayName = 'SvgMock'; | ||
|
|
||
| export default SvgMock; | ||
| export const ReactComponent = SvgMock; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { createBrowserHistory } from 'history' | ||
|
|
||
| import type { ReduxStore } from 'uiSrc/slices/store' | ||
|
|
||
| // Re-export all types and exports from the real store to avoid circular dependencies during tests | ||
|
|
||
| export type { RootState, AppDispatch, ReduxStore } from 'uiSrc/slices/store' | ||
| export const history = createBrowserHistory() | ||
|
|
||
| // Lazy reference to avoid circular dependencies | ||
| // The store will be set by the store module itself after it's created | ||
| let storeRef: ReduxStore | null = null | ||
|
|
||
| // This function will be called by the store modules to set the reference | ||
| export const setStoreRef = (store: ReduxStore) => { | ||
| storeRef = store | ||
| } | ||
|
|
||
| const getState: ReduxStore['getState'] = () => { | ||
| if (!storeRef) { | ||
| throw new Error( | ||
| 'Store not initialized. Make sure store-dynamic is imported after store creation.', | ||
| ) | ||
| } | ||
| return storeRef.getState() | ||
| } | ||
|
|
||
| const dispatch: ReduxStore['dispatch'] = (action: any) => { | ||
| if (!storeRef) { | ||
| throw new Error( | ||
| 'Store not initialized. Make sure store-dynamic is imported after store creation.', | ||
| ) | ||
| } | ||
| return storeRef.dispatch(action) | ||
| } | ||
|
|
||
| const subscribe: ReduxStore['subscribe'] = (listener: () => void) => { | ||
| if (!storeRef) { | ||
| throw new Error( | ||
| 'Store not initialized. Make sure store-dynamic is imported after store creation.', | ||
| ) | ||
| } | ||
| return storeRef.subscribe(listener) | ||
| } | ||
|
|
||
| // Export store object that matches the real store interface | ||
| export const store = { | ||
| getState, | ||
| dispatch, | ||
| subscribe, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ import { | |
| import { ThemeProvider } from 'styled-components' | ||
| import { themeLight } from '@redis-ui/styles' | ||
| import userEvent from '@testing-library/user-event' | ||
| import { RootState, store as rootStore } from 'uiSrc/slices/store' | ||
| import type { RootState, ReduxStore } from 'uiSrc/slices/store' | ||
| import { initialState as initialStateInstances } from 'uiSrc/slices/instances/instances' | ||
| import { initialState as initialStateTags } from 'uiSrc/slices/instances/tags' | ||
| import { initialState as initialStateCaCerts } from 'uiSrc/slices/instances/caCerts' | ||
|
|
@@ -70,12 +70,14 @@ import { initialState as initialStateAiAssistant } from 'uiSrc/slices/panels/aiA | |
| import { RESOURCES_BASE_URL } from 'uiSrc/services/resourcesService' | ||
| import { apiService } from 'uiSrc/services' | ||
| import { initialState as initialStateAppConnectivity } from 'uiSrc/slices/app/connectivity' | ||
| import { initialState as initialStateAppDbSettings } from 'uiSrc/slices/app/db-settings' | ||
| import { initialState as initialStateAppInit } from 'uiSrc/slices/app/init' | ||
| import * as appFeaturesSlice from 'uiSrc/slices/app/features' | ||
| import { setStoreRef } from './test-store' | ||
|
|
||
| interface Options { | ||
| initialState?: RootState | ||
| store?: typeof rootStore | ||
| store?: ReduxStore | ||
| withRouter?: boolean | ||
| [property: string]: any | ||
| } | ||
|
|
@@ -94,6 +96,7 @@ const initialStateDefault: RootState = { | |
| csrf: cloneDeep(initialStateAppCsrfReducer), | ||
| init: cloneDeep(initialStateAppInit), | ||
| connectivity: cloneDeep(initialStateAppConnectivity), | ||
| dbSettings: cloneDeep(initialStateAppDbSettings), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I forgot that this one was missing. Kudos for resolving it 👌 |
||
| }, | ||
| connections: { | ||
| instances: cloneDeep(initialStateInstances), | ||
|
|
@@ -166,6 +169,10 @@ export const mockStore = configureMockStore<RootState>([thunk]) | |
| export const mockedStore = mockStore(initialStateDefault) | ||
| export const mockedStoreFn = () => mockStore(initialStateDefault) | ||
|
|
||
| // Set the mock store reference for the dynamic store wrapper | ||
| // This ensures that store-dynamic works correctly in tests | ||
| setStoreRef(mockedStore) | ||
|
|
||
| // insert root state to the render Component | ||
| const render = ( | ||
| ui: JSX.Element, | ||
|
|
@@ -176,6 +183,10 @@ const render = ( | |
| ...renderOptions | ||
| }: Options = initialStateDefault, | ||
| ) => { | ||
| if (store !== mockedStore) { | ||
| setStoreRef(store) | ||
| } | ||
|
|
||
| const Wrapper = ({ children }: { children: JSX.Element }) => ( | ||
| <ThemeProvider theme={themeLight}> | ||
| <Provider store={store}>{children}</Provider> | ||
|
|
@@ -196,6 +207,10 @@ const renderHook = ( | |
| ...renderOptions | ||
| }: Options = initialStateDefault, | ||
| ) => { | ||
| if (store !== mockedStore) { | ||
| setStoreRef(store) | ||
| } | ||
|
|
||
| const Wrapper = ({ children }: { children: JSX.Element }) => ( | ||
| <Provider store={store}>{children}</Provider> | ||
| ) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.