-
Notifications
You must be signed in to change notification settings - Fork 17
feat: keep plan representation tab selection between query executions #2625
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 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
310514f
Initial plan
Copilot ce3435f
Add Redux state to persist selected tab between query executions
Copilot b1495c3
Add comprehensive tests for tab persistence functionality
Copilot 221a853
Fix TypeScript types in tab persistence tests
Copilot e66e8c5
docs: update commit messages to follow conventional commit format
Copilot bd8c60b
Merge branch 'main' into copilot/fix-2405
adameat 5ff3dee
refactor: remove duplicate test file resultTab.test.ts
Copilot 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 |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import queryReducer, {setResultTab} from '../query'; | ||
| import type {QueryState} from '../types'; | ||
|
|
||
| describe('resultTab functionality', () => { | ||
| const initialState: QueryState = { | ||
| input: '', | ||
| history: { | ||
| queries: [], | ||
| currentIndex: -1, | ||
| }, | ||
| }; | ||
|
|
||
| test('should set result tab for explain query type', () => { | ||
| const action = setResultTab({queryType: 'explain', tabId: 'json'}); | ||
| const newState = queryReducer(initialState, action); | ||
|
|
||
| expect(newState.selectedResultTab).toEqual({ | ||
| explain: 'json', | ||
| }); | ||
| }); | ||
|
|
||
| test('should set result tab for execute query type', () => { | ||
| const action = setResultTab({queryType: 'execute', tabId: 'stats'}); | ||
| const newState = queryReducer(initialState, action); | ||
|
|
||
| expect(newState.selectedResultTab).toEqual({ | ||
| execute: 'stats', | ||
| }); | ||
| }); | ||
|
|
||
| test('should maintain separate tabs for different query types', () => { | ||
| const state1 = queryReducer( | ||
| initialState, | ||
| setResultTab({queryType: 'explain', tabId: 'json'}), | ||
| ); | ||
| const state2 = queryReducer(state1, setResultTab({queryType: 'execute', tabId: 'stats'})); | ||
|
|
||
| expect(state2.selectedResultTab).toEqual({ | ||
| explain: 'json', | ||
| execute: 'stats', | ||
| }); | ||
| }); | ||
|
|
||
| test('should update existing tab preference', () => { | ||
| const state1 = queryReducer( | ||
| initialState, | ||
| setResultTab({queryType: 'explain', tabId: 'json'}), | ||
| ); | ||
| const state2 = queryReducer(state1, setResultTab({queryType: 'explain', tabId: 'ast'})); | ||
|
|
||
| expect(state2.selectedResultTab).toEqual({ | ||
| explain: 'ast', | ||
| }); | ||
| }); | ||
| }); |
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,79 @@ | ||
| import queryReducer, {setResultTab} from '../query'; | ||
| import type {QueryState} from '../types'; | ||
|
|
||
| describe('QueryResultViewer tab persistence integration', () => { | ||
| const initialState: QueryState = { | ||
| input: '', | ||
| history: { | ||
| queries: [], | ||
| currentIndex: -1, | ||
| }, | ||
| }; | ||
|
|
||
| it('should save and retrieve tab selection for explain queries', () => { | ||
| // Test that we can set and get the tab preference | ||
| let state = queryReducer(initialState, setResultTab({queryType: 'explain', tabId: 'json'})); | ||
|
|
||
| expect(state.selectedResultTab).toEqual({ | ||
| explain: 'json', | ||
| }); | ||
|
|
||
| // Test updating the same query type | ||
| state = queryReducer(state, setResultTab({queryType: 'explain', tabId: 'ast'})); | ||
|
|
||
| expect(state.selectedResultTab).toEqual({ | ||
| explain: 'ast', | ||
| }); | ||
| }); | ||
|
|
||
| it('should save and retrieve tab selection for execute queries', () => { | ||
| const state = queryReducer( | ||
| initialState, | ||
| setResultTab({queryType: 'execute', tabId: 'stats'}), | ||
| ); | ||
|
|
||
| expect(state.selectedResultTab).toEqual({ | ||
| execute: 'stats', | ||
| }); | ||
| }); | ||
|
|
||
| it('should maintain separate preferences for different query types', () => { | ||
| let state = initialState; | ||
|
|
||
| // Set explain tab | ||
| state = queryReducer(state, setResultTab({queryType: 'explain', tabId: 'json'})); | ||
| expect(state.selectedResultTab).toEqual({ | ||
| explain: 'json', | ||
| }); | ||
|
|
||
| // Set execute tab - should not override explain | ||
| state = queryReducer(state, setResultTab({queryType: 'execute', tabId: 'stats'})); | ||
| expect(state.selectedResultTab).toEqual({ | ||
| explain: 'json', | ||
| execute: 'stats', | ||
| }); | ||
|
|
||
| // Update explain tab - should not affect execute | ||
| state = queryReducer(state, setResultTab({queryType: 'explain', tabId: 'ast'})); | ||
| expect(state.selectedResultTab).toEqual({ | ||
| explain: 'ast', | ||
| execute: 'stats', | ||
| }); | ||
| }); | ||
|
|
||
| it('should handle multiple updates to the same query type', () => { | ||
| let state = initialState; | ||
|
|
||
| // Set initial value | ||
| state = queryReducer(state, setResultTab({queryType: 'explain', tabId: 'schema'})); | ||
| expect(state.selectedResultTab?.explain).toBe('schema'); | ||
|
|
||
| // Update to different tab | ||
| state = queryReducer(state, setResultTab({queryType: 'explain', tabId: 'json'})); | ||
| expect(state.selectedResultTab?.explain).toBe('json'); | ||
|
|
||
| // Update again | ||
| state = queryReducer(state, setResultTab({queryType: 'explain', tabId: 'ast'})); | ||
| expect(state.selectedResultTab?.explain).toBe('ast'); | ||
| }); | ||
| }); |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This useEffect only runs cleanup logic and doesn't depend on any values, but it's placed in the middle of the component logic. Consider moving it closer to other useEffect hooks or to the end of the component for better code organization.