cleanup
: more stds
This commit is contained in:
parent
c5eb074234
commit
e87dc83fbc
6 changed files with 188 additions and 118 deletions
|
@ -6,6 +6,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "semistandard --fix tests/**/*.js",
|
"lint": "semistandard --fix tests/**/*.js",
|
||||||
|
"codegen": "npx playwright codegen",
|
||||||
"test": "playwright test",
|
"test": "playwright test",
|
||||||
"prepare": "npm run lint"
|
"prepare": "npm run lint"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
// import { defineConfig, devices } from '@playwright/test';
|
|
||||||
//
|
|
||||||
// await import('dotenv/config');
|
|
||||||
|
|
||||||
const { defineConfig, devices } = require('@playwright/test');
|
const { defineConfig, devices } = require('@playwright/test');
|
||||||
|
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test.describe('General - Dashboard - Router', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('/', { waitUntil: 'networkidle' });
|
await page.goto('/', { waitUntil: 'networkidle' });
|
||||||
});
|
});
|
||||||
|
@ -43,3 +44,4 @@ test('Basic System Information', async ({ page }) => {
|
||||||
test('Network Information', async ({ page }) => {
|
test('Network Information', async ({ page }) => {
|
||||||
expect(await page.$('th:has-text("Network Information")')).toBeTruthy();
|
expect(await page.$('th:has-text("Network Information")')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test.describe('General - Dashboard - Telephony', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('/telephony', { waitUntil: 'networkidle' });
|
await page.goto('/telephony', { waitUntil: 'networkidle' });
|
||||||
});
|
});
|
||||||
|
@ -35,3 +36,4 @@ test('PBX Information', async ({ page }) => {
|
||||||
const coreStartupTimeText = await page.textContent('#core-startup-time');
|
const coreStartupTimeText = await page.textContent('#core-startup-time');
|
||||||
expect(yearRegex.test(coreStartupTimeText)).toBeTruthy();
|
expect(yearRegex.test(coreStartupTimeText)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
import { test, expect } from '@playwright/test';
|
import { expect, test } from '@playwright/test';
|
||||||
import { isValidMacAddress, isValidCidr } from '../../utils/utils.js';
|
import { isValidCidr, isValidMacAddress, clickSelect2Dropdown, hasToastText, sleep } from '../../utils/utils.js';
|
||||||
|
|
||||||
|
test.describe('Network & Services - Network - Guest LAN', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('/network/guest-lan', { waitUntil: 'networkidle' });
|
await page.goto('/network/guest-lan', { waitUntil: 'networkidle' });
|
||||||
|
await page.waitForFunction(async () => {
|
||||||
|
await sleep(1000);
|
||||||
|
const element = document.querySelector('.lan-netmask-select');
|
||||||
|
return element && element.classList.contains('select2-hidden-accessible');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Title', async ({ page }) => {
|
test('Title', async ({ page }) => {
|
||||||
|
@ -11,9 +17,6 @@ test('Title', async ({ page }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Info Table', async ({ page }) => {
|
test('Info Table', async ({ page }) => {
|
||||||
await page.waitForSelector('td:has-text("Static Address")', { timeout: 5000 });
|
|
||||||
await page.waitForTimeout(2500);
|
|
||||||
|
|
||||||
const rows = await page.$$('table > tbody > tr');
|
const rows = await page.$$('table > tbody > tr');
|
||||||
|
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
|
@ -37,11 +40,51 @@ test('Info Table', async ({ page }) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Bad IPv4 Form Submits', async ({ page }) => {
|
test('DHCP Toggle', async ({ page }) => {
|
||||||
await page.waitForSelector('#ipAddress', {timeout: 5000})
|
const dhcpCb = await page.$('.dhcp-cb');
|
||||||
await page.fill('#ipAddress', '111.111.111.111.111');
|
const isChecked = await dhcpCb.isChecked();
|
||||||
await page.click('button[type="submit"]');
|
|
||||||
const errorPopup = await page.waitForSelector('.swal2-popup', { state: 'visible' });
|
if(isChecked) {
|
||||||
const errorText = await errorPopup.textContent();
|
expect(await page.isVisible('label:has-text("DHCP Start")')).toBeTruthy();
|
||||||
expect(errorText).toContain('Invalid IP Address');
|
} else {
|
||||||
|
await dhcpCb.check();
|
||||||
|
expect(await page.isVisible('label:has-text("DHCP Start1")')).toBeTruthy();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe('Bad IPv4 Form Submits', () => {
|
||||||
|
test('Bad IPv4', async ({ page }) => {
|
||||||
|
const ip = await page.getByPlaceholder('192.168.1.1');
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
|
||||||
|
/* Hayzam - Fix This */
|
||||||
|
// test('Bad DHCP Leasetime', async ({ page }) => {
|
||||||
|
// await page.locator('#leaseTime').fill('55555555555555');
|
||||||
|
// await page.click('button.button.green:has-text("Save")');
|
||||||
|
// expect(await hasToastText(page, 'Invalid Lease Time')).toBeTruthy();
|
||||||
|
// });
|
||||||
|
});
|
||||||
});
|
});
|
|
@ -43,3 +43,29 @@ export function isValidCidr (cidr, type = 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function clickSelect2Dropdown(page, selectSelector) {
|
||||||
|
const select2ContainerSelector = `${selectSelector} + .select2-container`;
|
||||||
|
const select2ContainerExists = await page.$(select2ContainerSelector) !== null;
|
||||||
|
|
||||||
|
if (!select2ContainerExists) {
|
||||||
|
throw new Error('Select2 container not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
const select2Selection = `${select2ContainerSelector} .select2-selection`;
|
||||||
|
await page.click(select2Selection);
|
||||||
|
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);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function sleep(ms) {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
}
|
Loading…
Reference in a new issue