-
Notifications
You must be signed in to change notification settings - Fork 17
fix: conditionally show threads tab based on API response data #2666
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 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2787b86
Initial plan
Copilot 48ab220
fix: conditionally show threads tab based on API response data
Copilot f07b7c3
fix: move tests to e2e suite and fix node Threads data flow
Copilot 48eecc9
fix: correct linter errors and formatting issues
Copilot 349f6ff
fix: correct typo in variable name and simplify e2e test navigation
Copilot 844fd7a
Changes before error encountered
Copilot 2123638
fixes
Raubzeug adc8545
fix: tests
Raubzeug 4357d84
fix: tests
Raubzeug 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,84 @@ | ||
| import {NODE_TABS} from '../NodePages'; | ||
|
|
||
| describe('Node tab filtering logic', () => { | ||
| it('should filter out threads tab when no thread data is provided', () => { | ||
| // Simulate the filtering logic that happens in the Node component | ||
| const isStorageNode = false; | ||
| const isDiskPagesAvailable = false; | ||
| const node: {Threads?: any[]} = { | ||
| // No Threads property | ||
| }; | ||
|
|
||
| let actualNodeTabs = isStorageNode | ||
| ? NODE_TABS | ||
| : NODE_TABS.filter((el) => el.id !== 'storage'); | ||
|
|
||
| if (isDiskPagesAvailable) { | ||
| actualNodeTabs = actualNodeTabs.filter((el) => el.id !== 'structure'); | ||
| } | ||
|
|
||
| // Filter out threads tab if there's no thread data in the API response | ||
| if (!node.Threads || node.Threads.length === 0) { | ||
| actualNodeTabs = actualNodeTabs.filter((el) => el.id !== 'threads'); | ||
| } | ||
|
|
||
| // Should not include threads tab | ||
| expect(actualNodeTabs.some((tab) => tab.id === 'threads')).toBe(false); | ||
| // Should include other tabs | ||
| expect(actualNodeTabs.some((tab) => tab.id === 'tablets')).toBe(true); | ||
| }); | ||
|
|
||
| it('should include threads tab when thread data is provided', () => { | ||
| // Simulate the filtering logic that happens in the Node component | ||
| const isStorageNode = false; | ||
| const isDiskPagesAvailable = false; | ||
| const node: {Threads?: any[]} = { | ||
| Threads: [{Name: 'TestPool', Threads: 4}], | ||
| }; | ||
|
|
||
| let actualNodeTabs = isStorageNode | ||
| ? NODE_TABS | ||
| : NODE_TABS.filter((el) => el.id !== 'storage'); | ||
|
|
||
| if (isDiskPagesAvailable) { | ||
| actualNodeTabs = actualNodeTabs.filter((el) => el.id !== 'structure'); | ||
| } | ||
|
|
||
| // Filter out threads tab if there's no thread data in the API response | ||
| if (!node.Threads || node.Threads.length === 0) { | ||
| actualNodeTabs = actualNodeTabs.filter((el) => el.id !== 'threads'); | ||
| } | ||
|
|
||
| // Should include threads tab | ||
| expect(actualNodeTabs.some((tab) => tab.id === 'threads')).toBe(true); | ||
| // Should include other tabs | ||
| expect(actualNodeTabs.some((tab) => tab.id === 'tablets')).toBe(true); | ||
| }); | ||
|
|
||
| it('should filter out threads tab when thread data is empty array', () => { | ||
| // Simulate the filtering logic that happens in the Node component | ||
| const isStorageNode = false; | ||
| const isDiskPagesAvailable = false; | ||
| const node: {Threads?: any[]} = { | ||
| Threads: [], // Empty array | ||
| }; | ||
|
|
||
| let actualNodeTabs = isStorageNode | ||
| ? NODE_TABS | ||
| : NODE_TABS.filter((el) => el.id !== 'storage'); | ||
|
|
||
| if (isDiskPagesAvailable) { | ||
| actualNodeTabs = actualNodeTabs.filter((el) => el.id !== 'structure'); | ||
| } | ||
|
|
||
| // Filter out threads tab if there's no thread data in the API response | ||
| if (!node.Threads || node.Threads.length === 0) { | ||
| actualNodeTabs = actualNodeTabs.filter((el) => el.id !== 'threads'); | ||
| } | ||
|
|
||
| // Should not include threads tab | ||
| expect(actualNodeTabs.some((tab) => tab.id === 'threads')).toBe(false); | ||
| // Should include other tabs | ||
| expect(actualNodeTabs.some((tab) => tab.id === 'tablets')).toBe(true); | ||
| }); | ||
| }); | ||
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.