Files
leptos-shadcn-ui/tests/e2e/dynamic-loading.spec.ts
Ubuntu cad0f0fac6 drover: task-1767763673502758243
Task: Complete dynamic loading E2E tests
2026-01-07 11:32:14 +00:00

1548 lines
61 KiB
TypeScript

import { test, expect } from '@playwright/test';
import {
detectBrowserCapabilities,
detectWASMFeatures,
detectLoadingFeatures,
getPerformanceMetrics,
isComponentLoaded,
getComponentLoadingState,
waitForComponentLoad,
getComponentLoadingProgress,
isWASMInitialized,
getBundleSizeInfo,
getComponentCategories,
getComponentNames,
} from './feature-detection';
/**
* Dynamic Loading System Testing Suite
*
* This comprehensive test suite validates lazy and dynamic component loading
* with proper feature detection. Tests adapt based on available features.
*
* Features Tested:
* - Lazy component loading with progress tracking
* - Dynamic WASM module loading
* - Bundle analysis and optimization
* - Search and filter functionality
* - Favorites system
* - Error handling and retry
* - Cross-browser compatibility
* - Performance metrics
*/
test.describe('Dynamic Loading System - Comprehensive E2E Testing', () => {
test.beforeEach(async ({ page }) => {
// Navigate to the enhanced lazy loading demo
await page.goto('http://localhost:8082');
// Wait for the app to be fully loaded
await page.waitForLoadState('networkidle');
// Wait for WASM to initialize
await page.waitForFunction(() => (window as any).wasmBindings !== undefined, { timeout: 10000 });
});
test.describe('Feature Detection', () => {
test('should detect browser capabilities', async ({ page }) => {
const capabilities = await detectBrowserCapabilities(page);
// Log capabilities for debugging
console.log('Browser Capabilities:', JSON.stringify(capabilities, null, 2));
// Basic browser requirements
expect(capabilities.webAssembly).toBe(true);
expect(capabilities.bigInt).toBe(true);
// Optional capabilities
console.log('SharedArrayBuffer:', capabilities.sharedArrayBuffer);
console.log('Dynamic Import:', capabilities.supportsDynamicImport);
console.log('Module Scripts:', capabilities.supportsModuleScripts);
});
test('should detect WASM features', async ({ page }) => {
const wasmFeatures = await detectWASMFeatures(page);
// Log WASM features for debugging
console.log('WASM Features:', JSON.stringify(wasmFeatures, null, 2));
// At minimum, basic WASM should be supported
expect(wasmFeatures.extensions.length).toBeGreaterThan(0);
// Check for optional features
if (wasmFeatures.bulkMemory) {
console.log('✓ Bulk memory operations supported');
}
if (wasmFeatures.referenceTypes) {
console.log('✓ Reference types supported');
}
if (wasmFeatures.simd) {
console.log('✓ SIMD supported');
}
});
test('should detect loading features in application', async ({ page }) => {
const features = await detectLoadingFeatures(page);
// Log detected features for debugging
console.log('Loading Features:', JSON.stringify(features, null, 2));
// The app should have at least some dynamic loading features
if (features.componentCount > 0) {
console.log(`✓ Found ${features.componentCount} components`);
}
if (features.categoryCount > 0) {
console.log(`✓ Found ${features.categoryCount} categories`);
}
if (features.hasLazyLoadingUI) {
console.log('✓ Lazy loading UI detected');
}
if (features.hasDynamicLoaderUI) {
console.log('✓ Dynamic loader UI detected');
}
if (features.hasBundleAnalysis) {
console.log('✓ Bundle analysis detected');
}
if (features.hasSearchAndFilter) {
console.log('✓ Search and filter detected');
}
if (features.hasFavoritesSystem) {
console.log('✓ Favorites system detected');
}
if (features.hasErrorHandling) {
console.log('✓ Error handling detected');
}
});
test('should verify WASM initialization', async ({ page }) => {
const isInitialized = await isWASMInitialized(page);
expect(isInitialized).toBe(true);
// Additional WASM binding checks
const wasmBindings = await page.evaluate(() => {
return {
hasBindings: typeof (window as any).wasmBindings !== 'undefined',
hasInitTime: typeof (window as any).wasmInitTime !== 'undefined',
};
});
console.log('WASM Binding Status:', wasmBindings);
expect(wasmBindings.hasBindings).toBe(true);
});
test('should collect performance metrics', async ({ page }) => {
const metrics = await getPerformanceMetrics(page);
console.log('Performance Metrics:', JSON.stringify(metrics, null, 2));
// Some performance metrics should be available
if (metrics.firstPaint !== null) {
console.log(`First Paint: ${metrics.firstPaint.toFixed(2)}ms`);
expect(metrics.firstPaint).toBeGreaterThan(0);
}
if (metrics.firstContentfulPaint !== null) {
console.log(`First Contentful Paint: ${metrics.firstContentfulPaint.toFixed(2)}ms`);
expect(metrics.firstContentfulPaint).toBeGreaterThan(0);
}
if (metrics.domContentLoaded !== null) {
console.log(`DOM Content Loaded: ${metrics.domContentLoaded.toFixed(2)}ms`);
expect(metrics.domContentLoaded).toBeGreaterThan(0);
}
if (metrics.wasmInitTime !== null) {
console.log(`WASM Init Time: ${metrics.wasmInitTime.toFixed(2)}ms`);
}
});
});
test.describe('Page Structure & Navigation', () => {
test('should display main header and title', async ({ page }) => {
// Use first h1 to avoid strict mode violation
const header = page.locator('h1').first();
await expect(header).toBeVisible();
await expect(header).toContainText('Leptos ShadCN UI Demo');
// Check if subtitle exists (may not be implemented yet)
const subtitle = page.locator('h2');
if (await subtitle.count() > 0) {
await expect(subtitle).toBeVisible();
await expect(subtitle).toContainText('Dynamic Lazy Loading with Essential Components');
}
});
test('should display all main sections', async ({ page }) => {
// Check if advanced sections exist (may not be implemented yet)
const essentialSection = page.locator('h3:has-text("Essential Components")');
const lazySection = page.locator('h3:has-text("Lazy Loaded Components")');
const dynamicSection = page.locator('h3:has-text("Dynamic WASM Components")');
const bundlePanel = page.locator('.panel.bundle-analysis');
const loaderPanel = page.locator('.panel.bundle-status');
if (await essentialSection.count() > 0 || await lazySection.count() > 0 ||
await dynamicSection.count() > 0 || await bundlePanel.count() > 0 ||
await loaderPanel.count() > 0) {
// Test sections that exist
if (await essentialSection.count() > 0) {
await expect(essentialSection).toBeVisible();
}
if (await lazySection.count() > 0) {
await expect(lazySection).toBeVisible();
}
if (await dynamicSection.count() > 0) {
await expect(dynamicSection).toBeVisible();
}
if (await bundlePanel.count() > 0) {
await expect(bundlePanel).toBeVisible();
}
if (await loaderPanel.count() > 0) {
await expect(loaderPanel).toBeVisible();
}
} else {
// Advanced sections not implemented yet - skip test
test.skip('Advanced dynamic loading sections not implemented in current demo app');
}
});
});
test.describe('Bundle Analysis Panel', () => {
test('should display bundle metrics correctly', async ({ page }) => {
const bundlePanel = page.locator('.panel.bundle-analysis');
if (await bundlePanel.count() > 0) {
await expect(bundlePanel).toBeVisible();
// Check for bundle size information
await expect(bundlePanel.locator('text=Bundle Size:')).toBeVisible();
await expect(bundlePanel.locator('text=Components:')).toBeVisible();
await expect(bundlePanel.locator('text=Optimization:')).toBeVisible();
} else {
// Bundle analysis panel not implemented yet - skip test
test.skip('Bundle analysis panel not implemented in current demo app');
}
});
test('should show accurate bundle statistics', async ({ page }) => {
const bundlePanel = page.locator('.panel.bundle-analysis');
if (await bundlePanel.count() > 0) {
// Bundle size should be displayed
const sizeText = await bundlePanel.locator('text=/Bundle Size:.*/').textContent();
expect(sizeText).toMatch(/Bundle Size:.*\d+\.\d+MB/);
// Component count should be accurate
const componentText = await bundlePanel.locator('text=/Components:.*/').textContent();
expect(componentText).toMatch(/Components:.*\d+/);
} else {
// Bundle analysis panel not implemented yet - skip test
test.skip('Bundle analysis panel not implemented in current demo app');
}
});
});
test.describe('Dynamic WASM Loader Status Panel', () => {
test('should display loader status information', async ({ page }) => {
const loaderPanel = page.locator('.panel.bundle-status');
if (await loaderPanel.count() > 0) {
await expect(loaderPanel).toBeVisible();
// Check for loader header
await expect(loaderPanel.locator('.loader-header')).toBeVisible();
await expect(loaderPanel.locator('text=Dynamic WASM Loader Status')).toBeVisible();
} else {
// Dynamic loader panel not implemented yet - skip test
test.skip('Dynamic loader panel not implemented in current demo app');
}
});
test('should show initial loading state', async ({ page }) => {
const loaderPanel = page.locator('.panel.bundle-status');
if (await loaderPanel.count() > 0) {
// Initial state should show 0 loaded components
await expect(loaderPanel.locator('text=Loaded: 0')).toBeVisible();
await expect(loaderPanel.locator('text=Total Size: 0KB')).toBeVisible();
} else {
// Dynamic loader panel not implemented yet - skip test
test.skip('Dynamic loader panel not implemented in current demo app');
}
});
test('should have functional load test button', async ({ page }) => {
const loadButton = page.locator('.load-btn');
if (await loadButton.count() > 0) {
await expect(loadButton).toBeVisible();
await expect(loadButton).toHaveText('Load Test Component');
// Button should be clickable
await expect(loadButton).toBeEnabled();
} else {
// Load button not implemented yet - skip test
test.skip('Load button not implemented in current demo app');
}
});
test('should toggle details visibility', async ({ page }) => {
const toggleBtn = page.locator('.toggle-btn');
const detailsContent = page.locator('.details-content');
if (await toggleBtn.count() > 0 && await detailsContent.count() > 0) {
// Initially details should be hidden
await expect(detailsContent).toHaveClass(/hidden/);
// Click toggle button
await toggleBtn.click();
// Details should now be visible
await expect(detailsContent).not.toHaveClass(/hidden/);
// Click again to hide
await toggleBtn.click();
await expect(detailsContent).toHaveClass(/hidden/);
} else {
// Toggle functionality not implemented yet - skip test
test.skip('Toggle functionality not implemented in current demo app');
}
});
});
test.describe('Essential Components Section', () => {
test('should display all 5 essential components', async ({ page }) => {
const essentialSection = page.locator('h3:has-text("Essential Components")');
if (await essentialSection.count() > 0) {
const essentialSectionParent = essentialSection.locator('..');
// Should have 5 essential components
const components = essentialSectionParent.locator('.component-item');
await expect(components).toHaveCount(5);
// Check component names
const componentNames = ['Button', 'Input', 'Card', 'Badge', 'Label'];
for (const name of componentNames) {
await expect(essentialSectionParent.locator(`text=${name}`)).toBeVisible();
}
} else {
// Essential components section not implemented yet - skip test
test.skip('Essential components section not implemented in current demo app');
}
});
test('essential components should be immediately visible', async ({ page }) => {
const essentialSection = page.locator('h3:has-text("Essential Components")').locator('..');
// All essential components should be visible without loading
const components = essentialSection.locator('.component-item');
for (let i = 0; i < await components.count(); i++) {
const component = components.nth(i);
await expect(component).toBeVisible();
await expect(component).not.toHaveClass(/loading/);
}
});
});
test.describe('Lazy Loaded Components Section', () => {
test('should display all component categories', async ({ page }) => {
const lazySection = page.locator('h3:has-text("Lazy Loaded Components")');
if (await lazySection.count() > 0) {
const lazySectionParent = lazySection.locator('..');
// Check for all 4 categories
const categories = ['Form & Input', 'Layout & Navigation', 'Overlay & Feedback', 'Data & Media'];
for (const category of categories) {
await expect(lazySectionParent.locator(`text=${category}`)).toBeVisible();
}
} else {
// Lazy loaded components section not implemented yet - skip test
test.skip('Lazy loaded components section not implemented in current demo app');
}
});
test('should show correct component counts per category', async ({ page }) => {
const lazySection = page.locator('h3:has-text("Lazy Loaded Components")');
if (await lazySection.count() > 0) {
const lazySectionParent = lazySection.locator('..');
// Form & Input: 12 components
const formSection = lazySectionParent.locator('h4:has-text("Form & Input")').locator('..');
const formComponents = formSection.locator('.lazy-component-wrapper');
await expect(formComponents).toHaveCount(12);
// Layout & Navigation: 8 components
const layoutSection = lazySectionParent.locator('h4:has-text("Layout & Navigation")').locator('..');
const layoutComponents = layoutSection.locator('.lazy-component-wrapper');
await expect(layoutComponents).toHaveCount(8);
// Overlay & Feedback: 10 components
const overlaySection = lazySectionParent.locator('h4:has-text("Overlay & Feedback")').locator('..');
const overlayComponents = overlaySection.locator('.lazy-component-wrapper');
await expect(overlayComponents).toHaveCount(10);
// Data & Media: 9 components
const dataSection = lazySectionParent.locator('h4:has-text("Data & Media")').locator('..');
const dataComponents = dataSection.locator('.lazy-component-wrapper');
await expect(dataComponents).toHaveCount(9);
} else {
// Lazy loaded components section not implemented yet - skip test
test.skip('Lazy loaded components section not implemented in current demo app');
}
});
test('lazy components should start in placeholder state', async ({ page }) => {
const lazySection = page.locator('h3:has-text("Lazy Loaded Components")');
if (await lazySection.count() > 0) {
const lazySectionParent = lazySection.locator('..');
const lazyComponents = lazySectionParent.locator('.lazy-component-wrapper');
// All lazy components should start in placeholder state
for (let i = 0; i < await lazyComponents.count(); i++) {
const component = lazyComponents.nth(i);
await expect(component.locator('.component-placeholder')).toBeVisible();
await expect(component.locator('.component-content')).not.toBeVisible();
}
} else {
// Lazy loaded components section not implemented yet - skip test
test.skip('Lazy loaded components section not implemented in current demo app');
}
});
});
test.describe('Dynamic WASM Components Section', () => {
test('should display all 5 dynamic components', async ({ page }) => {
const dynamicSection = page.locator('h3:has-text("Dynamic WASM Components")');
if (await dynamicSection.count() > 0) {
const dynamicSectionParent = dynamicSection.locator('..');
// Should have 5 dynamic components
const components = dynamicSectionParent.locator('.dynamic-component-wrapper');
await expect(components).toHaveCount(5);
// Check component names
const componentNames = ['Button', 'Input', 'Card', 'Modal', 'Table'];
for (const name of componentNames) {
await expect(dynamicSectionParent.locator(`text=${name}`)).toBeVisible();
}
} else {
// Dynamic WASM components section not implemented yet - skip test
test.skip('Dynamic WASM components section not implemented in current demo app');
}
});
test('dynamic components should show correct metadata', async ({ page }) => {
const dynamicSection = page.locator('h3:has-text("Dynamic WASM Components")');
if (await dynamicSection.count() > 0) {
const dynamicSectionParent = dynamicSection.locator('..');
const components = dynamicSectionParent.locator('.dynamic-component-wrapper');
// Check first component (Button)
const buttonComponent = components.first();
await expect(buttonComponent.locator('.component-category')).toContainText('Form & Input');
await expect(buttonComponent.locator('.component-size')).toContainText('15KB');
await expect(buttonComponent.locator('.component-description')).toContainText('Interactive button component');
} else {
// Dynamic WASM components section not implemented yet - skip test
test.skip('Dynamic WASM components section not implemented in current demo app');
}
});
test('dynamic components should start in placeholder state', async ({ page }) => {
const dynamicSection = page.locator('h3:has-text("Dynamic WASM Components")');
if (await dynamicSection.count() > 0) {
const dynamicSectionParent = dynamicSection.locator('..');
const components = dynamicSectionParent.locator('.dynamic-component-wrapper');
// All dynamic components should start in placeholder state
for (let i = 0; i < await components.count(); i++) {
const component = components.nth(i);
await expect(component.locator('.component-placeholder')).toBeVisible();
await expect(component.locator('.component-content')).not.toBeVisible();
}
} else {
// Dynamic WASM components section not implemented yet - skip test
test.skip('Dynamic WASM components section not implemented in current demo app');
}
});
});
test.describe('Component Loading Functionality', () => {
test('should load lazy components on demand', async ({ page }) => {
const lazySection = page.locator('h3:has-text("Lazy Loaded Components")');
if (await lazySection.count() > 0) {
const lazySectionParent = lazySection.locator('..');
const firstComponent = lazySectionParent.locator('.lazy-component-wrapper').first();
// Click load button
const loadBtn = firstComponent.locator('.load-component-btn');
await loadBtn.click();
// Should show loading state
await expect(firstComponent.locator('.component-loading')).toBeVisible();
// Wait for loading to complete
await expect(firstComponent.locator('.component-success')).toBeVisible({ timeout: 10000 });
// Should show component content
await expect(firstComponent.locator('.component-content')).toBeVisible();
} else {
// Lazy loading functionality not implemented yet - skip test
test.skip('Lazy loading functionality not implemented in current demo app');
}
});
test('should load dynamic components on demand', async ({ page }) => {
const dynamicSection = page.locator('h3:has-text("Dynamic WASM Components")');
if (await dynamicSection.count() > 0) {
const dynamicSectionParent = dynamicSection.locator('..');
const firstComponent = dynamicSectionParent.locator('.dynamic-component-wrapper').first();
// Click load button
const loadBtn = firstComponent.locator('.load-component-btn');
await loadBtn.click();
// Should show loading state
await expect(firstComponent.locator('.component-loading')).toBeVisible();
// Wait for loading to complete
await expect(firstComponent.locator('.component-success')).toBeVisible({ timeout: 10000 });
// Should show component content
await expect(firstComponent.locator('.component-content')).toBeVisible();
} else {
// Dynamic loading functionality not implemented yet - skip test
test.skip('Dynamic loading functionality not implemented in current demo app');
}
});
test('should handle multiple component loads simultaneously', async ({ page }) => {
const dynamicSection = page.locator('h3:has-text("Dynamic WASM Components")');
if (await dynamicSection.count() > 0) {
const dynamicSectionParent = dynamicSection.locator('..');
const components = dynamicSectionParent.locator('.dynamic-component-wrapper');
// Load first 3 components simultaneously
for (let i = 0; i < 3; i++) {
const component = components.nth(i);
const loadBtn = component.locator('.load-component-btn');
await loadBtn.click();
}
// All should show loading state
for (let i = 0; i < 3; i++) {
const component = components.nth(i);
await expect(component.locator('.component-loading')).toBeVisible();
}
// Wait for all to complete
for (let i = 0; i < 3; i++) {
const component = components.nth(i);
await expect(component.locator('.component-success')).toBeVisible({ timeout: 15000 });
}
} else {
// Dynamic loading functionality not implemented yet - skip test
test.skip('Dynamic loading functionality not implemented in current demo app');
}
});
});
test.describe('Search and Filter Functionality', () => {
test('should display search input and category filter', async ({ page }) => {
const searchSection = page.locator('.search-filters');
if (await searchSection.count() > 0) {
await expect(searchSection).toBeVisible();
// Search input
await expect(searchSection.locator('input[placeholder*="search"]')).toBeVisible();
// Category filter
await expect(searchSection.locator('select')).toBeVisible();
} else {
// Search and filter functionality not implemented yet - skip test
test.skip('Search and filter functionality not implemented in current demo app');
}
});
test('should filter components by category', async ({ page }) => {
const categorySelect = page.locator('select');
if (await categorySelect.count() > 0) {
// Select "Form & Input" category
await categorySelect.selectOption('form-input');
// Should show only form components
const visibleComponents = page.locator('.lazy-component-wrapper:visible');
await expect(visibleComponents).toHaveCount(12);
// Should hide other categories
await expect(page.locator('h4:has-text("Layout & Navigation")')).not.toBeVisible();
} else {
// Category filtering not implemented yet - skip test
test.skip('Category filtering not implemented in current demo app');
}
});
test('should search components by name', async ({ page }) => {
const searchInput = page.locator('input[placeholder*="search"]');
if (await searchInput.count() > 0) {
// Search for "button"
await searchInput.fill('button');
// Should show only button-related components
const visibleComponents = page.locator('.lazy-component-wrapper:visible');
await expect(visibleComponents.count()).toBeLessThan(39); // Less than total
// Should show button components
await expect(page.locator('text=Button')).toBeVisible();
} else {
// Search functionality not implemented yet - skip test
test.skip('Search functionality not implemented in current demo app');
}
});
});
test.describe('Favorites System', () => {
test('should allow marking components as favorites', async ({ page }) => {
const firstComponent = page.locator('.lazy-component-wrapper').first();
const favoriteBtn = firstComponent.locator('.favorite-btn');
if (await favoriteBtn.count() > 0) {
// Initially not favorited
await expect(favoriteBtn).not.toHaveClass(/favorited/);
// Click to favorite
await favoriteBtn.click();
// Should now be favorited
await expect(favoriteBtn).toHaveClass(/favorited/);
} else {
// Favorites functionality not implemented yet - skip test
test.skip('Favorites functionality not implemented in current demo app');
}
});
test('should filter by favorites', async ({ page }) => {
// Check if favorites functionality exists
const firstComponent = page.locator('.lazy-component-wrapper').first();
const favoriteBtn = firstComponent.locator('.favorite-btn');
const favoritesFilter = page.locator('.favorites-filter');
if (await favoriteBtn.count() > 0 && await favoritesFilter.count() > 0) {
// Mark a few components as favorites
const components = page.locator('.lazy-component-wrapper');
for (let i = 0; i < 3; i++) {
const component = components.nth(i);
const favoriteBtn = component.locator('.favorite-btn');
await favoriteBtn.click();
}
// Click favorites filter
await favoritesFilter.click();
// Should show only favorited components
const visibleComponents = page.locator('.lazy-component-wrapper:visible');
await expect(visibleComponents).toHaveCount(3);
} else {
// Favorites filtering not implemented yet - skip test
test.skip('Favorites filtering not implemented in current demo app');
}
});
});
test.describe('Error Handling', () => {
test('should handle component loading errors gracefully', async ({ page }) => {
// Check if error handling infrastructure exists
const errorComponent = page.locator('.component-error');
if (await errorComponent.count() > 0) {
// This test would require mocking a failed component load
// For now, we'll test that error states are properly styled
// Error states should be properly styled when they occur
// (This will be empty initially, but ensures error styling is available)
await expect(errorComponent).toBeAttached();
} else {
// Error handling not implemented yet - skip test
test.skip('Error handling not implemented in current demo app');
}
});
test('should provide retry functionality for failed loads', async ({ page }) => {
// Check if retry functionality exists
const retryBtn = page.locator('.retry-btn');
if (await retryBtn.count() > 0) {
// Test retry button functionality
// Retry button should be available (though initially hidden)
await expect(retryBtn).toBeAttached();
} else {
// Retry functionality not implemented yet - skip test
test.skip('Retry functionality not implemented in current demo app');
}
});
});
test.describe('Performance and Responsiveness', () => {
test('should maintain performance with many components', async ({ page }) => {
// Check if lazy loading functionality exists
const components = page.locator('.lazy-component-wrapper');
if (await components.count() > 0) {
const loadButtons = components.locator('.load-component-btn');
// Load first 5 components
for (let i = 0; i < 5; i++) {
const loadBtn = loadButtons.nth(i);
await loadBtn.click();
}
// Wait for all to complete
for (let i = 0; i < 5; i++) {
const component = components.nth(i);
await expect(component.locator('.component-success')).toBeVisible({ timeout: 20000 });
}
// Page should remain responsive
await expect(page.locator('h1').first()).toBeVisible();
} else {
// Lazy loading functionality not implemented yet - skip test
test.skip('Lazy loading functionality not implemented in current demo app');
}
});
test('should be responsive on mobile devices', async ({ page }) => {
// Set mobile viewport
await page.setViewportSize({ width: 375, height: 667 });
// Check if advanced sections exist (may not be implemented yet)
const essentialSection = page.locator('h3:has-text("Essential Components")');
const lazySection = page.locator('h3:has-text("Lazy Loaded Components")');
const dynamicSection = page.locator('h3:has-text("Dynamic WASM Components")');
if (await essentialSection.count() > 0 || await lazySection.count() > 0 || await dynamicSection.count() > 0) {
// Test sections that exist
if (await essentialSection.count() > 0) {
await expect(essentialSection).toBeVisible();
}
if (await lazySection.count() > 0) {
await expect(lazySection).toBeVisible();
}
if (await dynamicSection.count() > 0) {
await expect(dynamicSection).toBeVisible();
}
// Components should be properly stacked
const components = page.locator('.lazy-component-wrapper');
if (await components.count() > 0) {
await expect(components.first()).toBeVisible();
}
} else {
// Advanced sections not implemented yet - skip test
test.skip('Advanced sections not implemented in current demo app');
}
});
});
test.describe('Accessibility', () => {
test('should have proper ARIA labels and roles', async ({ page }) => {
// Check for proper button labels
const loadButtons = page.locator('.load-component-btn');
for (let i = 0; i < await loadButtons.count(); i++) {
const button = loadButtons.nth(i);
await expect(button).toHaveAttribute('aria-label', /load.*component/i);
}
// Check for proper form labels if search input exists
const searchInput = page.locator('input[placeholder*="search"]');
if (await searchInput.count() > 0) {
await expect(searchInput).toHaveAttribute('aria-label', /search/i);
} else {
// Search functionality not implemented yet - skip this check
console.log('Search input not implemented in current demo app');
}
});
test('should support keyboard navigation', async ({ page }) => {
// Tab through interactive elements
await page.keyboard.press('Tab');
// Should focus on first interactive element
const focusedElement = page.locator(':focus');
await expect(focusedElement).toBeVisible();
// Should be able to navigate with arrow keys
await page.keyboard.press('ArrowDown');
});
});
test.describe('Integration with WASM', () => {
test('should properly initialize WASM bindings', async ({ page }) => {
// Check that WASM bindings are available
const wasmBindings = await page.evaluate(() => (window as any).wasmBindings);
expect(wasmBindings).toBeDefined();
// Check that the app is properly mounted
await expect(page.locator('h1').first()).toBeVisible();
});
test('should handle WASM loading states correctly', async ({ page }) => {
// Check if load component buttons exist
const loadComponentBtn = page.locator('.load-component-btn');
if (await loadComponentBtn.count() > 0) {
// The app should be fully loaded and interactive
await expect(loadComponentBtn.first()).toBeEnabled();
// No loading spinners should be visible initially
const loadingSpinners = page.locator('.loading-spinner:visible');
await expect(loadingSpinners).toHaveCount(0);
} else {
// Load component functionality not implemented yet - skip test
test.skip('Load component functionality not implemented in current demo app');
}
});
});
// New comprehensive tests with feature detection
test.describe('Lazy Component Loading with Feature Detection', () => {
test('should detect and verify lazy loading capability', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasLazyLoadingUI, 'Lazy loading UI not available');
test.skip(features.componentCount === 0, 'No components found for testing');
console.log(`Testing with ${features.componentCount} components`);
// Get all component names
const componentNames = await getComponentNames(page);
console.log('Available components:', componentNames);
expect(componentNames.length).toBeGreaterThan(0);
});
test('should track component loading state transitions', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasLazyLoadingUI, 'Lazy loading UI not available');
const componentNames = await getComponentNames(page);
test.skip(componentNames.length === 0, 'No components available');
const firstComponentName = componentNames[0];
// Initially should be in placeholder state
const initialState = await getComponentLoadingState(page, firstComponentName);
console.log(`Initial state for ${firstComponentName}:`, initialState);
expect(['placeholder', 'loaded']).toContain(initialState);
// If there's a load button, try loading the component
const component = page.locator('.lazy-component-wrapper, .dynamic-component-wrapper').filter({
hasText: firstComponentName,
});
const loadBtn = component.locator('.load-btn, .load-component-btn');
if ((await loadBtn.count()) > 0) {
await loadBtn.click();
// Should transition to loading
await page.waitForTimeout(100);
const loadingState = await getComponentLoadingState(page, firstComponentName);
console.log(`Loading state for ${firstComponentName}:`, loadingState);
expect(['loading', 'loaded']).toContain(loadingState);
// Wait for completion
const loaded = await waitForComponentLoad(page, firstComponentName, 5000);
if (loaded) {
const finalState = await getComponentLoadingState(page, firstComponentName);
console.log(`Final state for ${firstComponentName}:`, finalState);
expect(finalState).toBe('loaded');
}
}
});
test('should monitor loading progress', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasLazyLoadingUI, 'Lazy loading UI not available');
const componentNames = await getComponentNames(page);
test.skip(componentNames.length === 0, 'No components available');
const firstComponentName = componentNames[0];
// Get initial progress
const initialProgress = await getComponentLoadingProgress(page, firstComponentName);
console.log(`Initial progress for ${firstComponentName}: ${initialProgress}%`);
// If there's a load button, trigger loading and monitor progress
const component = page.locator('.lazy-component-wrapper, .dynamic-component-wrapper').filter({
hasText: firstComponentName,
});
const loadBtn = component.locator('.load-btn, .load-component-btn');
if ((await loadBtn.count()) > 0) {
await loadBtn.click();
// Monitor progress during loading
let previousProgress = initialProgress;
for (let i = 0; i < 10; i++) {
await page.waitForTimeout(200);
const currentProgress = await getComponentLoadingProgress(page, firstComponentName);
console.log(`Progress update ${i}: ${currentProgress}%`);
if (currentProgress > previousProgress) {
console.log(`✓ Progress increased from ${previousProgress}% to ${currentProgress}%`);
}
previousProgress = currentProgress;
if (currentProgress >= 100) {
break;
}
}
}
});
});
test.describe('Dynamic Component Loading with Feature Detection', () => {
test('should detect and verify dynamic loading capability', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasDynamicLoaderUI, 'Dynamic loader UI not available');
// Check for dynamic loader display
const loaderDisplay = page.locator('.dynamic-loader-display, .loader-status');
if ((await loaderDisplay.count()) > 0) {
console.log('✓ Dynamic loader display found');
await expect(loaderDisplay).toBeVisible();
} else {
console.log('Dynamic loader display not found, checking for components...');
const components = await getComponentNames(page);
console.log(`Found ${components.length} components available`);
}
});
test('should track module loading in dynamic loader', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasDynamicLoaderUI, 'Dynamic loader UI not available');
const loaderDisplay = page.locator('.dynamic-loader-display, .loader-status');
if ((await loaderDisplay.count()) > 0) {
// Check initial state
const loadedCountText = await loaderDisplay.locator('text=Loaded Modules:').textContent();
console.log('Initial loaded modules:', loadedCountText);
// Try to load a test component
const loadBtn = loaderDisplay.locator('.load-btn');
if ((await loadBtn.count()) > 0) {
await loadBtn.click();
// Wait a moment and check updated state
await page.waitForTimeout(2000);
const updatedCountText = await loaderDisplay.locator('text=Loaded Modules:').textContent();
console.log('Updated loaded modules:', updatedCountText);
}
}
});
test('should handle multiple simultaneous loads', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasLazyLoadingUI && !features.hasDynamicLoaderUI, 'No loading UI available');
const componentNames = await getComponentNames(page);
test.skip(componentNames.length < 3, 'Need at least 3 components for this test');
console.log(`Testing simultaneous load with ${componentNames.slice(0, 3).join(', ')}`);
// Load first 3 components
for (let i = 0; i < Math.min(3, componentNames.length); i++) {
const componentName = componentNames[i];
const component = page.locator('.lazy-component-wrapper, .dynamic-component-wrapper').filter({
hasText: componentName,
});
const loadBtn = component.locator('.load-btn, .load-component-btn');
if ((await loadBtn.count()) > 0) {
await loadBtn.click();
}
}
// Check that multiple components are loading
const loadingComponents = page.locator('.component-loading:visible');
const loadingCount = await loadingComponents.count();
console.log(`Components loading simultaneously: ${loadingCount}`);
});
});
test.describe('Bundle Analysis with Feature Detection', () => {
test('should detect and analyze bundle information', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasBundleAnalysis, 'Bundle analysis not available');
const bundleInfo = await getBundleSizeInfo(page);
if (bundleInfo) {
console.log('Bundle Information:', bundleInfo);
if (bundleInfo.initialBundle) {
console.log(`Initial bundle size: ${bundleInfo.initialBundle}`);
}
if (bundleInfo.loadedComponents > 0) {
console.log(`Loaded components: ${bundleInfo.loadedComponents}`);
}
if (bundleInfo.totalSize) {
console.log(`Total size: ${bundleInfo.totalSize}`);
}
if (bundleInfo.optimization) {
console.log(`Optimization: ${bundleInfo.optimization}`);
}
} else {
console.log('Bundle info panel not found, may not be implemented');
test.skip(true, 'Bundle information not available');
}
});
test('should track bundle size changes during loading', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasBundleAnalysis, 'Bundle analysis not available');
const initialBundleInfo = await getBundleSizeInfo(page);
if (initialBundleInfo) {
console.log('Initial bundle info:', initialBundleInfo);
// Load a component
const componentNames = await getComponentNames(page);
if (componentNames.length > 0) {
const firstComponent = page.locator('.lazy-component-wrapper, .dynamic-component-wrapper').filter({
hasText: componentNames[0],
});
const loadBtn = firstComponent.locator('.load-btn, .load-component-btn');
if ((await loadBtn.count()) > 0) {
await loadBtn.click();
await page.waitForTimeout(2000);
const updatedBundleInfo = await getBundleSizeInfo(page);
console.log('Updated bundle info:', updatedBundleInfo);
if (updatedBundleInfo && initialBundleInfo) {
const initialComponents = initialBundleInfo.loadedComponents;
const updatedComponents = updatedBundleInfo.loadedComponents;
if (updatedComponents > initialComponents) {
console.log(`✓ Component count increased from ${initialComponents} to ${updatedComponents}`);
}
}
}
}
}
});
});
test.describe('Component Categories with Feature Detection', () => {
test('should detect and list all component categories', async ({ page }) => {
const categories = await getComponentCategories(page);
console.log(`Found ${categories.length} categories:`, categories);
const expectedCategories = [
'Form & Input',
'Layout & Navigation',
'Overlay & Feedback',
'Data & Media',
];
if (categories.length > 0) {
// Verify at least some expected categories exist
const foundCategories = categories.filter((c) => expectedCategories.includes(c));
console.log(`Found ${foundCategories.length} expected categories`);
} else {
console.log('No categories detected, may not be implemented');
}
});
test('should filter components by category', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasSearchAndFilter, 'Search and filter not available');
const categories = await getComponentCategories(page);
test.skip(categories.length === 0, 'No categories available');
console.log(`Testing category filter with ${categories.length} categories`);
// Try to find category filter controls
const categorySelect = page.locator('select');
const categoryButtons = page.locator('[data-category], .category-filter');
if ((await categorySelect.count()) > 0) {
console.log('Found category select dropdown');
const options = await categorySelect.locator('option').allTextContents();
console.log('Available options:', options);
} else if ((await categoryButtons.count()) > 0) {
console.log(`Found ${await categoryButtons.count()} category filter buttons`);
} else {
console.log('No category filter controls found');
}
});
});
test.describe('Search and Filter with Feature Detection', () => {
test('should detect search functionality', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasSearchAndFilter, 'Search and filter not available');
const searchInput = page.locator('input[placeholder*="search" i], input[type="search"]');
const filterControls = page.locator('.filter-controls, .category-filter');
const hasSearch = (await searchInput.count()) > 0;
const hasFilters = (await filterControls.count()) > 0;
console.log('Search functionality detected:');
console.log(` - Search input: ${hasSearch}`);
console.log(` - Filter controls: ${hasFilters}`);
test.skip(!hasSearch && !hasFilters, 'No search or filter controls found');
});
test('should filter components by search term', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasSearchAndFilter, 'Search and filter not available');
const searchInput = page.locator('input[placeholder*="search" i], input[type="search"]');
if ((await searchInput.count()) > 0) {
const componentNames = await getComponentNames(page);
console.log(`Available components before search: ${componentNames.length}`);
// Search for a common term
await searchInput.fill('button');
await page.waitForTimeout(500);
// Check that results are filtered
const visibleComponents = page.locator('.lazy-component-wrapper:visible, .dynamic-component-wrapper:visible');
const visibleCount = await visibleComponents.count();
console.log(`Visible components after search: ${visibleCount}`);
} else {
test.skip(true, 'Search input not found');
}
});
});
test.describe('Favorites System with Feature Detection', () => {
test('should detect favorites functionality', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasFavoritesSystem, 'Favorites system not available');
const favoriteButtons = page.locator('.favorite-btn, .favorite-toggle');
const count = await favoriteButtons.count();
console.log(`Found ${count} favorite buttons`);
test.skip(count === 0, 'No favorite buttons found');
// Check the first favorite button
const firstFavoriteBtn = favoriteButtons.first();
await expect(firstFavoriteBtn).toBeVisible();
});
test('should toggle favorite state', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasFavoritesSystem, 'Favorites system not available');
const favoriteButtons = page.locator('.favorite-btn, .favorite-toggle');
test.skip((await favoriteButtons.count()) === 0, 'No favorite buttons found');
const firstFavoriteBtn = favoriteButtons.first();
const component = firstFavoriteBtn.locator('..');
// Get initial state
const initialText = await firstFavoriteBtn.textContent();
console.log('Initial favorite button text:', initialText);
// Toggle favorite
await firstFavoriteBtn.click();
await page.waitForTimeout(200);
const afterClickText = await firstFavoriteBtn.textContent();
console.log('After click favorite button text:', afterClickText);
// Toggle back
await firstFavoriteBtn.click();
await page.waitForTimeout(200);
const afterSecondClickText = await firstFavoriteBtn.textContent();
console.log('After second click favorite button text:', afterSecondClickText);
});
test('should filter by favorite status', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasFavoritesSystem, 'Favorites system not available');
const favoriteButtons = page.locator('.favorite-btn, .favorite-toggle');
const favoritesFilter = page.locator('.favorites-filter, [data-filter="favorites"]');
test.skip((await favoriteButtons.count()) === 0, 'No favorite buttons found');
test.skip((await favoritesFilter.count()) === 0, 'No favorites filter found');
console.log('Testing favorites filter functionality');
// Mark first component as favorite
const firstFavoriteBtn = favoriteButtons.first();
await firstFavoriteBtn.click();
await page.waitForTimeout(200);
// Apply favorites filter
await favoritesFilter.click();
await page.waitForTimeout(200);
const visibleComponents = page.locator('.lazy-component-wrapper:visible, .dynamic-component-wrapper:visible');
const visibleCount = await visibleComponents.count();
console.log(`Visible components after filtering by favorites: ${visibleCount}`);
});
});
test.describe('Error Handling with Feature Detection', () => {
test('should detect error handling infrastructure', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasErrorHandling, 'Error handling not available');
const errorStates = page.locator('.component-error, .error-state');
const retryButtons = page.locator('.retry-btn');
const hasErrorStates = (await errorStates.count()) > 0;
const hasRetryButtons = (await retryButtons.count()) > 0;
console.log('Error handling detected:');
console.log(` - Error states: ${hasErrorStates}`);
console.log(` - Retry buttons: ${hasRetryButtons}`);
if (hasErrorStates || hasRetryButtons) {
console.log('✓ Error handling infrastructure is available');
}
});
test('should handle loading errors gracefully', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasErrorHandling, 'Error handling not available');
// Check for error state elements
const errorStates = page.locator('.component-error, .error-state');
if ((await errorStates.count()) > 0) {
console.log('Error state elements found');
// Check that error states have proper styling
const firstErrorState = errorStates.first();
await expect(firstErrorState).toBeAttached();
} else {
console.log('No error state elements currently displayed');
}
});
test('should provide retry functionality', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasErrorHandling, 'Error handling not available');
const retryButtons = page.locator('.retry-btn');
if ((await retryButtons.count()) > 0) {
console.log('Retry buttons found');
// Check that retry buttons are properly configured
const firstRetryBtn = retryButtons.first();
await expect(firstRetryBtn).toBeAttached();
const buttonText = await firstRetryBtn.textContent();
console.log('Retry button text:', buttonText);
} else {
console.log('No retry buttons currently displayed');
}
});
});
test.describe('Cross-Browser Compatibility', () => {
test('should work across different browsers', async ({ page, browserName }) => {
console.log(`Testing on browser: ${browserName}`);
const capabilities = await detectBrowserCapabilities(page);
console.log('Browser capabilities:', JSON.stringify(capabilities, null, 2));
// WASM should be available on all modern browsers
expect(capabilities.webAssembly).toBe(true);
// The app should load correctly
await expect(page.locator('h1').first()).toBeVisible();
});
test('should handle WASM feature variations', async ({ page, browserName }) => {
console.log(`Checking WASM features on ${browserName}`);
const wasmFeatures = await detectWASMFeatures(page);
console.log('WASM features:', JSON.stringify(wasmFeatures, null, 2));
// Log feature support for this browser
const features = [];
if (wasmFeatures.bulkMemory) features.push('bulk-memory');
if (wasmFeatures.referenceTypes) features.push('reference-types');
if (wasmFeatures.exceptions) features.push('exceptions');
if (wasmFeatures.simd) features.push('simd');
if (wasmFeatures.multiValue) features.push('multi-value');
console.log(`Supported WASM features on ${browserName}:`, features.join(', '));
});
test('should maintain functionality with different feature sets', async ({ page }) => {
const capabilities = await detectBrowserCapabilities(page);
const wasmFeatures = await detectWASMFeatures(page);
// The app should work even with different feature sets
console.log('Testing with feature set:');
console.log(` - WASM: ${capabilities.webAssembly}`);
console.log(` - SharedArrayBuffer: ${capabilities.sharedArrayBuffer}`);
console.log(` - SIMD: ${wasmFeatures.simd}`);
// Basic functionality should always work
await expect(page.locator('h1').first()).toBeVisible();
// Check if WASM initialized successfully
const isInitialized = await isWASMInitialized(page);
expect(isInitialized).toBe(true);
});
});
test.describe('Performance Monitoring', () => {
test('should measure component load times', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasLazyLoadingUI && !features.hasDynamicLoaderUI, 'No loading UI available');
const componentNames = await getComponentNames(page);
test.skip(componentNames.length === 0, 'No components available');
console.log(`Measuring load times for ${componentNames.length} components`);
// Measure load time for first component
const firstComponentName = componentNames[0];
const component = page.locator('.lazy-component-wrapper, .dynamic-component-wrapper').filter({
hasText: firstComponentName,
});
const loadBtn = component.locator('.load-btn, .load-component-btn');
if ((await loadBtn.count()) > 0) {
const startTime = Date.now();
await loadBtn.click();
const loaded = await waitForComponentLoad(page, firstComponentName, 10000);
const loadTime = Date.now() - startTime;
console.log(`Component "${firstComponentName}" loaded in ${loadTime}ms`);
if (loaded) {
console.log(`✓ Component loaded successfully in ${loadTime}ms`);
}
}
});
test('should track performance metrics', async ({ page }) => {
const metrics = await getPerformanceMetrics(page);
console.log('Performance Metrics:', JSON.stringify(metrics, null, 2));
// Log all available metrics
if (metrics.firstPaint !== null) {
console.log(`✓ First Paint: ${metrics.firstPaint.toFixed(2)}ms`);
}
if (metrics.firstContentfulPaint !== null) {
console.log(`✓ First Contentful Paint: ${metrics.firstContentfulPaint.toFixed(2)}ms`);
}
if (metrics.domContentLoaded !== null) {
console.log(`✓ DOM Content Loaded: ${metrics.domContentLoaded.toFixed(2)}ms`);
}
if (metrics.loadComplete !== null) {
console.log(`✓ Load Complete: ${metrics.loadComplete.toFixed(2)}ms`);
}
if (metrics.wasmInitTime !== null) {
console.log(`✓ WASM Init Time: ${metrics.wasmInitTime.toFixed(2)}ms`);
}
});
test('should measure bundle optimization impact', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasBundleAnalysis, 'Bundle analysis not available');
const bundleInfo = await getBundleSizeInfo(page);
if (bundleInfo && bundleInfo.initialBundle) {
console.log('Bundle optimization metrics:');
console.log(` - Initial bundle: ${bundleInfo.initialBundle}`);
console.log(` - Loaded components: ${bundleInfo.loadedComponents}`);
console.log(` - Total size: ${bundleInfo.totalSize}`);
console.log(` - Optimization: ${bundleInfo.optimization}`);
// Calculate potential savings
if (bundleInfo.loadedComponents > 0 && bundleInfo.totalSize) {
const avgSize = parseFloat(bundleInfo.totalSize) / bundleInfo.loadedComponents;
console.log(` - Average component size: ${avgSize.toFixed(2)}KB`);
}
}
});
});
test.describe('Accessibility with Feature Detection', () => {
test('should have proper ARIA labels with feature detection', async ({ page }) => {
const features = await detectLoadingFeatures(page);
// Check for ARIA labels on interactive elements
const loadButtons = page.locator('.load-btn, .load-component-btn');
const favoriteButtons = page.locator('.favorite-btn, .favorite-toggle');
const loadButtonCount = await loadButtons.count();
const favoriteButtonCount = await favoriteButtons.count();
console.log(`Found ${loadButtonCount} load buttons and ${favoriteButtonCount} favorite buttons`);
if (loadButtonCount > 0) {
// Check first load button for ARIA attributes
const firstLoadBtn = loadButtons.first();
const ariaLabel = await firstLoadBtn.getAttribute('aria-label');
const role = await firstLoadBtn.getAttribute('role');
console.log(`Load button ARIA: label="${ariaLabel}", role="${role}"`);
}
if (favoriteButtonCount > 0) {
// Check first favorite button for ARIA attributes
const firstFavoriteBtn = favoriteButtons.first();
const ariaLabel = await firstFavoriteBtn.getAttribute('aria-label');
const ariaPressed = await firstFavoriteBtn.getAttribute('aria-pressed');
console.log(`Favorite button ARIA: label="${ariaLabel}", pressed="${ariaPressed}"`);
}
});
test('should support keyboard navigation', async ({ page }) => {
const features = await detectLoadingFeatures(page);
const interactiveElements = page.locator('button, [role="button"], select, input');
const count = await interactiveElements.count();
console.log(`Found ${count} interactive elements`);
if (count > 0) {
// Test Tab navigation
const firstElement = interactiveElements.first();
await firstElement.focus();
const focusedElement = page.locator(':focus');
await expect(focusedElement).toBeVisible();
console.log('✓ Keyboard navigation works');
}
});
test('should announce loading states to screen readers', async ({ page }) => {
const features = await detectLoadingFeatures(page);
test.skip(!features.hasLazyLoadingUI && !features.hasDynamicLoaderUI, 'No loading UI available');
// Check for ARIA live regions
const liveRegions = page.locator('[aria-live], [role="status"], [role="progressbar"]');
const count = await liveRegions.count();
console.log(`Found ${count} ARIA live regions for loading states`);
if (count > 0) {
for (let i = 0; i < Math.min(count, 5); i++) {
const region = liveRegions.nth(i);
const live = await region.getAttribute('aria-live');
const role = await region.getAttribute('role');
console.log(` Live region ${i}: aria-live="${live}", role="${role}"`);
}
}
});
});
test.describe('Comprehensive Integration Test', () => {
test('should complete full loading workflow with feature detection', async ({ page }) => {
const features = await detectLoadingFeatures(page);
const capabilities = await detectBrowserCapabilities(page);
const wasmFeatures = await detectWASMFeatures(page);
console.log('=== Environment ===');
console.log('Browser Capabilities:', JSON.stringify(capabilities, null, 2));
console.log('WASM Features:', JSON.stringify(wasmFeatures, null, 2));
console.log('Loading Features:', JSON.stringify(features, null, 2));
console.log('\n=== Performance Metrics ===');
const metrics = await getPerformanceMetrics(page);
console.log(JSON.stringify(metrics, null, 2));
console.log('\n=== Components ===');
const componentNames = await getComponentNames(page);
console.log(`Total components: ${componentNames.length}`);
console.log('Component names:', componentNames.slice(0, 10).join(', '));
if (componentNames.length > 10) {
console.log(`... and ${componentNames.length - 10} more`);
}
console.log('\n=== Categories ===');
const categories = await getComponentCategories(page);
console.log(`Total categories: ${categories.length}`);
console.log('Categories:', categories.join(', '));
console.log('\n=== Bundle Information ===');
const bundleInfo = await getBundleSizeInfo(page);
if (bundleInfo) {
console.log(JSON.stringify(bundleInfo, null, 2));
} else {
console.log('Bundle information not available');
}
// Final verification
console.log('\n=== Verification ===');
const isWasmReady = await isWASMInitialized(page);
console.log(`WASM Initialized: ${isWasmReady}`);
expect(isWasmReady).toBe(true);
const headerVisible = await page.locator('h1').first().isVisible();
console.log(`App Header Visible: ${headerVisible}`);
expect(headerVisible).toBe(true);
console.log('\n✓ Comprehensive integration test completed successfully');
});
});
});