1
+ import { expect } from "@playwright/test" ;
2
+ const path = require ( 'path' ) ;
3
+
4
+ async function createNewtabularData ( page , title , description ) {
5
+ await page . waitForTimeout ( 500 )
6
+ //click on the tabular data tab
7
+ await page . locator ( '.pr-1 > :nth-child(1)' ) . click ( )
8
+ // Select the New tabular data element header and verify its visibility
9
+ const headerElement = page . locator ( '.h2' ) ;
10
+ await expect ( headerElement ) . toBeVisible ( ) ;
11
+ await page . locator ( '#Title' ) . fill ( title ) ;
12
+ await page . locator ( '#Description' ) . fill ( description ) ;
13
+ // Wait for 500 milliseconds
14
+ await page . waitForTimeout ( 500 ) ;
15
+ //click on create button
16
+ await page . locator ( '.flex > .variant-filled-primary' ) . click ( )
17
+ // verify the visibiliy of the text of the file upload
18
+ await page . waitForTimeout ( 500 )
19
+ const fileuploadtitle = page . locator ( '.space-y-2 > form > :nth-child(1) > .dropzone > span > :nth-child(1)' ) ;
20
+ await page . waitForSelector ( '.space-y-2 > form > :nth-child(1) > .dropzone > span > :nth-child(1)' ) ;
21
+ await expect ( fileuploadtitle ) . toBeVisible ( ) ;
22
+ // Wait for 500 milliseconds
23
+ await page . waitForTimeout ( 500 )
24
+
25
+ }
26
+ async function uploadfiles ( page ) {
27
+ const filePath = path . resolve ( __dirname , '../../Date_and_time_formats.csv' ) ;
28
+ const handle = page . locator ( 'input[type="file"]' ) . nth ( 0 ) ;
29
+ await handle . setInputFiles ( filePath ) ;
30
+ // verifyy the alert message for file upload
31
+ const alertsuccess = page . locator ( '.alert-message > p' ) ;
32
+ await expect ( alertsuccess ) . toBeVisible ( ) ;
33
+ await page . locator ( '#SelectDataStructure' ) . fill ( 'Date_and_time_formats' ) ;
34
+ await page . waitForTimeout ( 2000 )
35
+ await page . locator ( '#SelectDataStructure' ) . press ( 'Enter' ) ;
36
+ }
37
+
38
+ async function markingVariableData ( page ) {
39
+
40
+ await page . waitForTimeout ( 500 )
41
+ await page . waitForSelector ( '#selectVar' ) ;
42
+ const title = page . locator ( '#edit > #title > b' ) ;
43
+ await expect ( title ) . toHaveText ( 'Mark at least Variable and Data' ) ;
44
+ await page . locator ( ':nth-child(1) > .w-8' ) . click ( )
45
+ await page . locator ( '#selectVar' ) . click ( )
46
+ await page . locator ( ':nth-child(2) > .w-8' ) . click ( )
47
+ await page . locator ( '#selectData' ) . click ( )
48
+ await page . waitForTimeout ( 500 )
49
+ await page . locator ( ':nth-child(8) > .btn' ) . click ( )
50
+ // await page.waitForTimeout(10000)
51
+ }
52
+
53
+ async function EnterTitleandDesc ( page , title , desc ) {
54
+ await page . waitForTimeout ( 500 )
55
+ //verify the primary key alert message
56
+ const alertmsg = page . locator ( '.alert-message > p' ) ;
57
+ await page . waitForSelector ( '.alert-message > p' ) ;
58
+ await expect ( alertmsg ) . toHaveText ( 'Please select a (combined) primary key.' ) ;
59
+ await page . waitForTimeout ( 500 )
60
+ await page . locator ( '#title' ) . fill ( title ) ;
61
+ await page . locator ( ':nth-child(2) > #description-container > .label > #description' ) . fill ( desc ) ;
62
+ }
63
+
64
+ async function AssignDataTypeDisplayPattern ( page , getindex , datatype , displaypattern ) {
65
+ await page . waitForTimeout ( 500 )
66
+ const index = getindex ; // Ensure this has a valid value
67
+ const setDesc = await page . locator ( `:nth-child(${ index } ) > #variable-0-container-info > .card > .py-2 > :nth-child(1) > .grow > [slot="property"] > #description-container > .label > #description` ) ;
68
+ const setDataType = await page . locator ( `:nth-child(${ index } ) > #variable-0-container-info #dataType` ) ;
69
+ const setDisplayPattern = await page . locator ( `:nth-child(${ index } ) > #variable-0-container-info > .card .svelte-select > .value-container > #displayPattern` ) ;
70
+
71
+ await page . waitForSelector ( ':nth-child(1) > #variable-0-container-info #dataType' ) ;
72
+ setDesc . fill ( 'this is test description' ) ;
73
+ await page . waitForTimeout ( 500 )
74
+
75
+
76
+
77
+ setDataType . fill ( datatype ) ;
78
+ await page . waitForTimeout ( 500 ) ;
79
+ setDataType . press ( 'ArrowDown' ) ;
80
+ await page . waitForTimeout ( 500 ) ;
81
+ setDataType . press ( 'Enter' ) ;
82
+
83
+ await page . waitForTimeout ( 500 )
84
+ setDisplayPattern . fill ( displaypattern ) ;
85
+ await page . waitForTimeout ( 500 )
86
+ setDisplayPattern . press ( 'Enter' ) ;
87
+
88
+ }
89
+
90
+ async function markPrimaryandSave ( page ) {
91
+
92
+ const firstToggleInput = page . locator ( '.slide-toggle .slide-toggle-label > .slide-toggle-track' ) . nth ( 0 ) ;
93
+ await firstToggleInput . click ( ) ; // Click the first matching element
94
+ await page . locator ( '#save' ) . click ( )
95
+
96
+ }
97
+
98
+
99
+ async function validatePrimaryandSucessSymbols ( page ) {
100
+
101
+ await page . waitForSelector ( '.text-error-500' ) ;
102
+ const primarykey = page . locator ( '.text-error-500' ) ;
103
+ await expect ( primarykey ) . toBeVisible ( ) ;
104
+ const succes = page . locator ( '.gap-1 > .text-success-500' ) ;
105
+ await page . waitForSelector ( '.gap-1 > .text-success-500' ) ;
106
+ await expect ( succes ) . toBeVisible ( ) ;
107
+ }
108
+
109
+ async function submitData ( page ) {
110
+
111
+ await page . locator ( '.h-full > :nth-child(1) > .flex > .btn' ) . click ( )
112
+ const submitmodal = page . locator ( '[data-testid="modal"]' ) ;
113
+ const importstartmodal = page . locator ( '[data-testid="modal"]' ) ;
114
+ await expect ( submitmodal ) . toBeVisible ( ) ;
115
+ await page . locator ( '.modal-footer > .variant-filled' ) . click ( )
116
+ await expect ( importstartmodal ) . toBeVisible ( ) ;
117
+ await page . locator ( '.modal-footer > .btn' ) . click ( )
118
+
119
+ const alertmsg = page . locator ( '.alert-message > p' ) ;
120
+ await page . waitForSelector ( '.alert-message > p' ) ;
121
+ await expect ( alertmsg ) . toHaveText ( 'All upload information has been entered and the upload will start now. After completion an email will be sent.' ) ;
122
+ }
123
+ module . exports = {
124
+ createNewtabularData,
125
+ uploadfiles,
126
+ markingVariableData,
127
+ EnterTitleandDesc,
128
+ AssignDataTypeDisplayPattern,
129
+ markPrimaryandSave,
130
+ validatePrimaryandSucessSymbols,
131
+ submitData
132
+
133
+ } ;
0 commit comments