import { expect, test } from '@playwright/test'; import { expectOnlineCrucibleCard, loginToDashboard } from './fixtures'; import { ensureLiveStubAgent, isLiveStubReady } from './live-stub'; import { E2E_STUB_AGENT_HOSTNAME, E2E_STUB_AGENT_ID } from './stub-agent'; test.describe('Crucible bulk command', () => { test.beforeAll(async ({ request }) => { await ensureLiveStubAgent(request); }); test.beforeEach(async ({ page }) => { test.skip( !isLiveStubReady(), 'Requires live E2E server (test-suite phase 8 on :18989 or AETHERFORGE_URL)', ); await loginToDashboard(page); await page.getByRole('link', { name: /Crucible/i }).click(); await expect(page.getByRole('heading', { name: 'Crucible' })).toBeVisible({ timeout: 10_000 }); await expect( page.locator('.crucible-node-card').filter({ hasText: E2E_STUB_AGENT_HOSTNAME }), ).toBeVisible({ timeout: 15_000 }); }); test('bulk pause on selected online node fires POST bulk-command', async ({ page }) => { const card = await expectOnlineCrucibleCard(page, E2E_STUB_AGENT_HOSTNAME); await card.click(); await expect(page.locator('.fleet-bulk-bar').getByText(/1 selected/)).toBeVisible({ timeout: 10_000, }); await expect( page.locator('.crucible-actions-card').getByText(new RegExp(`→ ${E2E_STUB_AGENT_HOSTNAME}`)), ).toBeVisible(); const bulkRequest = page.waitForRequest( (req) => req.method() === 'POST' && req.url().includes('/api/v1/agents/bulk-command'), ); await page .locator('.crucible-actions-card') .getByRole('button', { name: 'Pause', exact: true }) .click(); const request = await bulkRequest; expect(request.postDataJSON()).toEqual({ agent_ids: [E2E_STUB_AGENT_ID], action: 'pause', }); }); });