@@ -9,92 +9,99 @@ import {
9
9
const widgetsPage = require ( "../../../locators/Widgets.json" ) ;
10
10
const appPage = require ( "../../../locators/PgAdminlocators.json" ) ;
11
11
12
- describe ( "PgAdmin Clone App" , { tags : [ "@tag.Datasource" ] } , function ( ) {
13
- let datasourceName , tableName ;
12
+ describe (
13
+ "PgAdmin Clone App" ,
14
+ { tags : [ "@tag.Datasource" , "@tag.Git" , "@tag.AccessControl" ] } ,
15
+ function ( ) {
16
+ let datasourceName , tableName ;
14
17
15
- before ( "Add dsl and create datasource" , ( ) => {
16
- agHelper . AddDsl ( "PgAdmindsl" ) ;
17
- dataSources . CreateDataSource ( "Postgres" ) ;
18
- cy . get ( "@dsName" ) . then ( ( $dsName ) => {
19
- datasourceName = $dsName ;
18
+ before ( "Add dsl and create datasource" , ( ) => {
19
+ agHelper . AddDsl ( "PgAdmindsl" ) ;
20
+ dataSources . CreateDataSource ( "Postgres" ) ;
21
+ cy . get ( "@dsName" ) . then ( ( $dsName ) => {
22
+ datasourceName = $dsName ;
23
+ } ) ;
20
24
} ) ;
21
- } ) ;
22
25
23
- it ( "1. Create queries" , function ( ) {
24
- // writing query to get all schema
25
- dataSources . CreateQueryAfterDSSaved (
26
- "SELECT schema_name FROM information_schema.schemata;" ,
27
- "get_schema" ,
28
- ) ;
29
- // switching off Use Prepared Statement toggle
30
- dataSources . ToggleUsePreparedStatement ( false ) ;
31
- dataSources . RunQuery ( ) ;
26
+ it ( "1. Create queries" , function ( ) {
27
+ // writing query to get all schema
28
+ dataSources . CreateQueryAfterDSSaved (
29
+ "SELECT schema_name FROM information_schema.schemata;" ,
30
+ "get_schema" ,
31
+ ) ;
32
+ // switching off Use Prepared Statement toggle
33
+ dataSources . ToggleUsePreparedStatement ( false ) ;
34
+ dataSources . RunQuery ( ) ;
32
35
33
- // writing query to get all the tables
34
- dataSources . CreateQueryFromOverlay (
35
- datasourceName ,
36
- `select * from pg_catalog.pg_tables where schemaname = {{schema_select.selectedOptionValue || "public"}};` ,
37
- "get_tables" ,
38
- 2000 ,
39
- ) ;
40
- dataSources . RunQuery ( ) ;
36
+ // writing query to get all the tables
37
+ dataSources . CreateQueryFromOverlay (
38
+ datasourceName ,
39
+ `select * from pg_catalog.pg_tables where schemaname = {{schema_select.selectedOptionValue || "public"}};` ,
40
+ "get_tables" ,
41
+ 2000 ,
42
+ ) ;
43
+ dataSources . RunQuery ( ) ;
41
44
42
- // writing query to get all the columns
43
- dataSources . CreateQueryFromOverlay (
44
- datasourceName ,
45
- `SELECT column_name, data_type, table_name, ordinal_position, is_nullable FROM information_schema.COLUMNS` ,
46
- "get_columns" ,
47
- ) ;
48
- dataSources . RunQuery ( ) ;
45
+ // writing query to get all the columns
46
+ dataSources . CreateQueryFromOverlay (
47
+ datasourceName ,
48
+ `SELECT column_name, data_type, table_name, ordinal_position, is_nullable FROM information_schema.COLUMNS` ,
49
+ "get_columns" ,
50
+ ) ;
51
+ dataSources . RunQuery ( ) ;
49
52
50
- // writing query to get create table
51
- dataSources . CreateQueryFromOverlay (
52
- datasourceName ,
53
- `CREATE TABLE {{schema_select.selectedOptionValue}}.{{nt_name.text.replaceAll(" ","_")}}({{appsmith.store.nt_col.map((c)=> c.name.replaceAll(" ","_") + " " + c.dtype + (c.nnull ? " NOT NULL " : "") + (c.pkey ? " PRIMARY KEY " : "")).join(" , ")}})` ,
54
- "create_table" ,
55
- ) ;
56
- dataSources . ToggleUsePreparedStatement ( false ) ;
53
+ // writing query to get create table
54
+ dataSources . CreateQueryFromOverlay (
55
+ datasourceName ,
56
+ `CREATE TABLE {{schema_select.selectedOptionValue}}.{{nt_name.text.replaceAll(" ","_")}}({{appsmith.store.nt_col.map((c)=> c.name.replaceAll(" ","_") + " " + c.dtype + (c.nnull ? " NOT NULL " : "") + (c.pkey ? " PRIMARY KEY " : "")).join(" , ")}})` ,
57
+ "create_table" ,
58
+ ) ;
59
+ dataSources . ToggleUsePreparedStatement ( false ) ;
57
60
58
- // writing query to get drop table
59
- dataSources . CreateQueryFromOverlay (
60
- datasourceName ,
61
- `DROP TABLE {{schema_select.selectedOptionValue}}.{{nt_name.text.replaceAll(" ","_")}}({{appsmith.store.nt_col.map((c)=>c.name.replaceAll(" ","_") + " " + c.dtype + (c.nnull ? " NOT NULL " : "") + (c.pkey ? " PRIMARY KEY " : "")).join(" , ")}});` ,
62
- "drop_table" ,
63
- ) ;
64
- } ) ;
61
+ // writing query to get drop table
62
+ dataSources . CreateQueryFromOverlay (
63
+ datasourceName ,
64
+ `DROP TABLE {{schema_select.selectedOptionValue}}.{{nt_name.text.replaceAll(" ","_")}}({{appsmith.store.nt_col.map((c)=>c.name.replaceAll(" ","_") + " " + c.dtype + (c.nnull ? " NOT NULL " : "") + (c.pkey ? " PRIMARY KEY " : "")).join(" , ")}});` ,
65
+ "drop_table" ,
66
+ ) ;
67
+ } ) ;
65
68
66
- it ( "2. Add new table from app page, View and Delete table" , function ( ) {
67
- deployMode . DeployApp ( locators . _widgetInDeployed ( draggableWidgets . BUTTON ) ) ;
68
- // adding new table
69
- agHelper . GetNClick ( appPage . addNewtable , 0 , true ) ;
70
- agHelper . AssertElementAbsence ( appPage . loadButton , 40000 ) ; //for CI
71
- agHelper . WaitUntilEleAppear ( appPage . addTablename ) ;
72
- cy . generateUUID ( ) . then ( ( UUID ) => {
73
- cy . xpath ( appPage . addTablename ) . clear ( ) . type ( `table${ UUID } ` ) ;
74
- tableName = `table${ UUID } ` ;
69
+ it ( "2. Add new table from app page, View and Delete table" , function ( ) {
70
+ deployMode . DeployApp ( locators . _widgetInDeployed ( draggableWidgets . BUTTON ) ) ;
71
+ // adding new table
72
+ agHelper . GetNClick ( appPage . addNewtable , 0 , true ) ;
73
+ agHelper . AssertElementAbsence ( appPage . loadButton , 40000 ) ; //for CI
74
+ agHelper . WaitUntilEleAppear ( appPage . addTablename ) ;
75
+ cy . generateUUID ( ) . then ( ( UUID ) => {
76
+ cy . xpath ( appPage . addTablename ) . clear ( ) . type ( `table${ UUID } ` ) ;
77
+ tableName = `table${ UUID } ` ;
78
+ } ) ;
79
+ // adding column to the table
80
+ cy . xpath ( appPage . addColumn ) . click ( { force : true } ) ;
81
+ cy . xpath ( appPage . columnNamefield ) . should ( "be.visible" ) ;
82
+ cy . xpath ( appPage . datatypefield ) . should ( "be.visible" ) ;
83
+ agHelper . GetNClick ( appPage . addColumnName ) ;
84
+ agHelper . TypeText (
85
+ appPage . addColumnName + " " + locators . _inputField ,
86
+ "ID" ,
87
+ ) ;
88
+ agHelper . SelectFromDropDown ( "Varchar" , "" , 1 ) ;
89
+ // switching on the Primary Key toggle
90
+ cy . get ( widgetsPage . switchWidgetInactive ) . first ( ) . click ( ) ;
91
+ // switching on the Not Null toggle
92
+ cy . get ( widgetsPage . switchWidgetInactive ) . last ( ) . click ( ) ;
93
+ cy . xpath ( appPage . submitButton ) . click ( { force : true } ) ;
94
+ agHelper . AssertElementVisibility ( appPage . addColumn ) ;
95
+ cy . xpath ( appPage . submitButton ) . first ( ) . click ( { force : true } ) ;
96
+ assertHelper . AssertNetworkStatus ( "@postExecute" ) ;
97
+ cy . xpath ( appPage . closeButton ) . click ( { force : true } ) ;
98
+ cy . xpath ( appPage . addNewtable ) . should ( "be.visible" ) ;
99
+ // viewing the table's columns by clicking on view button
100
+ cy . xpath ( appPage . viewButton ) . first ( ) . click ( { force : true } ) ;
101
+ // deleting the table through modal
102
+ cy . xpath ( appPage . deleteButton ) . last ( ) . click ( { force : true } ) ;
103
+ cy . xpath ( appPage . confirmButton ) . click ( { force : true } ) ;
104
+ cy . xpath ( appPage . closeButton ) . click ( { force : true } ) ;
75
105
} ) ;
76
- // adding column to the table
77
- cy . xpath ( appPage . addColumn ) . click ( { force : true } ) ;
78
- cy . xpath ( appPage . columnNamefield ) . should ( "be.visible" ) ;
79
- cy . xpath ( appPage . datatypefield ) . should ( "be.visible" ) ;
80
- agHelper . GetNClick ( appPage . addColumnName ) ;
81
- agHelper . TypeText ( appPage . addColumnName + " " + locators . _inputField , "ID" ) ;
82
- agHelper . SelectFromDropDown ( "Varchar" , "" , 1 ) ;
83
- // switching on the Primary Key toggle
84
- cy . get ( widgetsPage . switchWidgetInactive ) . first ( ) . click ( ) ;
85
- // switching on the Not Null toggle
86
- cy . get ( widgetsPage . switchWidgetInactive ) . last ( ) . click ( ) ;
87
- cy . xpath ( appPage . submitButton ) . click ( { force : true } ) ;
88
- agHelper . AssertElementVisibility ( appPage . addColumn ) ;
89
- cy . xpath ( appPage . submitButton ) . first ( ) . click ( { force : true } ) ;
90
- assertHelper . AssertNetworkStatus ( "@postExecute" ) ;
91
- cy . xpath ( appPage . closeButton ) . click ( { force : true } ) ;
92
- cy . xpath ( appPage . addNewtable ) . should ( "be.visible" ) ;
93
- // viewing the table's columns by clicking on view button
94
- cy . xpath ( appPage . viewButton ) . first ( ) . click ( { force : true } ) ;
95
- // deleting the table through modal
96
- cy . xpath ( appPage . deleteButton ) . last ( ) . click ( { force : true } ) ;
97
- cy . xpath ( appPage . confirmButton ) . click ( { force : true } ) ;
98
- cy . xpath ( appPage . closeButton ) . click ( { force : true } ) ;
99
- } ) ;
100
- } ) ;
106
+ } ,
107
+ ) ;
0 commit comments