Network - Wifi : test Completed

This commit is contained in:
Ajas 2024-06-19 18:39:32 +05:30
parent ad88794018
commit 948403697f
2 changed files with 151 additions and 0 deletions

61
tests/network/wan.spec.js Normal file
View file

@ -0,0 +1,61 @@
import { test, expect } from '@playwright/test';
import { isValidMacAddress, isValidPrivateIPV4 } from '../../utils/utils.js';
test.describe('Network & Services - Network - WAN', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/network/wan', { waitUntil: 'networkidle' });
});
test('Title', async ({ page }) => {
expect(await page.title()).toBe('Difuse - Network - WAN');
});
test('Card Header Title', async ({ page }) => {
const title = await page.locator('.card-header-title');
expect(await title).toBeTruthy();
});
test('IPv4 Info Tables', async ({ page }) => {
const rows = await page.$$('table > tbody > tr');
for (let i = 0; i < rows.length && i < 6; i++) {
const row = rows[i];
const cells = await row.$$('td');
if (cells.length === 2) {
const label = await cells[0].textContent();
const value = await cells[1].textContent();
console.log(label + ' : ' + value);
if (label === 'Protocol') {
expect(value).toBe('DHCPv4');
} 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)).toBe(true);
}
}
}
});
test('Restart WAN Interface', async ({ page }) => {
const restartButton = await page.locator('#restartWAN');
const visible = await restartButton.isVisible();
expect(visible).toBeTruthy();
});
test('Stop WAN Interface', async ({ page }) => {
const stopWAN = await page.locator('#stopWAN');
const visible = await stopWAN.isVisible();
expect(visible).toBeTruthy();
});
test('Disable WAN Interface', async ({ page }) => {
const disableWAN = await page.locator('#disableWAN');
const visible = await disableWAN.isVisible();
expect(visible).toBeTruthy();
});
});

View file

@ -38,6 +38,13 @@ test.describe('Network & Services - Network - WiFi', () => {
expect(await primaryAPandRadio).toBeTruthy();
});
test('Primary AP & Radio Enable switch', async ({ page }) => {
const enableLabel = await page.locator('#\\34-form label:has-text("Enable")');
const enableSwitch = await page.locator('#\\34-form label.switch');
expect(enableLabel && enableSwitch).toBeTruthy();
});
test('SSID Validation', async ({ page }) => {
const ssid = await page.locator('#ssid-24');
const value = await ssid.inputValue();
@ -123,11 +130,38 @@ test.describe('Network & Services - Network - WiFi', () => {
expect(await hasToastQRcode(page, 'Difuse 2.4G - QR Code')).toBeTruthy();
});
test('Allow legacy 802.11b rates', async ({ page }) => {
const label = await page.locator('#\\34-form label:has-text("Allow legacy 802.11b rates")');
const allowSwitch = await page.locator('#\\34-form label.switch');
expect(label && allowSwitch).toBeTruthy();
});
test('MAC Filtering', async ({ page }) => {
const label = await page.locator('#\\34-form label:has-text("MAC Filtering")');
expect(label).toBeTruthy();
const selection = await page.locator('#\\34-form select.mac-filter-ena-24');
await selection.click();
await page.selectOption('#\\34-form select.mac-filter-ena-24', { label: 'Allow Listed Only' });
await page.waitForTimeout(1000);
const isVisible = await page.isVisible('#\\34-form div.field.mfl-24');
expect(isVisible).toBe(true);
});
test('Guest', async ({ page }) => {
const guest = await page.locator("span:has-text('Guest')");
expect(await guest).toBeTruthy();
});
test('Guest Enable switch', async ({ page }) => {
const enableLabel = await page.locator('#g-4-form label:has-text("Enable")');
const enableSwitch = await page.locator('#g-4-form label.switch');
expect(enableLabel && enableSwitch).toBeTruthy();
});
test('Guest SSID Validation', async ({ page }) => {
const guestSsid = await page.locator('#g-ssid-24');
const value = await guestSsid.inputValue();
@ -212,6 +246,20 @@ test.describe('Network & Services - Network - WiFi', () => {
await page.click('#g-4-form button.button.purple.showQR');
expect(await hasToastQRcode(page, 'Difuse 2.4Ghz Guest - QR Code')).toBeTruthy();
});
test('Guest MAC Filtering', async ({ page }) => {
const label = await page.locator('#g-4-form label:has-text("MAC Filtering")');
expect(label).toBeTruthy();
const selection = await page.locator('#g-4-form select.g-mac-filter-ena-24');
await selection.click();
await page.selectOption('#g-4-form select.g-mac-filter-ena-24', { label: 'Allow Listed Only' });
await page.waitForTimeout(2000);
const isVisible = await page.isVisible('#g-4-form div.field.g-mfl-24');
expect(isVisible).toBe(true);
});
});
test.describe('5Ghz WiFi Tab', () => {
@ -227,6 +275,13 @@ test.describe('Network & Services - Network - WiFi', () => {
expect(await primaryAPandRadio).toBeTruthy();
});
test('5ghz Primary AP & Radio Enable switch', async ({ page }) => {
const enableLabel = await page.locator('#\\35-form label:has-text("Enable")');
const enableSwitch = await page.locator('#\\35-form label.switch');
expect(enableLabel && enableSwitch).toBeTruthy();
});
test('5Ghz SSID Validation', async ({ page }) => {
const ssid = await page.locator('#ssid-5');
const value = await ssid.inputValue();
@ -313,11 +368,32 @@ test.describe('Network & Services - Network - WiFi', () => {
expect(await hasToastQRcode(page, 'Difuse 5G - QR Code')).toBeTruthy();
});
test('5Ghz MAC Filtering', async ({ page }) => {
const label = await page.locator('#\\35-form label:has-text("MAC Filtering")');
expect(label).toBeTruthy();
const selection = await page.locator('#\\35-form select.mac-filter-ena-5');
await selection.click();
await page.selectOption('#\\35-form select.mac-filter-ena-5', { label: 'Allow Listed Only' });
await page.waitForTimeout(1000);
const isVisible = await page.isVisible('#\\35-form div.field.mfl-5');
expect(isVisible).toBe(true);
});
test('Guest 5Ghz', async ({ page }) => {
const guest = await page.locator("span:has-text('Guest')");
expect(await guest).toBeTruthy();
});
test('Primary AP & Radio Enable switch', async ({ page }) => {
const enableLabel = await page.locator('#g-5-form label:has-text("Enable")');
const enableSwitch = await page.locator('#g-5-form label.switch');
expect(enableLabel && enableSwitch).toBeTruthy();
});
test('Guest 5Ghz SSID Validation', async ({ page }) => {
const guestSsid = await page.locator('#g-ssid-5');
const value = await guestSsid.inputValue();
@ -402,5 +478,19 @@ test.describe('Network & Services - Network - WiFi', () => {
await page.click('#g-5-form button.button.purple.showQR');
expect(await hasToastQRcode(page, 'Difuse 5Ghz Guest - QR Code')).toBeTruthy();
});
test('5Ghz Guest MAC Filtering', async ({ page }) => {
const label = await page.locator('#g-5-form label:has-text("MAC Filtering")');
expect(label).toBeTruthy();
const selection = await page.locator('#g-5-form select.g-mac-filter-ena-5');
await selection.click();
await page.selectOption('#g-5-form select.g-mac-filter-ena-5', { label: 'Allow Listed Only' });
await page.waitForTimeout(1000);
const isVisible = await page.isVisible('#g-5-form div.field.g-mfl-5');
expect(isVisible).toBe(true);
});
});
});