@@ -250,6 +250,8 @@ test.describe('Command bar tests', () => {
250
250
page,
251
251
homePage,
252
252
cmdBar,
253
+ scene,
254
+ editor,
253
255
} ) => {
254
256
await page . addInitScript ( async ( ) => {
255
257
localStorage . setItem (
@@ -265,20 +267,9 @@ test.describe('Command bar tests', () => {
265
267
)
266
268
} )
267
269
268
- const u = await getUtils ( page )
269
270
await page . setBodyDimensions ( { width : 1200 , height : 500 } )
270
-
271
271
await homePage . goToModelingScene ( )
272
-
273
- // Make sure the stream is up
274
- await u . openDebugPanel ( )
275
- await u . expectCmdLog ( '[data-message-type="execution-done"]' )
276
-
277
- await expect (
278
- page . getByRole ( 'button' , { name : 'Start Sketch' } )
279
- ) . not . toBeDisabled ( )
280
- await u . clearCommandLogs ( )
281
- await page . getByRole ( 'button' , { name : 'Extrude' } ) . isEnabled ( )
272
+ await scene . settled ( cmdBar )
282
273
283
274
let cmdSearchBar = page . getByPlaceholder ( 'Search commands' )
284
275
await page . keyboard . press ( 'ControlOrMeta+K' )
@@ -288,44 +279,121 @@ test.describe('Command bar tests', () => {
288
279
await cmdBar . cmdOptions . getByText ( 'Extrude' ) . click ( )
289
280
290
281
// Assert that we're on the selection step
291
- await expect ( page . getByRole ( 'button' , { name : 'Profiles' } ) ) . toBeDisabled ( )
282
+ await cmdBar . expectState ( {
283
+ stage : 'arguments' ,
284
+ commandName : 'Extrude' ,
285
+ currentArgKey : 'sketches' ,
286
+ currentArgValue : '' ,
287
+ headerArguments : {
288
+ Profiles : '' ,
289
+ Length : '' ,
290
+ } ,
291
+ highlightedHeaderArg : 'Profiles' ,
292
+ } )
292
293
// Select a face
293
- await page . mouse . move ( 700 , 200 )
294
- await page . mouse . click ( 700 , 200 )
294
+ await editor . selectText ( 'startProfile(at = [-6.95, 10.98])' )
295
295
await cmdBar . progressCmdBar ( )
296
296
297
297
// Assert that we're on the distance step
298
- await expect (
299
- page . getByRole ( 'button' , { name : 'length' , exact : false } )
300
- ) . toBeDisabled ( )
298
+ await cmdBar . expectState ( {
299
+ stage : 'arguments' ,
300
+ commandName : 'Extrude' ,
301
+ currentArgKey : 'length' ,
302
+ currentArgValue : '5' ,
303
+ headerArguments : {
304
+ Profiles : '1 profile' ,
305
+ Length : '' ,
306
+ } ,
307
+ highlightedHeaderArg : 'length' ,
308
+ } )
301
309
302
310
// Assert that the an alternative variable name is chosen,
303
311
// since the default variable name is already in use (distance)
304
312
await cmdBar . variableCheckbox . click ( )
305
313
await expect ( page . getByPlaceholder ( 'Variable name' ) ) . toHaveValue (
306
314
'length001'
307
315
)
308
-
309
- const continueButton = page . getByRole ( 'button' , { name : 'Continue' } )
310
- const submitButton = page . getByTestId ( 'command-bar-submit' )
311
- await continueButton . click ( )
316
+ await cmdBar . progressCmdBar ( )
312
317
313
318
// Review step and argument hotkeys
314
- await expect ( submitButton ) . toBeEnabled ( )
315
- await expect ( submitButton ) . toBeFocused ( )
316
- await submitButton . press ( 'Shift+Backspace' )
319
+ await cmdBar . expectState ( {
320
+ stage : 'review' ,
321
+ commandName : 'Extrude' ,
322
+ headerArguments : {
323
+ Profiles : '1 profile' ,
324
+ Length : '5' ,
325
+ } ,
326
+ } )
327
+ await page . keyboard . press ( 'Shift+Backspace' )
317
328
318
329
// Assert we're back on the distance step
319
330
await expect (
320
331
page . getByRole ( 'button' , { name : 'length' , exact : false } )
321
332
) . toBeDisabled ( )
322
333
323
- await continueButton . click ( )
324
- await submitButton . click ( )
334
+ await cmdBar . progressCmdBar ( )
325
335
326
- await u . waitForCmdReceive ( 'extrude' )
336
+ // Add optional arg
337
+ await cmdBar . expectState ( {
338
+ stage : 'review' ,
339
+ commandName : 'Extrude' ,
340
+ headerArguments : {
341
+ Profiles : '1 profile' ,
342
+ Length : '5' ,
343
+ } ,
344
+ } )
345
+ await cmdBar . clickOptionalArgument ( 'bidirectionalLength' )
346
+ await cmdBar . expectState ( {
347
+ stage : 'arguments' ,
348
+ commandName : 'Extrude' ,
349
+ currentArgKey : 'bidirectionalLength' ,
350
+ currentArgValue : '' ,
351
+ headerArguments : {
352
+ Profiles : '1 profile' ,
353
+ Length : '5' ,
354
+ BidirectionalLength : '' ,
355
+ } ,
356
+ highlightedHeaderArg : 'bidirectionalLength' ,
357
+ } )
358
+ await page . keyboard . type ( '10' ) // Set bidirectional length
359
+ await cmdBar . progressCmdBar ( )
360
+ await cmdBar . expectState ( {
361
+ stage : 'review' ,
362
+ commandName : 'Extrude' ,
363
+ headerArguments : {
364
+ Profiles : '1 profile' ,
365
+ Length : '5' ,
366
+ BidirectionalLength : '10' ,
367
+ } ,
368
+ } )
327
369
328
- await expect ( page . locator ( '.cm-content' ) ) . toContainText (
370
+ // Clear optional arg
371
+ await page . getByRole ( 'button' , { name : 'BidirectionalLength' } ) . click ( )
372
+ await cmdBar . expectState ( {
373
+ stage : 'arguments' ,
374
+ commandName : 'Extrude' ,
375
+ currentArgKey : 'bidirectionalLength' ,
376
+ currentArgValue : '10' ,
377
+ headerArguments : {
378
+ Profiles : '1 profile' ,
379
+ Length : '5' ,
380
+ BidirectionalLength : '10' ,
381
+ } ,
382
+ highlightedHeaderArg : 'bidirectionalLength' ,
383
+ } )
384
+ await cmdBar . clearNonRequiredButton . click ( )
385
+ await cmdBar . expectState ( {
386
+ stage : 'review' ,
387
+ commandName : 'Extrude' ,
388
+ headerArguments : {
389
+ Profiles : '1 profile' ,
390
+ Length : '5' ,
391
+ } ,
392
+ } )
393
+
394
+ await cmdBar . progressCmdBar ( )
395
+ await scene . settled ( cmdBar )
396
+ await editor . expectEditor . toContain (
329
397
'extrude001 = extrude(sketch001, length = length001)'
330
398
)
331
399
} )
@@ -659,6 +727,8 @@ theta = 45deg
659
727
)
660
728
} )
661
729
730
+ // TODO: add pw test for clear non-required arg button
731
+
662
732
test ( 'Command palette can be opened via query parameter' , async ( {
663
733
page,
664
734
homePage,
0 commit comments