network - WAN - IPv6 Tab, Priorities, Bridge slaves test compeled

This commit is contained in:
Ajas 2024-06-20 00:32:40 +05:30
parent 3412a6d178
commit 3ae8878669
3 changed files with 175 additions and 14 deletions

View file

@ -68,19 +68,15 @@ test.describe('Network & Services - Network - LAN', () => {
} else if (label === 'IPv4') {
expect(isValidPrivateIPV4(value)).toBe(true);
} else if (label === 'IPv6 (Prefixes)') {
const splittedValue = splitIPv6(value);
if (!splittedValue) {
expect(value).toBe(false);
} else if (splittedValue.length === 1) {
const isValid = isValidCidr(splittedValue[0]);
expect(isValid).toBe(true);
} else if (splittedValue.length === 2) {
const ipv6One = splittedValue[0];
const isValidIPv6One = isValidCidr(ipv6One);
const ipv6Two = splittedValue[1];
const isValidIPv6Two = isValidCidr(ipv6Two);
expect(await isValidIPv6One && isValidIPv6Two).toBe(true);
let splittedValue;
if (value) {
splittedValue = splitIPv6(value);
splittedValue.forEach((value) => {
const isValid = isValidCidr(value);
expect(isValid).toBe(true);
});
} else {
expect(false).toBe(false);
}
}
}

View file

@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test';
import { isValidMacAddress, isValidPrivateIPV4 } from '../../utils/utils.js';
import { hasToastInput, isValidCidr, isValidMacAddress, isValidPrivateIPV4, splitIPv6 } from '../../utils/utils.js';
test.describe('Network & Services - Network - WAN', () => {
test.describe('IPV4 Tab', () => {
@ -106,4 +106,141 @@ test.describe('Network & Services - Network - WAN', () => {
expect(pppoePassword && pppoePasswordField).toBeTruthy();
});
});
test.describe('IPV6 Tab', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/network/wan', { waitUntil: 'networkidle' });
const ipv6Tab = await page.locator('#v6-tab');
await ipv6Tab.click();
await page.waitForTimeout(2000);
});
test('Restart WAN Interface', async ({ page }) => {
const restartButton = await page.locator('#restartWAN6');
const visible = await restartButton.isVisible();
expect(visible).toBeTruthy();
});
test('Stop WAN Interface', async ({ page }) => {
const stopWAN = await page.locator('#stopWAN6');
const visible = await stopWAN.isVisible();
expect(visible).toBeTruthy();
});
test('Disable WAN Interface', async ({ page }) => {
const disableWAN = await page.locator('#disableWAN6');
const visible = await disableWAN.isVisible();
expect(visible).toBeTruthy();
});
test('IPv6 Source Routing', async ({ page }) => {
const label = await page.locator('label:has-text("IPv6 Source Routing")');
const switchField = await page.locator('.wan6-srcft');
expect(label && switchField).toBeTruthy();
});
test('Delegate Prefix', async ({ page }) => {
const label = await page.locator('label:has-text("Delegate Prefix")');
const switchField = await page.locator('.wan6-pdele');
expect(label && switchField).toBeTruthy();
});
test('IPv6 Info Tables', async ({ page }) => {
const rows = await page.$$('#content-v6 table > tbody > tr');
for (let i = 0; i < rows.length && i < 7; 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();
if (label === 'Protocol') {
expect(value).toBe('DHCPv6');
} 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 === 'IPv6') {
if (value) {
const htmlContent = await cells[1].innerHTML();
const ipv6Addresses = htmlContent.split('<br>');
for (const value of ipv6Addresses) {
const isValid = isValidCidr(value);
expect(isValid).toBe(true);
}
} else {
expect(false).toBe(false);
}
} else if (label === 'IPv6-PD') {
let splittedValue;
if (value) {
splittedValue = splitIPv6(value);
for (const value of splittedValue) {
const isValid = await isValidCidr(value);
expect(isValid).toBe(true);
}
} else {
expect(false).toBe(false);
}
}
}
}
});
test('Save button', async ({ page }) => {
const button = page.locator('button.button.green:has-text("Save")');
expect(button).toBeTruthy();
});
});
test.describe('Priorities Tab', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/network/wan', { waitUntil: 'networkidle' });
const priorityTab = await page.locator('#pri-tab');
await priorityTab.click();
await page.waitForTimeout(2000);
});
test('Priority Table', async ({ page }) => {
const table = await page.locator('#priority-table');
const tableVisible = await table.isVisible();
expect(tableVisible).toBeTruthy();
});
test('Edit Priority WAN', async ({ page }) => {
const button = await page.$('button[onclick="editPriority(\'wan\')"]');
button.click();
expect(await hasToastInput(page, 'Set Priority - WAN')).toBeTruthy();
});
test('Edit Priority WAN6', async ({ page }) => {
const button = await page.$('button[onclick="editPriority(\'wan6\')"]');
button.click();
expect(await hasToastInput(page, 'Set Priority - WAN6')).toBeTruthy();
});
test('Edit Priority 4G_6', async ({ page }) => {
const button = await page.$('button[onclick="editPriority(\'4G_6\')"]');
button.click();
expect(await hasToastInput(page, 'Set Priority - 4G_6')).toBeTruthy();
});
});
test.describe('Bridge Slaves', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/network/wan', { waitUntil: 'networkidle' });
const bridgeSlavesTab = await page.locator('#bs-tab');
await bridgeSlavesTab.click();
await page.waitForTimeout(2000);
});
test('Icon', async ({ page }) => {
const ethernetCable = await page.locator('.mdi-ethernet-cable');
const WAN = await page.locator('.mdi-ethernet');
expect(ethernetCable && WAN).toBeTruthy();
});
});
});

View file

@ -73,6 +73,34 @@ export async function hasToastText(page, text) {
}
}
export async function hasToastInput(page, text) {
try {
await page.waitForSelector(".swal2-popup", { state: "visible" });
const inputField = await page.waitForSelector(".swal2-input", {
state: "visible",
});
const okButton = await page.waitForSelector(".swal2-confirm", {
state: "visible",
});
const inputIsVisible = await inputField.isVisible();
const okButtonIsEnabled = await okButton.isEnabled();
const heading = await page.waitForSelector("#swal2-title", {
state: "visible",
});
const textContent = await heading.textContent();
const hasText = textContent.includes(text);
return inputIsVisible && okButtonIsEnabled && hasText;
} catch (error) {
return false;
}
}
export async function hasToastQRcode(page, text) {
try {
await page.waitForSelector(".swal2-popup", { state: "visible" });