Skip to content

Commit 9d99ad8

Browse files
xpath updated for all
1 parent c07ed7f commit 9d99ad8

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

tests/RPM/utils/dataStructureFunctions.js

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ async function checkDataStructure(page, hasTitle, hasDescription, hasPrimaryKey,
2929
}
3030
if (hasPrimaryKey) {
3131
// Click on make a part of primary key
32-
await page.click('xpath=//*[@id="0"]/div[2]/div[1]/div[2]/label/div');
32+
await page.click('text=Mark as part of primary key');
3333
}
34+
3435
if (hasOptionalValue) {
3536
// Click on optional value
36-
await page.click('xpath=//*[@id="0"]/div[2]/div[2]/div[2]/label/div');
37+
await page.click('text=Value can be optional');
3738
}
3839

39-
4040
if (hasName) {
4141
// Fill in the name input
42-
await page.locator('input[id=name]').fill(hasName);
42+
await page.locator('input[id=name-0]').fill(hasName);
4343
}
4444

4545
if (hasTitleDescription) {
@@ -57,7 +57,7 @@ async function checkDataStructure(page, hasTitle, hasDescription, hasPrimaryKey,
5757

5858
if (hasUnit) {
5959
// Click the on unit dropdown
60-
await page.click('div.value-container.svelte-u3g5ju > input#unit');
60+
await page.click('input[id=unit-0]');
6161
await page.waitForTimeout(500);
6262
const unit = await page.waitForSelector('.list-item .item:text("none")', { visible: true, enabled: true });
6363
await unit.click()
@@ -110,8 +110,9 @@ async function checkDataStructure(page, hasTitle, hasDescription, hasPrimaryKey,
110110
else if (hasTitle && hasDescription && hasPrimaryKey && hasOptionalValue && hasName && hasTitleDescription && hasDataType && !hasUnit) {
111111
await page.waitForLoadState('load');
112112
await page.waitForTimeout(1500);
113-
// Click on save button
114-
await page.click('#save');
113+
// Check if the save button is disabled and reload the page
114+
const saveButton = page.locator('button#save');
115+
await expect(saveButton).toBeDisabled();
115116

116117
}
117118
else if (hasTitle && hasDescription && hasPrimaryKey && hasOptionalValue && hasName && hasTitleDescription && !hasDataType && hasUnit) {
@@ -120,7 +121,6 @@ async function checkDataStructure(page, hasTitle, hasDescription, hasPrimaryKey,
120121
// Check if the save button is disabled and reload the page
121122
const saveButton = page.locator('button#save');
122123
await expect(saveButton).toBeDisabled();
123-
124124

125125
}
126126
}
@@ -151,10 +151,10 @@ async function createDataStructure(page, titleName) {
151151
await page.waitForTimeout(500);
152152

153153
// Click on make a part of primary key
154-
await page.click('xpath=//*[@id="0"]/div[2]/div[1]/div[2]/label/div');
154+
await page.click('text=Mark as part of primary key');
155155

156156
// Fill in the name input
157-
await page.locator('input[id=name]').fill(titleName);
157+
await page.locator('input[id=name-0]').fill(titleName);
158158

159159
// Fill in the description textarea
160160
await page.locator('textarea.textarea.variant-form-material.input-error').fill('Test data structure');
@@ -166,21 +166,25 @@ async function createDataStructure(page, titleName) {
166166
await dataType.click()
167167

168168
// Click the on unit dropdown
169-
await page.click('div.value-container.svelte-u3g5ju > input#unit');
169+
await page.click('input[id=unit-0]');
170170
await page.waitForTimeout(500);
171171
const unit = await page.waitForSelector('.list-item .item:text("none")', { visible: true, enabled: true });
172172
await unit.click()
173173
await page.waitForTimeout(500);
174174

175175
// Click on the dropdown
176-
await page.locator('#constraints').click();
176+
await page.locator('input[id=constraints-0]').click();
177177
await page.waitForTimeout(500);
178178
const constraint = await page.waitForSelector('.list-item .item:text("Test Constraint")', { visible: true, timeout: 500 });
179179
await constraint.click();
180180

181181
// Wait for 500 milliseconds
182182
await page.waitForTimeout(500);
183183

184+
// marking the Primary key
185+
const firstToggleInput = page.locator('.slide-toggle .slide-toggle-label > .slide-toggle-track').nth(0);
186+
await firstToggleInput.click(); // Click the first matching element
187+
184188
// Click on save button
185189
await page.click('#save');
186190
}
@@ -259,17 +263,17 @@ async function checkConstraint(page) {
259263

260264
try {
261265
// Click on the dropdown
262-
await page.locator('#constraints').click();
266+
await page.locator('input[id=constraints-0]').click();
263267
await page.waitForTimeout(500);
264268

265269
let option;
266270
try {
267271
// Check if the "TestConstraint" exists
268272
await page.waitForSelector('.list-item .item:text("Test Constraint")', { visible: true, timeout: 500 });
269-
273+
270274

271275
} catch (error) {
272-
276+
273277
// Perform actions if the element is not found
274278
// Click on the SVG element
275279
await page.waitForSelector('div.hidden:nth-child(4)', { visible: true });
@@ -330,25 +334,19 @@ async function editDataStructure(page) {
330334
// Wait for 500 milliseconds
331335
await page.waitForTimeout(500);
332336

333-
// Click on optional value
334-
await page.click('xpath=//*[@id="0"]/div[2]/div[2]/div[2]/label/div');
335-
336-
// Click the on template data dropdown
337-
await page.click('#variableTemplate');
338-
await page.waitForTimeout(500);
339-
const template = await page.waitForSelector('.list-item .item:text("percentage")', { visible: true, enabled: true });
340-
await template.click()
337+
// Click on make a part of primary key
338+
await page.click('text=Value can be optional');
341339

342340
// Click the on data type dropdown
343-
await page.click('#dataType');
341+
await page.click('div.value-container.svelte-u3g5ju > input.svelte-u3g5ju');
344342
await page.waitForTimeout(500);
345343
const dataType = await page.waitForSelector('.list-item .item:text("number")', { visible: true, enabled: true });
346344
await dataType.click()
347345

348346
// Click the on unit dropdown
349-
await page.click('#unit');
347+
await page.click('input[id=unit-0]');
350348
await page.waitForTimeout(500);
351-
const unit = await page.waitForSelector('.list-item .item:text("%")', { visible: true, enabled: true });
349+
const unit = await page.waitForSelector('.list-item .item:text("none")', { visible: true, enabled: true });
352350
await unit.click()
353351
await page.waitForTimeout(500);
354352

@@ -395,4 +393,4 @@ module.exports = {
395393
findEditedDataStructure,
396394
checkDataStructure
397395

398-
};
396+
};

0 commit comments

Comments
 (0)