@@ -579,6 +579,53 @@ test.describe('survey', () => {
579
579
await page . getByTestId ( 'product-sidebar' ) . getByLabel ( 'Bar' , { exact : true } ) . click ( )
580
580
await expect ( page . locator ( '[for=survey-comment]' ) ) . not . toBeVisible ( )
581
581
} )
582
+
583
+ test ( 'add survey comment, then modify the survey comment' , async ( { page } ) => {
584
+ let fulfilled = 0
585
+ // Important to set this up *before* interacting with the page
586
+ // in case of possible race conditions.
587
+ await page . route ( '**/api/events' , ( route , request ) => {
588
+ route . fulfill ( { } )
589
+ expect ( request . method ( ) ) . toBe ( 'POST' )
590
+ fulfilled ++
591
+ // At the time of writing you can't get the posted payload
592
+ // when you use `navigator.sendBeacon(url, data)`.
593
+ // So we can't make assertions about the payload.
594
+ // See https://github.com/microsoft/playwright/issues/12231
595
+ } )
596
+
597
+ await page . goto ( '/get-started/foo/for-playwright' )
598
+
599
+ // The label is visually an SVG. Finding it by its `for` value feels easier.
600
+ await page . locator ( '[for=survey-yes]' ) . click ( )
601
+ await expect ( page . getByRole ( 'button' , { name : 'Next' } ) ) . toBeVisible ( )
602
+ await expect ( page . getByRole ( 'button' , { name : 'Send' } ) ) . not . toBeVisible ( )
603
+
604
+ await page . locator ( '[for=survey-comment]' ) . click ( )
605
+ await page . locator ( '[for=survey-comment]' ) . fill ( 'This is a comment' )
606
+ await page . getByRole ( 'button' , { name : 'Next' } ) . click ( )
607
+ await expect ( page . getByRole ( 'button' , { name : 'Cancel' } ) ) . toBeVisible ( )
608
+ await expect ( page . getByRole ( 'button' , { name : 'Send' } ) ) . toBeVisible ( )
609
+ await expect ( page . getByRole ( 'button' , { name : 'Next' } ) ) . not . toBeVisible ( )
610
+
611
+ await page . locator ( '[for=survey-comment]' ) . click ( )
612
+ await page . locator ( '[for=survey-comment]' ) . fill ( 'This is a modified comment' )
613
+ // The "Send" button should no longer be visible
614
+ // and the "Next" button should be visible
615
+ await expect ( page . getByRole ( 'button' , { name : 'Cancel' } ) ) . toBeVisible ( )
616
+ await expect ( page . getByRole ( 'button' , { name : 'Send' } ) ) . not . toBeVisible ( )
617
+ await expect ( page . getByRole ( 'button' , { name : 'Next' } ) ) . toBeVisible ( )
618
+ await page . getByRole ( 'button' , { name : 'Next' } ) . click ( )
619
+ await expect ( page . getByRole ( 'button' , { name : 'Cancel' } ) ) . toBeVisible ( )
620
+ await expect ( page . getByRole ( 'button' , { name : 'Send' } ) ) . toBeVisible ( )
621
+ await expect ( page . getByRole ( 'button' , { name : 'Next' } ) ) . not . toBeVisible ( )
622
+
623
+ await page . getByRole ( 'button' , { name : 'Send' } ) . click ( )
624
+ // One for the page view event, one for the thumbs up click, one for
625
+ // the submission.
626
+ expect ( fulfilled ) . toBe ( 1 + 2 )
627
+ await expect ( page . getByTestId ( 'survey-end' ) ) . toBeVisible ( )
628
+ } )
582
629
} )
583
630
584
631
test . describe ( 'rest API reference pages' , ( ) => {
0 commit comments