import { test, expect } from '@playwright/test'; import { isValidMacAddress, isValidPrivateIPV4 } from '../../utils/utils.js'; test.describe('Network & Services - Network - LAN', () => { test.beforeEach(async ({ page }) => { await page.goto('/network/lan', { waitUntil: 'networkidle' }); }); test('Title', async ({ page }) => { expect(await page.title()).toBe('Difuse - Network - LAN'); }); test('Card Header Title', async ({ page }) => { const title = await page.locator('.card-header-title'); expect(await title).toBeTruthy(); }); test('Tabs', async ({ page }) => { const ipv4Tab = await page.$('a[role="tab"][id="4-tab"]'); const ipv4visible = await ipv4Tab.isVisible(); expect(ipv4visible).toBeTruthy(); await page.click('a[role="tab"][id="4-tab"]'); await page.waitForSelector('#content-4'); const ipv4Content = await page.locator('#content-4'); const ipv4ContentVisible = await ipv4Content.isVisible(); expect(ipv4ContentVisible).toBeTruthy(); const ipv6Tab = await page.$('a[role="tab"][id="6-tab"]'); const ipv6visible = await ipv6Tab.isVisible(); expect(ipv6visible).toBeTruthy(); await page.click('a[role="tab"][id="6-tab"]'); await page.waitForSelector('#content-6'); const ipv6Content = await page.locator('#content-6'); const ipv6ContentVisible = await ipv6Content.isVisible(); expect(ipv6ContentVisible).toBeTruthy(); const bridgeSlaves = await page.$('a[role="tab"][id="bs-tab"]'); const bridgeSlavesVisible = await bridgeSlaves.isVisible(); expect(bridgeSlavesVisible).toBeTruthy(); await page.click('a[role="tab"][id="bs-tab"]'); await page.waitForSelector('#content-bs'); const bsContent = await page.locator('#content-bs'); const bsContentVisible = await bsContent.isVisible(); expect(bsContentVisible).toBeTruthy(); }); test('Info Tables', async ({ page }) => { const rows = await page.$$('table > tbody > tr'); for (const row of rows) { const cells = await row.$$('td'); if (cells.length === 2) { const label = await cells[0].textContent(); const value = await cells[1].textContent(); if (label === 'Protocol') { expect(value).toBe('Static Address'); } else if (label === 'Uptime') { expect(typeof parseInt(value)).toBe('number'); } else if (label === 'MAC') { expect(isValidMacAddress(value)).toBeTruthy(); } else if (label === 'RX' || label === 'TX') { expect(typeof parseInt(value)).toBe('number'); } else if (label === 'IPv4') { expect(isValidPrivateIPV4(value)).toBeTruthy(); } } } }); });