import { test, expect } from '@playwright/test'; test.describe('Network & Services - Network - DHCP', () => { test.describe('General Settings Tab', () => { test.beforeEach(async ({ page }) => { await page.goto('/network/dhcp', { waitUntil: 'networkidle' }); await page.waitForSelector('#general-tab-dndh'); const generalSettingsTab = await page.locator('#general-tab-dndh'); await generalSettingsTab.click(); await page.waitForTimeout(3000); }); test('Title', async ({ page }) => { expect(await page.title()).toBe('Difuse - Network - DHCP'); }); test('Card Header Title', async ({ page }) => { const title = await page.locator('.card-header-title'); expect(await title).toBeTruthy(); }); test('Allocate IPs Sequentially', async ({ page }) => { const label = await page.$('#general-form label:has-text("Allocate IPs Sequentially")'); expect(label).toBeTruthy(); const switchField = await page.locator('#general-form .sequential_ip'); const switchFieldIsVisible = await switchField.isVisible(); expect(switchFieldIsVisible).toBeTruthy(); }); test('Authoritative ', async ({ page }) => { const label = await page.$('#general-form label:has-text("Authoritative")'); expect(label).toBeTruthy(); const switchField = await page.locator('#general-form .authoritative'); const switchFieldIsVisible = await switchField.isVisible(); expect(switchFieldIsVisible).toBeTruthy(); }); test('Hijack DNS ', async ({ page }) => { const label = await page.$('#general-form label:has-text("Hijack DNS")'); expect(label).toBeTruthy(); const switchField = await page.locator('#general-form .hijackdns'); const switchFieldIsVisible = await switchField.isVisible(); expect(switchFieldIsVisible).toBeTruthy(); }); test('Save Button', async ({ page }) => { const button = page.locator('#general-form button.button.green:has-text("Save")'); expect(button).toBeTruthy(); }); }); test.describe('Static Leases Tab', () => { test.beforeEach(async ({ page }) => { await page.goto('/network/dhcp', { waitUntil: 'networkidle' }); await page.waitForSelector('#static-tab-dndh'); const staticLeasesTab = await page.locator('#static-tab-dndh'); await staticLeasesTab.click(); await page.waitForTimeout(3000); }); test('Static Leases', async ({ page }) => { const label = await page.locator('#content-static span:has-text("Static Leases")'); const visible = await label.isVisible(); expect(visible).toBeTruthy(); }); test('Static Leases Table Visible', async ({ page }) => { const filterField = await page.locator('#sl-filter-field'); const filterFieldIsVisible = await filterField.isVisible(); const filterType = await page.locator('#sl-filter-type'); const filterTypeIsVisible = await filterType.isVisible(); const filterValue = await page.locator('#sl-filter-value'); const filterValueIsVisible = await filterValue.isVisible(); const ClearFilter = await page.locator('#sl-filter-clear'); const ClearFilterIsVisible = await ClearFilter.isVisible(); expect(filterFieldIsVisible && filterTypeIsVisible && filterValueIsVisible && ClearFilterIsVisible).toBe(true); const table = await page.locator('#static-leases-t'); const tableIsVisible = await table.isVisible(); expect(tableIsVisible).toBe(true); }); test('Static Leases Add Button', async ({ page }) => { const addButton = await page.locator('#addNewStatic'); const visible = await addButton.isVisible(); expect(visible).toBeTruthy(); }); test('Active DHCPv4 Leases', async ({ page }) => { const label = await page.locator('#content-static span:has-text("Active DHCPv4 Leases")'); const visible = await label.isVisible(); expect(visible).toBeTruthy(); }); test('Active DHCPv4 Leases Table Visible', async ({ page }) => { const filterField = await page.locator('#\\34-filter-field'); const filterFieldIsVisible = await filterField.isVisible(); const filterType = await page.locator('#\\34-filter-type'); const filterTypeIsVisible = await filterType.isVisible(); const filterValue = await page.locator('#\\34-filter-value'); const filterValueIsVisible = await filterValue.isVisible(); const ClearFilter = await page.locator('#\\34-filter-clear'); const ClearFilterIsVisible = await ClearFilter.isVisible(); expect(filterFieldIsVisible && filterTypeIsVisible && filterValueIsVisible && ClearFilterIsVisible).toBe(true); const table = await page.locator('#active-leases-t'); const tableIsVisible = await table.isVisible(); expect(tableIsVisible).toBe(true); }); test('Active DHCPv6 Leases', async ({ page }) => { const label = await page.locator('#content-static span:has-text("Active DHCPv6 Leases")'); const visible = await label.isVisible(); expect(visible).toBeTruthy(); }); test('Active DHCPv6 Leases Table Visible', async ({ page }) => { const filterField = await page.locator('#\\36-filter-field'); const filterFieldIsVisible = await filterField.isVisible(); const filterType = await page.locator('#\\36-filter-type'); const filterTypeIsVisible = await filterType.isVisible(); const filterValue = await page.locator('#\\36-filter-value'); const filterValueIsVisible = await filterValue.isVisible(); const ClearFilter = await page.locator('#\\36-filter-clear'); const ClearFilterIsVisible = await ClearFilter.isVisible(); expect(filterFieldIsVisible && filterTypeIsVisible && filterValueIsVisible && ClearFilterIsVisible).toBe(true); const table = await page.locator('#active-6leases-t'); const tableIsVisible = await table.isVisible(); expect(tableIsVisible).toBe(true); }); }); test.describe('TFTP Server Tab', () => { test.beforeEach(async ({ page }) => { await page.goto('/network/dhcp', { waitUntil: 'networkidle' }); await page.waitForSelector('#pxetftp-tab-dndh'); const tftpServerTab = await page.locator('#pxetftp-tab-dndh'); await tftpServerTab.click(); await page.waitForTimeout(3000); }); test('TFTP Server', async ({ page }) => { const label = await page.$('#content-pxetftp label:has-text("TFTP Server")'); expect(label).toBeTruthy(); }); test('TFTP Server Root Input Field', async ({ page }) => { const label = await page.$('#content-pxetftp label:has-text("TFTP Server Root")'); expect(label).toBeTruthy(); const inputField = await page.locator('#tftp-root'); const inputFieldIsVisible = await inputField.isVisible(); expect(inputFieldIsVisible).toBeTruthy(); }); test('Network Boot Image', async ({ page }) => { const label = await page.$('#content-pxetftp label:has-text("Network Boot Image")'); expect(label).toBeTruthy(); }); test('Network Boot Image Input Field', async ({ page }) => { const label = await page.$('#content-pxetftp label:has-text("Network Boot Image")'); expect(label).toBeTruthy(); const inputField = await page.locator('#tftp-boot-image'); const inputFieldIsVisible = await inputField.isVisible(); expect(inputFieldIsVisible).toBeTruthy(); }); test('Save Button', async ({ page }) => { const button = page.locator('#content-pxetftp button.button.green:has-text("Save")'); expect(button).toBeTruthy(); }); test('check Add New PXE Boot Option visible', async ({ page }) => { await page.waitForSelector('#newPxeOption'); const addButton = await page.locator('#newPxeOption'); await addButton.click(); await page.waitForSelector('#newPxe'); const section = await page.locator('#newPxe'); const isSectionVisible = await section.isVisible(); expect(isSectionVisible).toBe(true); const label = await page.$('#content-pxetftp p:has-text("New PXE Boot Option")'); expect(label).toBeTruthy(); const fileName = await page.$('#content-pxetftp p:has-text("Filename")'); expect(fileName).toBeTruthy(); const fileNameInputField = await page.locator('#pxe-filename'); const fileNameInputFieldIsVisible = await fileNameInputField.isVisible(); expect(fileNameInputFieldIsVisible).toBeTruthy(); const serverName = await page.$('#content-pxetftp p:has-text("Server Name")'); expect(serverName).toBeTruthy(); const serverNameInputField = await page.locator('#pxe-server-name'); const serverNameInputFieldIsVisible = await serverNameInputField.isVisible(); expect(serverNameInputFieldIsVisible).toBeTruthy(); const serverAddress = await page.$('#content-pxetftp p:has-text("Server Address")'); expect(serverAddress).toBeTruthy(); const serverAddressInputField = await page.locator('#pxe-server-address'); const serverAddressInputFieldIsVisible = await serverAddressInputField.isVisible(); expect(serverAddressInputFieldIsVisible).toBeTruthy(); const dhcpOptions = await page.$('#content-pxetftp p:has-text("DHCP Options")'); expect(dhcpOptions).toBeTruthy(); const dhcpOptionsInputField = await page.locator('#pxe-dhcp-options'); const dhcpOptionsInputFieldIsVisible = await dhcpOptionsInputField.isVisible(); expect(dhcpOptionsInputFieldIsVisible).toBeTruthy(); const ForceDhcpOptions = await page.$('#content-pxetftp p:has-text("Force DHCP Options ")'); expect(ForceDhcpOptions).toBeTruthy(); const ForceDhcpOptionsToggle = await page.locator('#newPxe .pxe-force'); const ForceDhcpOptionsToggleIsVisible = await ForceDhcpOptionsToggle.isVisible(); expect(ForceDhcpOptionsToggleIsVisible).toBeTruthy(); const saveButton = page.locator('#newPxe button.button.green:has-text("Save")'); expect(saveButton).toBeTruthy(); const discardButton = page.locator('#discardPxeOption'); expect(discardButton).toBeTruthy(); }); }); });