diff --git a/e2e/storage/connections-management.spec.ts b/e2e/storage/connections-management.spec.ts index e05a9686..c449f43e 100644 --- a/e2e/storage/connections-management.spec.ts +++ b/e2e/storage/connections-management.spec.ts @@ -1,4 +1,4 @@ -import { test, expect, type Page } from '../support/fixtures.js'; +import { test, expect, type Locator, type Page } from '../support/fixtures.js'; import { createGarageBucketCredentials, hasGarageAdmin, @@ -21,6 +21,29 @@ async function openFirstConnectionEditPage(page: Page) { await waitForHydration(page); } +/** + * Asserts that an open dropdown menu sits right below its trigger, aligned to its end. Up to 8 px + * gap for the scripted fallback in browsers without CSS anchor positioning; a few px for the + * popover's padding and border around the menu. + */ +async function expectMenuBelow(trigger: Locator, menu: Locator) { + await expect(menu).toBeVisible(); + // Let DaisyUI's scale-in animation finish before measuring. + await menu.evaluate((el) => + Promise.all( + el + .closest('[popover]')! + .getAnimations() + .map((a) => a.finished) + ) + ); + const t = (await trigger.boundingBox())!; + const m = (await menu.boundingBox())!; + expect(m.y).toBeGreaterThanOrEqual(t.y + t.height - 1); + expect(m.y).toBeLessThan(t.y + t.height + 14); + expect(Math.abs(m.x + m.width - (t.x + t.width))).toBeLessThan(14); +} + test.describe('Storage — Connections management', () => { test.use({ locale: 'en-US' }); @@ -184,10 +207,11 @@ test.describe('Storage — Connections management', () => { const dataRows = page.locator('table tbody tr'); const initialItems = await dataRows.count(); - await page - .getByRole('button', { name: /Options for/i }) - .first() - .click({ force: true }); + // Opened from the keyboard, which used to put the menu at the viewport's top-left corner. + const trigger = page.getByRole('button', { name: /Options for/i }).first(); + await trigger.focus(); + await page.keyboard.press('Enter'); + await expectMenuBelow(trigger, page.getByRole('menu', { name: /Options for/i })); await page.getByRole('menuitem', { name: 'Delete' }).click(); // Confirm deletion in the modal @@ -204,12 +228,18 @@ test.describe('Storage — Connections management', () => { await page.getByRole('dialog').getByRole('button', { name: 'Disconnect' }).click(); await expect(page.getByRole('heading', { name: 'Connect to storage' })).toBeVisible(); const savedList = page.getByRole('list', { name: 'Saved connections' }); - await savedList.getByRole('button', { name: 'More options' }).first().click({ force: true }); + await savedList + .getByRole('button', { name: /Options for/ }) + .first() + .click({ force: true }); await page.getByRole('menuitem', { name: 'Edit', exact: true }).click(); await waitForHydration(page); await expect(page.getByRole('heading', { name: 'Edit connection' })).toBeVisible(); - await savedList.getByRole('button', { name: 'More options' }).first().click({ force: true }); + const trigger = savedList.getByRole('button', { name: /Options for/ }).first(); + await trigger.focus(); + await page.keyboard.press('Enter'); + await expectMenuBelow(trigger, page.getByRole('menu', { name: /Options for/ })); await page.getByRole('menuitem', { name: 'Delete', exact: true }).click(); await page.getByRole('dialog').getByRole('button', { name: 'Delete', exact: true }).click(); @@ -377,7 +407,10 @@ test.describe('Storage — Connection edit sidebar', () => { await expect(page.getByRole('heading', { name: 'Connect to storage' })).toBeVisible(); const savedList = page.getByRole('list', { name: 'Saved connections' }); await expect(savedList.getByRole('listitem')).toHaveCount(2); - await savedList.getByRole('button', { name: 'More options' }).first().click({ force: true }); + await savedList + .getByRole('button', { name: /Options for/ }) + .first() + .click({ force: true }); await page.getByRole('menuitem', { name: 'Edit', exact: true }).click(); await waitForHydration(page); await expect(page.getByRole('heading', { name: 'Edit connection' })).toBeVisible(); @@ -398,7 +431,7 @@ test.describe('Storage — Connection edit sidebar', () => { async function deleteFromSidebar(page: Page, index: number) { await page .getByRole('list', { name: 'Saved connections' }) - .getByRole('button', { name: 'More options' }) + .getByRole('button', { name: /Options for/ }) .nth(index) .click({ force: true }); await page.getByRole('menuitem', { name: 'Delete', exact: true }).click(); diff --git a/e2e/storage/context-menu.spec.ts b/e2e/storage/context-menu.spec.ts index 979e05d5..6533c56f 100644 --- a/e2e/storage/context-menu.spec.ts +++ b/e2e/storage/context-menu.spec.ts @@ -99,37 +99,6 @@ test.describe('Storage S3 — Context Menu', () => { } }); - test('unpins a pinned location from its sidebar menu', async ({ page }, testInfo) => { - const credentials = requireGarageCredentials(); - const client = createS3Client(credentials); - const prefix = uniquePrefix(testInfo, 'ctx-unpin'); - const cleanupKeys = [`${prefix}file.txt`]; - - try { - await putTextObject(client, credentials.bucket, cleanupKeys[0], 'x'); - await connectAndOpenPrefix(page, credentials, prefix); - - const breadcrumb = page.getByRole('navigation', { name: 'Breadcrumb' }); - await breadcrumb.getByText(credentials.bucket).hover(); - await page - .getByRole('button', { name: 'Pin this location' }) - .filter({ visible: true }) - .first() - .click(); - const sidebar = page.getByRole('navigation', { name: 'Buckets' }); - await expect(sidebar.getByText('Pinned Access')).toBeVisible(); - - await sidebar.getByRole('button', { name: 'More options' }).click({ force: true }); - const menu = page.getByRole('menu', { name: 'Actions' }); - await menu.getByRole('menuitem', { name: 'Unpin' }).click(); - - await expect(menu).toHaveCount(0); - await expect(sidebar.getByText('Pinned Access')).toHaveCount(0); - } finally { - await deleteKnownKeys(client, credentials.bucket, cleanupKeys); - } - }); - test('deletes a single file via context menu', async ({ page }, testInfo) => { const credentials = requireGarageCredentials(); const client = createS3Client(credentials); diff --git a/e2e/storage/pinning.spec.ts b/e2e/storage/pinning.spec.ts new file mode 100644 index 00000000..4c402de6 --- /dev/null +++ b/e2e/storage/pinning.spec.ts @@ -0,0 +1,48 @@ +import { test, expect } from '../support/fixtures.js'; +import { + createS3Client, + hasGarageCredentials, + requireGarageCredentials +} from '../support/garage.js'; +import { connectAndOpenPrefix, deleteKnownKeys, putTextObject, uniquePrefix } from './helpers.js'; + +test.describe('Storage S3 — Pinned locations', () => { + test.use({ locale: 'en-US' }); + + test.beforeEach(() => { + test.skip( + !hasGarageCredentials(), + 'Skipped: no s3-config.json found (requires a running Garage instance)' + ); + }); + + test('unpins a pinned location with its sidebar button', async ({ page }, testInfo) => { + const credentials = requireGarageCredentials(); + const client = createS3Client(credentials); + const prefix = uniquePrefix(testInfo, 'unpin'); + const cleanupKeys = [`${prefix}file.txt`]; + + try { + await putTextObject(client, credentials.bucket, cleanupKeys[0], 'x'); + await connectAndOpenPrefix(page, credentials, prefix); + + const breadcrumb = page.getByRole('navigation', { name: 'Breadcrumb' }); + await breadcrumb.getByText(credentials.bucket).hover(); + await page + .getByRole('button', { name: 'Pin this location' }) + .filter({ visible: true }) + .first() + .click(); + const sidebar = page.getByRole('navigation', { name: 'Buckets' }); + await expect(sidebar.getByText('Pinned Access')).toBeVisible(); + + await sidebar.getByRole('button', { name: `Unpin ${credentials.bucket}` }).click({ + force: true + }); + + await expect(sidebar.getByText('Pinned Access')).toHaveCount(0); + } finally { + await deleteKnownKeys(client, credentials.bucket, cleanupKeys); + } + }); +}); diff --git a/messages/de.json b/messages/de.json index 33059d9f..ce87961f 100644 --- a/messages/de.json +++ b/messages/de.json @@ -323,6 +323,7 @@ "storage_action_pin": "Ort anheften", "storage_action_details": "Details", "storage_action_unpin": "Loslösen", + "storage_unpin_location": "{label} lösen", "storage_action_copy_filename": "Dateiname kopieren", "storage_action_copy_filename_success": "Dateiname in die Zwischenablage kopiert.", "storage_action_copy_filename_error": "Dateiname konnte nicht in die Zwischenablage kopiert werden.", @@ -333,7 +334,6 @@ "storage_action_copy_path_success": "Pfad in die Zwischenablage kopiert.", "storage_action_copy_path_error": "Pfad konnte nicht in die Zwischenablage kopiert werden.", "storage_pinned_label": "Angeheftete Orte", - "storage_more_options": "Weitere Optionen", "storage_recent_files": "Zuletzt geöffnete Dateien", "storage_recent_locations": "Zuletzt besuchte Orte", "storage_recent_empty_files": "Keine zuletzt geöffneten Dateien.", diff --git a/messages/en.json b/messages/en.json index 647dbc5e..ccd3a871 100644 --- a/messages/en.json +++ b/messages/en.json @@ -323,6 +323,7 @@ "storage_action_pin": "Pin this location", "storage_action_details": "Details", "storage_action_unpin": "Unpin", + "storage_unpin_location": "Unpin {label}", "storage_action_copy_filename": "Copy filename", "storage_action_copy_filename_success": "Filename copied to clipboard.", "storage_action_copy_filename_error": "Could not copy filename to clipboard.", @@ -333,7 +334,6 @@ "storage_action_copy_path_success": "Path copied to clipboard.", "storage_action_copy_path_error": "Could not copy path to clipboard.", "storage_pinned_label": "Pinned Access", - "storage_more_options": "More options", "storage_recent_files": "Recent Files", "storage_recent_locations": "Recent Locations", "storage_recent_empty_files": "No recently accessed files.", diff --git a/src/lib/components/DateTimePicker.svelte b/src/lib/components/DateTimePicker.svelte index a3b47531..e6efcbe6 100644 --- a/src/lib/components/DateTimePicker.svelte +++ b/src/lib/components/DateTimePicker.svelte @@ -9,7 +9,7 @@ positionPopoverRelativeToTrigger, supportsAnchorPositioning, trackPopover - } from '$lib/components/popover-position.js'; + } from '$lib/components/ui/popover-position.js'; import IconCalendar from 'virtual:icons/material-symbols/calendar-today'; import IconChevronLeft from 'virtual:icons/material-symbols/chevron-left'; import IconChevronRight from 'virtual:icons/material-symbols/chevron-right'; diff --git a/src/lib/components/storage/BucketSelect.svelte b/src/lib/components/storage/BucketSelect.svelte index 75ca4bab..ab684d9a 100644 --- a/src/lib/components/storage/BucketSelect.svelte +++ b/src/lib/components/storage/BucketSelect.svelte @@ -1,6 +1,6 @@ - -