61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
|
|
const { chromium } = require('playwright');
|
||
|
|
|
||
|
|
async function testEdit() {
|
||
|
|
const browser = await chromium.launch({ headless: true });
|
||
|
|
const context = await browser.newContext({ ignoreHTTPSErrors: true });
|
||
|
|
const page = await context.newPage();
|
||
|
|
|
||
|
|
try {
|
||
|
|
await page.goto('https://admin-panel.habland.orb.local/furni', {
|
||
|
|
waitUntil: 'networkidle',
|
||
|
|
timeout: 15000
|
||
|
|
});
|
||
|
|
|
||
|
|
await page.waitForTimeout(2000);
|
||
|
|
|
||
|
|
// Get first row
|
||
|
|
const firstRow = page.locator('tbody tr').first();
|
||
|
|
|
||
|
|
// Get item ID from the row
|
||
|
|
const itemId = await firstRow.locator('td').first().textContent();
|
||
|
|
console.log(`Testing edit on item: ${itemId}`);
|
||
|
|
|
||
|
|
// Hover to reveal buttons
|
||
|
|
await firstRow.hover();
|
||
|
|
await page.waitForTimeout(500);
|
||
|
|
|
||
|
|
// Count edit rows before clicking
|
||
|
|
const beforeEdit = await page.locator('tr.bg-purple-500\\/5').count();
|
||
|
|
console.log(`Edit rows before click: ${beforeEdit}`);
|
||
|
|
|
||
|
|
// Click edit button
|
||
|
|
await firstRow.locator('button[title="Edit"]').click();
|
||
|
|
console.log('Clicked edit button');
|
||
|
|
|
||
|
|
await page.waitForTimeout(1000);
|
||
|
|
|
||
|
|
// Count edit rows after clicking
|
||
|
|
const afterEdit = await page.locator('tr.bg-purple-500\\/5').count();
|
||
|
|
console.log(`Edit rows after click: ${afterEdit}`);
|
||
|
|
|
||
|
|
if (afterEdit > beforeEdit) {
|
||
|
|
console.log('✅ Edit row appeared!');
|
||
|
|
} else {
|
||
|
|
console.log('❌ Edit row did NOT appear');
|
||
|
|
|
||
|
|
// Check if item row is still there
|
||
|
|
const rowStillExists = await page.locator(`td:has-text("${itemId}")`).count();
|
||
|
|
console.log(`Original row still exists: ${rowStillExists > 0}`);
|
||
|
|
}
|
||
|
|
|
||
|
|
await page.screenshot({ path: '/Users/matt/DEV/habland/admin-panel/edit-test.png', fullPage: true });
|
||
|
|
|
||
|
|
} catch (error) {
|
||
|
|
console.error('Error:', error.message);
|
||
|
|
} finally {
|
||
|
|
await browser.close();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
testEdit();
|