clean: use best practices
This commit is contained in:
parent
c1fc6907f7
commit
c5eb074234
7 changed files with 27 additions and 29 deletions
1
.husky/pre-commit
Normal file
1
.husky/pre-commit
Normal file
|
@ -0,0 +1 @@
|
||||||
|
npm run lint
|
3
package-lock.json
generated
3
package-lock.json
generated
|
@ -10,13 +10,13 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^16.4.1",
|
"dotenv": "^16.4.1",
|
||||||
"husky": "^9.0.10",
|
|
||||||
"ip-address": "^9.0.5",
|
"ip-address": "^9.0.5",
|
||||||
"ip-cidr": "^4.0.0"
|
"ip-cidr": "^4.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test": "^1.41.2",
|
"@playwright/test": "^1.41.2",
|
||||||
"@types/node": "^20.11.16",
|
"@types/node": "^20.11.16",
|
||||||
|
"husky": "^9.0.10",
|
||||||
"semistandard": "^17.0.0"
|
"semistandard": "^17.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1613,6 +1613,7 @@
|
||||||
"version": "9.0.10",
|
"version": "9.0.10",
|
||||||
"resolved": "https://registry.npmjs.org/husky/-/husky-9.0.10.tgz",
|
"resolved": "https://registry.npmjs.org/husky/-/husky-9.0.10.tgz",
|
||||||
"integrity": "sha512-TQGNknoiy6bURzIO77pPRu+XHi6zI7T93rX+QnJsoYFf3xdjKOur+IlfqzJGMHIK/wXrLg+GsvMs8Op7vI2jVA==",
|
"integrity": "sha512-TQGNknoiy6bURzIO77pPRu+XHi6zI7T93rX+QnJsoYFf3xdjKOur+IlfqzJGMHIK/wXrLg+GsvMs8Op7vI2jVA==",
|
||||||
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"husky": "bin.mjs"
|
"husky": "bin.mjs"
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "semistandard --fix tests/**/*.js",
|
"lint": "semistandard --fix tests/**/*.js",
|
||||||
"test": "playwright test"
|
"test": "playwright test",
|
||||||
|
"prepare": "npm run lint"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
|
@ -19,11 +20,11 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test": "^1.41.2",
|
"@playwright/test": "^1.41.2",
|
||||||
"@types/node": "^20.11.16",
|
"@types/node": "^20.11.16",
|
||||||
|
"husky": "^9.0.10",
|
||||||
"semistandard": "^17.0.0"
|
"semistandard": "^17.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^16.4.1",
|
"dotenv": "^16.4.1",
|
||||||
"husky": "^9.0.10",
|
|
||||||
"ip-address": "^9.0.5",
|
"ip-address": "^9.0.5",
|
||||||
"ip-cidr": "^4.0.0"
|
"ip-cidr": "^4.0.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ const authFile = 'playwright/.auth/user.json';
|
||||||
test('Authenticate', async ({ page }) => {
|
test('Authenticate', async ({ page }) => {
|
||||||
await page.goto('/login');
|
await page.goto('/login');
|
||||||
await page.waitForSelector('input[name="user"]', { timeout: 3000 });
|
await page.waitForSelector('input[name="user"]', { timeout: 3000 });
|
||||||
await page.fill('input[name="user"]', process.env.ADMIN_USER);
|
await page.getByPlaceholder('Username').fill( process.env.ADMIN_USER);
|
||||||
await page.fill('input[name="password"]', process.env.ADMIN_PASS);
|
await page.getByPlaceholder('Password').fill(process.env.ADMIN_PASS);
|
||||||
await page.click('#subBut');
|
await page.getByRole('link', { name: 'Login' }).click();
|
||||||
await page.waitForSelector('span:has-text("Quick Actions")', { timeout: 3000 });
|
await page.waitForSelector('span:has-text("Quick Actions")', { timeout: 3000 });
|
||||||
expect(await page.title()).toBe('Difuse - Dashboard - Router');
|
expect(await page.title()).toBe('Difuse - Dashboard - Router');
|
||||||
await page.context().storageState({ path: authFile });
|
await page.context().storageState({ path: authFile });
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('/', { waitUntil: 'networkidle' });
|
||||||
|
});
|
||||||
|
|
||||||
test('Title', async ({ page }) => {
|
test('Title', async ({ page }) => {
|
||||||
await page.goto('/');
|
|
||||||
const title = await page.title();
|
const title = await page.title();
|
||||||
expect(title).toBe('Difuse - Dashboard - Router');
|
expect(title).toBe('Difuse - Dashboard - Router');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Top Cards', async ({ page }) => {
|
test('Top Cards', async ({ page }) => {
|
||||||
await page.goto('/');
|
const lanClients = await page.getByRole('heading', { name: 'LAN Clients' });
|
||||||
const lanClients = await page.$('h4:has-text("LAN Clients")');
|
const wifiClients = await page.getByRole('heading', { name: 'GHz & 5 GHz Clients' });
|
||||||
const wifiClients = await page.$('h4:has-text("5 GHz Clients")');
|
const wgEndpoints = await page.getByRole('heading', { name: 'Peers & Clients' });
|
||||||
const wgEndpoints = await page.$('h4:has-text("Peers")');
|
|
||||||
|
|
||||||
expect(lanClients && wifiClients && wgEndpoints).toBeTruthy();
|
expect(lanClients && wifiClients && wgEndpoints).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Basic System Information', async ({ page }) => {
|
test('Basic System Information', async ({ page }) => {
|
||||||
await page.goto('/');
|
|
||||||
|
|
||||||
const cells = (await page.$$('.tabulator-cell')).filter(async (cell) => {
|
const cells = (await page.$$('.tabulator-cell')).filter(async (cell) => {
|
||||||
const field = await cell.getAttribute('tabulator-field');
|
const field = await cell.getAttribute('tabulator-field');
|
||||||
return field === 'value';
|
return field === 'value';
|
||||||
|
@ -41,7 +41,5 @@ test('Basic System Information', async ({ page }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Network Information', async ({ page }) => {
|
test('Network Information', async ({ page }) => {
|
||||||
await page.goto('/');
|
expect(await page.$('th:has-text("Network Information")')).toBeTruthy();
|
||||||
const networkInfo = await page.$('th:has-text("Network Information")');
|
|
||||||
expect(networkInfo).toBeTruthy();
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,30 +1,28 @@
|
||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('/telephony', { waitUntil: 'networkidle' });
|
||||||
|
});
|
||||||
|
|
||||||
test('Title', async ({ page }) => {
|
test('Title', async ({ page }) => {
|
||||||
await page.goto('/telephony');
|
|
||||||
const title = await page.title();
|
const title = await page.title();
|
||||||
expect(title).toBe('Difuse - Dashboard - Telephony');
|
expect(title).toBe('Difuse - Dashboard - Telephony');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Top Cards', async ({ page }) => {
|
test('Top Cards', async ({ page }) => {
|
||||||
await page.goto('/telephony');
|
const sipExtensions = await page.getByRole('heading', { name: 'SIP Extensions' });
|
||||||
const sipExtensions = await page.$('h3:has-text("SIP Extensions")');
|
const sipTrunks = await page.getByRole('heading', { name: 'SIP Trunks' });
|
||||||
const sipTrunks = await page.$('h3:has-text("SIP Trunks")');
|
const currentChannels = await page.getByRole('heading', { name: 'Current Channels' });
|
||||||
const currentChannels = await page.$('h3:has-text("Current Channels")');
|
const completedCalls = await page.getByRole('heading', { name: 'Completed Calls' });
|
||||||
const completedCalls = await page.$('h3:has-text("Completed Calls")');
|
|
||||||
|
|
||||||
expect(sipExtensions && sipTrunks && currentChannels && completedCalls).toBeTruthy();
|
expect(sipExtensions && sipTrunks && currentChannels && completedCalls).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Endpoint Table', async ({ page }) => {
|
test('Endpoint Table', async ({ page }) => {
|
||||||
await page.goto('/telephony');
|
expect(await page.getByText('Page Size')).toBeTruthy();
|
||||||
await page.waitForSelector('.tabulator-header', { timeout: 5000 });
|
|
||||||
expect(await page.$('.tabulator-header')).toBeTruthy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('PBX Information', async ({ page }) => {
|
test('PBX Information', async ({ page }) => {
|
||||||
await page.goto('/telephony');
|
|
||||||
|
|
||||||
const yearRegex = /\b\d{4}\b/;
|
const yearRegex = /\b\d{4}\b/;
|
||||||
|
|
||||||
const coreReloadText = await page.textContent('td:has-text("Core Last Reload") + td');
|
const coreReloadText = await page.textContent('td:has-text("Core Last Reload") + td');
|
||||||
|
|
|
@ -2,8 +2,7 @@ import { test, expect } from '@playwright/test';
|
||||||
import { isValidMacAddress, isValidCidr } from '../../utils/utils.js';
|
import { isValidMacAddress, isValidCidr } from '../../utils/utils.js';
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('/network/guest-lan');
|
await page.goto('/network/guest-lan', { waitUntil: 'networkidle' });
|
||||||
await page.waitForTimeout(2500);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Title', async ({ page }) => {
|
test('Title', async ({ page }) => {
|
||||||
|
|
Loading…
Reference in a new issue