forked from mirror/crumbs-original
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:
committed by
Fred Cabassut
co-authored by
Claude Opus 4.6
parent
501a5d3920
commit
0fec60a56a
@@ -66,6 +66,7 @@ sqlite.exec(`
|
|||||||
mime_type TEXT NOT NULL,
|
mime_type TEXT NOT NULL,
|
||||||
size INTEGER NOT NULL,
|
size INTEGER NOT NULL,
|
||||||
path TEXT NOT NULL,
|
path TEXT NOT NULL,
|
||||||
|
thumbnail_path TEXT,
|
||||||
created_at INTEGER NOT NULL
|
created_at INTEGER NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,9 @@
|
|||||||
import { test, expect, noteCard } from './helpers/fixtures.js';
|
import { test, expect, noteCard } from './helpers/fixtures.js';
|
||||||
import path from 'path';
|
import { fileURLToPath } from 'url';
|
||||||
import fs from 'fs';
|
import { dirname, join } from 'path';
|
||||||
|
|
||||||
// Create a minimal test PNG (1x1 red pixel) for upload tests
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
const TEST_IMAGE_PATH = path.join(process.cwd(), 'tests', 'e2e', 'helpers', 'test-image.png');
|
const TEST_IMAGE_PATH = join(__dirname, '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
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/** Helper: create a note, close editor, reopen it */
|
/** Helper: create a note, close editor, reopen it */
|
||||||
async function createAndReopenNote(page: import('@playwright/test').Page, title: string) {
|
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 page.getByTestId('close-editor-btn').click();
|
||||||
await noteCard(page, 'Persist Test').click();
|
await noteCard(page, 'Persist Test').click();
|
||||||
|
|
||||||
// Then the image thumbnail is still visible in the editor
|
// Then the image is still visible in the editor
|
||||||
// (attachments show even without toggling image panel when they exist)
|
|
||||||
await expect(page.getByTestId('note-editor').locator('img')).toBeVisible();
|
await expect(page.getByTestId('note-editor').locator('img')).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -90,6 +72,7 @@ test.describe('Image Attachments', () => {
|
|||||||
await expect(page.getByTestId('attachment-thumbnail')).toBeVisible();
|
await expect(page.getByTestId('attachment-thumbnail')).toBeVisible();
|
||||||
|
|
||||||
// When the user removes the image
|
// When the user removes the image
|
||||||
|
await page.getByTestId('attachment-thumbnail').hover();
|
||||||
await page.getByTestId('remove-attachment').click();
|
await page.getByTestId('remove-attachment').click();
|
||||||
|
|
||||||
// Then the thumbnail is gone from the editor
|
// Then the thumbnail is gone from the editor
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 70 B |
Reference in New Issue
Block a user