Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 1 addition & 36 deletions e2e/storage-s3.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect } from './support/fixtures.js';
import { waitForHydration } from './support/helpers';
import { openConnectForm } from './storage/helpers.js';

declare const process: {
env: Record<string, string | undefined>;
Expand All @@ -18,41 +18,6 @@ declare const process: {
test.describe('Storage S3 (Garage)', () => {
test.use({ locale: 'en-US' });

async function openConnectForm(page: import('@playwright/test').Page) {
await page.goto('/storage');
await waitForHydration(page);

const disconnectButton = page.getByRole('button', { name: 'Disconnect' });
if (await disconnectButton.isVisible().catch(() => false)) {
await disconnectButton.click();
await page.getByRole('dialog').getByRole('button', { name: 'Disconnect' }).click();
}

await expect(page.getByRole('heading', { name: 'Connect to storage' })).toBeVisible();

// Clear all saved connections so tests start from a clean state.
const savedList = page.getByRole('list', { name: 'Saved connections' });
while (await savedList.isVisible().catch(() => false)) {
const items = savedList.getByRole('listitem');
if ((await items.count()) === 0) break;
if (
await items
.first()
.filter({ hasText: 'No saved connections yet' })
.isVisible()
.catch(() => false)
)
break;
await items.first().getByRole('button').last().click({ force: true });
const deleteMenuItem = page.getByRole('menuitem', { name: 'Delete', exact: true });
if (await deleteMenuItem.isVisible().catch(() => false)) {
await deleteMenuItem.click();
await page.getByRole('button', { name: 'Delete', exact: true }).click();
}
await waitForHydration(page);
}
}

test('connects to Garage S3 bucket and lists buckets', async ({ page }) => {
test.skip(
!process.env.S3_TEST_ENDPOINT,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/storage/explorer/FileRow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<td class="w-10 py-0 pr-2 text-right">
<div class="tooltip tooltip-left" data-tip={m.storage_context_menu_actions()}>
<button
class="btn btn-ghost btn-xs opacity-0 group-hover:opacity-100"
class="btn btn-ghost btn-xs text-muted"
aria-label={m.storage_action_actions_for({ name: keyToName(file.key) })}
onclick={(e) => storage.openContextMenu(e, file.key)}
>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/storage/explorer/FolderRow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<td class="w-10 py-0 pr-2 text-right">
<div class="tooltip tooltip-left" data-tip={m.storage_context_menu_actions()}>
<button
class="btn btn-ghost btn-xs opacity-0 group-hover:opacity-100"
class="btn btn-ghost btn-xs text-muted"
aria-label={m.storage_action_actions_for({ name: keyToName(folder.key) })}
onclick={(e) => storage.openContextMenu(e, folder.key)}
>
Expand Down
5 changes: 3 additions & 2 deletions src/lib/components/storage/explorer/StorageBreadcrumb.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
class="
pointer-events-none w-0 shrink-0 overflow-hidden
group-hover:pointer-events-auto group-hover:w-5
focus-within:pointer-events-auto focus-within:w-5
motion-safe:transition-[width] motion-safe:duration-150 motion-safe:group-hover:delay-700
"
>
Expand All @@ -265,12 +266,12 @@
>
<span class="relative inline-flex size-3.5">
<span
class="absolute inset-0 flex items-center justify-center transition-opacity duration-150 group-hover/pin:opacity-0"
class="absolute inset-0 flex items-center justify-center transition-opacity duration-150 group-hover/pin:opacity-0 group-focus-visible/pin:opacity-0"
>
<PinIcon class="size-3.5" aria-hidden="true" />
</span>
<span
class="absolute inset-0 flex items-center justify-center opacity-0 transition-opacity duration-150 group-hover/pin:opacity-100"
class="absolute inset-0 flex items-center justify-center opacity-0 transition-opacity duration-150 group-hover/pin:opacity-100 group-focus-visible/pin:opacity-100"
>
<UnpinIcon class="size-3.5" aria-hidden="true" />
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ describe('FileRow', () => {
await expect.element(btn).toBeInTheDocument();
});

it('should show the actions button without hover or focus', async () => {
const file = makeFile({ key: 'path/my-file.txt', contentType: 'text/plain' });
const state = createState([file]);
render(FileRowWrapper, { state, file });

const btn = page.getByRole('button', { name: 'Actions for my-file.txt' });
await expect.element(btn).toBeInTheDocument();
expect(getComputedStyle(btn.element()).opacity).toBe('1');
});

it('should call toggleSelect on click', async () => {
const file = makeFile({ key: 'click.txt', contentType: 'text/plain' });
const state = createState([file]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ describe('FolderRow', () => {
await expect.element(btn).toBeInTheDocument();
});

it('should show the actions button without hover or focus', async () => {
const folder = makeFolder('my-folder/');
const state = createState([folder]);
render(FolderRowWrapper, { state, folder });

const btn = page.getByRole('button', { name: 'Actions for my-folder' });
await expect.element(btn).toBeInTheDocument();
expect(getComputedStyle(btn.element()).opacity).toBe('1');
});

it('should toggle selection on ctrl+click when not in selection mode', async () => {
const folder = makeFolder('photos/');
const state = createState([folder]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,18 @@ describe('StorageBreadcrumb', () => {
(unpinButton.element() as HTMLElement).click();
expect(spy).toHaveBeenCalledWith('test-bucket', 'data/');
});

it('should expand the pin control when it receives keyboard focus', async () => {
const state = createState({ bucket: 'test-bucket', prefix: 'data/' });
render(StorageBreadcrumbWrapper, { state });

const pinButton = page.getByRole('button', { name: 'Pin' }).last();
await expect.element(pinButton).toBeInTheDocument();
(pinButton.element() as HTMLElement).focus();

await expect.element(pinButton).toHaveFocus();
await expectPointerReachable(pinButton);
});
});

describe('navigation clicks', () => {
Expand Down
Loading