@@ -27,7 +27,7 @@ async function checkPatternConstraint(page, constraint, hasDescription, hasPatte
27
27
28
28
// Fill in the name and description if provided
29
29
if ( constraint ) {
30
- await page . locator ( '# name' ) . fill ( constraint ) ;
30
+ await page . locator ( 'input[id= name] ' ) . fill ( constraint ) ;
31
31
}
32
32
if ( hasDescription ) {
33
33
await page . locator ( 'textarea[id=description]' ) . fill ( 'Test constraint' ) ;
@@ -52,12 +52,12 @@ async function checkPatternConstraint(page, constraint, hasDescription, hasPatte
52
52
if ( ! constraint && ! hasDescription && hasPatternType && ! hasExpInput ) {
53
53
await page . waitForLoadState ( 'load' ) ;
54
54
await page . waitForTimeout ( 1500 ) ;
55
- // Check if the save button is disabled and reload the page
56
- const saveButton = page . locator ( 'button#save' ) ;
57
- await expect ( saveButton ) . toBeDisabled ( ) ;
58
- await page . reload ( ) ;
59
- // Set the value
60
- handler . constraintDelete = true ;
55
+ // Check if the save button is disabled and reload the page
56
+ const saveButton = page . locator ( 'button#save' ) ;
57
+ await expect ( saveButton ) . toBeDisabled ( ) ;
58
+ await page . reload ( ) ;
59
+ // Set the value
60
+ handler . constraintDelete = true ;
61
61
}
62
62
else if ( constraint && ! hasDescription && hasPatternType && ! hasExpInput ) {
63
63
await page . waitForLoadState ( 'load' ) ;
@@ -101,13 +101,18 @@ async function checkPatternConstraint(page, constraint, hasDescription, hasPatte
101
101
else if ( ! constraint && ! hasDescription && hasPatternType && hasExpInput ) {
102
102
await page . waitForLoadState ( 'load' ) ;
103
103
await page . waitForTimeout ( 1500 ) ;
104
- // Check if the save button is disabled and reload the page
105
- const saveButton = page . locator ( 'button#save' ) ;
106
- await expect ( saveButton ) . toBeDisabled ( ) ;
107
- await page . reload ( ) ;
108
- // Set the value
109
- handler . constraintDelete = true ;
110
-
104
+ // Click on save button and wait for toast message
105
+ await page . click ( '#save' ) ;
106
+ // Set the value
107
+ await page . waitForSelector ( '.toast[data-testid=toast] .text-base' ) ;
108
+ const toast = await page . locator ( '.toast[data-testid=toast]' ) ;
109
+ let expectedMessage = "Can't save Constraint \"null\" .Name is Null or Empty" ;
110
+
111
+ await expect ( await toast . locator ( '.text-base' ) ) . toHaveText ( expectedMessage ) ;
112
+ await toast . locator ( 'button' ) . click ( ) ; // Close the toast
113
+ handler . constraintDelete = true ;
114
+ await page . reload ( ) ;
115
+
111
116
}
112
117
}
113
118
@@ -225,4 +230,4 @@ module.exports = {
225
230
findPatternConstraint,
226
231
editPatternDescription,
227
232
findEditedPatternConstraint
228
- } ;
233
+ } ;
0 commit comments