forked from nocodb/nocodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainPage.js
178 lines (144 loc) · 5.7 KB
/
mainPage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// main page
export class _mainPage {
constructor() {
// Top Right items
this.SHARE = 0
this.THEME_BODY = 1
this.THEME_HEADER = 2
this.ALERT = 3
this.LANGUAGE = 4
this.USER = 5
// Top Left items
this.HOME = 0
this.GIT_HOME = 1
this.GIT_STAR = 2
this.GIT_DOCS = 3
this.AUDIT = 0
this.APPSTORE = 2
this.TEAM_N_AUTH = 3
this.PROJ_METADATA = 4
this.ROLE_VIEW = 5
}
toolBarTopLeft(toolBarItem) {
return cy.get('header.v-toolbar').eq(0).find('a').eq(toolBarItem)
}
toolBarTopRight(toolBarItem) {
return cy.get('header.v-toolbar').eq(0).find('button').eq(toolBarItem)
}
navigationDraw(item) {
if (item == this.ROLE_VIEW)
return cy.get('.nc-nav-drawer').find('.v-list').last()
else
return cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').eq(item)
}
// add new user to specified role
//
addNewUserToProject = (userCred, roleType) => {
let linkText
// click on New User button, feed details
cy.get('button:contains("New User")').first().click()
cy.get('label:contains("Email")').next('input').type(userCred.username).trigger('input')
cy.get('label:contains("Select User roles")').click()
// opt-in requested role & submit
// note that, 'editor' is set by default
//
cy.getActiveMenu().contains(roleType).click()
cy.getActiveMenu().contains('editor').click()
cy.get('.mdi-menu-down').click()
cy.get('.nc-invite-or-save-btn').click()
// get URL, invoke
cy.getActiveModal().find('.v-alert').then(($obj) => {
linkText = $obj.text()
cy.log(linkText)
cy.visit(linkText)
cy.wait(3000)
// Redirected to new URL, feed details
//
cy.get('input[type="email"]').type(userCred.username)
cy.get('input[type="password"]').type(userCred.password)
cy.get('button:contains("SIGN UP")').click()
cy.url({ timeout: 6000 }).should('contain', '#/project')
cy.wait(1000)
})
}
addExistingUserToProject = (emailId, role) => {
cy.get('.v-list-item:contains("Team & Auth")').click()
cy.get(`tr:contains(${emailId})`).find('.mdi-plus', {timeout: 2000}).click()
cy.get(`tr:contains(${emailId})`).find('.mdi-pencil-outline', {timeout: 2000}).click()
cy.get('label:contains(Select User roles)').click()
// opt-in requested role & submit
// note that, 'editor' is set by default
//
cy.getActiveMenu().contains(role).click()
cy.getActiveMenu().contains('editor').click()
cy.get('.mdi-menu-down').click()
cy.get('.nc-invite-or-save-btn').click()
cy.wait(1000)
}
getCell = (columnHeader, cellNumber) => {
return cy.get(`tbody > :nth-child(${cellNumber}) > [data-col="${columnHeader}"]`)
}
getPagination = (pageNumber) => {
if(pageNumber == '<')
return cy.get('.nc-pagination .v-pagination > li:first-child')
if(pageNumber == '>')
return cy.get('.nc-pagination .v-pagination > li:last-child')
return cy.get(`.nc-pagination .v-pagination > li:contains(${pageNumber}) button`)
}
getRow = (rowIndex) => {
return cy.get('.xc-row-table').find('tr').eq(rowIndex)
}
addColumn = (colName) => {
cy.get('.v-window-item--active .nc-grid tr > th:last button').click({force: true});
cy.get('.nc-column-name-input input', {timeout: 3000}).clear().type(colName)
cy.get('.nc-col-create-or-edit-card').contains('Save').click()
}
getAuthToken = () => {
let obj = JSON.parse(localStorage['vuex'])
return obj["users"]["token"]
}
configureSMTP = (from, host, port, secure) => {
cy.get('.v-card__title.title')
.contains('SMTP')
.parents('.elevatio')
.find('button')
.contains(" Install ")
.click({ force: true })
cy.getActiveModal().find('[placeholder="eg: admin@example.com"]').click().type(from)
cy.getActiveModal().find('[placeholder="eg: smtp.example.com"]').click().type(host)
cy.getActiveModal().find('[placeholder="Port"]').click().type(port)
cy.getActiveModal().find('[placeholder="Secure"]').click().type(secure)
cy.getActiveModal().find('button').contains('Save').click()
}
resetSMTP = () => {
cy.get('.v-card__title.title')
.contains('SMTP')
.parents('.elevatio')
.find('button')
.contains(" Reset ")
.click({ force: true })
cy.getActiveModal().find('button').contains('Submit').click()
}
}
export const mainPage = new _mainPage;
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Raju Udava <sivadstala@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/