fix: E2E test fixes — static test image, thumbnail_path in init SQL, hover for remove

- 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 <noreply@anthropic.com>
This commit is contained in:
Frederic Cabassut
2026-03-08 22:37:50 +01:00
committed by Fred Cabassut
co-authored by Claude Opus 4.6
parent 3492d824ea
commit a1f6d63e0a
3 changed files with 7 additions and 23 deletions
+1
View File
@@ -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
);
+6 -23
View File
@@ -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
Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B