- Added integration tests (Preseem, Gaiia, Slack, webhooks) - Added SNMP configuration and discovery tests - Added form validation and error handling tests - Added detailed alert workflow tests (lifecycle, actions, filtering, history) - Added agent token management tests (creation, assignment, deletion) Covers: - Third-party integration UI - SNMP credential hierarchy (org/site/device) - Form validation and error states - Alert bulk actions and filtering - Agent token lifecycle and device assignment
185 lines
6.1 KiB
TypeScript
185 lines
6.1 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('SNMP Configuration', () => {
|
|
test.describe('Device SNMP Settings', () => {
|
|
test('can access SNMP settings from device page', async ({ page }) => {
|
|
await page.goto('/devices');
|
|
|
|
// Navigate to first device
|
|
const firstDevice = page.locator('a[href*="/devices/"]:not([href*="/devices/new"])').first();
|
|
|
|
if (await firstDevice.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await firstDevice.click();
|
|
await page.waitForTimeout(500);
|
|
|
|
// Look for edit or settings button
|
|
const editButton = page.locator(
|
|
'a[href*="/edit"], button:has-text("Edit")'
|
|
).first();
|
|
|
|
if (await editButton.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await editButton.click();
|
|
await page.waitForTimeout(500);
|
|
}
|
|
}
|
|
});
|
|
|
|
test('shows SNMP credential fields', async ({ page }) => {
|
|
await page.goto('/devices');
|
|
|
|
const firstDevice = page.locator('a[href*="/devices/"]:not([href*="/devices/new"])').first();
|
|
|
|
if (await firstDevice.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await firstDevice.click();
|
|
await page.waitForTimeout(500);
|
|
|
|
const editButton = page.locator('a[href*="/edit"]').first();
|
|
|
|
if (await editButton.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await editButton.click();
|
|
await page.waitForTimeout(500);
|
|
|
|
// Look for SNMP fields
|
|
const snmpFields = page.locator(
|
|
'input[name*="snmp"], select[name*="version"], :has-text("Community"), :has-text("SNMP")'
|
|
).first();
|
|
|
|
if (await snmpFields.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await expect(snmpFields).toBeVisible();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
test('shows SNMP version selector', async ({ page }) => {
|
|
await page.goto('/devices');
|
|
|
|
const firstDevice = page.locator('a[href*="/devices/"]:not([href*="/devices/new"])').first();
|
|
|
|
if (await firstDevice.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await firstDevice.click();
|
|
await page.waitForTimeout(500);
|
|
|
|
const editButton = page.locator('a[href*="/edit"]').first();
|
|
|
|
if (await editButton.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await editButton.click();
|
|
await page.waitForTimeout(500);
|
|
|
|
// Look for SNMP version selector
|
|
const versionSelect = page.locator(
|
|
'select[name*="version"], :has-text("v2c"), :has-text("v3")'
|
|
).first();
|
|
|
|
if (await versionSelect.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await expect(versionSelect).toBeVisible();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
test.describe('SNMP Discovery', () => {
|
|
test('can access discovery page', async ({ page }) => {
|
|
await page.goto('/devices/new');
|
|
|
|
// Check if we can access the new device page
|
|
if ((await page.url()).includes('/devices/new')) {
|
|
await expect(page.locator('body')).toBeVisible();
|
|
}
|
|
});
|
|
|
|
test('shows discovery form fields', async ({ page }) => {
|
|
await page.goto('/devices/new');
|
|
|
|
if ((await page.url()).includes('/devices/new')) {
|
|
// Look for IP address or hostname field
|
|
const ipField = page.locator(
|
|
'input[name*="ip"], input[name*="host"], input[placeholder*="IP"]'
|
|
).first();
|
|
|
|
if (await ipField.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await expect(ipField).toBeVisible();
|
|
}
|
|
}
|
|
});
|
|
|
|
test('shows SNMP community field for discovery', async ({ page }) => {
|
|
await page.goto('/devices/new');
|
|
|
|
if ((await page.url()).includes('/devices/new')) {
|
|
// Look for SNMP community field
|
|
const communityField = page.locator(
|
|
'input[name*="community"], :has-text("Community")'
|
|
).first();
|
|
|
|
if (await communityField.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await expect(communityField).toBeVisible();
|
|
}
|
|
}
|
|
});
|
|
|
|
test('shows discover button', async ({ page }) => {
|
|
await page.goto('/devices/new');
|
|
|
|
if ((await page.url()).includes('/devices/new')) {
|
|
// Look for discover button
|
|
const discoverButton = page.locator(
|
|
'button:has-text("Discover"), button:has-text("Add"), button[type="submit"]'
|
|
).first();
|
|
|
|
if (await discoverButton.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await expect(discoverButton).toBeVisible();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
test.describe('SNMP Credentials Hierarchy', () => {
|
|
test('can configure site-level SNMP credentials', async ({ page }) => {
|
|
await page.goto('/sites');
|
|
|
|
// Navigate to first site
|
|
const firstSite = page.locator('a[href*="/sites/"]:not([href*="/sites/new"])').first();
|
|
|
|
if (await firstSite.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await firstSite.click();
|
|
await page.waitForTimeout(500);
|
|
|
|
// Look for edit button
|
|
const editButton = page.locator('a[href*="/edit"]').first();
|
|
|
|
if (await editButton.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await editButton.click();
|
|
await page.waitForTimeout(500);
|
|
|
|
// Look for SNMP credential fields
|
|
const snmpSection = page.locator(
|
|
':has-text("SNMP"), input[name*="community"]'
|
|
).first();
|
|
|
|
if (await snmpSection.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await expect(snmpSection).toBeVisible();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
test('can configure organization-level SNMP credentials', async ({ page }) => {
|
|
await page.goto('/settings');
|
|
|
|
if ((await page.url()).includes('sudo-verify')) {
|
|
return;
|
|
}
|
|
|
|
// Look for SNMP settings section
|
|
const snmpSection = page.locator(
|
|
':has-text("SNMP"), :has-text("Default"), input[name*="community"]'
|
|
).first();
|
|
|
|
if (await snmpSection.isVisible({ timeout: 2000 }).catch(() => false)) {
|
|
await expect(snmpSection).toBeVisible();
|
|
}
|
|
});
|
|
});
|
|
});
|