-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: renterd file rename, add e2e tests
- Loading branch information
1 parent
1a4a2bd
commit b573d33
Showing
27 changed files
with
419 additions
and
109 deletions.
There are no files selected for viewing
This file contains 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,5 @@ | ||
--- | ||
'@siafoundation/design-system': minor | ||
--- | ||
|
||
Updated react-hook-form. |
This file contains 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,5 @@ | ||
--- | ||
'renterd': patch | ||
--- | ||
|
||
Fixed an issue where renaming a file would throw an error. |
This file contains 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,5 @@ | ||
--- | ||
'renterd': patch | ||
--- | ||
|
||
Fixed an issue where the empty directory state was showing an empty bucket message. |
This file contains 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,16 @@ | ||
import { mockApiSiaCentralExchangeRates } from '@siafoundation/sia-central-mock' | ||
import { login } from './login' | ||
import { navigateToConfig } from './navigate' | ||
import { configResetAllSettings } from './configResetAllSettings' | ||
import { setViewMode } from './configViewMode' | ||
import { Page } from 'playwright' | ||
|
||
export async function beforeTest(page: Page) { | ||
await mockApiSiaCentralExchangeRates({ page }) | ||
await login({ page }) | ||
|
||
// Reset state. | ||
await navigateToConfig({ page }) | ||
await configResetAllSettings({ page }) | ||
await setViewMode({ page, state: 'basic' }) | ||
} |
This file contains 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 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 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,115 @@ | ||
import { Page, expect } from '@playwright/test' | ||
import { readFileSync } from 'fs' | ||
import { fillTextInputByName } from './textInput' | ||
|
||
export async function deleteFile(page: Page, path: string) { | ||
await openFileContextMenu(page, path) | ||
await page.getByRole('menuitem', { name: 'Delete file' }).click() | ||
await expect(page.getByRole('dialog').getByText('Delete file')).toBeVisible() | ||
await page.locator('form button[type=submit]').click() | ||
await expect(page.getByRole('dialog')).toBeHidden() | ||
await fileNotInList(page, path) | ||
} | ||
|
||
export async function deleteFileIfExists(page: Page, path: string) { | ||
const exists = await page.getByRole('table').getByTestId(path).isVisible() | ||
if (exists) { | ||
await deleteFile(page, path) | ||
} | ||
} | ||
|
||
export async function deleteDirectory(page: Page, path: string) { | ||
await openDirectoryContextMenu(page, path) | ||
const deleteDirectoryItem = page.getByRole('menuitem', { | ||
name: 'Delete directory', | ||
}) | ||
await expect(deleteDirectoryItem).toBeVisible() | ||
await deleteDirectoryItem.click() | ||
await expect( | ||
page.getByRole('dialog').getByText('Delete directory') | ||
).toBeVisible() | ||
await page.locator('form button[type=submit]').click() | ||
await expect(page.getByRole('dialog')).toBeHidden() | ||
await fileNotInList(page, path) | ||
} | ||
|
||
export async function deleteDirectoryIfExists(page: Page, path: string) { | ||
const exists = await page.getByRole('table').getByTestId(path).isVisible() | ||
if (exists) { | ||
await deleteDirectory(page, path) | ||
} | ||
} | ||
|
||
export async function openDirectoryContextMenu(page: Page, path: string) { | ||
const selector = page.getByTestId(path).getByLabel('Directory context menu') | ||
// Click doesn't work until animation is finished. | ||
// eslint-disable-next-line playwright/no-wait-for-timeout | ||
await page.waitForTimeout(100) | ||
await expect(selector).toBeVisible() | ||
await selector.click() | ||
} | ||
|
||
export async function openFileContextMenu(page: Page, path: string) { | ||
const selector = page.getByTestId(path).getByLabel('File context menu') | ||
await expect(selector).toBeVisible() | ||
await selector.click() | ||
} | ||
|
||
export async function openDirectory(page: Page, path: string) { | ||
await page.getByRole('table').getByTestId(path).click() | ||
for (const dir of path.split('/').slice(0, -1)) { | ||
await expect(page.getByTestId('navbar').getByText(dir)).toBeVisible() | ||
} | ||
} | ||
|
||
export async function crateDirectory(page: Page, name: string) { | ||
await expect(page.getByLabel('Create directory')).toBeVisible() | ||
await page.getByLabel('Create directory').click() | ||
await fillTextInputByName(page, 'name', name) | ||
await page.locator('input[name=name]').press('Enter') | ||
await expect(page.getByRole('dialog')).toBeHidden() | ||
} | ||
|
||
export async function createDirectoryIfNotExists(page: Page, name: string) { | ||
const exists = await page.getByRole('table').getByTestId(name).isVisible() | ||
if (!exists) { | ||
await crateDirectory(page, name) | ||
} | ||
} | ||
|
||
export async function fileInList(page: Page, path: string) { | ||
await expect(page.getByRole('table').getByTestId(path)).toBeVisible() | ||
} | ||
|
||
export async function fileNotInList(page: Page, path: string) { | ||
await expect(page.getByRole('table').getByTestId(path)).toBeHidden() | ||
} | ||
|
||
export async function dragAndDropFile( | ||
page: Page, | ||
selector: string, | ||
filePath: string, | ||
fileName: string, | ||
fileType = '' | ||
) { | ||
const buffer = readFileSync(filePath).toString('base64') | ||
|
||
const dataTransfer = await page.evaluateHandle( | ||
async ({ bufferData, localFileName, localFileType }) => { | ||
const dt = new DataTransfer() | ||
|
||
const blobData = await fetch(bufferData).then((res) => res.blob()) | ||
|
||
const file = new File([blobData], localFileName, { type: localFileType }) | ||
dt.items.add(file) | ||
return dt | ||
}, | ||
{ | ||
bufferData: `data:application/octet-stream;base64,${buffer}`, | ||
localFileName: fileName, | ||
localFileType: fileType, | ||
} | ||
) | ||
|
||
await page.dispatchEvent(selector, 'drop', { dataTransfer }) | ||
} |
This file contains 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 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 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.