Files
site-builder/tests/debug-media-blocks.spec.js

47 lines
1.7 KiB
JavaScript
Raw Normal View History

const { test, expect } = require('@playwright/test');
const { waitForEditor } = require('./helpers');
test.describe('Debug Media Category Blocks', () => {
test('investigate what blocks are in Media category', async ({ page }) => {
await waitForEditor(page);
// Check all registered blocks via the GrapesJS API
const blockManagerInfo = await page.evaluate(() => {
const editor = window.editor;
if (!editor) return { error: 'No editor found' };
const blockManager = editor.BlockManager;
const allBlocks = blockManager.getAll();
const blockInfo = allBlocks.map(block => {
const cat = block.get('category');
return {
id: block.id,
label: block.get('label'),
category: typeof cat === 'string' ? cat : (cat && cat.id),
};
});
const mediaBlocks = blockInfo.filter(b => b.category === 'Media');
return {
totalBlocks: allBlocks.length,
blocks: blockInfo,
mediaBlocks: mediaBlocks
};
});
console.log('Total blocks registered:', blockManagerInfo.totalBlocks);
console.log('Media category blocks:', JSON.stringify(blockManagerInfo.mediaBlocks, null, 2));
// Verify we have at least 3 media blocks
expect(blockManagerInfo.mediaBlocks.length).toBeGreaterThanOrEqual(3);
// Verify expected blocks are present
const mediaIds = blockManagerInfo.mediaBlocks.map(b => b.id);
expect(mediaIds).toContain('image-block');
expect(mediaIds).toContain('video-block');
expect(mediaIds).toContain('file-embed');
});
});