Skip to content

Commit 8e0c20b

Browse files
Adding functions for check constariant to variableFunctions.js #17
1 parent f1ba9c7 commit 8e0c20b

File tree

1 file changed

+72
-3
lines changed

1 file changed

+72
-3
lines changed

tests/RPM/utils/variableFunctions.js

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ async function createVariable(page, variableName) {
169169
await page.waitForLoadState('load');
170170
await page.locator('#create').click();
171171
await page.waitForLoadState('load');
172-
await page.waitForTimeout(4000);
172+
await page.waitForTimeout(4250);
173173
await page.locator('#create').click();
174-
await page.waitForTimeout(250);
174+
await page.waitForTimeout(350);
175175

176176
// Adding name
177177
await page.waitForTimeout(250);
@@ -328,13 +328,82 @@ async function findEditedVariable(page, variable) {
328328
);
329329
}
330330

331+
async function checkConstraint(page) {
332+
await page.waitForLoadState('load');
333+
await page.locator('#create').click();
334+
await page.waitForLoadState('load');
335+
await page.waitForTimeout(4250);
336+
await page.locator('#create').click();
337+
await page.waitForTimeout(300);
338+
339+
try {
340+
// Click on the dropdown
341+
await page.locator('#constraints').click();
342+
await page.waitForTimeout(500);
343+
344+
let option;
345+
try {
346+
// Check if the "TestConstraint" exists
347+
await page.waitForSelector('.list-item .item:text("Test Constraint")', { visible: true, timeout: 500 });
348+
349+
350+
} catch (error) {
351+
352+
// Perform actions if the element is not found
353+
// Click on the SVG element
354+
await page.waitForSelector('div.hidden:nth-child(4)', { visible: true });
355+
356+
// Click on the div element
357+
await page.click('div.hidden:nth-child(4)');
358+
await page.waitForSelector('text="Manage Constraints"', { visible: true });
359+
360+
// Click on the div element
361+
await page.click('text="Manage Constraints"');
362+
await page.waitForLoadState('load');
363+
await page.waitForTimeout(1000);
364+
await page.locator('#create').click();
365+
await page.waitForTimeout(1000);
366+
await page.locator('input[id=name]').fill("Test Constraint");
367+
await page.locator('textarea[id=description]').fill('Test constraint');
368+
await page.selectOption('#constraintTypes', 'Domain');
369+
await page.click('div.cm-activeLine.cm-line');
370+
await page.waitForTimeout(1000);
371+
await page.keyboard.type('Hello Testing Domain');
372+
await page.waitForTimeout(1000);
373+
await page.click('#save');
374+
await page.waitForSelector('.toast[data-testid=toast] .text-base');
375+
const toast = await page.locator('.toast[data-testid=toast]');
376+
await expect(await toast.locator('.text-base')).toHaveText(`Constraint "Test Constraint" saved.`);
377+
await toast.locator('button').click();
378+
console.log("Element 'Test Constraint' is added.");
379+
}
380+
381+
} catch (error) {
382+
console.log("An error occurred:", error);
383+
}
384+
}
385+
386+
async function navVariableManage(page) {
387+
388+
// Click on the div element
389+
await page.click('div.hidden:nth-child(4)');
390+
await page.waitForSelector('text="Manage Variable Templates"', { visible: true });
391+
392+
// Click on the div element
393+
await page.click('text="Manage Variable Templates"');
394+
}
395+
396+
331397

332398
module.exports = {
333399
checkVariables,
334400
deleteVariable,
335401
createVariable,
336402
findVariable,
337403
editVariable,
338-
findEditedVariable
404+
findEditedVariable,
405+
navVariableManage,
406+
checkConstraint
407+
339408
};
340409

0 commit comments

Comments
 (0)