difuse-playwright/tests/network/routes.spec.js
2024-06-26 01:25:58 +05:30

197 lines
8.2 KiB
JavaScript

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();
});
});
});