Files
sencho/frontend/src/components/blueprints/StateReviewDialog.test.tsx
T
Anso f6c6ffea15 fix(blueprints): stop the deployment detail sheet flickering and show deploy progress (#1278)
* fix(blueprints): stop the blueprint detail sheet flickering while open

The Fleet > Deployments blueprint detail sheet reloaded its data on a short
timer while open, flickering the body through its loading skeleton every few
seconds.

The sheet's load effect was keyed on the refresh callback, which was memoized
with the parent's onOpenChange prop. The parent passes a fresh onOpenChange
closure on every render, so each parent re-render (driven by the Fleet view's
polling) recreated refresh, re-ran the load effect, and refetched the
blueprint. Every refetch flipped the loading flag, swapping the populated body
for skeletons and back.

Hold onOpenChange in a ref so refresh depends only on blueprintId. The load
effect now runs on open and on blueprint change, not on every parent render.
Switching to a different blueprint still refetches.

* fix(blueprints): keep the blueprint detail body visible during a refresh

After the sheet has loaded, a reload triggered by an action (apply, withdraw,
accept, enable/disable, save) flipped the loading flag and swapped the whole
body for skeletons until the reload finished, a brief flash on every action.

Gate the skeleton on whether the blueprint has loaded yet, not on the loading
flag. The skeleton now shows only on the first load; later reloads keep the
populated body, deployment table, and compose source on screen while they run.

* fix(blueprints): show progress while a fresh deploy runs

Confirming a fresh deploy from the blueprint detail sheet starts a remote
deploy that can take several seconds. The button only became disabled with no
other change, so the action looked frozen.

Show a spinner and a "Deploying" label on the button while the deploy runs, and
dim it, so the click clearly registers as in progress.
2026-06-02 09:50:51 -04:00

31 lines
1.1 KiB
TypeScript

/**
* The fresh-deploy action triggers a remote deploy that can take several seconds.
* The dialog must show an in-progress indicator while it runs, otherwise the click
* looks like it did nothing.
*/
import { describe, it, expect } from 'vitest';
import { render, screen } from '@testing-library/react';
import { StateReviewDialog } from './StateReviewDialog';
const baseProps = {
open: true,
onOpenChange: () => {},
blueprintName: 'heimdall',
nodeName: 'sencho-test-01',
onAccept: () => {},
};
describe('StateReviewDialog', () => {
it('offers the fresh deploy action when idle', () => {
render(<StateReviewDialog {...baseProps} busy={false} />);
expect(screen.getByText('Deploy fresh')).toBeInTheDocument();
expect(screen.queryByText(/deploying/i)).not.toBeInTheDocument();
});
it('shows an in-progress indicator and disables the action while deploying', () => {
render(<StateReviewDialog {...baseProps} busy />);
expect(screen.getByText(/deploying/i)).toBeInTheDocument();
expect(screen.getByRole('button', { name: /deploying/i })).toBeDisabled();
});
});