@@ -24,8 +24,6 @@ test('Should render form fields', async ({ page }) => {
24
24
const data = parsedData . parameters . data ;
25
25
expect ( data . actionKey ) . toBe ( 'submit' ) ;
26
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
27
[ 'text-input-key' ] : 'This is some text' ,
30
28
[ 'dropdown-field-key' ] : '' ,
31
29
[ 'radio-group-key' ] : '' ,
@@ -39,29 +37,31 @@ test('should render form validation fields', async ({ page }) => {
39
37
await expect ( page . locator ( '#form' ) ) . toContainText ( 'Form Validation' ) ;
40
38
await page . getByRole ( 'button' , { name : 'Form Validation' } ) . click ( ) ;
41
39
await expect ( page . getByRole ( 'heading' , { name : 'Form Fields Validation' } ) ) . toBeVisible ( ) ;
42
- await expect ( page . getByText ( 'Username' ) ) . toBeVisible ( ) ;
43
- await expect ( page . getByRole ( 'textbox' , { name : 'Username' } ) ) . toBeVisible ( ) ;
44
- await expect ( page . getByText ( 'Email Address' ) ) . toBeVisible ( ) ;
45
- await expect ( page . getByRole ( 'textbox' , { name : 'Email Address' } ) ) . toBeVisible ( ) ;
46
- await expect ( page . getByRole ( 'button' , { name : 'Submit' } ) ) . toBeVisible ( ) ;
47
- await page . getByRole ( 'textbox' , { name : 'Username' } ) . click ( ) ;
40
+
48
41
await page . getByRole ( 'textbox' , { name : 'Username' } ) . fill ( 'sdk-user' ) ;
49
42
await expect ( page . getByRole ( 'textbox' , { name : 'Username' } ) ) . toHaveValue ( 'sdk-user' ) ;
50
- await page . getByRole ( 'textbox' , { name : 'Email Address' } ) . click ( ) ;
43
+
44
+ const password = page . getByRole ( 'textbox' , { name : 'Password' } ) ;
45
+ await password . type ( 'password' ) ;
46
+ await expect ( password ) . toHaveValue ( 'password' ) ;
47
+
51
48
await page . getByRole ( 'textbox' , { name :
'Email Address' } ) . fill ( '[email protected] ' ) ;
52
49
await expect ( page . getByRole ( 'textbox' , { name : 'Email Address' } ) ) . toHaveValue (
53
50
54
51
) ;
52
+
55
53
const requestPromise = page . waitForRequest ( ( request ) => request . url ( ) . includes ( '/customForm' ) ) ;
56
54
await page . getByRole ( 'button' , { name : 'Submit' } ) . click ( ) ;
55
+
57
56
const request = await requestPromise ;
58
57
const parsedData = JSON . parse ( request . postData ( ) ) ;
58
+
59
59
const data = parsedData . parameters . data ;
60
+
60
61
expect ( data . actionKey ) . toBe ( 'submit' ) ;
61
62
expect ( data . formData ) . toEqual ( {
62
- [ 'undefined' ] : '' ,
63
- 'user.username' : '' ,
64
- 'user.password' : '' ,
65
- 'user.email' : '' ,
63
+ 'user.username' : 'sdk-user' ,
64
+ 'user.password' : 'password' ,
65
+ 'user.email' :
'[email protected] ' ,
66
66
} ) ;
67
67
} ) ;
0 commit comments