Skip to content

Commit c861e47

Browse files
Resolved issues for execution of pattern constraints management #12
1 parent 1bac241 commit c861e47

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

tests/RPM/utils/patternFunctions.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ async function checkPatternConstraint(page, constraint, hasDescription, hasPatte
4949
}
5050

5151
// Handling different conditions based on parameters
52-
if (!constraint && !hasDescription && hasPatternType) {
52+
if (!constraint && !hasDescription && hasPatternType && !hasExpInput) {
5353
await page.waitForLoadState('load');
5454
await page.waitForTimeout(1500);
5555
// Check if the save button is disabled and reload the page
5656
const saveButton = page.locator('button#save');
5757
await expect(saveButton).toBeDisabled();
58-
await page.reload()
58+
await page.reload();
5959
// Set the value
6060
handler.constraintDelete = true;
6161
}
62-
else if (constraint && !hasDescription && hasPatternType) {
62+
else if (constraint && !hasDescription && hasPatternType && !hasExpInput) {
6363
await page.waitForLoadState('load');
6464
await page.waitForTimeout(1500);
6565
// Check if the save button is disabled and reload the page
@@ -79,7 +79,7 @@ async function checkPatternConstraint(page, constraint, hasDescription, hasPatte
7979
// Set the value
8080
handler.constraintDelete = true;
8181
}
82-
else if (constraint && hasDescription && hasPatternType) {
82+
else if (constraint && hasDescription && hasPatternType && !hasExpInput) {
8383
await page.waitForLoadState('load');
8484
await page.waitForTimeout(1500);
8585
// Click on save button and wait for toast message
@@ -101,12 +101,18 @@ async function checkPatternConstraint(page, constraint, hasDescription, hasPatte
101101
else if (!constraint && !hasDescription && hasPatternType && hasExpInput) {
102102
await page.waitForLoadState('load');
103103
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();
104+
// Click on save button and wait for toast message
105+
await page.click('#save');
108106
// 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
109113
handler.constraintDelete = true;
114+
await page.reload();
115+
110116
}
111117
}
112118

@@ -172,7 +178,7 @@ async function editPatternDescription(page, constraint) {
172178
await page
173179
.locator('textarea[id=description]')
174180
.fill('Test constraint edited');
175-
// Wait for 500 milliseconds
181+
// Wait for 500 milliseconds
176182
await page.waitForTimeout(500);
177183
await page.locator('input[id=name]').fill(constraint);
178184
await page.locator('textarea[id=description]').fill('Test edited pattern constraint');

0 commit comments

Comments
 (0)