Compare commits
22 commits
Author | SHA1 | Date | |
---|---|---|---|
|
84f7f72230 | ||
|
1fa86050b3 | ||
|
7ba89b995a | ||
|
649b9d8fd2 | ||
|
99bca667e2 | ||
|
c690199f69 | ||
|
49a47cce0f | ||
|
16f3a509ca | ||
|
3ae8878669 | ||
|
3412a6d178 | ||
|
948403697f | ||
|
ad88794018 | ||
|
530701b1be | ||
|
4cadd63e99 | ||
|
13de59c665 | ||
|
6c0a6e1620 | ||
|
ff99dcee54 | ||
|
578f3b9ca1 | ||
|
d8b0efefba | ||
|
514c855fea | ||
|
254dede49b | ||
|
fe9ce1d8c9 |
13 changed files with 2046 additions and 27 deletions
25
package-lock.json
generated
25
package-lock.json
generated
|
@ -9,6 +9,7 @@
|
|||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cidr-regex": "^4.1.1",
|
||||
"dotenv": "^16.4.1",
|
||||
"ip-address": "^9.0.5",
|
||||
"ip-cidr": "^4.0.0"
|
||||
|
@ -504,6 +505,18 @@
|
|||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/cidr-regex": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/cidr-regex/-/cidr-regex-4.1.1.tgz",
|
||||
"integrity": "sha512-ekKcVp+iRB9zlKFXyx7io7nINgb0oRjgRdXNEodp1OuxRui8FXr/CA40Tz1voWUp9DPPrMyQKy01vJhDo4N1lw==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"ip-regex": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
|
@ -1711,6 +1724,18 @@
|
|||
"node": ">=16.14.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ip-regex": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-5.0.0.tgz",
|
||||
"integrity": "sha512-fOCG6lhoKKakwv+C6KdsOnGvgXnmgfmp0myi3bcNwj3qfwPAxRKWEuFhvEFF7ceYIz6+1jRZ+yguLFAmUNPEfw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/is-array-buffer": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.4.tgz",
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
"semistandard": "^17.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"cidr-regex": "^4.1.1",
|
||||
"dotenv": "^16.4.1",
|
||||
"ip-address": "^9.0.5",
|
||||
"ip-cidr": "^4.0.0"
|
||||
|
|
|
@ -63,7 +63,6 @@ test.describe('General - Dashboard - Network Analyzer - Deep Packet Inspection',
|
|||
const dpiMap = await page.locator('#dpi-map');
|
||||
const isVisible = await dpiMap.isVisible();
|
||||
const isEnabled = await dpiMap.isEnabled();
|
||||
|
||||
expect(isVisible && isEnabled).toBeTruthy();
|
||||
});
|
||||
|
||||
|
@ -123,6 +122,7 @@ test.describe('General - Dashboard - Network Analyzer - Deep Packet Inspection',
|
|||
});
|
||||
|
||||
await page.click('#detail-tab-dpi');
|
||||
await page.waitForTimeout(15000);
|
||||
});
|
||||
|
||||
test('Detail Explorer Top Cards', async ({ page }) => {
|
||||
|
@ -215,6 +215,8 @@ test.describe('General - Dashboard - Network Analyzer - Deep Packet Inspection',
|
|||
await page.goto('network-analyzer/deep-packet-inspector', { waitUntil: 'networkidle' });
|
||||
|
||||
await page.click('#liveview-tab-dpi');
|
||||
|
||||
await page.waitForTimeout(15000);
|
||||
});
|
||||
|
||||
test('Toggle icon is Pause', async ({ page }) => {
|
||||
|
@ -242,6 +244,8 @@ test.describe('General - Dashboard - Network Analyzer - Deep Packet Inspection',
|
|||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('network-analyzer/deep-packet-inspector', { waitUntil: 'networkidle' });
|
||||
await page.click('#settings-tab-dpi');
|
||||
|
||||
await page.waitForTimeout(15000);
|
||||
});
|
||||
|
||||
test('Enable Label', async ({ page }) => {
|
||||
|
@ -253,6 +257,56 @@ test.describe('General - Dashboard - Network Analyzer - Deep Packet Inspection',
|
|||
expect(checkbox).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Enable Switch Function', async ({ page }) => {
|
||||
const checkBox = page.locator('.cb-enable');
|
||||
|
||||
const isChecked = await checkBox.isChecked();
|
||||
|
||||
if (!isChecked) {
|
||||
await page.evaluate((checkbox) => checkbox.click(), await checkBox.elementHandle());
|
||||
const saveButton = await page.getByRole('button', { name: 'Save' });
|
||||
await saveButton.click();
|
||||
await page.waitForTimeout(8000);
|
||||
}
|
||||
|
||||
const overviewTab = await page.locator('#overview-tab-dpi');
|
||||
const overviewTabElement = await overviewTab.elementHandle();
|
||||
const overviewIsEnabled = await overviewTabElement.isEnabled();
|
||||
|
||||
const detailExplorerTab = await page.locator('#detail-tab-dpi');
|
||||
const detailExplorerTabElement = await detailExplorerTab.elementHandle();
|
||||
const detailExplorerTabIsEnabled = await detailExplorerTabElement.isEnabled();
|
||||
|
||||
const liveViewTab = await page.locator('#liveview-tab-dpi');
|
||||
const liveViewTabElement = await liveViewTab.elementHandle();
|
||||
const liveViewIsEnabled = await liveViewTabElement.isEnabled();
|
||||
|
||||
expect(overviewIsEnabled && detailExplorerTabIsEnabled && liveViewIsEnabled).toBe(true);
|
||||
});
|
||||
|
||||
test('Disable Switch Function', async ({ page }) => {
|
||||
const checkBox = page.locator('.cb-enable');
|
||||
|
||||
const isChecked = await checkBox.isChecked();
|
||||
|
||||
if (isChecked) {
|
||||
await page.evaluate((checkbox) => checkbox.click(), await checkBox.elementHandle());
|
||||
const saveButton = await page.getByRole('button', { name: 'Save' });
|
||||
await saveButton.click();
|
||||
await page.waitForTimeout(8000);
|
||||
}
|
||||
|
||||
const overviewTabElement = await page.locator('#overview-tab-dpi').elementHandle();
|
||||
const detailExplorerTabElement = await page.locator('#detail-tab-dpi').elementHandle();
|
||||
const liveViewTabElement = await page.locator('#liveview-tab-dpi').elementHandle();
|
||||
|
||||
const overviewIsDisable = await overviewTabElement.getAttribute('disabled');
|
||||
const detailExplorerIsDisable = await detailExplorerTabElement.getAttribute('disabled');
|
||||
const liveViewIsDisable = await liveViewTabElement.getAttribute('disabled');
|
||||
|
||||
expect(overviewIsDisable && detailExplorerIsDisable && liveViewIsDisable).toBe('disabled');
|
||||
});
|
||||
|
||||
test('Ignore Bittorrent Traffic', async ({ page }) => {
|
||||
expect(await page.$('label:has-text("Ignore Bittorrent Traffic")')).toBeTruthy();
|
||||
});
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
import { isValidDate } from '../../../utils/utils.js';
|
||||
|
||||
test.describe('General - Dashboard - Network Analyzer - Traffic Monitor', () => {
|
||||
test.describe('Traffic Distribution', () => {
|
||||
|
@ -22,20 +23,15 @@ test.describe('General - Dashboard - Network Analyzer - Traffic Monitor', () =>
|
|||
test('Traffic Monitor select Date', async ({ page }) => {
|
||||
const selectElement = page.locator('select.period-select');
|
||||
|
||||
const options = await selectElement.locator('option');
|
||||
await expect(selectElement).toBeVisible();
|
||||
|
||||
const optionCount = await options.count();
|
||||
const date = [];
|
||||
for (let i = 0; i < optionCount; i++) {
|
||||
const option = options.nth(i);
|
||||
const value = await option.getAttribute('value');
|
||||
date.push(value);
|
||||
const currentValue = await selectElement.inputValue();
|
||||
|
||||
if (currentValue === 'Period') {
|
||||
expect(currentValue).toBe('Period');
|
||||
} else {
|
||||
expect(isValidDate(currentValue)).toBeTruthy();
|
||||
}
|
||||
|
||||
await selectElement.selectOption(date[1]);
|
||||
|
||||
const selectedValue = await selectElement.inputValue();
|
||||
expect(selectedValue).toBe(date[1]);
|
||||
});
|
||||
|
||||
test('Tabs', async ({ page }) => {
|
||||
|
|
348
tests/network/dhcp.spec.js
Normal file
348
tests/network/dhcp.spec.js
Normal file
|
@ -0,0 +1,348 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Network & Services - Network - DHCP', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/network/dhcp', { waitUntil: 'networkidle' });
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
test.describe('General Settings Tab', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
const generalSettingsTab = await page.locator('#general-tab-dndh');
|
||||
await generalSettingsTab.click();
|
||||
await page.waitForTimeout(3000);
|
||||
});
|
||||
|
||||
test('Title', async ({ page }) => {
|
||||
expect(await page.title()).toBe('Difuse - Network - DHCP');
|
||||
});
|
||||
|
||||
test('Card Header Title', async ({ page }) => {
|
||||
const title = await page.locator('.card-header-title');
|
||||
expect(await title).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Allocate IPs Sequentially', async ({ page }) => {
|
||||
const label = await page.$('#general-form label:has-text("Allocate IPs Sequentially")');
|
||||
expect(label).toBeTruthy();
|
||||
|
||||
const switchField = await page.locator('#general-form .sequential_ip');
|
||||
const switchFieldIsVisible = await switchField.isVisible();
|
||||
expect(switchFieldIsVisible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Authoritative ', async ({ page }) => {
|
||||
const label = await page.$('#general-form label:has-text("Authoritative")');
|
||||
expect(label).toBeTruthy();
|
||||
|
||||
const switchField = await page.locator('#general-form .authoritative');
|
||||
const switchFieldIsVisible = await switchField.isVisible();
|
||||
expect(switchFieldIsVisible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Hijack DNS ', async ({ page }) => {
|
||||
const label = await page.$('#general-form label:has-text("Hijack DNS")');
|
||||
expect(label).toBeTruthy();
|
||||
|
||||
const switchField = await page.locator('#general-form .hijackdns');
|
||||
const switchFieldIsVisible = await switchField.isVisible();
|
||||
expect(switchFieldIsVisible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Save Button', async ({ page }) => {
|
||||
const button = page.locator('#general-form button.button.green:has-text("Save")');
|
||||
expect(button).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Static Leases Tab', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
const staticLeasesTab = await page.locator('#static-tab-dndh');
|
||||
await staticLeasesTab.click();
|
||||
await page.waitForTimeout(3000);
|
||||
});
|
||||
|
||||
test('Static Leases', async ({ page }) => {
|
||||
const label = await page.locator('#content-static span:has-text("Static Leases")');
|
||||
const visible = await label.isVisible();
|
||||
expect(visible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Static Leases Table Visible', async ({ page }) => {
|
||||
const filterField = await page.locator('#sl-filter-field');
|
||||
const filterFieldIsVisible = await filterField.isVisible();
|
||||
const filterType = await page.locator('#sl-filter-type');
|
||||
const filterTypeIsVisible = await filterType.isVisible();
|
||||
const filterValue = await page.locator('#sl-filter-value');
|
||||
const filterValueIsVisible = await filterValue.isVisible();
|
||||
const ClearFilter = await page.locator('#sl-filter-clear');
|
||||
const ClearFilterIsVisible = await ClearFilter.isVisible();
|
||||
|
||||
expect(filterFieldIsVisible && filterTypeIsVisible && filterValueIsVisible && ClearFilterIsVisible).toBe(true);
|
||||
|
||||
const table = await page.locator('#static-leases-t');
|
||||
const tableIsVisible = await table.isVisible();
|
||||
expect(tableIsVisible).toBe(true);
|
||||
});
|
||||
|
||||
test('Static Leases Add Button', async ({ page }) => {
|
||||
const addButton = await page.locator('#addNewStatic');
|
||||
const visible = await addButton.isVisible();
|
||||
expect(visible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Active DHCPv4 Leases', async ({ page }) => {
|
||||
const label = await page.locator('#content-static span:has-text("Active DHCPv4 Leases")');
|
||||
const visible = await label.isVisible();
|
||||
expect(visible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Active DHCPv4 Leases Table Visible', async ({ page }) => {
|
||||
const filterField = await page.locator('#\\34-filter-field');
|
||||
const filterFieldIsVisible = await filterField.isVisible();
|
||||
const filterType = await page.locator('#\\34-filter-type');
|
||||
const filterTypeIsVisible = await filterType.isVisible();
|
||||
const filterValue = await page.locator('#\\34-filter-value');
|
||||
const filterValueIsVisible = await filterValue.isVisible();
|
||||
const ClearFilter = await page.locator('#\\34-filter-clear');
|
||||
const ClearFilterIsVisible = await ClearFilter.isVisible();
|
||||
|
||||
expect(filterFieldIsVisible && filterTypeIsVisible && filterValueIsVisible && ClearFilterIsVisible).toBe(true);
|
||||
|
||||
const table = await page.locator('#active-leases-t');
|
||||
const tableIsVisible = await table.isVisible();
|
||||
expect(tableIsVisible).toBe(true);
|
||||
});
|
||||
|
||||
test('Active DHCPv6 Leases', async ({ page }) => {
|
||||
const label = await page.locator('#content-static span:has-text("Active DHCPv6 Leases")');
|
||||
const visible = await label.isVisible();
|
||||
expect(visible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Active DHCPv6 Leases Table Visible', async ({ page }) => {
|
||||
const filterField = await page.locator('#\\36-filter-field');
|
||||
const filterFieldIsVisible = await filterField.isVisible();
|
||||
const filterType = await page.locator('#\\36-filter-type');
|
||||
const filterTypeIsVisible = await filterType.isVisible();
|
||||
const filterValue = await page.locator('#\\36-filter-value');
|
||||
const filterValueIsVisible = await filterValue.isVisible();
|
||||
const ClearFilter = await page.locator('#\\36-filter-clear');
|
||||
const ClearFilterIsVisible = await ClearFilter.isVisible();
|
||||
|
||||
expect(filterFieldIsVisible && filterTypeIsVisible && filterValueIsVisible && ClearFilterIsVisible).toBe(true);
|
||||
|
||||
const table = await page.locator('#active-6leases-t');
|
||||
const tableIsVisible = await table.isVisible();
|
||||
expect(tableIsVisible).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('TFTP Server Tab', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
const tftpServerTab = await page.locator('#pxetftp-tab-dndh');
|
||||
await tftpServerTab.click();
|
||||
await page.waitForTimeout(3000);
|
||||
});
|
||||
|
||||
test('TFTP Server', async ({ page }) => {
|
||||
const label = await page.$('#content-pxetftp label:has-text("TFTP Server")');
|
||||
expect(label).toBeTruthy();
|
||||
});
|
||||
|
||||
test('TFTP Server Root Input Field', async ({ page }) => {
|
||||
const label = await page.$('#content-pxetftp label:has-text("TFTP Server Root")');
|
||||
expect(label).toBeTruthy();
|
||||
|
||||
const inputField = await page.locator('#tftp-root');
|
||||
const inputFieldIsVisible = await inputField.isVisible();
|
||||
expect(inputFieldIsVisible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Network Boot Image', async ({ page }) => {
|
||||
const label = await page.$('#content-pxetftp label:has-text("Network Boot Image")');
|
||||
expect(label).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Network Boot Image Input Field', async ({ page }) => {
|
||||
const label = await page.$('#content-pxetftp label:has-text("Network Boot Image")');
|
||||
expect(label).toBeTruthy();
|
||||
|
||||
const inputField = await page.locator('#tftp-boot-image');
|
||||
const inputFieldIsVisible = await inputField.isVisible();
|
||||
expect(inputFieldIsVisible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Save Button', async ({ page }) => {
|
||||
const button = page.locator('#content-pxetftp button.button.green:has-text("Save")');
|
||||
expect(button).toBeTruthy();
|
||||
});
|
||||
|
||||
test('check Add New PXE Boot Option visible', async ({ page }) => {
|
||||
await page.waitForSelector('#newPxeOption');
|
||||
const addButton = await page.locator('#newPxeOption');
|
||||
await addButton.click();
|
||||
|
||||
await page.waitForSelector('#newPxe');
|
||||
const section = await page.locator('#newPxe');
|
||||
const isSectionVisible = await section.isVisible();
|
||||
expect(isSectionVisible).toBe(true);
|
||||
|
||||
const label = await page.$('#newPxe p:has-text("New PXE Boot Option")');
|
||||
expect(label).toBeTruthy();
|
||||
|
||||
const fileName = await page.$('#content-pxetftp label:has-text("Filename")');
|
||||
expect(fileName).toBeTruthy();
|
||||
const fileNameInputField = await page.locator('#pxe-filename');
|
||||
const fileNameInputFieldIsVisible = await fileNameInputField.isVisible();
|
||||
expect(fileNameInputFieldIsVisible).toBeTruthy();
|
||||
|
||||
const serverName = await page.$('#content-pxetftp label:has-text("Server Name")');
|
||||
expect(serverName).toBeTruthy();
|
||||
const serverNameInputField = await page.locator('#pxe-server-name');
|
||||
const serverNameInputFieldIsVisible = await serverNameInputField.isVisible();
|
||||
expect(serverNameInputFieldIsVisible).toBeTruthy();
|
||||
|
||||
const serverAddress = await page.$('#content-pxetftp label:has-text("Server Address")');
|
||||
expect(serverAddress).toBeTruthy();
|
||||
const serverAddressInputField = await page.locator('#pxe-server-address');
|
||||
const serverAddressInputFieldIsVisible = await serverAddressInputField.isVisible();
|
||||
expect(serverAddressInputFieldIsVisible).toBeTruthy();
|
||||
|
||||
const dhcpOptions = await page.$('#content-pxetftp label:has-text("DHCP Options")');
|
||||
expect(dhcpOptions).toBeTruthy();
|
||||
const dhcpOptionsInputField = await page.locator('#pxe-dhcp-options');
|
||||
const dhcpOptionsInputFieldIsVisible = await dhcpOptionsInputField.isVisible();
|
||||
expect(dhcpOptionsInputFieldIsVisible).toBeTruthy();
|
||||
|
||||
const ForceDhcpOptions = await page.$('#content-pxetftp label:has-text("Force DHCP Options ")');
|
||||
expect(ForceDhcpOptions).toBeTruthy();
|
||||
const ForceDhcpOptionsToggle = await page.locator('#newPxe .pxe-force');
|
||||
const ForceDhcpOptionsToggleIsVisible = await ForceDhcpOptionsToggle.isVisible();
|
||||
expect(ForceDhcpOptionsToggleIsVisible).toBeTruthy();
|
||||
|
||||
const saveButton = page.locator('#newPxe button.button.green:has-text("Save")');
|
||||
expect(saveButton).toBeTruthy();
|
||||
|
||||
const discardButton = page.locator('#discardPxeOption');
|
||||
expect(discardButton).toBeTruthy();
|
||||
});
|
||||
|
||||
// test('Add, Read Values in Add New PXE Boot Option', async ({ page }) => {
|
||||
// await page.waitForSelector('#newPxeOption');
|
||||
// const addButton = await page.locator('#newPxeOption');
|
||||
// await addButton.click();
|
||||
|
||||
// await page.waitForSelector('#pxe-filename');
|
||||
// const filename = await page.locator('#pxe-filename');
|
||||
// await filename.fill('pxelinux.0');
|
||||
|
||||
// const serverName = await page.locator('#pxe-server-name');
|
||||
// await serverName.fill('office-server');
|
||||
|
||||
// const serverAddress = await page.locator('#pxe-server-address');
|
||||
// await serverAddress.fill('192.168.2.1');
|
||||
|
||||
// const dhcpOptions = await page.locator('#pxe-dhcp-options');
|
||||
// await dhcpOptions.fill('42,192.168.1.4');
|
||||
|
||||
// const forceDHCPOptions = await page.locator('.pxe-force').elementHandle();
|
||||
// const isChecked = await forceDHCPOptions.isChecked();
|
||||
// if (!isChecked) {
|
||||
// await page.evaluate((checkbox) => checkbox.click(), forceDHCPOptions);
|
||||
// }
|
||||
|
||||
// const saveButton = await page.locator('#newPxe button.button.green:has-text("Save")');
|
||||
// await saveButton.click();
|
||||
|
||||
// expect(page.locator('div:has-text("pxelinux.0")')).toBeTruthy();
|
||||
// expect(page.locator('div:has-text("office-server")')).toBeTruthy();
|
||||
// expect(page.locator('div:has-text("192.168.2.1")')).toBeTruthy();
|
||||
// expect(page.locator('div:has-text("42,192.168.1.4")')).toBeTruthy();
|
||||
// });
|
||||
});
|
||||
|
||||
test.describe('DHCP Options Tab', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
const staticLeasesTab = await page.locator('#options-tab-dndh');
|
||||
await staticLeasesTab.click();
|
||||
await page.waitForTimeout(1000);
|
||||
});
|
||||
|
||||
test('Option table', async ({ page }) => {
|
||||
expect(await page.locator('#options-t'));
|
||||
});
|
||||
|
||||
test('Check Add DHCP option Elements', async ({ page }) => {
|
||||
const addButton = await page.locator('#addNewOption');
|
||||
await addButton.click();
|
||||
|
||||
await page.waitForSelector('#newOption');
|
||||
|
||||
const header = await page.$('p:has-text("New DHCP Option")');
|
||||
expect(header).toBeTruthy();
|
||||
|
||||
const optionLabel = await page.$('label:has-text("Option")');
|
||||
expect(optionLabel).toBeTruthy();
|
||||
|
||||
const optionSelectField = await page.locator('.dhcp-opts-options');
|
||||
expect(optionSelectField).toBeTruthy();
|
||||
|
||||
const interfaceLabel = await page.$('label:has-text("Interface")');
|
||||
expect(interfaceLabel).toBeTruthy();
|
||||
|
||||
const interfaceSelectField = await page.locator('.dhcp-opt-iface');
|
||||
expect(interfaceSelectField).toBeTruthy();
|
||||
|
||||
const valueLabel = await page.$('label:has-text("Value")');
|
||||
expect(valueLabel).toBeTruthy();
|
||||
|
||||
const valueInput = await page.locator('#dhcp-opts-value');
|
||||
expect(valueInput).toBeTruthy();
|
||||
|
||||
const saveButton = await page.locator('#saveNewOption');
|
||||
expect(saveButton).toBeTruthy();
|
||||
|
||||
const discardButton = await page.locator('#discardNewOption');
|
||||
expect(discardButton).toBeTruthy();
|
||||
});
|
||||
|
||||
// test('Add DHCP Options Values', async ({ page }) => {
|
||||
// const addButton = await page.locator('#addNewOption');
|
||||
// await addButton.click();
|
||||
|
||||
// await page.waitForSelector('#newOption');
|
||||
|
||||
// const selectOptionElement = await page.locator('select.dhcp-opts-options');
|
||||
// await selectOptionElement.selectOption({ label: '6 - dns-server' });
|
||||
// await page.waitForTimeout(1000);
|
||||
|
||||
// const selectInterfaceElement = await page.locator('select.dhcp-opt-iface');
|
||||
// await selectInterfaceElement.selectOption({ label: 'LAN' });
|
||||
// await page.waitForTimeout(1000);
|
||||
|
||||
// await page.fill('#dhcp-opts-value', '192.168.1.100');
|
||||
|
||||
// const saveButton = await page.locator('#newOptionForm #saveNewOption');
|
||||
// await saveButton.click();
|
||||
|
||||
// await page.waitForSelector('#options-t');
|
||||
|
||||
// await page.waitForSelector('.tabulator-cell[tabulator-field="option"]');
|
||||
// const optionValue = await page.$eval('.tabulator-cell[tabulator-field="option"]', cell => cell.textContent.trim());
|
||||
// expect(optionValue).toBe('6');
|
||||
|
||||
// await page.waitForSelector('.tabulator-cell[tabulator-field="iface"]');
|
||||
// const interfaceValue = await page.$eval('.tabulator-cell[tabulator-field="iface"]', cell => cell.textContent.trim());
|
||||
// expect(interfaceValue).toBe('LAN');
|
||||
|
||||
// await page.waitForSelector('.tabulator-cell[tabulator-field="optionName"]');
|
||||
// const optionName = await page.$eval('.tabulator-cell[tabulator-field="optionName"]', cell => cell.textContent.trim());
|
||||
// expect(optionName).toBe('dns-server');
|
||||
|
||||
// await page.waitForSelector('.tabulator-cell[tabulator-field="value"]');
|
||||
// const currentValue = await page.$eval('.tabulator-cell[tabulator-field="value"]', cell => cell.textContent.trim());
|
||||
// expect(currentValue).toBe('192.168.1.100');
|
||||
// });
|
||||
});
|
||||
});
|
50
tests/network/dns-adguard.spec.js
Normal file
50
tests/network/dns-adguard.spec.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Network & Services - Network - LAN', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/network/dns', { waitUntil: 'networkidle' });
|
||||
await page.waitForTimeout(3000);
|
||||
});
|
||||
|
||||
test('Title', async ({ page }) => {
|
||||
expect(await page.title()).toBe('Difuse - Services - DNS (AdGuard)');
|
||||
});
|
||||
|
||||
test('Heading', async ({ page }) => {
|
||||
const heading = await page.$("p:has-text('DNS (AdGuard)')");
|
||||
expect(heading).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Check visibility of iframe', async ({ page }) => {
|
||||
await page.waitForSelector('#ipfsFrame');
|
||||
const iframe = await page.$('#ipfsFrame');
|
||||
const Visible = await iframe.isVisible();
|
||||
expect(Visible).toBe(true);
|
||||
});
|
||||
|
||||
test('Custom Adguard Settings', async ({ page }) => {
|
||||
const label = await page.$("p:has-text('Custom Adguard Settings')");
|
||||
expect(label).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Automatic MAC to IP Conversion', async ({ page }) => {
|
||||
const label = await page.$('#custom-settings label:has-text("Automatic MAC to IP Conversion")');
|
||||
expect(label).toBeTruthy();
|
||||
|
||||
const switchField = await page.locator('.mac-to-ip');
|
||||
expect(switchField).toBeTruthy();
|
||||
});
|
||||
|
||||
test('DNS64', async ({ page }) => {
|
||||
const label = await page.$('#custom-settings label:has-text("DNS64")');
|
||||
expect(label).toBeTruthy();
|
||||
|
||||
const switchField = await page.locator('.dns64');
|
||||
expect(switchField).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Save Button', async ({ page }) => {
|
||||
const button = page.locator('button.button.green:has-text("Save")');
|
||||
expect(button).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,5 +1,5 @@
|
|||
import { expect, test } from '@playwright/test';
|
||||
import { isValidCidr, isValidMacAddress, clickSelect2Dropdown, hasToastText, sleep } from '../../utils/utils.js';
|
||||
import { isValidMacAddress, clickSelect2Dropdown, hasToastText, sleep, isValidPrivateIPV4, getDefaultNetmask, isValidCidr } from '../../utils/utils.js';
|
||||
|
||||
test.describe('Network & Services - Network - Guest LAN', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
|
@ -30,14 +30,46 @@ test.describe('Network & Services - Network - Guest LAN', () => {
|
|||
} else if (label === 'Uptime') {
|
||||
expect(typeof parseInt(value)).toBe('number');
|
||||
} else if (label === 'MAC') {
|
||||
if (value === '00:00:00:00:00:00' || '') {
|
||||
expect(false).toBe(false);
|
||||
} else {
|
||||
expect(isValidMacAddress(value)).toBeTruthy();
|
||||
}
|
||||
} else if (label === 'RX' || label === 'TX') {
|
||||
expect(typeof parseInt(value)).toBe('number');
|
||||
} else if (label === 'IPv4') {
|
||||
expect(isValidCidr(value)).toBeTruthy();
|
||||
if (value === '0.0.0.0' || '') {
|
||||
expect(false).toBe(false);
|
||||
} else {
|
||||
expect(isValidPrivateIPV4(value)).toBeTruthy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Validate Ip Address', async ({ page }) => {
|
||||
await page.waitForSelector('#ipAddress');
|
||||
const ipAddress = await page.locator('#ipAddress');
|
||||
const ipValue = await ipAddress.inputValue();
|
||||
|
||||
const validateIP = await isValidPrivateIPV4(ipValue);
|
||||
expect(validateIP).toBe(true);
|
||||
});
|
||||
|
||||
test('Validate Network Mask Address', async ({ page }) => {
|
||||
await page.waitForSelector('#ipAddress');
|
||||
const ipAddress = await page.locator('#ipAddress');
|
||||
const ipValue = await ipAddress.inputValue();
|
||||
|
||||
const networkMask = await page.locator('.lan-netmask-select');
|
||||
const networkValue = await networkMask.inputValue();
|
||||
const defaultValue = await getDefaultNetmask(ipValue);
|
||||
if (defaultValue === networkValue) {
|
||||
expect(defaultValue).toBe(networkValue);
|
||||
} else {
|
||||
expect(() => { throw new Error('Expected defaultValue to match networkValue'); }).toThrow();
|
||||
}
|
||||
});
|
||||
|
||||
test('DHCP Toggle', async ({ page }) => {
|
||||
|
@ -80,4 +112,23 @@ test.describe('Network & Services - Network - Guest LAN', () => {
|
|||
expect(await hasToastText(page, 'Invalid DHCP Range')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('IPV6 Tab', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/network/guest-lan', { waitUntil: 'networkidle' });
|
||||
const ipv6Tab = await page.$("a:has-text('IPv6')");
|
||||
await ipv6Tab.click();
|
||||
});
|
||||
|
||||
test('ULA Prefix Validation', async ({ page }) => {
|
||||
await page.waitForSelector('#ulaPrefix');
|
||||
const ulaPrefix = await page.locator('#ulaPrefix');
|
||||
const value = await ulaPrefix.inputValue();
|
||||
|
||||
if (value) {
|
||||
const isValidIPv6 = isValidCidr(value);
|
||||
expect(isValidIPv6).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
282
tests/network/lan.spec.js
Normal file
282
tests/network/lan.spec.js
Normal file
|
@ -0,0 +1,282 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
import { clickSelect2Dropdown, getDefaultNetmask, hasToastText, isValidCidr, isValidMacAddress, isValidPrivateIPV4, isValidateDhcpInput, splitIPv6 } 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)).toBe(true);
|
||||
} else if (label === 'IPv6 (Prefixes)') {
|
||||
let splittedValue;
|
||||
if (value) {
|
||||
splittedValue = splitIPv6(value);
|
||||
splittedValue.forEach((value) => {
|
||||
const isValid = isValidCidr(value);
|
||||
expect(isValid).toBe(true);
|
||||
});
|
||||
} else {
|
||||
expect(false).toBe(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Validate Ip Address', async ({ page }) => {
|
||||
await page.waitForSelector('#ipAddress');
|
||||
const ipAddress = await page.locator('#ipAddress');
|
||||
const ipValue = await ipAddress.inputValue();
|
||||
|
||||
const validateIP = await isValidPrivateIPV4(ipValue);
|
||||
expect(validateIP).toBe(true);
|
||||
});
|
||||
|
||||
test('Validate Network Mask Address', async ({ page }) => {
|
||||
await page.waitForSelector('#ipAddress');
|
||||
const ipAddress = await page.locator('#ipAddress');
|
||||
const ipValue = await ipAddress.inputValue();
|
||||
|
||||
const networkMask = await page.locator('.lan-netmask-select');
|
||||
const networkValue = await networkMask.inputValue();
|
||||
const defaultValue = getDefaultNetmask(ipValue);
|
||||
expect(defaultValue).toBe(networkValue);
|
||||
});
|
||||
|
||||
test('Enable DHCP Toggle', async ({ page }) => {
|
||||
const dhcpCb = await page.$('.dhcp-cb');
|
||||
const isChecked = await dhcpCb.isChecked();
|
||||
|
||||
if (isChecked) {
|
||||
expect(await page.isVisible('label:has-text("DHCP Start")')).toBeTruthy();
|
||||
} else {
|
||||
await page.evaluate((checkbox) => checkbox.click(), dhcpCb);
|
||||
expect(await page.isVisible('label:has-text("DHCP Start")')).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
test('Disable DHCP Toggle', async ({ page }) => {
|
||||
const dhcpCb = await page.$('.dhcp-cb');
|
||||
const isChecked = await dhcpCb.isChecked();
|
||||
|
||||
if (isChecked) {
|
||||
await page.evaluate((checkbox) => checkbox.click(), dhcpCb);
|
||||
expect(await page.isVisible('label:has-text("DHCP Start")')).toBe(false);
|
||||
} else {
|
||||
expect(await page.isVisible('label:has-text("DHCP Start")')).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
test('DHCP validation', async ({ page }) => {
|
||||
await page.waitForSelector('#ipAddress');
|
||||
const ipAddress = await page.locator('#ipAddress');
|
||||
const ipValue = await ipAddress.inputValue().toString();
|
||||
|
||||
const networkMask = await page.locator('.lan-netmask-select');
|
||||
const networkValue = await networkMask.inputValue().toString();
|
||||
|
||||
const dhcpStart = await page.locator('#dhcpStart');
|
||||
const dhcpStartValue = await dhcpStart.inputValue();
|
||||
|
||||
const dhcpMax = await page.locator('#dhcpMax');
|
||||
const dhcpMaxValue = await dhcpMax.inputValue();
|
||||
|
||||
const isValid = isValidateDhcpInput(ipValue, networkValue, dhcpStartValue, dhcpMaxValue);
|
||||
|
||||
if (isValid) {
|
||||
expect(isValid).toBe(true);
|
||||
} else {
|
||||
expect(isValid).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
test.describe('Bad IPv4 Form Submits', () => {
|
||||
test('Bad IPv4', async ({ page }) => {
|
||||
const ip = await page.locator('#ipAddress');
|
||||
await ip.fill('1.1.1.1.1.1.1.1.1.1.1');
|
||||
await page.click('button.button.green:has-text("Save")');
|
||||
expect(await hasToastText(page, 'Invalid IP Address')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Bad Netmask', async ({ page }) => {
|
||||
await clickSelect2Dropdown(page, '.lan-netmask-select');
|
||||
await page.getByRole('searchbox', { name: 'Search' }).fill('15151515515151515');
|
||||
await page.keyboard.press('Enter');
|
||||
await page.click('button.button.green:has-text("Save")');
|
||||
expect(await hasToastText(page, 'Invalid Netmask')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Bad DHCP Start', async ({ page }) => {
|
||||
await page.locator('#dhcpStart').fill('55555555555555');
|
||||
await page.click('button.button.green:has-text("Save")');
|
||||
expect(await hasToastText(page, 'Invalid DHCP Range')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Bad DHCP Max Leases', async ({ page }) => {
|
||||
await page.locator('#dhcpMax').fill('55555555555555');
|
||||
await page.click('button.button.green:has-text("Save")');
|
||||
expect(await hasToastText(page, 'Invalid DHCP Range')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
test('Lease Time', async ({ page }) => {
|
||||
await page.waitForTimeout(2000);
|
||||
const leaseTimeInput = await page.$('#leaseTime');
|
||||
const value = await leaseTimeInput.inputValue();
|
||||
const leaseTimeValue = Number(value);
|
||||
expect(leaseTimeValue).toBeGreaterThanOrEqual(1);
|
||||
expect(leaseTimeValue).toBeLessThanOrEqual(12);
|
||||
});
|
||||
|
||||
test.describe('IPV6 Tab', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/network/lan', { waitUntil: 'networkidle' });
|
||||
const ipv6Tab = await page.$("a:has-text('IPv6')");
|
||||
await ipv6Tab.click();
|
||||
});
|
||||
|
||||
test('ULA Prefix Validation', async ({ page }) => {
|
||||
await page.waitForSelector('#ulaPrefix');
|
||||
const ulaPrefix = await page.locator('#ulaPrefix');
|
||||
const value = await ulaPrefix.inputValue();
|
||||
|
||||
if (value) {
|
||||
const isValidIPv6 = isValidCidr(value);
|
||||
expect(isValidIPv6).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
test('Bad ULA Prefix Validation', async ({ page }) => {
|
||||
await page.waitForSelector('#ulaPrefix');
|
||||
const ulaPrefix = await page.locator('#ulaPrefix');
|
||||
await ulaPrefix.fill('1.1.1.1.1.1.1.1.1.1.1');
|
||||
const saveButton = await page.getByRole('button', { name: 'Save' });
|
||||
await saveButton.click();
|
||||
expect(await hasToastText(page, 'Invalid ULA Prefix')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('RA & DHCPv6', async ({ page }) => {
|
||||
const selectElement = await page.locator('label:has-text("RA & DHCPv6") + .field-body select.rad-select');
|
||||
|
||||
const optionDatas = await selectElement.evaluate(select => {
|
||||
const options = Array.from(select.querySelectorAll('option'));
|
||||
return options.map(option => {
|
||||
return {
|
||||
label: option.textContent.trim(),
|
||||
value: option.value.trim()
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
for (const optionData of optionDatas) {
|
||||
if (optionData.label === 'SLAAC') {
|
||||
expect(optionData.value).toBe('slaac');
|
||||
} else if (optionData.label === 'SLAAC & DHCPv6') {
|
||||
expect(optionData.value).toBe('slaac-dhcp');
|
||||
} else if (optionData.label === 'IPv6 Relay') {
|
||||
expect(optionData.value).toBe('relay');
|
||||
} else if (optionData.label === 'IPv6 Hybrid') {
|
||||
expect(optionData.value).toBe('hybrid');
|
||||
} else if (optionData.label === 'Automatic') {
|
||||
expect(optionData.value).toBe('default');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('RA Default', async ({ page }) => {
|
||||
const selectElement = await page.locator('label:has-text("RA Default") + .control.icons-left select.raDefaultSelect');
|
||||
const optionDatas = await selectElement.evaluate(select => {
|
||||
const options = Array.from(select.querySelectorAll('option'));
|
||||
return options.map(option => {
|
||||
return {
|
||||
label: option.textContent.trim(),
|
||||
value: option.value.trim()
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
for (const optionData of optionDatas) {
|
||||
if (optionData.label === 'Automatic') {
|
||||
expect(optionData.value).toBe('0');
|
||||
} else if (optionData.label === 'On Available Prefix') {
|
||||
expect(optionData.value).toBe('1');
|
||||
} else if (optionData.label === 'Forced') {
|
||||
expect(optionData.value).toBe('2');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Bridge Slaves Tab', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/network/lan', { waitUntil: 'networkidle' });
|
||||
const bridgeSlaveTab = await page.$("a:has-text('Bridge Slaves')");
|
||||
await bridgeSlaveTab.click();
|
||||
});
|
||||
|
||||
test('SFP 2', async ({ page }) => {
|
||||
const sfp = page.locator('.mdi-ethernet-cable');
|
||||
expect(await sfp.isVisible()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
92
tests/network/overview.spec.js
Normal file
92
tests/network/overview.spec.js
Normal file
|
@ -0,0 +1,92 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Network & Services - Network - Overview', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/network/overview', { waitUntil: 'networkidle' });
|
||||
});
|
||||
|
||||
test('Title', async ({ page }) => {
|
||||
expect(await page.title()).toBe('Difuse - Network - Overview');
|
||||
});
|
||||
|
||||
test('Overview Header', async ({ page }) => {
|
||||
const header = await page.locator('.card-heaer-title');
|
||||
expect(header).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Notification', async ({ page }) => {
|
||||
const notification = await page.locator('.notification');
|
||||
const isVisible = await notification.isVisible();
|
||||
expect(isVisible).toBe(true);
|
||||
});
|
||||
|
||||
test('WAN Label', async ({ page }) => {
|
||||
const wan = await page.$('span:has-text("WAN")');
|
||||
expect(wan).toBeTruthy();
|
||||
});
|
||||
|
||||
test('SFP 1 Icon', async ({ page }) => {
|
||||
const sfp = page.locator('#sfpWanInterface');
|
||||
|
||||
expect(await sfp.isVisible()).toBeTruthy();
|
||||
});
|
||||
|
||||
test('WAN Icon', async ({ page }) => {
|
||||
await page.waitForSelector('#wanInterface', { visible: true });
|
||||
const wanIcon = await page.$('#wanInterface');
|
||||
const isVisible = await wanIcon.isVisible();
|
||||
expect(isVisible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Lan - SFP / Ethernet Label', async ({ page }) => {
|
||||
const wan = await page.$('span:has-text("LAN - SFP / Ethernet")');
|
||||
expect(wan).toBeTruthy();
|
||||
});
|
||||
|
||||
test('SFP 2', async ({ page }) => {
|
||||
const sfp = page.locator('#sfpLanInterface');
|
||||
|
||||
expect(await sfp.isVisible()).toBeTruthy();
|
||||
});
|
||||
|
||||
test('LAN 1, 2 ,3 and 4 Icon', async ({ page }) => {
|
||||
const lan1 = page.locator('#lan1Interface');
|
||||
const lan1Visible = await lan1.isVisible();
|
||||
expect(lan1Visible).toBeTruthy();
|
||||
|
||||
await page.waitForSelector('#lan2Interface', { visible: true });
|
||||
const lan2Icon = await page.isVisible('#lan2Interface');
|
||||
expect(lan2Icon).toBeTruthy();
|
||||
|
||||
await page.waitForSelector('#lan3Interface', { visible: true });
|
||||
const lan3Icon = await page.isVisible('#lan3Interface');
|
||||
expect(lan3Icon).toBeTruthy();
|
||||
|
||||
await page.waitForSelector('#lan4Interface', { visible: true });
|
||||
const lan4Icon = await page.isVisible('#lan4Interface');
|
||||
expect(lan4Icon).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Lan - Wifi Icon', async ({ page }) => {
|
||||
await page.waitForSelector('#wlan0Interface', { visible: true });
|
||||
const wlan0 = await page.isVisible('#wlan0Interface');
|
||||
expect(wlan0).toBeTruthy();
|
||||
|
||||
await page.waitForSelector('#wlan1Interface', { visible: true });
|
||||
const wlan1 = await page.isVisible('#wlan1Interface');
|
||||
expect(wlan1).toBeTruthy();
|
||||
|
||||
await page.waitForSelector('#gwlan0Interface', { visible: true });
|
||||
const gwlan0 = await page.isVisible('#gwlan0Interface');
|
||||
expect(gwlan0).toBeTruthy();
|
||||
|
||||
await page.waitForSelector('#gwlan1Interface', { visible: true });
|
||||
const gwlan1 = await page.isVisible('#gwlan1Interface');
|
||||
expect(gwlan1).toBeTruthy();
|
||||
});
|
||||
|
||||
test('LAN - WiFi Label', async ({ page }) => {
|
||||
const wan = await page.$('span:has-text("LAN - WiFi")');
|
||||
expect(wan).toBeTruthy();
|
||||
});
|
||||
});
|
197
tests/network/routes.spec.js
Normal file
197
tests/network/routes.spec.js
Normal file
|
@ -0,0 +1,197 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Network & Services - Network - Routes', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/network/routes', { waitUntil: 'networkidle' });
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
test.describe('Policy Based Routes', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
const policyBasedRoutesTab = await page.locator('#pbr-tab');
|
||||
await policyBasedRoutesTab.click();
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
test('Title', async ({ page }) => {
|
||||
expect(await page.title()).toBe('Difuse - Network - Routes');
|
||||
});
|
||||
|
||||
test('Check Visible PBR Filter fields and Table', async ({ page }) => {
|
||||
const filterField = await page.locator('#pbr-filter-field');
|
||||
expect(filterField).toBeTruthy();
|
||||
|
||||
const filterType = await page.locator('#pbr-filter-type');
|
||||
expect(filterType).toBeTruthy();
|
||||
|
||||
const filterValue = await page.locator('#pbr-filter-value');
|
||||
expect(filterValue).toBeTruthy();
|
||||
|
||||
const clearButton = await page.locator('#pbr-filter-clear');
|
||||
expect(clearButton).toBeTruthy();
|
||||
|
||||
const pbrTable = await page.locator('#pbrTable');
|
||||
expect(pbrTable).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('IPv4 Static Routes', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
const staticIPv4RoutesTab = await page.locator('#s4r-tab');
|
||||
await staticIPv4RoutesTab.click();
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
test('Check Visible Static Ipv4 Filter fields and Table', async ({ page }) => {
|
||||
const filterField = await page.locator('#\\34-filter-field');
|
||||
expect(filterField).toBeTruthy();
|
||||
|
||||
const filterType = await page.locator('#\\34-filter-type');
|
||||
expect(filterType).toBeTruthy();
|
||||
|
||||
const filterValue = await page.locator('#\\34-filter-value');
|
||||
expect(filterValue).toBeTruthy();
|
||||
|
||||
const clearButton = await page.locator('#\\34-filter-clear');
|
||||
expect(clearButton).toBeTruthy();
|
||||
|
||||
const pbrTable = await page.locator('#routes4Table');
|
||||
expect(pbrTable).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Check Add IPv4 Static Route', async ({ page }) => {
|
||||
const createIPv4Route = await page.locator('#trigger-add-4-sec');
|
||||
await createIPv4Route.click();
|
||||
await page.waitForSelector('#new-4-r');
|
||||
|
||||
expect(await page.$('p:has-text("Add IPv4 Static Route")')).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-4-r label:has-text("Index")')).toBeTruthy();
|
||||
const indexInput = await page.locator('#new-4-r #\\34-index');
|
||||
const indexFieldVisible = await indexInput.isVisible();
|
||||
expect(indexFieldVisible).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-4-r label:has-text("Interface")')).toBeTruthy();
|
||||
const interfaceInput = await page.locator('#new-4-r .\\34-iface-select');
|
||||
const interfaceFieldVisible = await interfaceInput.isVisible();
|
||||
expect(interfaceFieldVisible).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-4-r label:has-text("Route Type")')).toBeTruthy();
|
||||
const routerInput = await page.locator('#new-4-r .\\34-routeType-select');
|
||||
const routerFieldVisible = await routerInput.isVisible();
|
||||
expect(routerFieldVisible).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-4-r label:has-text("Target")')).toBeTruthy();
|
||||
const targetInput = await page.locator('#new-4-r #\\34-targetIp');
|
||||
const targetFieldVisible = await targetInput.isVisible();
|
||||
expect(targetFieldVisible).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-4-r label:has-text("Gateway")')).toBeTruthy();
|
||||
const gatewayInput = await page.locator('#new-4-r #\\34-gatewayIp');
|
||||
const gatewayFieldVisible = await gatewayInput.isVisible();
|
||||
expect(gatewayFieldVisible).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-4-r label:has-text("Metric")')).toBeTruthy();
|
||||
const metricInput = await page.locator('#new-4-r #\\34-metric');
|
||||
const metricFieldVisible = await metricInput.isVisible();
|
||||
expect(metricFieldVisible).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-4-r label:has-text("MTU")')).toBeTruthy();
|
||||
const mtuInput = await page.locator('#new-4-r #\\34-mtu');
|
||||
const mtuFieldVisible = await mtuInput.isVisible();
|
||||
expect(mtuFieldVisible).toBeTruthy();
|
||||
});
|
||||
|
||||
// test('Fill value to Add IPv4 Static Route', async ({ page }) => {
|
||||
// const createIPv4Route = await page.locator('#trigger-add-4-sec');
|
||||
// await createIPv4Route.click();
|
||||
// await page.waitForSelector('#new-4-r');
|
||||
|
||||
// await page.fill('#new-4-r #\\34-index', '12');
|
||||
|
||||
// const interfaceElement = await page.locator('#new-4-r select.\\34-iface-select');
|
||||
// await interfaceElement.selectOption({ label: '4G' });
|
||||
// await page.waitForTimeout(1000);
|
||||
|
||||
// const routeTypeElement = await page.locator('#new-4-r .\\34-routeType-select');
|
||||
// await routeTypeElement.selectOption({ label: 'Unicast' });
|
||||
// await page.waitForTimeout(1000);
|
||||
|
||||
// await page.fill('#new-4-r #\\34-targetIp', '10.0.0.0/0');
|
||||
// await page.fill('#new-4-r #\\34-gatewayIp', '192.168.1.1');
|
||||
// await page.fill('#new-4-r #\\34-metric', '0');
|
||||
// await page.fill('#new-4-r #\\34-mtu', '1500');
|
||||
|
||||
// const saveButton = await page.locator('#new-4-r button.button.green');
|
||||
// await saveButton.click();
|
||||
// });
|
||||
});
|
||||
|
||||
test.describe('IPv6 Static Routes', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
const staticIPv6RoutesTab = await page.locator('#s6r-tab');
|
||||
await staticIPv6RoutesTab.click();
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
test('Check Visible Static Ipv6 Filter fields and Table', async ({ page }) => {
|
||||
const filterField = await page.locator('#\\36-filter-field');
|
||||
expect(filterField).toBeTruthy();
|
||||
|
||||
const filterType = await page.locator('#\\36-filter-type');
|
||||
expect(filterType).toBeTruthy();
|
||||
|
||||
const filterValue = await page.locator('#\\36-filter-value');
|
||||
expect(filterValue).toBeTruthy();
|
||||
|
||||
const clearButton = await page.locator('#\\36-filter-clear');
|
||||
expect(clearButton).toBeTruthy();
|
||||
|
||||
const pbrTable = await page.locator('#routes6Table');
|
||||
expect(pbrTable).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Check Add IPv6 Static Route', async ({ page }) => {
|
||||
const createIPv4Route = await page.locator('#trigger-add-6-sec');
|
||||
await createIPv4Route.click();
|
||||
await page.waitForSelector('#new-6-r');
|
||||
|
||||
expect(await page.$('p:has-text("Add IPv6 Static Route")')).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-6-r label:has-text("Index")')).toBeTruthy();
|
||||
const indexInput = await page.locator('#new-6-r #\\36-index');
|
||||
const indexFieldVisible = await indexInput.isVisible();
|
||||
expect(indexFieldVisible).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-6-r label:has-text("Interface")')).toBeTruthy();
|
||||
const interfaceInput = await page.locator('#new-6-r .\\36-iface-select');
|
||||
const interfaceFieldVisible = await interfaceInput.isVisible();
|
||||
expect(interfaceFieldVisible).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-6-r label:has-text("Route Type")')).toBeTruthy();
|
||||
const routerInput = await page.locator('#new-6-r .\\36-routeType-select');
|
||||
const routerFieldVisible = await routerInput.isVisible();
|
||||
expect(routerFieldVisible).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-6-r label:has-text("Target")')).toBeTruthy();
|
||||
const targetInput = await page.locator('#new-6-r #\\36-targetIp');
|
||||
const targetFieldVisible = await targetInput.isVisible();
|
||||
expect(targetFieldVisible).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-6-r label:has-text("Gateway")')).toBeTruthy();
|
||||
const gatewayInput = await page.locator('#new-6-r #\\36-gatewayIp');
|
||||
const gatewayFieldVisible = await gatewayInput.isVisible();
|
||||
expect(gatewayFieldVisible).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-6-r label:has-text("Metric")')).toBeTruthy();
|
||||
const metricInput = await page.locator('#new-6-r #\\36-metric');
|
||||
const metricFieldVisible = await metricInput.isVisible();
|
||||
expect(metricFieldVisible).toBeTruthy();
|
||||
|
||||
expect(await page.$('#new-6-r label:has-text("MTU")')).toBeTruthy();
|
||||
const mtuInput = await page.locator('#new-6-r #\\36-mtu');
|
||||
const mtuFieldVisible = await mtuInput.isVisible();
|
||||
expect(mtuFieldVisible).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
246
tests/network/wan.spec.js
Normal file
246
tests/network/wan.spec.js
Normal file
|
@ -0,0 +1,246 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
import { hasToastInput, isValidCidr, isValidMacAddress, isValidPrivateIPV4, splitIPv6 } from '../../utils/utils.js';
|
||||
|
||||
test.describe('Network & Services - Network - WAN', () => {
|
||||
test.describe('IPV4 Tab', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/network/wan', { waitUntil: 'networkidle' });
|
||||
await page.waitForTimeout(3000);
|
||||
});
|
||||
|
||||
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();
|
||||
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();
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
496
tests/network/wifi.spec.js
Normal file
496
tests/network/wifi.spec.js
Normal file
|
@ -0,0 +1,496 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
import { hasToastQRcode, hasToastText } from '../../utils/utils.js';
|
||||
|
||||
test.describe('Network & Services - Network - WiFi', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/network/wifi', { waitUntil: 'networkidle' });
|
||||
});
|
||||
|
||||
test('Title', async ({ page }) => {
|
||||
expect(await page.title()).toBe('Difuse - Network - WiFi');
|
||||
});
|
||||
|
||||
test('Card Header Title', async ({ page }) => {
|
||||
const title = await page.locator('.card-header-title');
|
||||
expect(await title).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Tab Content', async ({ page }) => {
|
||||
const tab = page.locator('#tabs-tabContent');
|
||||
expect(await tab).toBeTruthy();
|
||||
});
|
||||
|
||||
test.describe('2.4Ghz WiFi Tab', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/network/wifi', { waitUntil: 'networkidle' });
|
||||
await page.waitForTimeout(2000);
|
||||
const twoPointFourGHzTab = await page.$("a:has-text('2.4Ghz WiFi')");
|
||||
await twoPointFourGHzTab.click();
|
||||
});
|
||||
|
||||
test('2.4Ghz WiFi Notification', async ({ page }) => {
|
||||
const notification = page.locator('.notification');
|
||||
expect(await notification).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Primary AP & Radio', async ({ page }) => {
|
||||
const primaryAPandRadio = await page.locator("span:has-text('Primary AP & Radio')");
|
||||
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();
|
||||
if (value) {
|
||||
const length = value.length;
|
||||
expect(length).toBeGreaterThanOrEqual(1);
|
||||
expect(length).toBeLessThanOrEqual(32);
|
||||
}
|
||||
});
|
||||
|
||||
test('Bad SSID Validation', async ({ page }) => {
|
||||
const ssid = await page.locator('#ssid-24');
|
||||
await ssid.fill('qwertyuiopasdfghjklzxcvbnmlkjhgfdsaqw');
|
||||
await page.click('button.button.green:has-text("Save")');
|
||||
|
||||
expect(await hasToastText(page, 'Invalid SSID')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Encryption Type Fields Validation', async ({ page }) => {
|
||||
const selectElement = await page.locator('label:has-text("Encryption Type ") + .field-body select.encryption24 ');
|
||||
|
||||
const optionDatas = await selectElement.evaluate(select => {
|
||||
const options = Array.from(select.querySelectorAll('option'));
|
||||
return options.map(option => {
|
||||
return {
|
||||
label: option.textContent.trim(),
|
||||
value: option.value.trim()
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
for (const optionData of optionDatas) {
|
||||
if (optionData.label === 'WPA2-PSK (Strong Security)') {
|
||||
expect(optionData.value).toBe('psk2');
|
||||
} else if (optionData.label === 'WPA3-SAE (Strong Security)') {
|
||||
expect(optionData.value).toBe('sae');
|
||||
} else if (optionData.label === 'WPA2-PSK/WPA3-SAE Mixed (Strong Security)') {
|
||||
expect(optionData.value).toBe('sae-mixed');
|
||||
} else if (optionData.label === 'WPA-PSK/WPA2-PSK Mixed (Medium Security)') {
|
||||
expect(optionData.value).toBe('psk-mixed');
|
||||
} else if (optionData.label === 'WPA-PSK (Weak Security)') {
|
||||
expect(optionData.value).toBe('psk');
|
||||
} else if (optionData.label === 'OWE (Open Network)') {
|
||||
expect(optionData.value).toBe('owe');
|
||||
} else if (optionData.label === 'No Encryption (Open Network)') {
|
||||
expect(optionData.value).toBe('none');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Password Validation', async ({ page }) => {
|
||||
const password = await page.locator('#password24');
|
||||
const value = await password.inputValue();
|
||||
if (value) {
|
||||
const length = value.length;
|
||||
expect(length).toBeGreaterThanOrEqual(8);
|
||||
}
|
||||
});
|
||||
|
||||
test('Bad Password Validation', async ({ page }) => {
|
||||
const password = await page.locator('#password24');
|
||||
|
||||
await password.fill('qwerty');
|
||||
await page.click('button.button.green:has-text("Save")');
|
||||
|
||||
expect(await hasToastText(page, 'Password must be at least 8 characters long')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Click Save Button without Change', async ({ page }) => {
|
||||
await page.click('button.button.green:has-text("Save")');
|
||||
|
||||
expect(await hasToastText(page, 'No changes detected')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Click Apply Button without Change', async ({ page }) => {
|
||||
await page.click('button#apply24');
|
||||
|
||||
expect(await hasToastText(page, 'Nothing to apply')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Click on QR Code Button', async ({ page }) => {
|
||||
await page.click('button.button.purple.showQR');
|
||||
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();
|
||||
if (value) {
|
||||
const length = value.length;
|
||||
expect(length).toBeGreaterThanOrEqual(1);
|
||||
expect(length).toBeLessThanOrEqual(32);
|
||||
}
|
||||
});
|
||||
|
||||
test('Guest Bad SSID Validation', async ({ page }) => {
|
||||
const guestSsid = await page.locator('#g-ssid-24');
|
||||
await guestSsid.fill('qwertyuiopasdfghjklzxcvbnmlkjhgfdsaqw');
|
||||
await page.click('#g-4-form button.button.green:has-text("Save")');
|
||||
|
||||
expect(await hasToastText(page, 'Invalid SSID')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Guest Encryption Type Fields Validation', async ({ page }) => {
|
||||
const selectElement = await page.locator('label:has-text("Encryption Type ") + .field-body select.g-encryption24');
|
||||
|
||||
const optionDatas = await selectElement.evaluate(select => {
|
||||
const options = Array.from(select.querySelectorAll('option'));
|
||||
return options.map(option => {
|
||||
return {
|
||||
label: option.textContent.trim(),
|
||||
value: option.value.trim()
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
for (const optionData of optionDatas) {
|
||||
if (optionData.label === 'WPA2-PSK (Strong Security)') {
|
||||
expect(optionData.value).toBe('psk2');
|
||||
} else if (optionData.label === 'WPA3-SAE (Strong Security)') {
|
||||
expect(optionData.value).toBe('sae');
|
||||
} else if (optionData.label === 'WPA2-PSK/WPA3-SAE Mixed (Strong Security)') {
|
||||
expect(optionData.value).toBe('sae-mixed');
|
||||
} else if (optionData.label === 'WPA-PSK/WPA2-PSK Mixed (Medium Security)') {
|
||||
expect(optionData.value).toBe('psk-mixed');
|
||||
} else if (optionData.label === 'WPA-PSK (Weak Security)') {
|
||||
expect(optionData.value).toBe('psk');
|
||||
} else if (optionData.label === 'OWE (Open Network)') {
|
||||
expect(optionData.value).toBe('owe');
|
||||
} else if (optionData.label === 'No Encryption (Open Network)') {
|
||||
expect(optionData.value).toBe('none');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Guest Password Validation', async ({ page }) => {
|
||||
const password = await page.locator('#g-password24');
|
||||
const value = await password.inputValue();
|
||||
if (value) {
|
||||
const length = value.length;
|
||||
expect(length).toBeGreaterThanOrEqual(8);
|
||||
}
|
||||
});
|
||||
|
||||
test('Guest Bad Password Validation', async ({ page }) => {
|
||||
const password = await page.locator('#g-password24');
|
||||
|
||||
await password.fill('qwerty');
|
||||
await page.click('#g-4-form button.button.green:has-text("Save")');
|
||||
|
||||
expect(await hasToastText(page, 'Password must be at least 8 characters long')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Guest Click Save Button without Change', async ({ page }) => {
|
||||
await page.click('#g-4-form button.button.green:has-text("Save")');
|
||||
|
||||
expect(await hasToastText(page, 'No changes detected')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Guest Click Apply Button without Change', async ({ page }) => {
|
||||
await page.click('button#apply24-g');
|
||||
|
||||
expect(await hasToastText(page, 'Nothing to apply')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Guest Click on QR Code Button', async ({ page }) => {
|
||||
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', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/network/wifi', { waitUntil: 'networkidle' });
|
||||
await page.waitForTimeout(2000);
|
||||
const fiveGHzTab = await page.$("a:has-text('5Ghz WiFi')");
|
||||
await fiveGHzTab.click();
|
||||
});
|
||||
|
||||
test('5Ghz Primary AP & Radio', async ({ page }) => {
|
||||
const primaryAPandRadio = await page.locator("span:has-text('Primary AP & Radio')");
|
||||
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();
|
||||
if (value) {
|
||||
const length = value.length;
|
||||
expect(length).toBeGreaterThanOrEqual(1);
|
||||
expect(length).toBeLessThanOrEqual(32);
|
||||
}
|
||||
});
|
||||
|
||||
test('5Ghz Bad SSID Validation', async ({ page }) => {
|
||||
const ssid = await page.locator('#ssid-5');
|
||||
await ssid.fill('qwertyuiopasdfghjklzxcvbnmlkjhgfdsaqw');
|
||||
const saveButton = page.locator('#\\35-form button.button.green:has-text("Save")');
|
||||
await saveButton.click();
|
||||
|
||||
expect(await hasToastText(page, 'Invalid SSID')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('5Ghz Encryption Type Fields Validation', async ({ page }) => {
|
||||
const selectElement = await page.locator('label:has-text("Encryption Type ") + .field-body select.encryption5');
|
||||
|
||||
const optionDatas = await selectElement.evaluate(select => {
|
||||
const options = Array.from(select.querySelectorAll('option'));
|
||||
return options.map(option => {
|
||||
return {
|
||||
label: option.textContent.trim(),
|
||||
value: option.value.trim()
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
for (const optionData of optionDatas) {
|
||||
if (optionData.label === 'WPA2-PSK (Strong Security)') {
|
||||
expect(optionData.value).toBe('psk2');
|
||||
} else if (optionData.label === 'WPA3-SAE (Strong Security)') {
|
||||
expect(optionData.value).toBe('sae');
|
||||
} else if (optionData.label === 'WPA2-PSK/WPA3-SAE Mixed (Strong Security)') {
|
||||
expect(optionData.value).toBe('sae-mixed');
|
||||
} else if (optionData.label === 'WPA-PSK/WPA2-PSK Mixed (Medium Security)') {
|
||||
expect(optionData.value).toBe('psk-mixed');
|
||||
} else if (optionData.label === 'WPA-PSK (Weak Security)') {
|
||||
expect(optionData.value).toBe('psk');
|
||||
} else if (optionData.label === 'OWE (Open Network)') {
|
||||
expect(optionData.value).toBe('owe');
|
||||
} else if (optionData.label === 'No Encryption (Open Network)') {
|
||||
expect(optionData.value).toBe('none');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('5Ghz Password Validation', async ({ page }) => {
|
||||
const password = await page.locator('#password5');
|
||||
const value = await password.inputValue();
|
||||
if (value) {
|
||||
const length = value.length;
|
||||
expect(length).toBeGreaterThanOrEqual(8);
|
||||
}
|
||||
});
|
||||
|
||||
test('5Ghz Bad Password Validation', async ({ page }) => {
|
||||
const password = await page.locator('#password5');
|
||||
|
||||
await password.fill('qwerty');
|
||||
await page.click('#\\35-form button.button.green:has-text("Save")');
|
||||
|
||||
expect(await hasToastText(page, 'Password must be at least 8 characters')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('5Ghz Save Button', async ({ page }) => {
|
||||
const saveButton = await page.locator('#\\35-form button.button.green:has-text("Save")');
|
||||
const visible = await saveButton.isVisible();
|
||||
expect(visible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('5Ghz Apply Button', async ({ page }) => {
|
||||
const applyButton = await page.locator('button#apply5');
|
||||
const visible = await applyButton.isVisible();
|
||||
expect(visible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Click on 5Ghz QR Code Button', async ({ page }) => {
|
||||
await page.click('#\\35-form button.button.purple.showQR');
|
||||
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();
|
||||
if (value) {
|
||||
const length = value.length;
|
||||
expect(length).toBeGreaterThanOrEqual(1);
|
||||
expect(length).toBeLessThanOrEqual(32);
|
||||
}
|
||||
});
|
||||
|
||||
test('Guest 5Ghz Bad SSID Validation', async ({ page }) => {
|
||||
const guestSsid = await page.locator('#g-ssid-5');
|
||||
await guestSsid.fill('qwertyuiopasdfghjklzxcvbnmlkjhgfdsaqw');
|
||||
await page.click('#g-5-form button.button.green:has-text("Save")');
|
||||
|
||||
expect(await hasToastText(page, 'Invalid SSID')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Guest 5Ghz Encryption Type Fields Validation', async ({ page }) => {
|
||||
const selectElement = await page.locator('label:has-text("Encryption Type ") + .field-body select.g-encryption5');
|
||||
|
||||
const optionDatas = await selectElement.evaluate(select => {
|
||||
const options = Array.from(select.querySelectorAll('option'));
|
||||
return options.map(option => {
|
||||
return {
|
||||
label: option.textContent.trim(),
|
||||
value: option.value.trim()
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
for (const optionData of optionDatas) {
|
||||
if (optionData.label === 'WPA2-PSK (Strong Security)') {
|
||||
expect(optionData.value).toBe('psk2');
|
||||
} else if (optionData.label === 'WPA3-SAE (Strong Security)') {
|
||||
expect(optionData.value).toBe('sae');
|
||||
} else if (optionData.label === 'WPA2-PSK/WPA3-SAE Mixed (Strong Security)') {
|
||||
expect(optionData.value).toBe('sae-mixed');
|
||||
} else if (optionData.label === 'WPA-PSK/WPA2-PSK Mixed (Medium Security)') {
|
||||
expect(optionData.value).toBe('psk-mixed');
|
||||
} else if (optionData.label === 'WPA-PSK (Weak Security)') {
|
||||
expect(optionData.value).toBe('psk');
|
||||
} else if (optionData.label === 'OWE (Open Network)') {
|
||||
expect(optionData.value).toBe('owe');
|
||||
} else if (optionData.label === 'No Encryption (Open Network)') {
|
||||
expect(optionData.value).toBe('none');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Guest 5Ghz Password Validation', async ({ page }) => {
|
||||
const password = await page.locator('#g-password5');
|
||||
const value = await password.inputValue();
|
||||
if (value) {
|
||||
const length = value.length;
|
||||
expect(length).toBeGreaterThanOrEqual(8);
|
||||
}
|
||||
});
|
||||
|
||||
test('Guest 5Ghz Bad Password Validation', async ({ page }) => {
|
||||
const password = await page.locator('#g-password5');
|
||||
|
||||
await password.fill('qwerty');
|
||||
await page.click('#g-5-form button.button.green:has-text("Save")');
|
||||
|
||||
expect(await hasToastText(page, 'Password must be at least 8 characters long')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Guest 5Ghz Save Button', async ({ page }) => {
|
||||
const saveButton = await page.locator('#g-5-form button.button.green:has-text("Save")');
|
||||
const visible = await saveButton.isVisible();
|
||||
expect(visible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Guest 5Ghz Apply Button', async ({ page }) => {
|
||||
const applyButton = await page.locator('button#apply5-g');
|
||||
const visible = await applyButton.isVisible();
|
||||
expect(visible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Guest Click on 5Ghz QR Code Button', async ({ page }) => {
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
197
utils/utils.js
197
utils/utils.js
|
@ -1,5 +1,5 @@
|
|||
import IPCIDR from 'ip-cidr';
|
||||
import IPAddress from 'ip-address';
|
||||
import IPCIDR from "ip-cidr";
|
||||
import IPAddress from "ip-address";
|
||||
|
||||
export function isValidMacAddress(mac) {
|
||||
try {
|
||||
|
@ -46,26 +46,207 @@ export function isValidCidr (cidr, type = 0) {
|
|||
|
||||
export async function clickSelect2Dropdown(page, selectSelector) {
|
||||
const select2ContainerSelector = `${selectSelector} + .select2-container`;
|
||||
const select2ContainerExists = await page.$(select2ContainerSelector) !== null;
|
||||
await page.waitForTimeout(2000);
|
||||
const select2ContainerExists =
|
||||
(await page.$(select2ContainerSelector)) !== null;
|
||||
|
||||
if (!select2ContainerExists) {
|
||||
throw new Error('Select2 container not found');
|
||||
throw new Error("Select2 container not found");
|
||||
}
|
||||
|
||||
const select2Selection = `${select2ContainerSelector} .select2-selection`;
|
||||
await page.click(select2Selection);
|
||||
await page.waitForSelector('.select2-dropdown .select2-results__option');
|
||||
await page.waitForSelector(".select2-dropdown .select2-results__option");
|
||||
}
|
||||
|
||||
export async function hasToastText(page, text) {
|
||||
try {
|
||||
return (await (await page.waitForSelector('.swal2-popup', {state: 'visible'})).textContent()).includes(text);
|
||||
await page.waitForSelector(".swal2-popup", { state: "visible" });
|
||||
const message = await page.waitForSelector("#swal2-html-container", {
|
||||
state: "visible",
|
||||
});
|
||||
|
||||
const textContent = await message.textContent();
|
||||
return textContent.includes(text);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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" });
|
||||
|
||||
const heading = await page.waitForSelector("#swal2-title", {
|
||||
state: "visible",
|
||||
});
|
||||
|
||||
const imgElement = await page.waitForSelector("#swal2-html-container img", {
|
||||
state: "visible",
|
||||
});
|
||||
|
||||
if (imgElement) {
|
||||
const style = await imgElement.evaluate((el) => {
|
||||
const computedStyle = window.getComputedStyle(el);
|
||||
return {
|
||||
display: computedStyle.getPropertyValue("display"),
|
||||
};
|
||||
});
|
||||
|
||||
if (style.display === "none") {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const textContent = await heading.textContent();
|
||||
return textContent.includes(text);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
export function isValidDate(date) {
|
||||
try {
|
||||
const dateRegex = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/;
|
||||
return dateRegex.test(date);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function isValidPrivateIPV4(ip) {
|
||||
try {
|
||||
const privateRanges = [
|
||||
["10.0.0.0", "10.255.255.255"],
|
||||
["172.16.0.0", "172.31.255.255"],
|
||||
["192.168.0.0", "192.168.255.255"],
|
||||
];
|
||||
|
||||
const ipNumber = ip
|
||||
.split(".")
|
||||
.reduce(
|
||||
(acc, octet, index) => acc + (parseInt(octet) << ((3 - index) * 8)),
|
||||
0
|
||||
);
|
||||
|
||||
for (const [start, end] of privateRanges) {
|
||||
const startNumber = start
|
||||
.split(".")
|
||||
.reduce(
|
||||
(acc, octet, index) => acc + (parseInt(octet) << ((3 - index) * 8)),
|
||||
0
|
||||
);
|
||||
const endNumber = end
|
||||
.split(".")
|
||||
.reduce(
|
||||
(acc, octet, index) => acc + (parseInt(octet) << ((3 - index) * 8)),
|
||||
0
|
||||
);
|
||||
|
||||
if (ipNumber >= startNumber && ipNumber <= endNumber) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function getDefaultNetmask(ip) {
|
||||
const firstOctet = parseInt(ip.split(".")[0], 10);
|
||||
|
||||
if (firstOctet >= 1 && firstOctet <= 126) {
|
||||
return "255.0.0.0";
|
||||
} else if (firstOctet >= 128 && firstOctet <= 191) {
|
||||
return "255.255.0.0";
|
||||
} else if (firstOctet >= 192 && firstOctet <= 223) {
|
||||
return "255.255.255.0";
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function calculateDhcpLimits(ip, mask) {
|
||||
function toBinary(octet) {
|
||||
return ("00000000" + parseInt(octet, 10).toString(2)).substr(-8);
|
||||
}
|
||||
|
||||
const maskBinary = mask
|
||||
.split(".")
|
||||
.map((octet) => toBinary(octet))
|
||||
.join("");
|
||||
const subnetBits = maskBinary.split("1").length - 1;
|
||||
const totalHosts = Math.pow(2, 32 - subnetBits) - 2;
|
||||
|
||||
return {
|
||||
minStart: 1,
|
||||
maxStart: totalHosts,
|
||||
maxLeases: totalHosts,
|
||||
};
|
||||
}
|
||||
|
||||
export function isValidateDhcpInput(ip, mask, dhcpStart, maxLeases) {
|
||||
const limits = calculateDhcpLimits(ip, mask);
|
||||
const isValidStart =
|
||||
dhcpStart >= limits.minStart && dhcpStart <= limits.maxStart;
|
||||
const isValidLeases =
|
||||
maxLeases <= limits.maxLeases &&
|
||||
dhcpStart + maxLeases - 1 <= limits.maxStart;
|
||||
|
||||
return isValidStart && isValidLeases;
|
||||
}
|
||||
|
||||
export function splitIPv6(ipv6Prefixes) {
|
||||
if (ipv6Prefixes == "") {
|
||||
return false;
|
||||
}
|
||||
|
||||
const splitPrefixes = ipv6Prefixes.split(/(?<=\/\d+)/);
|
||||
|
||||
const formattedPrefixes = [];
|
||||
|
||||
for (let i = 0; i < splitPrefixes.length; i += 2) {
|
||||
const prefix = splitPrefixes[i].trim();
|
||||
const subnet = splitPrefixes[i + 1] ? splitPrefixes[i + 1].trim() : "";
|
||||
|
||||
if (prefix && subnet) {
|
||||
formattedPrefixes.push(`${prefix}${subnet}`);
|
||||
}
|
||||
}
|
||||
|
||||
return formattedPrefixes;
|
||||
}
|
Loading…
Reference in a new issue