From a1f6d63e0aa857105ea1b5531de4b7ae00fc337e Mon Sep 17 00:00:00 2001 From: Frederic Cabassut Date: Sun, 8 Mar 2026 21:33:57 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20E2E=20test=20fixes=20=E2=80=94=20static?= =?UTF-8?q?=20test=20image,=20thumbnail=5Fpath=20in=20init=20SQL,=20hover?= =?UTF-8?q?=20for=20remove?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use static test-image.png fixture instead of dynamic beforeAll creation - Add thumbnail_path column to auto-create SQL in db/index.ts - Hover on thumbnail before clicking remove button (group-hover:block CSS) Co-Authored-By: Claude Opus 4.6 --- src/lib/server/db/index.ts | 1 + tests/e2e/attachments.spec.ts | 29 ++++++----------------------- tests/e2e/helpers/test-image.png | Bin 0 -> 70 bytes 3 files changed, 7 insertions(+), 23 deletions(-) create mode 100644 tests/e2e/helpers/test-image.png diff --git a/src/lib/server/db/index.ts b/src/lib/server/db/index.ts index 78177ac..d2a553f 100644 --- a/src/lib/server/db/index.ts +++ b/src/lib/server/db/index.ts @@ -66,6 +66,7 @@ sqlite.exec(` mime_type TEXT NOT NULL, size INTEGER NOT NULL, path TEXT NOT NULL, + thumbnail_path TEXT, created_at INTEGER NOT NULL ); diff --git a/tests/e2e/attachments.spec.ts b/tests/e2e/attachments.spec.ts index b809806..0c9d6da 100644 --- a/tests/e2e/attachments.spec.ts +++ b/tests/e2e/attachments.spec.ts @@ -1,26 +1,9 @@ import { test, expect, noteCard } from './helpers/fixtures.js'; -import path from 'path'; -import fs from 'fs'; +import { fileURLToPath } from 'url'; +import { dirname, join } from 'path'; -// Create a minimal test PNG (1x1 red pixel) for upload tests -const TEST_IMAGE_PATH = path.join(process.cwd(), 'tests', 'e2e', 'helpers', 'test-image.png'); - -test.beforeAll(() => { - // Minimal 1x1 PNG (red pixel) - const png = Buffer.from( - 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==', - 'base64' - ); - fs.writeFileSync(TEST_IMAGE_PATH, png); -}); - -test.afterAll(() => { - try { - fs.unlinkSync(TEST_IMAGE_PATH); - } catch { - // Cleanup is best-effort - } -}); +const __dirname = dirname(fileURLToPath(import.meta.url)); +const TEST_IMAGE_PATH = join(__dirname, 'helpers', 'test-image.png'); /** Helper: create a note, close editor, reopen it */ async function createAndReopenNote(page: import('@playwright/test').Page, title: string) { @@ -62,8 +45,7 @@ test.describe('Image Attachments', () => { await page.getByTestId('close-editor-btn').click(); await noteCard(page, 'Persist Test').click(); - // Then the image thumbnail is still visible in the editor - // (attachments show even without toggling image panel when they exist) + // Then the image is still visible in the editor await expect(page.getByTestId('note-editor').locator('img')).toBeVisible(); }); @@ -90,6 +72,7 @@ test.describe('Image Attachments', () => { await expect(page.getByTestId('attachment-thumbnail')).toBeVisible(); // When the user removes the image + await page.getByTestId('attachment-thumbnail').hover(); await page.getByTestId('remove-attachment').click(); // Then the thumbnail is gone from the editor diff --git a/tests/e2e/helpers/test-image.png b/tests/e2e/helpers/test-image.png new file mode 100644 index 0000000000000000000000000000000000000000..0f2de3749df299a6b84bf6ff1a0b393a1c1fd22b GIT binary patch literal 70 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1|;Q0k92}1TpU9xZYBTuKYyVd1A7xwz3mB) Q_dp2-Pgg&ebxsLQ0NDZ%