Skip to content

Commit c4c0619

Browse files
Fixed the primary and optional key issue #20
1 parent 9d43f2c commit c4c0619

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

tests/RPM/utils/dataStructureFunctions.js

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

39+
4040
if (hasName) {
4141
// Fill in the name input
4242
await page.locator('input[id=name]').fill(hasName);
@@ -110,9 +110,8 @@ 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-
// Check if the save button is disabled and reload the page
114-
const saveButton = page.locator('button#save');
115-
await expect(saveButton).toBeDisabled();
113+
// Click on save button
114+
await page.click('#save');
116115

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

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

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

156156
// Fill in the name input
157157
await page.locator('input[id=name]').fill(titleName);
@@ -266,10 +266,10 @@ async function checkConstraint(page) {
266266
try {
267267
// Check if the "TestConstraint" exists
268268
await page.waitForSelector('.list-item .item:text("Test Constraint")', { visible: true, timeout: 500 });
269-
269+
270270

271271
} catch (error) {
272-
272+
273273
// Perform actions if the element is not found
274274
// Click on the SVG element
275275
await page.waitForSelector('div.hidden:nth-child(4)', { visible: true });
@@ -314,6 +314,7 @@ async function navDataStructure(page) {
314314
await page.click('text="Manage Data Structures"');
315315
}
316316

317+
317318
async function editDataStructure(page) {
318319

319320
// Wait for 500 milliseconds
@@ -322,25 +323,32 @@ async function editDataStructure(page) {
322323
await page.waitForLoadState('load');
323324
await page.waitForTimeout(500);
324325

326+
325327
// Fill in the title description textarea
326328
await page.locator('textarea[id=description]').fill('Edited test data structure');
327329

328330
// Wait for 500 milliseconds
329331
await page.waitForTimeout(500);
330332

331-
// Click on make a part of primary key
332-
await page.click('text=Value can be optional');
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()
333341

334342
// Click the on data type dropdown
335-
await page.click('div.value-container.svelte-u3g5ju > input.svelte-u3g5ju');
343+
await page.click('#dataType');
336344
await page.waitForTimeout(500);
337345
const dataType = await page.waitForSelector('.list-item .item:text("number")', { visible: true, enabled: true });
338346
await dataType.click()
339347

340348
// Click the on unit dropdown
341-
await page.click('div.value-container.svelte-u3g5ju > input#unit');
349+
await page.click('#unit');
342350
await page.waitForTimeout(500);
343-
const unit = await page.waitForSelector('.list-item .item:text("cm")', { visible: true, enabled: true });
351+
const unit = await page.waitForSelector('.list-item .item:text("%")', { visible: true, enabled: true });
344352
await unit.click()
345353
await page.waitForTimeout(500);
346354

@@ -374,6 +382,7 @@ async function findEditedDataStructure(page, dataStructure) {
374382
);
375383
}
376384

385+
377386
module.exports = {
378387

379388
createDataStructure,

0 commit comments

Comments
 (0)