@@ -29,17 +29,17 @@ async function checkDataStructure(page, hasTitle, hasDescription, hasPrimaryKey,
29
29
}
30
30
if ( hasPrimaryKey ) {
31
31
// 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 ' ) ;
33
33
}
34
+
34
35
if ( hasOptionalValue ) {
35
36
// 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 ' ) ;
37
38
}
38
39
39
-
40
40
if ( hasName ) {
41
41
// Fill in the name input
42
- await page . locator ( 'input[id=name]' ) . fill ( hasName ) ;
42
+ await page . locator ( 'input[id=name-0 ]' ) . fill ( hasName ) ;
43
43
}
44
44
45
45
if ( hasTitleDescription ) {
@@ -57,7 +57,7 @@ async function checkDataStructure(page, hasTitle, hasDescription, hasPrimaryKey,
57
57
58
58
if ( hasUnit ) {
59
59
// Click the on unit dropdown
60
- await page . click ( 'div.value-container.svelte-u3g5ju > input# unit' ) ;
60
+ await page . click ( 'input[id= unit-0] ' ) ;
61
61
await page . waitForTimeout ( 500 ) ;
62
62
const unit = await page . waitForSelector ( '.list-item .item:text("none")' , { visible : true , enabled : true } ) ;
63
63
await unit . click ( )
@@ -110,8 +110,9 @@ async function checkDataStructure(page, hasTitle, hasDescription, hasPrimaryKey,
110
110
else if ( hasTitle && hasDescription && hasPrimaryKey && hasOptionalValue && hasName && hasTitleDescription && hasDataType && ! hasUnit ) {
111
111
await page . waitForLoadState ( 'load' ) ;
112
112
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 ( ) ;
115
116
116
117
}
117
118
else if ( hasTitle && hasDescription && hasPrimaryKey && hasOptionalValue && hasName && hasTitleDescription && ! hasDataType && hasUnit ) {
@@ -120,7 +121,6 @@ async function checkDataStructure(page, hasTitle, hasDescription, hasPrimaryKey,
120
121
// Check if the save button is disabled and reload the page
121
122
const saveButton = page . locator ( 'button#save' ) ;
122
123
await expect ( saveButton ) . toBeDisabled ( ) ;
123
-
124
124
125
125
}
126
126
}
@@ -151,10 +151,10 @@ async function createDataStructure(page, titleName) {
151
151
await page . waitForTimeout ( 500 ) ;
152
152
153
153
// 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 ' ) ;
155
155
156
156
// Fill in the name input
157
- await page . locator ( 'input[id=name]' ) . fill ( titleName ) ;
157
+ await page . locator ( 'input[id=name-0 ]' ) . fill ( titleName ) ;
158
158
159
159
// Fill in the description textarea
160
160
await page . locator ( 'textarea.textarea.variant-form-material.input-error' ) . fill ( 'Test data structure' ) ;
@@ -166,21 +166,25 @@ async function createDataStructure(page, titleName) {
166
166
await dataType . click ( )
167
167
168
168
// Click the on unit dropdown
169
- await page . click ( 'div.value-container.svelte-u3g5ju > input# unit' ) ;
169
+ await page . click ( 'input[id= unit-0] ' ) ;
170
170
await page . waitForTimeout ( 500 ) ;
171
171
const unit = await page . waitForSelector ( '.list-item .item:text("none")' , { visible : true , enabled : true } ) ;
172
172
await unit . click ( )
173
173
await page . waitForTimeout ( 500 ) ;
174
174
175
175
// Click on the dropdown
176
- await page . locator ( '# constraints' ) . click ( ) ;
176
+ await page . locator ( 'input[id= constraints-0] ' ) . click ( ) ;
177
177
await page . waitForTimeout ( 500 ) ;
178
178
const constraint = await page . waitForSelector ( '.list-item .item:text("Test Constraint")' , { visible : true , timeout : 500 } ) ;
179
179
await constraint . click ( ) ;
180
180
181
181
// Wait for 500 milliseconds
182
182
await page . waitForTimeout ( 500 ) ;
183
183
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
+
184
188
// Click on save button
185
189
await page . click ( '#save' ) ;
186
190
}
@@ -259,17 +263,17 @@ async function checkConstraint(page) {
259
263
260
264
try {
261
265
// Click on the dropdown
262
- await page . locator ( '# constraints' ) . click ( ) ;
266
+ await page . locator ( 'input[id= constraints-0] ' ) . click ( ) ;
263
267
await page . waitForTimeout ( 500 ) ;
264
268
265
269
let option ;
266
270
try {
267
271
// Check if the "TestConstraint" exists
268
272
await page . waitForSelector ( '.list-item .item:text("Test Constraint")' , { visible : true , timeout : 500 } ) ;
269
-
273
+
270
274
271
275
} catch ( error ) {
272
-
276
+
273
277
// Perform actions if the element is not found
274
278
// Click on the SVG element
275
279
await page . waitForSelector ( 'div.hidden:nth-child(4)' , { visible : true } ) ;
@@ -330,25 +334,19 @@ async function editDataStructure(page) {
330
334
// Wait for 500 milliseconds
331
335
await page . waitForTimeout ( 500 ) ;
332
336
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' ) ;
341
339
342
340
// Click the on data type dropdown
343
- await page . click ( '#dataType ' ) ;
341
+ await page . click ( 'div.value-container.svelte-u3g5ju > input.svelte-u3g5ju ' ) ;
344
342
await page . waitForTimeout ( 500 ) ;
345
343
const dataType = await page . waitForSelector ( '.list-item .item:text("number")' , { visible : true , enabled : true } ) ;
346
344
await dataType . click ( )
347
345
348
346
// Click the on unit dropdown
349
- await page . click ( '# unit' ) ;
347
+ await page . click ( 'input[id= unit-0] ' ) ;
350
348
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 } ) ;
352
350
await unit . click ( )
353
351
await page . waitForTimeout ( 500 ) ;
354
352
@@ -395,4 +393,4 @@ module.exports = {
395
393
findEditedDataStructure,
396
394
checkDataStructure
397
395
398
- } ;
396
+ } ;
0 commit comments