test: consolidate automations page suites (#28953)

This commit is contained in:
Neil
2026-10-14 20:33:42 -07:00
committed by GitHub
parent d717798055
commit 1d60a21cbd
10 changed files with 30 additions and 17 deletions
@@ -0,0 +1,9 @@
// @vitest-environment happy-dom
import './AutomationsPage.cross-authority-actions.spec'
import './AutomationsPage.escape-precedence.spec'
import './AutomationsPage.external-scope.spec'
import './AutomationsPage.notice-recovery.spec'
import './AutomationsPage.refresh-selection.spec'
import './AutomationsPage.run-visibility.spec'
import './AutomationsPage.save-visibility.spec'
import './AutomationsPage.strict-mode-save-visibility.spec'
@@ -25,8 +25,6 @@ import {
import { listedRows } from './automations-page-listed-items'
import { makeAutomation } from './automations-page-fixtures'
installAutomationsPageHarness()
/** Desktop and runtime both hold `a-1`; the runtime's row is committed last. */
async function collidingHosts(): Promise<void> {
runtimeHost([makeAutomation({ id: 'a-1', name: 'Remote nightly' })], [])
@@ -52,6 +50,8 @@ function runtimeAutomationCalls(): string[] {
}
describe('AutomationsPage row actions under a colliding automation id', () => {
installAutomationsPageHarness()
it('names the selected row’s own host, not the desktop that listed it', async () => {
await collidingHosts()
await renderPage()
@@ -15,8 +15,6 @@ import {
settleHostQueries
} from './automations-page-test-harness'
installAutomationsPageHarness()
function pressEscape(target: EventTarget): KeyboardEvent {
const event = new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true })
target.dispatchEvent(event)
@@ -32,6 +30,8 @@ async function renderWithCloseSpy(): Promise<ReturnType<typeof vi.fn>> {
}
describe('automations page Escape precedence', () => {
installAutomationsPageHarness()
it('closes the page when nothing is layered above it', async () => {
const closeAutomationsPage = await renderWithCloseSpy()
@@ -23,8 +23,6 @@ import {
import { listedExternalEntries } from './automations-page-listed-items'
import { makeExternalManager } from './automations-page-fixtures'
installAutomationsPageHarness()
const DESKTOP_SELF_FILTER = {
kind: 'host' as const,
host: { authority: { kind: 'desktop' as const }, selector: { kind: 'self' as const } }
@@ -67,6 +65,8 @@ function openclawOnly(): void {
}
describe('AutomationsPage external manager probes', () => {
installAutomationsPageHarness()
it('probes no SSH host when the selection is the local desktop', async () => {
withSshHosts('staging', 'web-01', 'web-02')
mocks.state.automationHostFilter = DESKTOP_SELF_FILTER
@@ -28,8 +28,6 @@ import {
import { listedRow } from './automations-page-listed-items'
import { makeAutomation } from './automations-page-fixtures'
installAutomationsPageHarness()
const FENCING_REQUIRED = 'The host changed: automation_owner_fencing_required'
/** Fails one runtime RPC the way an under-versioned server does, leaving the rest answering. */
@@ -54,6 +52,8 @@ function watchSettings(): { open: ReturnType<typeof vi.fn>; target: ReturnType<t
}
describe('AutomationsPage notice recovery', () => {
installAutomationsPageHarness()
it('sends the create dialog Update server to where that destination host is versioned', async () => {
api.automations.list.mockResolvedValue([])
scopedList([])
@@ -25,8 +25,6 @@ import {
import { listedRows } from './automations-page-listed-items'
import { makeAutomation, makeRun } from './automations-page-fixtures'
installAutomationsPageHarness()
async function openAutomationRow(container: HTMLElement, name: string): Promise<void> {
const row = [
...container.querySelectorAll<HTMLButtonElement>('[data-testid="automation-row"]')
@@ -37,6 +35,8 @@ async function openAutomationRow(container: HTMLElement, name: string): Promise<
}
describe('AutomationsPage refresh', () => {
installAutomationsPageHarness()
it('never asks a host for every run it has retained', async () => {
const run = makeRun({ id: 'run-1', automationId: 'a-1' })
api.automations.list.mockResolvedValue([makeAutomation({ id: 'a-1' })])
@@ -120,6 +120,8 @@ describe('AutomationsPage refresh', () => {
})
describe('AutomationsPage selection', () => {
installAutomationsPageHarness()
it('loads the first automation into the detail pane and fetches its runs', async () => {
const run = makeRun({ id: 'run-1', automationId: 'a-1' })
api.automations.list.mockResolvedValue([makeAutomation({ id: 'a-1', name: 'Nightly' })])
@@ -164,6 +166,8 @@ describe('AutomationsPage selection', () => {
})
describe('AutomationsPage multi-host selection', () => {
installAutomationsPageHarness()
it('keeps a selection that lives on another host when the window regains focus', async () => {
runtimeHost([makeAutomation({ id: 'a-remote', name: 'Remote nightly' })], [])
const desktop = makeAutomation({ id: 'a-desktop', name: 'Desktop nightly' })
@@ -24,8 +24,6 @@ import {
import { listedRow, listedRows } from './automations-page-listed-items'
import { makeAutomation } from './automations-page-fixtures'
installAutomationsPageHarness()
const DESKTOP_SELF_FILTER = {
kind: 'host' as const,
host: { authority: { kind: 'desktop' as const }, selector: { kind: 'self' as const } }
@@ -46,6 +44,8 @@ function listedNextRunAt(): number | null | undefined {
}
describe('AutomationsPage run visibility', () => {
installAutomationsPageHarness()
it('shows the post-run schedule the host reports, not the row the run started from', async () => {
desktopStoreHolds([BEFORE_RUN])
mocks.state.automationHostFilter = DESKTOP_SELF_FILTER
@@ -24,8 +24,6 @@ import {
} from './automations-page-test-harness'
import { makeAutomation, REPO_ID, WORKSPACE_ID } from './automations-page-fixtures'
installAutomationsPageHarness()
const DESKTOP_SELF_FILTER = {
kind: 'host' as const,
host: { authority: { kind: 'desktop' as const }, selector: { kind: 'self' as const } }
@@ -60,6 +58,8 @@ async function createSweep(): Promise<void> {
}
describe('AutomationsPage save visibility', () => {
installAutomationsPageHarness()
it('lists a newly created automation on the host it was saved to', async () => {
desktopStoreHolds([])
mocks.state.automationHostFilter = DESKTOP_SELF_FILTER
@@ -31,8 +31,6 @@ import {
} from './automations-page-test-harness'
import { makeAutomation, REPO_ID, WORKSPACE_ID } from './automations-page-fixtures'
installAutomationsPageHarness()
const CREATED = makeAutomation({ id: 'a-new', name: 'Sweep' })
const RUNTIME_SELF_KEY = hostStableKey({
@@ -66,6 +64,8 @@ async function createSweep(): Promise<void> {
}
describe('AutomationsPage save visibility under StrictMode', () => {
installAutomationsPageHarness()
it('lists a newly created automation without a reload', async () => {
desktopStoreHolds([])
api.automations.create.mockResolvedValue(CREATED)
@@ -399,7 +399,7 @@ export function rows(container: HTMLElement, testId: string): string[] {
)
}
/** Registers the reset both page test files depend on; call once per file. */
/** Registers the per-case store reset and renderer cleanup for the current suite. */
export function installAutomationsPageHarness(): void {
beforeEach(() => {
globalThis.IS_REACT_ACT_ENVIRONMENT = true