-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-frontend-core.js
More file actions
75 lines (59 loc) · 2.76 KB
/
Copy pathtest-frontend-core.js
File metadata and controls
75 lines (59 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { chromium } from 'playwright';
(async () => {
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
// Listen for console logs and errors
page.on('console', msg => console.log('CONSOLE:', msg.text()));
page.on('pageerror', error => console.log('ERROR:', error.message));
try {
console.log('Testing core frontend functionality...');
await page.goto('http://localhost:5174/tenant/user0001_project0001/dashboard', { waitUntil: 'networkidle' });
await page.waitForTimeout(3000);
console.log('Page loaded, title:', await page.title());
console.log('URL:', page.url());
// Test navigation elements
const navCount = await page.locator('nav').count();
const dashboardCount = await page.getByText('Dashboard').count();
const productsCount = await page.getByText('Products').count();
const categoriesCount = await page.getByText('Categories').count();
const customersCount = await page.getByText('Customers').count();
const ordersCount = await page.getByText('Orders').count();
console.log('Navigation elements:', {
nav: navCount,
dashboard: dashboardCount,
products: productsCount,
categories: categoriesCount,
customers: customersCount,
orders: ordersCount
});
// Test navigation to Products page
console.log('\nTesting Products page navigation...');
await page.getByText('Products').first().click();
await page.waitForTimeout(2000);
const currentUrl = page.url();
console.log('Products page URL:', currentUrl);
// Check for products table/grid
const productsTable = await page.locator('table, [data-testid="products-grid"], .products-container').count();
console.log('Products display elements:', productsTable);
// Check for product data or loading state
const productRows = await page.locator('table tbody tr, [data-testid="product-item"]').count();
console.log('Product rows found:', productRows);
// Test search functionality if present
const searchInput = page.getByPlaceholder(/search/i).first();
const searchVisible = await searchInput.isVisible().catch(() => false);
console.log('Search input visible:', searchVisible);
if (searchVisible) {
await searchInput.fill('test');
await page.waitForTimeout(1000);
console.log('Search executed successfully');
}
// Take final screenshot
await page.screenshot({ path: 'frontend-core-test.png' });
console.log('Screenshot saved as frontend-core-test.png');
console.log('\n✅ Core frontend functionality test completed successfully');
} catch (error) {
console.error('❌ Error during frontend test:', error);
await page.screenshot({ path: 'frontend-error.png' });
}
await browser.close();
})();