Skip to content

Commit

Permalink
refactor(renterd): remove default bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Sep 26, 2024
1 parent 7b2555d commit 7a333ff
Show file tree
Hide file tree
Showing 37 changed files with 480 additions and 126 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-ligers-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The bucket list now has an empty state.
5 changes: 5 additions & 0 deletions .changeset/gentle-grapes-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The cmdk menu now has an two separate files search options, one for across all buckets and one for the current bucket.
5 changes: 5 additions & 0 deletions .changeset/honest-books-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

It is now possible to delete a bucket named 'default'.
7 changes: 7 additions & 0 deletions .changeset/many-numbers-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/renterd-js': minor
'@siafoundation/renterd-react': minor
'@siafoundation/renterd-types': minor
---

Updated to the new objects remove API.
5 changes: 5 additions & 0 deletions .changeset/proud-rules-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The file search feature can now search across all buckets.
6 changes: 6 additions & 0 deletions .changeset/silver-months-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'hostd': minor
'renterd': minor
---

The command menu now opens via Ctrl+K on Linux and Windows.
7 changes: 7 additions & 0 deletions .changeset/wild-hats-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/renterd-js': minor
'@siafoundation/renterd-react': minor
'@siafoundation/renterd-types': minor
---

Adjusted the name of the objects rename API.
2 changes: 1 addition & 1 deletion apps/hostd/components/CmdKDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function CmdKDialog({ open, onOpenChange, setOpen }: Props) {
return
}
const down = (e: KeyboardEvent) => {
if (e.key === 'k' && e.metaKey) {
if (e.key === 'k' && (e.metaKey || e.ctrlKey)) {
setOpen()
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/renterd-e2e/src/fixtures/buckets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { deleteDirectory, deleteFile } from './files'

export async function createBucket(page: Page, name: string) {
await navigateToBuckets({ page })
await page.getByText('Create bucket').click()
await page.getByText('Create bucket').first().click()
await fillTextInputByName(page, 'name', name)
await page.locator('input[name=name]').press('Enter')
await expect(page.getByRole('dialog')).toBeHidden()
Expand Down
10 changes: 10 additions & 0 deletions apps/renterd-e2e/src/fixtures/cmdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Page, expect } from '@playwright/test'

export async function openCmdkMenu(page: Page) {
const isMac = process.platform === 'darwin'
const modifier = isMac ? 'Meta' : 'Control'
await page.keyboard.press(`${modifier}+k`)
const dialog = page.getByRole('dialog')
await expect(dialog.locator('div[cmdk-root]')).toBeVisible()
return dialog
}
13 changes: 10 additions & 3 deletions apps/renterd-e2e/src/fixtures/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,17 @@ export async function openDirectory(page: Page, path: string) {
}

export async function navigateToParentDirectory(page: Page) {
await page.getByRole('cell', { name: '..' }).click()
const isEmpty = await page
.getByText('The current directory does not contain any files yet')
.isVisible()
if (isEmpty) {
await page.getByRole('button', { name: 'Back' }).click()
} else {
await page.getByRole('cell', { name: '..' }).click()
}
}

export async function crateDirectory(page: Page, name: string) {
export async function createDirectory(page: Page, name: string) {
await expect(page.getByLabel('Create directory')).toBeVisible()
await page.getByLabel('Create directory').click()
await fillTextInputByName(page, 'name', name)
Expand All @@ -86,7 +93,7 @@ export async function createDirectoryIfNotExists(page: Page, name: string) {
.getByTestId(name)
.isVisible()
if (!exists) {
await crateDirectory(page, name)
await createDirectory(page, name)
}
}

Expand Down
19 changes: 12 additions & 7 deletions apps/renterd-e2e/src/specs/buckets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
bucketInList,
createBucket,
deleteBucket,
deleteBucketIfExists,
openBucketContextMenu,
} from '../fixtures/buckets'
import { afterTest, beforeTest } from '../fixtures/beforeTest'
Expand All @@ -18,19 +17,25 @@ test.afterEach(async () => {
})

test('can change a buckets policy', async ({ page }) => {
const bucketName = 'bucket1'
await navigateToBuckets({ page })
await openBucketContextMenu(page, 'default')
await expect(page.getByText('Create a bucket to get started.')).toBeVisible()
await createBucket(page, bucketName)
await openBucketContextMenu(page, bucketName)
await page.getByRole('menuitem', { name: 'Change policy' }).click()
await page.getByRole('heading', { name: 'Change Policy: default' }).click()
await page
.getByRole('heading', { name: `Change Policy: ${bucketName}` })
.click()
await page.getByRole('combobox').selectOption('public')
await page.getByRole('button', { name: 'Update policy' }).click()
await expect(page.getByText('Bucket policy has been updated')).toBeVisible()
await bucketInList(page, 'default')
await bucketInList(page, bucketName)
})

test('can create and delete a bucket', async ({ page }) => {
const bucketName = 'my-new-bucket'
await navigateToBuckets({ page })
await deleteBucketIfExists(page, 'my-new-bucket')
await createBucket(page, 'my-new-bucket')
await deleteBucket(page, 'my-new-bucket')
await expect(page.getByText('Create a bucket to get started.')).toBeVisible()
await createBucket(page, bucketName)
await deleteBucket(page, bucketName)
})
66 changes: 43 additions & 23 deletions apps/renterd-e2e/src/specs/files.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import { test, expect } from '@playwright/test'
import { navigateToBuckets } from '../fixtures/navigate'
import {
createBucket,
deleteBucketIfExists,
openBucket,
} from '../fixtures/buckets'
import { createBucket, deleteBucket, openBucket } from '../fixtures/buckets'
import path from 'path'
import {
createDirectoryIfNotExists,
deleteDirectoryIfExists,
deleteFileIfExists,
deleteDirectory,
deleteFile,
dragAndDropFile,
fileInList,
fileNotInList,
getFileRowById,
navigateToParentDirectory,
openDirectory,
openFileContextMenu,
createDirectory,
} from '../fixtures/files'
import { fillTextInputByName } from '../fixtures/textInput'
import { clearToasts } from '../fixtures/clearToasts'
Expand All @@ -32,28 +28,53 @@ test.afterEach(async () => {
await afterTest()
})

test('can create directory and delete a directory', async ({ page }) => {
test.setTimeout(120_000)
const bucketName = 'files-test'
const dirName1 = 'test-dir'
const dirName2 = 'test-dir-2-same-prefix'
const dirPath1 = `${bucketName}/${dirName1}/`
const dirPath2 = `${bucketName}/${dirName2}/`

await navigateToBuckets({ page })
await createBucket(page, bucketName)
await openBucket(page, bucketName)
await expect(
page.getByText('bucket does not contain any files')
).toBeVisible()

// Create directory.
await createDirectory(page, dirName1)
await createDirectory(page, dirName2)
await openDirectory(page, dirPath1)
await navigateToParentDirectory(page)
await deleteDirectory(page, dirPath1)
await fileNotInList(page, dirPath1)
await fileNotInList(page, dirPath1)
await fileInList(page, dirPath2)
})

test('can create directory, upload file, rename file, navigate, delete a file, delete a directory', async ({
page,
}) => {
test.setTimeout(80_000)
test.setTimeout(120_000)
const bucketName = 'files-test'
const dirName = `test-dir-${Date.now()}`
const dirName = 'test-dir'
const originalFileName = 'sample.txt'
const newFileName = 'renamed.txt'
const dirPath = `${bucketName}/${dirName}/`
const originalFilePath = `${bucketName}/${dirName}/${originalFileName}`
const newFilePath = `${bucketName}/${dirName}/${newFileName}`

await navigateToBuckets({ page })
await deleteBucketIfExists(page, bucketName)
await createBucket(page, bucketName)
await openBucket(page, bucketName)
await expect(
page.getByText('bucket does not contain any files')
).toBeVisible()

// Create directory.
await createDirectoryIfNotExists(page, dirName)
await createDirectory(page, dirName)
await fileInList(page, dirPath)
await openDirectory(page, dirPath)
await expect(
Expand All @@ -74,13 +95,13 @@ test('can create directory, upload file, rename file, navigate, delete a file, d
// Rename file.
await openFileContextMenu(page, originalFilePath)
await page.getByRole('menuitem', { name: 'Rename file' }).click()
await fillTextInputByName(page, 'name', 'renamed.txt')
await fillTextInputByName(page, 'name', newFileName)
await page.locator('input[name=name]').press('Enter')
await expect(page.getByRole('dialog')).toBeHidden()
await fileInList(page, newFilePath)

// Delete file.
await deleteFileIfExists(page, newFilePath)
await deleteFile(page, newFilePath)
await fileNotInList(page, newFilePath)
await clearToasts({ page })

Expand All @@ -97,20 +118,20 @@ test('can create directory, upload file, rename file, navigate, delete a file, d
// Clean up the directory.
await navigateToParentDirectory(page)
await fileInList(page, dirPath)
await deleteDirectoryIfExists(page, dirPath)
await deleteDirectory(page, dirPath)
await fileNotInList(page, dirPath)

// Clean up the bucket.
await navigateToBuckets({ page })
await deleteBucketIfExists(page, bucketName)
await deleteBucket(page, bucketName)
})

test('shows a new intermediate directory when uploading nested files', async ({
page,
}) => {
test.setTimeout(80_000)
test.setTimeout(120_000)
const bucketName = 'files-test'
const containerDir = `test-dir-${Date.now()}`
const containerDir = 'test-dir'
const containerDirPath = `${bucketName}/${containerDir}/`
const systemDir = 'nested-sample'
const systemFile = 'sample.txt'
Expand All @@ -119,15 +140,14 @@ test('shows a new intermediate directory when uploading nested files', async ({
const filePath = `${dirPath}${systemFile}`

await navigateToBuckets({ page })
await deleteBucketIfExists(page, bucketName)
await createBucket(page, bucketName)
await openBucket(page, bucketName)
await expect(
page.getByText('bucket does not contain any files')
).toBeVisible()

// Create a container directory for the test.
await createDirectoryIfNotExists(page, containerDir)
await createDirectory(page, containerDir)
await fileInList(page, containerDirPath)
await openDirectory(page, containerDirPath)
await expect(
Expand Down Expand Up @@ -163,10 +183,10 @@ test('shows a new intermediate directory when uploading nested files', async ({
// Clean up the container directory.
await navigateToParentDirectory(page)
await fileInList(page, containerDirPath)
await deleteDirectoryIfExists(page, containerDirPath)
await deleteDirectory(page, containerDirPath)
await fileNotInList(page, containerDirPath)

// Clean up the bucket.
// Delete the bucket once its empty.
await navigateToBuckets({ page })
await deleteBucketIfExists(page, bucketName)
await deleteBucket(page, bucketName)
})
Loading

0 comments on commit 7a333ff

Please sign in to comment.