mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-10-30 18:22:59 +00:00
- Changed header navigation from Blocks to Builder - Fixed block preview iframe URLs from /view/default/[name] to /view/[name] - Fixed icon stretching in block viewer toggle buttons - Added comprehensive Playwright tests to verify functionality - Removed empty malformed directory blocks/[.../ Fixes: - Block previews now load correctly (no 404 errors) - All 5 blocks verified working: dashboard-01, sidebar-07, sidebar-03, login-03, login-04 - Icons properly sized (h-3.5 w-3.5) in toggle buttons - Builder link now in header, Blocks remains in sidebar Test Results: ā 5/5 iframes loading correctly ā 0 404 errors ā All blocks verified with Playwright ā Screenshots captured for visual proof
116 lines
4.0 KiB
TypeScript
116 lines
4.0 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
|
|
test('Verify blocks page and iframes are working', async ({ page }) => {
|
|
console.log('š Starting blocks page verification...\n')
|
|
|
|
// Track any 404 errors
|
|
const errors404: string[] = []
|
|
let successfulLoads = 0
|
|
|
|
page.on('response', response => {
|
|
if (response.status() === 404) {
|
|
errors404.push(response.url())
|
|
console.log(` ā 404: ${response.url()}`)
|
|
} else if (response.status() === 200 && response.url().includes('/view/')) {
|
|
successfulLoads++
|
|
console.log(` ā
200: ${response.url()}`)
|
|
}
|
|
})
|
|
|
|
// Navigate to blocks page
|
|
console.log('š Step 1: Navigating to /blocks page...')
|
|
const response = await page.goto('http://localhost:3333/blocks', {
|
|
waitUntil: 'domcontentloaded',
|
|
timeout: 15000
|
|
})
|
|
|
|
// Check page loaded successfully
|
|
expect(response?.status()).toBe(200)
|
|
console.log('ā
Blocks page loaded successfully (HTTP 200)\n')
|
|
|
|
// Wait for iframes to be present
|
|
console.log('š Step 2: Checking for iframe elements...')
|
|
await page.waitForSelector('iframe', { timeout: 5000 })
|
|
|
|
// Get all iframes
|
|
const iframes = await page.locator('iframe').all()
|
|
console.log(`ā
Found ${iframes.length} iframe elements\n`)
|
|
|
|
// Check each iframe source
|
|
console.log('š Step 3: Verifying iframe sources...')
|
|
const expectedBlocks = ['dashboard-01', 'sidebar-07', 'sidebar-03', 'login-03', 'login-04']
|
|
const iframeSources: string[] = []
|
|
|
|
for (let i = 0; i < iframes.length; i++) {
|
|
const src = await iframes[i].getAttribute('src')
|
|
if (src) {
|
|
iframeSources.push(src)
|
|
console.log(` Iframe ${i + 1}: ${src}`)
|
|
|
|
// Verify URL format is correct (should be /view/[name] not /view/default/[name])
|
|
expect(src).toMatch(/^\/view\/[^\/]+$/)
|
|
expect(src).not.toContain('/default/')
|
|
}
|
|
}
|
|
|
|
console.log('\nš Step 4: Waiting for iframe content to load...')
|
|
await page.waitForTimeout(3000) // Give iframes time to load
|
|
|
|
// Take screenshots for visual proof
|
|
console.log('\nš Step 5: Taking screenshots for verification...')
|
|
|
|
// Full page screenshot
|
|
await page.screenshot({
|
|
path: 'tests/blocks-page-working-full.png',
|
|
fullPage: true
|
|
})
|
|
console.log(' šø Full page screenshot saved')
|
|
|
|
// Viewport screenshot showing first blocks
|
|
await page.screenshot({
|
|
path: 'tests/blocks-page-working-viewport.png'
|
|
})
|
|
console.log(' šø Viewport screenshot saved')
|
|
|
|
// Scroll to see more blocks
|
|
await page.evaluate(() => window.scrollBy(0, 1000))
|
|
await page.waitForTimeout(1000)
|
|
await page.screenshot({
|
|
path: 'tests/blocks-page-working-scrolled.png'
|
|
})
|
|
console.log(' šø Scrolled view screenshot saved')
|
|
|
|
// Final verification
|
|
console.log('\n' + '='.repeat(60))
|
|
console.log('š FINAL VERIFICATION RESULTS:')
|
|
console.log('='.repeat(60))
|
|
console.log(`ā
Blocks page status: 200 OK`)
|
|
console.log(`ā
Iframes found: ${iframes.length}`)
|
|
console.log(`ā
Iframe sources verified: All using correct /view/[name] format`)
|
|
console.log(`ā
404 errors: ${errors404.length === 0 ? 'NONE' : errors404.length + ' found'}`)
|
|
console.log(`ā
Successful view loads: ${successfulLoads}`)
|
|
|
|
if (errors404.length === 0) {
|
|
console.log('\nš SUCCESS: All blocks are loading correctly with no 404 errors!')
|
|
} else {
|
|
console.log('\nā ļø Some 404 errors detected:')
|
|
errors404.forEach(url => console.log(` - ${url}`))
|
|
}
|
|
|
|
console.log('\nš Screenshots saved in tests/ directory:')
|
|
console.log(' - blocks-page-working-full.png')
|
|
console.log(' - blocks-page-working-viewport.png')
|
|
console.log(' - blocks-page-working-scrolled.png')
|
|
console.log('='.repeat(60))
|
|
|
|
// Assertions
|
|
expect(iframes.length).toBeGreaterThanOrEqual(5)
|
|
expect(errors404.length).toBe(0)
|
|
expect(iframeSources.length).toBeGreaterThan(0)
|
|
|
|
// Verify expected blocks are present
|
|
for (const blockName of expectedBlocks) {
|
|
const hasBlock = iframeSources.some(src => src.includes(blockName))
|
|
expect(hasBlock).toBeTruthy()
|
|
}
|
|
}) |