From 79bd42aa72bfb7c9a5fdb7d6d9f7e28f59e4f301 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 24 Jun 2026 12:50:10 +0000 Subject: [PATCH] Add playwright test --- .../tests/pages/pui_dashboard.spec.ts | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/frontend/tests/pages/pui_dashboard.spec.ts b/src/frontend/tests/pages/pui_dashboard.spec.ts index eca6c9a004..b90d115fa6 100644 --- a/src/frontend/tests/pages/pui_dashboard.spec.ts +++ b/src/frontend/tests/pages/pui_dashboard.spec.ts @@ -38,6 +38,53 @@ test('Dashboard - Basic', async ({ browser }) => { await page.getByText('Overdue Sales Orders').waitFor(); await page.getByText('Overdue Purchase Orders').waitFor(); + // Enter edit mode and verify widgets can be dragged to new positions + await page.getByLabel('dashboard-menu').click(); + await page.getByRole('menuitem', { name: 'Edit Layout' }).click(); + + const salesItem = page + .locator('.react-grid-item') + .filter({ hasText: 'Overdue Sales Orders' }); + const purchaseItem = page + .locator('.react-grid-item') + .filter({ hasText: 'Overdue Purchase Orders' }); + + const salesBoxBefore = await salesItem.boundingBox(); + const purchaseBoxBefore = await purchaseItem.boundingBox(); + expect(salesBoxBefore).not.toBeNull(); + expect(purchaseBoxBefore).not.toBeNull(); + + // Drag the sales widget toward the purchase widget + await salesItem.dragTo(purchaseItem); + await page.waitForTimeout(500); + + // At least one of the two widgets should have moved + const salesBoxAfter = await salesItem.boundingBox(); + const purchaseBoxAfter = await purchaseItem.boundingBox(); + const totalDelta = + Math.abs((salesBoxAfter?.x ?? 0) - salesBoxBefore!.x) + + Math.abs((salesBoxAfter?.y ?? 0) - salesBoxBefore!.y) + + Math.abs((purchaseBoxAfter?.x ?? 0) - purchaseBoxBefore!.x) + + Math.abs((purchaseBoxAfter?.y ?? 0) - purchaseBoxBefore!.y); + expect(totalDelta).toBeGreaterThan(10); + + // Drag the purchase widget to the right of the screen + const purchaseBoxMid = await purchaseItem.boundingBox(); + expect(purchaseBoxMid).not.toBeNull(); + const pStartX = purchaseBoxMid!.x + purchaseBoxMid!.width / 2; + const pStartY = purchaseBoxMid!.y + purchaseBoxMid!.height / 2; + await page.mouse.move(pStartX, pStartY); + await page.mouse.down(); + await page.mouse.move(pStartX + 400, pStartY, { steps: 20 }); + await page.mouse.up(); + await page.waitForTimeout(500); + + const purchaseBoxRight = await purchaseItem.boundingBox(); + expect(purchaseBoxRight!.x).toBeGreaterThan(purchaseBoxMid!.x); + + // Accept the layout before the remove step + await page.getByLabel('dashboard-accept-layout').click(); + // Let's remove one of the widgets await page.getByLabel('dashboard-menu').click(); await page.getByRole('menuitem', { name: 'Remove Widgets' }).click();