Network - Wifi : Clients Tab test Completed and 2.4Ghz Wifi Tab Partially completed
This commit is contained in:
parent
4cadd63e99
commit
530701b1be
2 changed files with 248 additions and 0 deletions
216
tests/network/wifi.spec.js
Normal file
216
tests/network/wifi.spec.js
Normal file
|
@ -0,0 +1,216 @@
|
||||||
|
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('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('Guest', async ({ page }) => {
|
||||||
|
const guest = await page.locator("span:has-text('Guest')");
|
||||||
|
expect(await guest).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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -73,6 +73,38 @@ export async function hasToastText(page, text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function sleep(ms) {
|
export async function sleep(ms) {
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue