@@ -14,6 +14,7 @@ import {
1414 expectRowVisible ,
1515 expectVisible ,
1616 selectOption ,
17+ sleep ,
1718 test ,
1819 type Page ,
1920} from './utils'
@@ -550,8 +551,22 @@ test('create instance with additional disks', async ({ page }) => {
550551 // verify that an existing name can't be used
551552 await createForm . getByRole ( 'textbox' , { name : 'Name' , exact : true } ) . fill ( 'disk-6' )
552553
553- // this fill fails to happen sometimes, causing test flakes. the assert here
554- // should catch it slightly sooner
554+ // If we try to fill the size field too soon after render (unnaturally fast --
555+ // a real user would not be able to do it), the value gets quickly overwritten
556+ // back to the default of 10, possibly because there are renders already in
557+ // flight by the type we fill. This causes test flakes where the field is 10
558+ // after we've filled 5 and the disk we're creating ends up with 10 GiB in
559+ // the table. The flakes happened in Safari, but by adding a sleep _after_ the
560+ // fill but before the check, we can force the failure in every browser. By
561+ // waiting a bit here _before_ the fill, we give those renders a chance to
562+ // wrap up before we fill.
563+ //
564+ // This is a HACK -- logging in instance create and disk create shows that
565+ // disk create does seem to render again a few hundred ms after the initial
566+ // one, and it appears driven by renders in instance create (specifically the
567+ // usePrefetchedApiQuery calls), but I wasn't able to fix it for real.
568+ await sleep ( 1000 )
569+
555570 const sizeField = createForm . getByRole ( 'textbox' , { name : 'Size (GiB)' } )
556571 await sizeField . fill ( '5' )
557572 await expect ( sizeField ) . toHaveValue ( '5' )
0 commit comments