Skip to content

Commit c07ed7f

Browse files
Add files via upload
1 parent a81d78f commit c07ed7f

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

tests/RPM/utils/patternFunctions.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async function checkPatternConstraint(page, constraint, hasDescription, hasPatte
2727

2828
// Fill in the name and description if provided
2929
if (constraint) {
30-
await page.locator('#name').fill(constraint);
30+
await page.locator('input[id=name]').fill(constraint);
3131
}
3232
if (hasDescription) {
3333
await page.locator('textarea[id=description]').fill('Test constraint');
@@ -52,12 +52,12 @@ async function checkPatternConstraint(page, constraint, hasDescription, hasPatte
5252
if (!constraint && !hasDescription && hasPatternType && !hasExpInput) {
5353
await page.waitForLoadState('load');
5454
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;
6161
}
6262
else if (constraint && !hasDescription && hasPatternType && !hasExpInput) {
6363
await page.waitForLoadState('load');
@@ -101,13 +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();
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+
111116
}
112117
}
113118

@@ -225,4 +230,4 @@ module.exports = {
225230
findPatternConstraint,
226231
editPatternDescription,
227232
findEditedPatternConstraint
228-
};
233+
};

0 commit comments

Comments
 (0)