@@ -6,9 +6,10 @@ import { addWorktree, fakeWorktrees, git, makeRepo } from '../support/daemon-hos
66import { installRemote } from '../support/fake-ssh.js' ;
77import { freePort , type HubHost } from '../support/hub-host.js' ;
88import { remoteHub } from '../support/remote-hub.js' ;
9- import { byTestId , hubsEntry , repoTab , TID , worktreeEntry } from './contract.js' ;
9+ import { byTestId , hubsEntry , repoTab , terminalBox , TID , worktreeEntry } from './contract.js' ;
1010import {
1111 expect ,
12+ LOCAL ,
1213 makeRepoWith ,
1314 newTerminal ,
1415 nodeRemote ,
@@ -20,8 +21,11 @@ import {
2021 selectWorktree ,
2122 stopHub ,
2223 test ,
24+ waitScreen ,
25+ watcher ,
2326 writeHubConfig ,
2427} from './fixture.js' ;
28+ import { pickerSeen , watchPicker } from './panes.js' ;
2529import type { BrowserMessage , HubMessage , WireRecorder } from './wire.js' ;
2630
2731const ENABLED_TITLE = 'Open in editor (right-click to change the command)' ;
@@ -225,6 +229,51 @@ test.describe('open in editor', () => {
225229 await expect ( control ( page ) ) . toBeEnabled ( ) ;
226230 } ) ;
227231
232+ test ( 'while the failure dialog is open shortcuts act not; once it closes, the terminal takes typed input' , async ( { hub, page } ) => {
233+ const route = await routeEditor ( page ) ;
234+ const { repo } = makeRepoWith ( hub , 'app' , [ ] ) ;
235+ configure ( hub , [ repo ] , null ) ;
236+ await openUi ( hub , page ) ;
237+ const term = await newTerminal ( page ) ;
238+ await ready ( page , term ) ;
239+ await control ( page ) . click ( ) ;
240+ route . answer ( { t : 'error' , req : await heldReq ( route ) , host : null , code : 'editor-missing' , message : 'kate' } ) ;
241+ await expect ( dialog ( page ) ) . toBeFocused ( ) ;
242+
243+ await watchPicker ( page ) ;
244+ await page . keyboard . press ( 'Control+Shift+KeyT' ) ;
245+ await page . waitForTimeout ( 300 ) ; // NOSONAR(S2925) — absence check: nothing to synchronise on
246+ expect ( await pickerSeen ( page ) ) . toBe ( false ) ;
247+ await expect ( dialog ( page ) ) . toBeFocused ( ) ;
248+ await page . keyboard . press ( 'Escape' ) ;
249+ await expect ( dialog ( page ) ) . toHaveCount ( 0 ) ;
250+ await page . keyboard . type ( "echo EDITOR''-CLOSED" ) ;
251+ await page . keyboard . press ( 'Enter' ) ;
252+ await waitScreen ( page , term , 'EDITOR-CLOSED' ) ;
253+ } ) ;
254+
255+ test ( 'preset choices shown while the failure dialog is open leave it the focus, and take it once it closes' , async ( { hub, page } ) => {
256+ const route = await routeEditor ( page ) ;
257+ const { repo } = makeRepoWith ( hub , 'app' , [ ] ) ;
258+ configure ( hub , [ repo ] , null ) ;
259+ await openUi ( hub , page ) ;
260+ const daemon = await watcher ( hub , repo ) ;
261+ const term = await daemon . create ( repo , { command : 'read -r _; exit 0' } ) ;
262+ await expect ( page . locator ( terminalBox ( LOCAL , term . termId ) ) ) . toBeVisible ( ) ;
263+ await control ( page ) . click ( ) ;
264+ route . answer ( { t : 'error' , req : await heldReq ( route ) , host : null , code : 'editor-missing' , message : 'kate' } ) ;
265+ await expect ( dialog ( page ) ) . toBeFocused ( ) ;
266+
267+ daemon . sendInput ( term . termId , '\r' ) ;
268+ const options = page . locator ( byTestId ( TID . presetChoices ) ) . locator ( byTestId ( TID . presetOption ) ) ;
269+ await expect ( options . nth ( 0 ) ) . toBeVisible ( ) ;
270+ await page . waitForTimeout ( 300 ) ; // NOSONAR(S2925) — absence check: nothing to synchronise on
271+ await expect ( dialog ( page ) ) . toBeFocused ( ) ;
272+ await page . keyboard . press ( 'Escape' ) ;
273+ await expect ( dialog ( page ) ) . toHaveCount ( 0 ) ;
274+ await expect ( options . nth ( 0 ) ) . toBeFocused ( ) ;
275+ } ) ;
276+
228277 test ( 'names the first word of the shown command as the missing program' , async ( { hub, page } ) => {
229278 const route = await routeEditor ( page ) ;
230279 const { repo } = makeRepoWith ( hub , 'app' , [ ] ) ;
0 commit comments