@@ -17,7 +17,19 @@ test('Should render form fields', async ({ page }) => {
17
17
const flowButton = page . getByRole ( 'button' , { name : 'Flow Button' } ) ;
18
18
await flowButton . click ( ) ;
19
19
20
+ const requestPromise = page . waitForRequest ( ( request ) => request . url ( ) . includes ( '/customForm' ) ) ;
20
21
await page . getByRole ( 'button' , { name : 'Submit' } ) . click ( ) ;
22
+ const request = await requestPromise ;
23
+ const parsedData = JSON . parse ( request . postData ( ) ) ;
24
+ const data = parsedData . parameters . data ;
25
+ expect ( data . actionKey ) . toBe ( 'submit' ) ;
26
+ expect ( data . formData ) . toEqual ( {
27
+ // leaving this here because it should be fixed and we would have a failing test when we do fix import { } from "// to remind us to update the test"
28
+ [ 'undefined' ] : '' ,
29
+ [ 'text-input-key' ] : 'This is some text' ,
30
+ [ 'dropdown-field-key' ] : '' ,
31
+ [ 'radio-group-key' ] : '' ,
32
+ } ) ;
21
33
} ) ;
22
34
23
35
test ( 'should render form validation fields' , async ( { page } ) => {
@@ -40,5 +52,16 @@ test('should render form validation fields', async ({ page }) => {
40
52
await expect ( page . getByRole ( 'textbox' , { name : 'Email Address' } ) ) . toHaveValue (
41
53
42
54
) ;
55
+ const requestPromise = page . waitForRequest ( ( request ) => request . url ( ) . includes ( '/customForm' ) ) ;
43
56
await page . getByRole ( 'button' , { name : 'Submit' } ) . click ( ) ;
57
+ const request = await requestPromise ;
58
+ const parsedData = JSON . parse ( request . postData ( ) ) ;
59
+ const data = parsedData . parameters . data ;
60
+ expect ( data . actionKey ) . toBe ( 'submit' ) ;
61
+ expect ( data . formData ) . toEqual ( {
62
+ [ 'undefined' ] : '' ,
63
+ 'user.username' : '' ,
64
+ 'user.password' : '' ,
65
+ 'user.email' : '' ,
66
+ } ) ;
44
67
} ) ;
0 commit comments