Skip to content

Commit 03fd323

Browse files
Edit function is added in variableFunctions.js #15
1 parent 162b58b commit 03fd323

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tests/RPM/utils/variableFunctions.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ async function editVariable(page) {
277277
await page.waitForSelector('.toast[data-testid=toast] .text-base');
278278
const toast = await page.locator('.toast[data-testid=toast]');
279279

280-
let expectedMessage = 'Variable Template created.';
280+
let expectedMessage = 'Variable Template updated.';
281281
await expect(await toast.locator('.text-base')).toHaveText(expectedMessage);
282282
await toast.locator('button').click(); // Close the toast
283283
await page.reload();
@@ -304,11 +304,37 @@ async function deleteVariable(page) {
304304

305305
}
306306

307+
async function findEditedVariable(page, variable) {
308+
// await page.reload()
309+
await page.waitForLoadState('load');
310+
// Wait for 500 milliseconds
311+
await page.waitForTimeout(500);
312+
// Search for the variable
313+
await page.locator('#VariableTemplates-search').fill(variable);
314+
// Wait for 1000 milliseconds
315+
await page.waitForTimeout(1000);
316+
// Click on the Search button
317+
await page.click('form.flex > button:nth-child(2)');
318+
// Locate the correct row
319+
const row = page.locator('[id^=VariableTemplates-row-]');
320+
await expect(row).toHaveCount(1);
321+
// Get the index of the row
322+
const id = (await row.getAttribute('id'));
323+
const index = id.split('-')[2];
324+
// Check values for the row
325+
await expect(page.locator(`#VariableTemplates-name-${index}`)).toHaveText(variable);
326+
await expect(page.locator(`#VariableTemplates-description-${index}`)).toHaveText(
327+
'Test Edit Variable'
328+
);
329+
}
330+
331+
307332
module.exports = {
308333
checkVariables,
309334
deleteVariable,
310335
createVariable,
311336
findVariable,
312337
editVariable,
338+
findEditedVariable
313339
};
314340

0 commit comments

Comments
 (0)