mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
Chore/fix storage explorer when switching buckets (#43541)
## Context Taking a slightly different approach to [this PR](https://github.com/supabase/supabase/pull/43370) Original problem was that if you opened some folders while in a bucket and then switched to a different bucket, the folder UI will persists (folders from Bucket A will render when landing on Bucket B) ## Changes involved - Shift `StorageExplorerStateContextProvider` into `[bucketId].tsx]` instead of `ProjectContext` - The valtio store here only applies for the storage explorer so having it so high in the project's context was unnecessary - This also just implies that the valtio store will automatically reset whenever the bucket changes - Simplify storage explorer valtio store by initializing the store with the bucket - We'll initialize the selected bucket with the store now (Same as previous PR) - Removes unnecessary `setSelectedBucket` method which required a separate `useEffect` in `StorageExplorer.tsx` ## To test - [ ] Verify that the original is resolved - [ ] General smoke test of the storage explorer - i've also re-added the e2e test that Gildas wrote up in his PR
This commit is contained in:
1 parent
4a173eea60
commit
9b0dc8d9b9
6 files changed
+68
-50
No files matched your search
@@ -1,8 +1,7 @@
|
||||
import { expect } from '@playwright/test'
|
||||
import path from 'path'
|
||||
import { expect } from '@playwright/test'
|
||||
|
||||
import { env } from '../env.config.js'
|
||||
import { test } from '../utils/test.js'
|
||||
import { waitForApiResponse } from '../utils/wait-for-response.js'
|
||||
import {
|
||||
createBucket,
|
||||
createFolder,
|
||||
@@ -18,6 +17,8 @@ import {
|
||||
createBucket as createBucketViaApi,
|
||||
deleteBucket as deleteBucketViaApi,
|
||||
} from '../utils/storage/index.js'
|
||||
import { test } from '../utils/test.js'
|
||||
import { waitForApiResponse } from '../utils/wait-for-response.js'
|
||||
|
||||
const bucketNamePrefix = 'pw_bucket'
|
||||
|
||||
@@ -291,6 +292,34 @@ test.describe('Storage', () => {
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
test('resets storage view when switching buckets', async ({ page, ref }) => {
|
||||
const bucketName = `${bucketNamePrefix}_navigation`
|
||||
const bucketName2 = `${bucketNamePrefix}2_navigation`
|
||||
const folderName = 'folder_navigation'
|
||||
const fileName = 'test-file.txt'
|
||||
|
||||
// Create 2 bucket via API, navigate to the first
|
||||
await deleteBucketViaApi(bucketName)
|
||||
await deleteBucketViaApi(bucketName2)
|
||||
await createBucketViaApi(bucketName, false)
|
||||
await createBucketViaApi(bucketName2, false)
|
||||
await navigateToStorageFiles(page, ref)
|
||||
await navigateToBucket(page, ref, bucketName)
|
||||
|
||||
// create a folder and add a file
|
||||
await createFolder(page, folderName)
|
||||
// Open the folder
|
||||
await page.getByTitle(folderName).click()
|
||||
const filePath = path.join(import.meta.dirname, 'files', fileName)
|
||||
await uploadFile(page, filePath, fileName)
|
||||
|
||||
// Navigate to bucket list
|
||||
await page.getByRole('link', { name: 'Files' }).nth(1).click()
|
||||
// Navigate to the 2nd bucket
|
||||
await navigateToBucket(page, ref, bucketName2)
|
||||
await expect(page.getByTitle(fileName)).not.toBeVisible()
|
||||
})
|
||||
|
||||
test('can delete a file', async ({ page, ref }) => {
|
||||
const bucketName = `${bucketNamePrefix}_delete_file`
|
||||
const fileName = 'test-file.txt'
|
||||
|
||||
Reference in new issue
Block a user