Repository navigation
fix(wework): restore persisted task pane on startup #3037
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 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c1031c7
fix(wework): restore persisted task pane on startup
qdaxb c843b38
fix(wework): reconcile stale startup panes
qdaxb 466ff46
fix(wework): open forked task before refresh
qdaxb 0e42a25
test(wework): stabilize automation visibility refresh
qdaxb be20b2e
Merge remote-tracking branch 'origin/main' into fix/wework-restore-co…
qdaxb 7ab675f
fix(wework): preserve project when opening fork
qdaxb 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
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
138 changes: 138 additions & 0 deletions
138
wework/src/components/layout/useWorkbenchSplitGroups.test.tsx
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,138 @@ | ||
| import { act, renderHook, waitFor } from '@testing-library/react' | ||
| import { beforeEach, describe, expect, it } from 'vitest' | ||
| import { | ||
| createWorkbenchSplitGroupsState, | ||
| getActiveWorkbenchLayout, | ||
| serializeWorkbenchSplitGroups, | ||
| } from './workbenchSplitGroups' | ||
| import { collectWorkbenchPaneKeys } from './workbenchSplitLayout' | ||
| import { useWorkbenchSplitGroups } from './useWorkbenchSplitGroups' | ||
|
|
||
| const storageKey = 'workbench-split-groups-test' | ||
| const legacyStorageKey = 'workbench-split-layout-test' | ||
| const restoredRuntimePaneKey = 'runtime:device:finished-task' | ||
|
|
||
| function activePaneKeys(state: ReturnType<typeof useWorkbenchSplitGroups>['state']) { | ||
| return collectWorkbenchPaneKeys(getActiveWorkbenchLayout(state).root) | ||
| } | ||
|
|
||
| describe('useWorkbenchSplitGroups', () => { | ||
| beforeEach(() => { | ||
| localStorage.clear() | ||
| localStorage.setItem( | ||
| storageKey, | ||
| serializeWorkbenchSplitGroups(createWorkbenchSplitGroupsState(restoredRuntimePaneKey)) | ||
| ) | ||
| }) | ||
|
|
||
| it('keeps a restored runtime pane while the startup active pane is still blank', async () => { | ||
| const { result, rerender } = renderHook( | ||
| ({ activePaneKey, runtimeKeysReady }) => | ||
| useWorkbenchSplitGroups({ | ||
| storageKey, | ||
| legacyStorageKey, | ||
| activePaneKey, | ||
| validRuntimeKeys: runtimeKeysReady ? [restoredRuntimePaneKey] : [], | ||
| runtimeKeysReady, | ||
| }), | ||
| { | ||
| initialProps: { | ||
| activePaneKey: 'blank:0', | ||
| runtimeKeysReady: false, | ||
| }, | ||
| } | ||
| ) | ||
|
|
||
| expect(activePaneKeys(result.current.state)).toEqual([restoredRuntimePaneKey]) | ||
|
|
||
| rerender({ | ||
| activePaneKey: 'blank:0', | ||
| runtimeKeysReady: true, | ||
| }) | ||
|
|
||
| await waitFor(() => | ||
| expect(activePaneKeys(result.current.state)).toEqual([restoredRuntimePaneKey]) | ||
| ) | ||
| }) | ||
|
|
||
| it('replaces a stale persisted blank pane with the current startup blank pane', async () => { | ||
| localStorage.setItem( | ||
| storageKey, | ||
| serializeWorkbenchSplitGroups(createWorkbenchSplitGroupsState('blank:1')) | ||
| ) | ||
|
|
||
| const { result } = renderHook(() => | ||
| useWorkbenchSplitGroups({ | ||
| storageKey, | ||
| legacyStorageKey, | ||
| activePaneKey: 'blank:2', | ||
| validRuntimeKeys: [restoredRuntimePaneKey], | ||
| runtimeKeysReady: true, | ||
| }) | ||
| ) | ||
|
|
||
| await waitFor(() => expect(activePaneKeys(result.current.state)).toEqual(['blank:2'])) | ||
| }) | ||
|
|
||
| it('activates an initial runtime pane over a different persisted runtime pane', async () => { | ||
| const currentRuntimePaneKey = 'runtime:device:current-task' | ||
|
|
||
| const { result } = renderHook(() => | ||
| useWorkbenchSplitGroups({ | ||
| storageKey, | ||
| legacyStorageKey, | ||
| activePaneKey: currentRuntimePaneKey, | ||
| validRuntimeKeys: [restoredRuntimePaneKey, currentRuntimePaneKey], | ||
| runtimeKeysReady: true, | ||
| }) | ||
| ) | ||
|
|
||
| await waitFor(() => | ||
| expect(activePaneKeys(result.current.state)).toEqual([currentRuntimePaneKey]) | ||
| ) | ||
| }) | ||
|
|
||
| it('opens the current blank pane after explicit navigation', async () => { | ||
| const { result } = renderHook(() => | ||
| useWorkbenchSplitGroups({ | ||
| storageKey, | ||
| legacyStorageKey, | ||
| activePaneKey: 'blank:0', | ||
| validRuntimeKeys: [restoredRuntimePaneKey], | ||
| runtimeKeysReady: true, | ||
| }) | ||
| ) | ||
|
|
||
| act(() => { | ||
| result.current.activatePane('blank:0') | ||
| }) | ||
|
|
||
| await waitFor(() => expect(activePaneKeys(result.current.state)).toEqual(['blank:0'])) | ||
| }) | ||
|
|
||
| it('removes a restored runtime pane after the loaded task list proves it is invalid', async () => { | ||
| const { result, rerender } = renderHook( | ||
| ({ runtimeKeysReady }) => | ||
| useWorkbenchSplitGroups({ | ||
| storageKey, | ||
| legacyStorageKey, | ||
| activePaneKey: 'blank:0', | ||
| validRuntimeKeys: [], | ||
| runtimeKeysReady, | ||
| }), | ||
| { | ||
| initialProps: { | ||
| runtimeKeysReady: false, | ||
| }, | ||
| } | ||
| ) | ||
|
|
||
| rerender({ runtimeKeysReady: true }) | ||
|
|
||
| await waitFor(() => expect(activePaneKeys(result.current.state)).toEqual(['blank:0'])) | ||
|
|
||
| act(() => { | ||
| expect(localStorage.getItem(storageKey)).toContain('blank:0') | ||
| }) | ||
| }) | ||
| }) |
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.
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.