Repository navigation
[PB-7050]: feat/show Photos as the location of trashed photos #2349
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
8 commits
Select commit
Hold shift + click to select a range
dc6b3b1
feat(user): keep photos bucket on refresh
xabg2 c85bee1
feat(trash): label trashed photos as Photos
xabg2 c50b090
test(trash): cover photos without parent folder
xabg2 f945f18
chore(deps): bump sdk to 1.28.0
xabg2 306fa63
Merge branch 'master' into feat/PB-7050-photos-trash-label
xabg2 6dbea5d
Merge branch 'master' into feat/PB-7050-photos-trash-label
xabg2 81734e7
fix(user): refresh stale photos bucket
xabg2 3c5e098
Merge branch 'master' into feat/PB-7050-photos-trash-label
xabg2 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
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
68 changes: 68 additions & 0 deletions
68
...rive/components/DriveExplorer/components/DriveExplorerList/DriveExplorerListItem.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,68 @@ | ||
| import { afterEach, describe, expect, test, vi } from 'vitest'; | ||
| import { cleanup, render, screen } from '@testing-library/react'; | ||
| import { FileStatus } from '@internxt/sdk/dist/drive/storage/types'; | ||
| import { getDriveItemData } from 'testUtils/fixtures/drive.fixtures'; | ||
| import DriveExplorerListItem from './DriveExplorerListItem'; | ||
|
|
||
| const PHOTOS_BUCKET = 'photos-bucket-id'; | ||
|
|
||
| const mockState = vi.hoisted(() => ({ | ||
| user: { user: { photosBucket: 'photos-bucket-id' as string | null } }, | ||
| workspaces: { selectedWorkspace: null }, | ||
| })); | ||
|
|
||
| vi.mock('app/i18n/provider/TranslationProvider', () => ({ | ||
| useTranslationContext: () => ({ translate: (key: string) => key }), | ||
| })); | ||
|
|
||
| vi.mock('app/store/hooks', () => ({ | ||
| useAppSelector: (selector: (state: typeof mockState) => unknown) => selector(mockState), | ||
| })); | ||
|
|
||
| vi.mock('views/Drive/hooks', () => ({ | ||
| useDriveItemStoreProps: () => ({ isItemSelected: () => false, isEditingName: () => false }), | ||
| useDriveItemActions: () => ({ nameInputRef: { current: null }, downloadAndSetThumbnail: vi.fn() }), | ||
| useDriveItemDrag: () => ({ connectDragSource: (element: JSX.Element) => element, isDraggingThisItem: false }), | ||
| useDriveItemDrop: () => ({ connectDropTarget: (element: JSX.Element) => element, isDraggingOverThisItem: false }), | ||
| })); | ||
|
|
||
| const parentFolder = { plainName: 'Holidays', status: FileStatus.EXISTS, uuid: 'parent-uuid' }; | ||
|
|
||
| const renderTrashItem = (overrides: Parameters<typeof getDriveItemData>[0]) => | ||
| render(<DriveExplorerListItem isTrash item={getDriveItemData({ status: 'TRASHED', ...overrides })} />); | ||
|
|
||
| describe('Trash list item location', () => { | ||
| afterEach(() => { | ||
| cleanup(); | ||
| mockState.user.user.photosBucket = PHOTOS_BUCKET; | ||
| }); | ||
|
|
||
| test('When a photo is in the trash, then its location is Photos', () => { | ||
| renderTrashItem({ bucket: PHOTOS_BUCKET, parent: parentFolder }); | ||
|
|
||
| expect(screen.getByText('sideNav.photos')).toBeInTheDocument(); | ||
| expect(screen.queryByText('Holidays')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('When the original folder of a photo no longer exists, then its location is still Photos', () => { | ||
| renderTrashItem({ bucket: PHOTOS_BUCKET, parent: undefined }); | ||
|
|
||
| expect(screen.getByText('sideNav.photos')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('When a Drive file is in the trash, then its location is the folder it was in', () => { | ||
| renderTrashItem({ bucket: 'drive-bucket-id', parent: parentFolder }); | ||
|
|
||
| expect(screen.getByText('Holidays')).toBeInTheDocument(); | ||
| expect(screen.queryByText('sideNav.photos')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('When the user has not activated Photos, then trashed folders keep their location', () => { | ||
| mockState.user.user.photosBucket = null; | ||
|
|
||
| renderTrashItem({ isFolder: true, bucket: null as unknown as string, parent: parentFolder }); | ||
|
|
||
| expect(screen.getByText('Holidays')).toBeInTheDocument(); | ||
| expect(screen.queryByText('sideNav.photos')).not.toBeInTheDocument(); | ||
| }); | ||
| }); |
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
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.
Store the refreshed bucket when avatar refresh fails.
If
refreshUserDatasucceeds butrefreshAvatarfails, execution enters the catch before it dispatches the refreshed user. The Photos bucket remains stale even though the user response contained the new value. Handle avatar failure separately so the successful user-data refresh can still update the bucket.