496 lines
19 KiB
JavaScript
496 lines
19 KiB
JavaScript
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('Primary AP & Radio Enable switch', async ({ page }) => {
|
|
const enableLabel = await page.locator('#\\34-form label:has-text("Enable")');
|
|
const enableSwitch = await page.locator('#\\34-form label.switch');
|
|
|
|
expect(enableLabel && enableSwitch).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('Allow legacy 802.11b rates', async ({ page }) => {
|
|
const label = await page.locator('#\\34-form label:has-text("Allow legacy 802.11b rates")');
|
|
const allowSwitch = await page.locator('#\\34-form label.switch');
|
|
expect(label && allowSwitch).toBeTruthy();
|
|
});
|
|
|
|
test('MAC Filtering', async ({ page }) => {
|
|
const label = await page.locator('#\\34-form label:has-text("MAC Filtering")');
|
|
expect(label).toBeTruthy();
|
|
|
|
const selection = await page.locator('#\\34-form select.mac-filter-ena-24');
|
|
await selection.click();
|
|
|
|
await page.selectOption('#\\34-form select.mac-filter-ena-24', { label: 'Allow Listed Only' });
|
|
await page.waitForTimeout(1000);
|
|
|
|
const isVisible = await page.isVisible('#\\34-form div.field.mfl-24');
|
|
expect(isVisible).toBe(true);
|
|
});
|
|
|
|
test('Guest', async ({ page }) => {
|
|
const guest = await page.locator("span:has-text('Guest')");
|
|
expect(await guest).toBeTruthy();
|
|
});
|
|
|
|
test('Guest Enable switch', async ({ page }) => {
|
|
const enableLabel = await page.locator('#g-4-form label:has-text("Enable")');
|
|
const enableSwitch = await page.locator('#g-4-form label.switch');
|
|
|
|
expect(enableLabel && enableSwitch).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();
|
|
});
|
|
|
|
test('Guest MAC Filtering', async ({ page }) => {
|
|
const label = await page.locator('#g-4-form label:has-text("MAC Filtering")');
|
|
expect(label).toBeTruthy();
|
|
|
|
const selection = await page.locator('#g-4-form select.g-mac-filter-ena-24');
|
|
await selection.click();
|
|
|
|
await page.selectOption('#g-4-form select.g-mac-filter-ena-24', { label: 'Allow Listed Only' });
|
|
await page.waitForTimeout(2000);
|
|
|
|
const isVisible = await page.isVisible('#g-4-form div.field.g-mfl-24');
|
|
expect(isVisible).toBe(true);
|
|
});
|
|
});
|
|
|
|
test.describe('5Ghz WiFi Tab', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('/network/wifi', { waitUntil: 'networkidle' });
|
|
await page.waitForTimeout(2000);
|
|
const fiveGHzTab = await page.$("a:has-text('5Ghz WiFi')");
|
|
await fiveGHzTab.click();
|
|
});
|
|
|
|
test('5Ghz Primary AP & Radio', async ({ page }) => {
|
|
const primaryAPandRadio = await page.locator("span:has-text('Primary AP & Radio')");
|
|
expect(await primaryAPandRadio).toBeTruthy();
|
|
});
|
|
|
|
test('5ghz Primary AP & Radio Enable switch', async ({ page }) => {
|
|
const enableLabel = await page.locator('#\\35-form label:has-text("Enable")');
|
|
const enableSwitch = await page.locator('#\\35-form label.switch');
|
|
|
|
expect(enableLabel && enableSwitch).toBeTruthy();
|
|
});
|
|
|
|
test('5Ghz SSID Validation', async ({ page }) => {
|
|
const ssid = await page.locator('#ssid-5');
|
|
const value = await ssid.inputValue();
|
|
if (value) {
|
|
const length = value.length;
|
|
expect(length).toBeGreaterThanOrEqual(1);
|
|
expect(length).toBeLessThanOrEqual(32);
|
|
}
|
|
});
|
|
|
|
test('5Ghz Bad SSID Validation', async ({ page }) => {
|
|
const ssid = await page.locator('#ssid-5');
|
|
await ssid.fill('qwertyuiopasdfghjklzxcvbnmlkjhgfdsaqw');
|
|
const saveButton = page.locator('#\\35-form button.button.green:has-text("Save")');
|
|
await saveButton.click();
|
|
|
|
expect(await hasToastText(page, 'Invalid SSID')).toBeTruthy();
|
|
});
|
|
|
|
test('5Ghz Encryption Type Fields Validation', async ({ page }) => {
|
|
const selectElement = await page.locator('label:has-text("Encryption Type ") + .field-body select.encryption5');
|
|
|
|
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('5Ghz Password Validation', async ({ page }) => {
|
|
const password = await page.locator('#password5');
|
|
const value = await password.inputValue();
|
|
if (value) {
|
|
const length = value.length;
|
|
expect(length).toBeGreaterThanOrEqual(8);
|
|
}
|
|
});
|
|
|
|
test('5Ghz Bad Password Validation', async ({ page }) => {
|
|
const password = await page.locator('#password5');
|
|
|
|
await password.fill('qwerty');
|
|
await page.click('#\\35-form button.button.green:has-text("Save")');
|
|
|
|
expect(await hasToastText(page, 'Password must be at least 8 characters')).toBeTruthy();
|
|
});
|
|
|
|
test('5Ghz Save Button', async ({ page }) => {
|
|
const saveButton = await page.locator('#\\35-form button.button.green:has-text("Save")');
|
|
const visible = await saveButton.isVisible();
|
|
expect(visible).toBeTruthy();
|
|
});
|
|
|
|
test('5Ghz Apply Button', async ({ page }) => {
|
|
const applyButton = await page.locator('button#apply5');
|
|
const visible = await applyButton.isVisible();
|
|
expect(visible).toBeTruthy();
|
|
});
|
|
|
|
test('Click on 5Ghz QR Code Button', async ({ page }) => {
|
|
await page.click('#\\35-form button.button.purple.showQR');
|
|
expect(await hasToastQRcode(page, 'Difuse 5G - QR Code')).toBeTruthy();
|
|
});
|
|
|
|
test('5Ghz MAC Filtering', async ({ page }) => {
|
|
const label = await page.locator('#\\35-form label:has-text("MAC Filtering")');
|
|
expect(label).toBeTruthy();
|
|
|
|
const selection = await page.locator('#\\35-form select.mac-filter-ena-5');
|
|
await selection.click();
|
|
|
|
await page.selectOption('#\\35-form select.mac-filter-ena-5', { label: 'Allow Listed Only' });
|
|
await page.waitForTimeout(1000);
|
|
|
|
const isVisible = await page.isVisible('#\\35-form div.field.mfl-5');
|
|
expect(isVisible).toBe(true);
|
|
});
|
|
|
|
test('Guest 5Ghz', async ({ page }) => {
|
|
const guest = await page.locator("span:has-text('Guest')");
|
|
expect(await guest).toBeTruthy();
|
|
});
|
|
|
|
test('Primary AP & Radio Enable switch', async ({ page }) => {
|
|
const enableLabel = await page.locator('#g-5-form label:has-text("Enable")');
|
|
const enableSwitch = await page.locator('#g-5-form label.switch');
|
|
|
|
expect(enableLabel && enableSwitch).toBeTruthy();
|
|
});
|
|
|
|
test('Guest 5Ghz SSID Validation', async ({ page }) => {
|
|
const guestSsid = await page.locator('#g-ssid-5');
|
|
const value = await guestSsid.inputValue();
|
|
if (value) {
|
|
const length = value.length;
|
|
expect(length).toBeGreaterThanOrEqual(1);
|
|
expect(length).toBeLessThanOrEqual(32);
|
|
}
|
|
});
|
|
|
|
test('Guest 5Ghz Bad SSID Validation', async ({ page }) => {
|
|
const guestSsid = await page.locator('#g-ssid-5');
|
|
await guestSsid.fill('qwertyuiopasdfghjklzxcvbnmlkjhgfdsaqw');
|
|
await page.click('#g-5-form button.button.green:has-text("Save")');
|
|
|
|
expect(await hasToastText(page, 'Invalid SSID')).toBeTruthy();
|
|
});
|
|
|
|
test('Guest 5Ghz Encryption Type Fields Validation', async ({ page }) => {
|
|
const selectElement = await page.locator('label:has-text("Encryption Type ") + .field-body select.g-encryption5');
|
|
|
|
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 5Ghz Password Validation', async ({ page }) => {
|
|
const password = await page.locator('#g-password5');
|
|
const value = await password.inputValue();
|
|
if (value) {
|
|
const length = value.length;
|
|
expect(length).toBeGreaterThanOrEqual(8);
|
|
}
|
|
});
|
|
|
|
test('Guest 5Ghz Bad Password Validation', async ({ page }) => {
|
|
const password = await page.locator('#g-password5');
|
|
|
|
await password.fill('qwerty');
|
|
await page.click('#g-5-form button.button.green:has-text("Save")');
|
|
|
|
expect(await hasToastText(page, 'Password must be at least 8 characters long')).toBeTruthy();
|
|
});
|
|
|
|
test('Guest 5Ghz Save Button', async ({ page }) => {
|
|
const saveButton = await page.locator('#g-5-form button.button.green:has-text("Save")');
|
|
const visible = await saveButton.isVisible();
|
|
expect(visible).toBeTruthy();
|
|
});
|
|
|
|
test('Guest 5Ghz Apply Button', async ({ page }) => {
|
|
const applyButton = await page.locator('button#apply5-g');
|
|
const visible = await applyButton.isVisible();
|
|
expect(visible).toBeTruthy();
|
|
});
|
|
|
|
test('Guest Click on 5Ghz QR Code Button', async ({ page }) => {
|
|
await page.click('#g-5-form button.button.purple.showQR');
|
|
expect(await hasToastQRcode(page, 'Difuse 5Ghz Guest - QR Code')).toBeTruthy();
|
|
});
|
|
|
|
test('5Ghz Guest MAC Filtering', async ({ page }) => {
|
|
const label = await page.locator('#g-5-form label:has-text("MAC Filtering")');
|
|
expect(label).toBeTruthy();
|
|
|
|
const selection = await page.locator('#g-5-form select.g-mac-filter-ena-5');
|
|
await selection.click();
|
|
|
|
await page.selectOption('#g-5-form select.g-mac-filter-ena-5', { label: 'Allow Listed Only' });
|
|
await page.waitForTimeout(1000);
|
|
|
|
const isVisible = await page.isVisible('#g-5-form div.field.g-mfl-5');
|
|
expect(isVisible).toBe(true);
|
|
});
|
|
});
|
|
});
|