283 lines
10 KiB
JavaScript
283 lines
10 KiB
JavaScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('General - Dashboard - Network Analyzer - Deep Packet Inspection', () => {
|
|
test.describe('Overview', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('network-analyzer/deep-packet-inspector', { waitUntil: 'load' });
|
|
});
|
|
|
|
test('Title', async ({ page }) => {
|
|
const title = await page.title();
|
|
expect(title).toBe(
|
|
'Difuse - Dashboard - Network Analyzer - Deep Packet Inspector (DPI)'
|
|
);
|
|
});
|
|
|
|
test('Deep Packet Inspection (DPI)', async ({ page }) => {
|
|
expect(await page.$('p:has-text("Deep Packet Inspection (DPI)")')).toBeTruthy();
|
|
});
|
|
|
|
test('Tabs', async ({ page }) => {
|
|
const overviewTab = await page.locator('#overview-tab-dpi');
|
|
const detailExplorerTab = await page.locator('#detail-tab-dpi');
|
|
const liveViewTab = await page.locator('#liveview-tab-dpi');
|
|
const settingsTab = await page.locator('#settings-tab-dpi');
|
|
|
|
expect(overviewTab && detailExplorerTab && liveViewTab && settingsTab).toBeTruthy();
|
|
});
|
|
|
|
test('Overview Top Cards', async ({ page }) => {
|
|
const inspectedFlows = await page.getByRole('heading', { name: 'Inspected Flows' });
|
|
const inspectedFlowsIcon = await page.locator('.mdi-magnify');
|
|
|
|
const inspectedFlowsValue = await page.textContent('#tip');
|
|
expect(typeof parseInt(inspectedFlowsValue)).toBe('number');
|
|
|
|
const applications = await page.getByRole('heading', { name: 'Applications' });
|
|
const applicationsIcon = await page.locator('.mdi-apps');
|
|
|
|
const applicationsValue = await page.textContent('#tia');
|
|
expect(typeof parseInt(applicationsValue)).toBe('number');
|
|
|
|
const countries = await page.getByRole('heading', { name: 'Countries' });
|
|
const countriesIcon = await page.locator('.mdi-earth');
|
|
|
|
const countriesValue = await page.textContent('#tcc');
|
|
expect(typeof parseInt(countriesValue)).toBe('number');
|
|
|
|
const domains = await page.getByRole('heading', { name: 'Domains' });
|
|
const domainsIcon = await page.locator('.mdi-server');
|
|
|
|
const domainsValue = await page.textContent('#tia');
|
|
expect(typeof parseInt(domainsValue)).toBe('number');
|
|
|
|
expect(inspectedFlows && applications && countries && domains).toBeTruthy();
|
|
expect(inspectedFlowsIcon && applicationsIcon && countriesIcon && domainsIcon).toBeTruthy();
|
|
});
|
|
|
|
test('Connections by Country', async ({ page }) => {
|
|
expect(await page.$('p:has-text("Connections by Country")')).toBeTruthy();
|
|
});
|
|
|
|
test('DPI Map', async ({ page }) => {
|
|
const dpiMap = await page.locator('#dpi-map');
|
|
const isVisible = await dpiMap.isVisible();
|
|
const isEnabled = await dpiMap.isEnabled();
|
|
|
|
expect(isVisible && isEnabled).toBeTruthy();
|
|
});
|
|
|
|
test('Detected Applications', async ({ page }) => {
|
|
expect(await page.$('p:has-text("Detected Application")')).toBeTruthy();
|
|
});
|
|
|
|
test('Detected Applications Filter', async ({ page }) => {
|
|
const filterField = await page.locator('#filter-field-apps');
|
|
expect(filterField).toBeTruthy();
|
|
|
|
const typeField = await page.locator('#filter-type-apps');
|
|
expect(typeField).toBeTruthy();
|
|
|
|
const valueField = await page.locator('#filter-value-categories');
|
|
expect(valueField).toBeTruthy();
|
|
});
|
|
|
|
test('Clear Filter', async ({ page }) => {
|
|
const clearFilter = await page.locator('#filter-clear-apps');
|
|
expect(clearFilter).toBeTruthy();
|
|
});
|
|
|
|
test('Download PDF Button', async ({ page }) => {
|
|
const button = await page.$('button[data-type="PDF"].download-table-apps');
|
|
expect(button).toBeTruthy();
|
|
const buttonName = await button.textContent();
|
|
expect(buttonName).toBe('Download PDF');
|
|
});
|
|
|
|
test('Download XLSX Button', async ({ page }) => {
|
|
const button = await page.$('button[data-type="XLSX"].download-table-apps');
|
|
expect(button).toBeTruthy();
|
|
const buttonName = await button.textContent();
|
|
expect(buttonName).toBe('Download XLSX');
|
|
});
|
|
|
|
test('Download CSV Button', async ({ page }) => {
|
|
const button = await page.$('button[data-type="CSV"].download-table-apps');
|
|
expect(button).toBeTruthy();
|
|
const buttonName = await button.textContent();
|
|
expect(buttonName).toBe('Download CSV');
|
|
});
|
|
|
|
test('Download JSON Button', async ({ page }) => {
|
|
const button = await page.$('button[data-type="JSON"].download-table-apps');
|
|
expect(button).toBeTruthy();
|
|
const buttonName = await button.textContent();
|
|
expect(buttonName).toBe('Download JSON');
|
|
});
|
|
});
|
|
|
|
test.describe('Detail Explorer Tab', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('network-analyzer/deep-packet-inspector', {
|
|
waitUntil: 'networkidle'
|
|
});
|
|
|
|
await page.click('#detail-tab-dpi');
|
|
});
|
|
|
|
test('Detail Explorer Top Cards', async ({ page }) => {
|
|
const disoveredIps = await page.$('header', { name: 'Discovered IPs' });
|
|
const dicoveredIpsIcon = await page.locator('.mdi-magnify');
|
|
|
|
const disoveredIpsValue = await page.textContent('#deips');
|
|
expect(typeof parseInt(disoveredIpsValue)).toBe('number');
|
|
|
|
const disoveredMacS = await page.$('header', { name: 'Discovered MACs' });
|
|
const disoveredMacSicon = await page.locator('.mdi-magnify');
|
|
|
|
const disoveredMacSValue = await page.textContent('#demacs');
|
|
expect(typeof parseInt(disoveredMacSValue)).toBe('number');
|
|
|
|
expect(disoveredIps && disoveredMacS).toBeTruthy();
|
|
expect(dicoveredIpsIcon && disoveredMacSicon).toBeTruthy();
|
|
});
|
|
|
|
test('Detected Network Peers', async ({ page }) => {
|
|
expect(await page.$('p:has-text("Detected Network Peers")')).toBeTruthy();
|
|
});
|
|
|
|
test('Detected Network Filter', async ({ page }) => {
|
|
const filterField = await page.locator('#filter-field-de1');
|
|
const loadFilterField = await filterField.isVisible();
|
|
expect(loadFilterField).toBeTruthy();
|
|
|
|
const typeField = await page.locator('#filter-type-de1');
|
|
const loadType = await typeField.isVisible();
|
|
expect(loadType).toBeTruthy();
|
|
|
|
const valueField = await page.locator('#filter-value-de1');
|
|
const loadValue = await valueField.isVisible();
|
|
expect(loadValue).toBeTruthy();
|
|
});
|
|
|
|
test('Explorer Clear Filter Button', async ({ page }) => {
|
|
const clearFilter = await page.locator('#filter-clear-de1');
|
|
expect(await clearFilter.isVisible()).toBeTruthy();
|
|
});
|
|
|
|
test('Explorer Download PDF Button', async ({ page }) => {
|
|
const button = await page.$('button[data-type="PDF"].download-table-de1');
|
|
const isVisible = await button.isVisible();
|
|
const isEnabled = await button.isEnabled();
|
|
const buttonName = await button.textContent();
|
|
|
|
expect(isVisible && isEnabled).toBeTruthy();
|
|
expect(buttonName).toBe('Download PDF');
|
|
});
|
|
|
|
test('Explorer Download XLSX Button', async ({ page }) => {
|
|
const button = await page.$('button[data-type="XLSX"].download-table-de1');
|
|
const isVisible = await button.isVisible();
|
|
const buttonName = await button.textContent();
|
|
|
|
expect(isVisible).toBeTruthy();
|
|
expect(buttonName).toBe('Download XLSX');
|
|
});
|
|
|
|
test('Explorer Download CSV Button', async ({ page }) => {
|
|
const button = await page.$('button[data-type="CSV"].download-table-de1');
|
|
const isVisible = await button.isVisible();
|
|
const isEnabled = await button.isEnabled();
|
|
const buttonName = await button.textContent();
|
|
|
|
expect(isVisible && isEnabled).toBeTruthy();
|
|
expect(buttonName).toBe('Download CSV');
|
|
});
|
|
|
|
test('Explorer Download JSON Button', async ({ page }) => {
|
|
const button = await page.$('button[data-type="JSON"].download-table-de1');
|
|
const isVisible = await button.isVisible();
|
|
const isEnabled = await button.isEnabled();
|
|
const buttonName = await button.textContent();
|
|
|
|
expect(isVisible && isEnabled).toBeTruthy();
|
|
expect(buttonName).toBe('Download JSON');
|
|
});
|
|
|
|
test('Explore Peer Table', async ({ page }) => {
|
|
const table = page.locator('#de2-sec');
|
|
await expect(table).toBeHidden();
|
|
});
|
|
});
|
|
|
|
test.describe('Live View Tab', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('network-analyzer/deep-packet-inspector', { waitUntil: 'networkidle' });
|
|
|
|
await page.click('#liveview-tab-dpi');
|
|
});
|
|
|
|
test('Toggle icon is Pause', async ({ page }) => {
|
|
const toggleIcon = await page.locator('#toggle-icon');
|
|
const classAttribute = await toggleIcon.getAttribute('class');
|
|
expect(classAttribute).toContain('mdi-pause');
|
|
});
|
|
|
|
test('Toggle icon is Play', async ({ page }) => {
|
|
await page.click('#toggle-icon');
|
|
const toggleIcon = await page.locator('#toggle-icon');
|
|
const classAttribute = await toggleIcon.getAttribute('class');
|
|
expect(classAttribute).toContain('mdi-play');
|
|
});
|
|
|
|
test('Live Code Check', async ({ page }) => {
|
|
const code = await page.locator('#liveview');
|
|
expect(code).toBeTruthy();
|
|
const codeData = await code.getAttribute('class');
|
|
expect(codeData).toContain('json');
|
|
});
|
|
});
|
|
|
|
test.describe('Settings', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('network-analyzer/deep-packet-inspector', { waitUntil: 'networkidle' });
|
|
await page.click('#settings-tab-dpi');
|
|
});
|
|
|
|
test('Enable Label', async ({ page }) => {
|
|
expect(await page.$('label:has-text("Enable")')).toBeTruthy();
|
|
});
|
|
|
|
test('Enable Checkbox', async ({ page }) => {
|
|
const checkbox = await page.locator('input.cb-enable');
|
|
expect(checkbox).toBeTruthy();
|
|
});
|
|
|
|
test('Ignore Bittorrent Traffic', async ({ page }) => {
|
|
expect(await page.$('label:has-text("Ignore Bittorrent Traffic")')).toBeTruthy();
|
|
});
|
|
|
|
test('Ignore Bittorrent Traffic Checkbox', async ({ page }) => {
|
|
const checkbox = await page.locator('input.cb-ignorebtt');
|
|
expect(checkbox).toBeTruthy();
|
|
});
|
|
|
|
test('Maximum Storage', async ({ page }) => {
|
|
expect(await page.$('label:has-text("Maximum Storage")')).toBeTruthy();
|
|
});
|
|
|
|
test('Maximum Storage Input', async ({ page }) => {
|
|
const input = await page.locator('#max-storage');
|
|
expect(input).toBeTruthy();
|
|
});
|
|
|
|
test('Save Button', async ({ page }) => {
|
|
const button = await page.getByRole('button', { name: 'Save' });
|
|
const visible = await button.isVisible();
|
|
expect(visible).toBeTruthy();
|
|
|
|
const type = await button.getAttribute('type');
|
|
expect(type).toBe('submit');
|
|
});
|
|
});
|
|
});
|