Network - WAN : IPv4 Tab completed

This commit is contained in:
Ajas 2024-06-19 19:30:44 +05:30
parent 948403697f
commit 3412a6d178

View file

@ -2,60 +2,108 @@ import { test, expect } from '@playwright/test';
import { isValidMacAddress, isValidPrivateIPV4 } from '../../utils/utils.js'; import { isValidMacAddress, isValidPrivateIPV4 } from '../../utils/utils.js';
test.describe('Network & Services - Network - WAN', () => { test.describe('Network & Services - Network - WAN', () => {
test.beforeEach(async ({ page }) => { test.describe('IPV4 Tab', () => {
await page.goto('/network/wan', { waitUntil: 'networkidle' }); test.beforeEach(async ({ page }) => {
}); await page.goto('/network/wan', { waitUntil: 'networkidle' });
await page.waitForTimeout(3000);
});
test('Title', async ({ page }) => { test('Title', async ({ page }) => {
expect(await page.title()).toBe('Difuse - Network - WAN'); expect(await page.title()).toBe('Difuse - Network - WAN');
}); });
test('Card Header Title', async ({ page }) => { test('Card Header Title', async ({ page }) => {
const title = await page.locator('.card-header-title'); const title = await page.locator('.card-header-title');
expect(await title).toBeTruthy(); expect(await title).toBeTruthy();
}); });
test('IPv4 Info Tables', async ({ page }) => { test('IPv4 Info Tables', async ({ page }) => {
const rows = await page.$$('table > tbody > tr'); const rows = await page.$$('table > tbody > tr');
for (let i = 0; i < rows.length && i < 6; i++) { for (let i = 0; i < rows.length && i < 6; i++) {
const row = rows[i]; const row = rows[i];
const cells = await row.$$('td'); const cells = await row.$$('td');
if (cells.length === 2) { if (cells.length === 2) {
const label = await cells[0].textContent(); const label = await cells[0].textContent();
const value = await cells[1].textContent(); const value = await cells[1].textContent();
console.log(label + ' : ' + value); if (label === 'Protocol') {
expect(value).toBe('DHCPv4');
if (label === 'Protocol') { } else if (label === 'Uptime') {
expect(value).toBe('DHCPv4'); expect(typeof parseInt(value)).toBe('number');
} else if (label === 'Uptime') { } else if (label === 'MAC') {
expect(typeof parseInt(value)).toBe('number'); expect(isValidMacAddress(value)).toBeTruthy();
} else if (label === 'MAC') { } else if (label === 'RX' || label === 'TX') {
expect(isValidMacAddress(value)).toBeTruthy(); expect(typeof parseInt(value)).toBe('number');
} else if (label === 'RX' || label === 'TX') { } else if (label === 'IPv4') {
expect(typeof parseInt(value)).toBe('number'); expect(isValidPrivateIPV4(value)).toBe(true);
} else if (label === 'IPv4') { }
expect(isValidPrivateIPV4(value)).toBe(true);
} }
} }
} });
});
test('Restart WAN Interface', async ({ page }) => { test('Restart WAN Interface', async ({ page }) => {
const restartButton = await page.locator('#restartWAN'); const restartButton = await page.locator('#restartWAN');
const visible = await restartButton.isVisible(); const visible = await restartButton.isVisible();
expect(visible).toBeTruthy(); expect(visible).toBeTruthy();
}); });
test('Stop WAN Interface', async ({ page }) => { test('Stop WAN Interface', async ({ page }) => {
const stopWAN = await page.locator('#stopWAN'); const stopWAN = await page.locator('#stopWAN');
const visible = await stopWAN.isVisible(); const visible = await stopWAN.isVisible();
expect(visible).toBeTruthy(); expect(visible).toBeTruthy();
}); });
test('Disable WAN Interface', async ({ page }) => { test('Disable WAN Interface', async ({ page }) => {
const disableWAN = await page.locator('#disableWAN'); const disableWAN = await page.locator('#disableWAN');
const visible = await disableWAN.isVisible(); const visible = await disableWAN.isVisible();
expect(visible).toBeTruthy(); expect(visible).toBeTruthy();
});
test('IPv4 Protocol Static IP', async ({ page }) => {
const label = await page.locator('label:has-text("Protocol")');
expect(label).toBeTruthy();
const selectElement = await page.locator('select.proto-select');
await selectElement.selectOption({ label: 'Static IP' });
await page.waitForTimeout(1000);
const isVisible = await page.isVisible('#staticip-sub-div');
expect(isVisible).toBe(true);
const ipv4Address = await page.locator('label:has-text("IPv4 Address")');
const ipv4AddressField = await page.locator('#static-ip');
expect(ipv4Address && ipv4AddressField).toBeTruthy();
const networkMask = await page.locator('label:has-text("Network Mask")');
const networkMaskField = await page.locator('select.static-netmask-select');
expect(networkMask && networkMaskField).toBeTruthy();
const ipv4Gateway = await page.locator('label:has-text("IPv4 Gateway")');
const ipv4GatewayField = await page.locator('#static-gateway');
expect(ipv4Gateway && ipv4GatewayField).toBeTruthy();
const ipv4Broadcast = await page.locator('label:has-text("IPv4 Broadcast")');
const ipv4BroadcastField = await page.locator('#static-broadcast');
expect(ipv4Broadcast && ipv4BroadcastField).toBeTruthy();
});
test('IPv4 Protocol PPPoE', async ({ page }) => {
const selectElement = await page.locator('select.proto-select');
await selectElement.selectOption({ label: 'PPPoE' });
await page.waitForTimeout(1000);
const isVisible = await page.isVisible('#pppoe-sub-div');
expect(isVisible).toBe(true);
const pppoeUsername = await page.locator('label:has-text("PAP/CHAP Username")');
const pppoeUsernameField = await page.locator('#pppoe-username');
expect(pppoeUsername && pppoeUsernameField).toBeTruthy();
const pppoePassword = await page.locator('label:has-text("PAP/CHAP Password")');
const pppoePasswordField = await page.locator('#pppoe-password');
expect(pppoePassword && pppoePasswordField).toBeTruthy();
});
}); });
}); });