@@ -42,24 +42,38 @@ test('should CRUD service with required fields', async ({ page }) => {
4242 await servicesPom . getAddServiceBtn ( page ) . click ( ) ;
4343 await servicesPom . isAddPage ( page ) ;
4444
45+
46+
47+
4548 await test . step ( 'submit with required fields' , async ( ) => {
4649 await uiFillServiceRequiredFields ( page , {
4750 name : serviceName ,
4851 } ) ;
49-
52+
53+ // Ensure upstream is valid. In some configurations (e.g. http&stream),
54+ // the backend might require a valid upstream configuration.
55+ const upstreamSection = page . getByRole ( 'group' , { name : 'Upstream' } ) . first ( ) ;
56+ const addNodeBtn = page . getByRole ( 'button' , { name : 'Add a Node' } ) ;
57+ await addNodeBtn . click ( ) ;
58+
59+ const rows = upstreamSection . locator ( 'tr.ant-table-row' ) ;
60+ await rows . first ( ) . locator ( 'input' ) . first ( ) . fill ( '127.0.0.1' ) ;
61+ await rows . first ( ) . locator ( 'input' ) . nth ( 1 ) . fill ( '80' ) ;
62+ await rows . first ( ) . locator ( 'input' ) . nth ( 2 ) . fill ( '1' ) ;
63+
5064 // Ensure the name field is properly filled before submitting
5165 const nameField = page . getByRole ( 'textbox' , { name : 'Name' } ) . first ( ) ;
5266 await expect ( nameField ) . toHaveValue ( serviceName ) ;
53-
67+
5468 await servicesPom . getAddBtn ( page ) . click ( ) ;
55-
69+
5670 // Wait for either success or error toast (longer timeout for CI)
5771 const alertMsg = page . getByRole ( 'alert' ) ;
5872 await expect ( alertMsg ) . toBeVisible ( { timeout : 30000 } ) ;
59-
73+
6074 // Check if it's a success message
6175 await expect ( alertMsg ) . toContainText ( 'Add Service Successfully' , { timeout : 5000 } ) ;
62-
76+
6377 // Close the toast
6478 await alertMsg . getByRole ( 'button' ) . click ( ) ;
6579 await expect ( alertMsg ) . toBeHidden ( ) ;
0 commit comments