mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
257 lines
8.5 KiB
257 lines
8.5 KiB
3 years ago
|
|
||
|
// 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
|
||
3 years ago
|
|
||
|
this.roleURL = {}
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
|
||
|
|
||
3 years ago
|
toolBarTopLeft(toolBarItem) {
|
||
3 years ago
|
return cy.get('header.v-toolbar', {timeout: 20000}).eq(0).find('a').eq(toolBarItem)
|
||
3 years ago
|
}
|
||
|
|
||
|
toolBarTopRight(toolBarItem) {
|
||
3 years ago
|
return cy.get('header.v-toolbar', {timeout: 20000}).eq(0).find('button').eq(toolBarItem)
|
||
3 years ago
|
}
|
||
|
|
||
|
navigationDraw(item) {
|
||
|
if (item == this.ROLE_VIEW)
|
||
3 years ago
|
return cy.get('.nc-nav-drawer').find('.v-list').last()
|
||
3 years ago
|
else
|
||
|
return cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').eq(item)
|
||
|
}
|
||
3 years ago
|
|
||
|
|
||
|
// 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()
|
||
3 years ago
|
cy.get('.mdi-menu-down').last().click()
|
||
3 years ago
|
cy.get('.nc-invite-or-save-btn').click()
|
||
|
|
||
|
// get URL, invoke
|
||
|
cy.getActiveModal().find('.v-alert').then(($obj) => {
|
||
|
linkText = $obj.text()
|
||
|
cy.log(linkText)
|
||
3 years ago
|
this.roleURL[roleType] = linkText
|
||
|
|
||
|
cy.get('body').click('right')
|
||
3 years ago
|
|
||
3 years ago
|
// cy.visit(linkText)
|
||
3 years ago
|
|
||
3 years ago
|
// cy.wait(3000)
|
||
3 years ago
|
|
||
3 years ago
|
// // Redirected to new URL, feed details
|
||
|
// //
|
||
|
// cy.get('input[type="text"]').type(userCred.username)
|
||
|
// cy.get('input[type="password"]').type(userCred.password)
|
||
|
// cy.get('button:contains("SIGN UP")').click()
|
||
3 years ago
|
|
||
3 years ago
|
// cy.url({ timeout: 6000 }).should('contain', '#/project')
|
||
|
// cy.wait(1000)
|
||
3 years ago
|
})
|
||
|
}
|
||
|
|
||
|
addExistingUserToProject = (emailId, role) => {
|
||
|
|
||
|
cy.get('.v-list-item:contains("Team & Auth")').click()
|
||
3 years ago
|
cy.get(`tr:contains(${emailId})`).find('.mdi-plus', { timeout: 2000 }).click()
|
||
|
cy.get(`tr:contains(${emailId})`).find('.mdi-pencil-outline', { timeout: 2000 }).click()
|
||
3 years ago
|
|
||
|
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()
|
||
3 years ago
|
cy.get('.nc-invite-or-save-btn').click()
|
||
|
cy.wait(1000)
|
||
3 years ago
|
|
||
|
this.roleURL[role] = "http://localhost:3000/#/user/authentication/signin"
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
|
getCell = (columnHeader, cellNumber) => {
|
||
|
return cy.get(`tbody > :nth-child(${cellNumber}) > [data-col="${columnHeader}"]`)
|
||
|
}
|
||
|
|
||
|
getPagination = (pageNumber) => {
|
||
3 years ago
|
if (pageNumber == '<')
|
||
3 years ago
|
return cy.get('.nc-pagination .v-pagination > li:first-child')
|
||
3 years ago
|
if (pageNumber == '>')
|
||
3 years ago
|
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)
|
||
|
}
|
||
3 years ago
|
|
||
|
addColumn = (colName) => {
|
||
3 years ago
|
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()
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
|
getAuthToken = () => {
|
||
|
let obj = JSON.parse(localStorage['vuex'])
|
||
|
return obj["users"]["token"]
|
||
|
}
|
||
3 years ago
|
|
||
|
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)
|
||
3 years ago
|
cy.getActiveModal().find('button').contains('Save').click()
|
||
3 years ago
|
}
|
||
|
|
||
|
resetSMTP = () => {
|
||
|
cy.get('.v-card__title.title')
|
||
|
.contains('SMTP')
|
||
|
.parents('.elevatio')
|
||
|
.find('button')
|
||
|
.contains(" Reset ")
|
||
|
.click({ force: true })
|
||
3 years ago
|
cy.getActiveModal().find('button').contains('Submit').click()
|
||
|
}
|
||
|
|
||
|
hideUnhideField = (field) => {
|
||
|
cy.get('.nc-fields-menu-btn').click()
|
||
|
cy.get(`.menuable__content__active .v-list-item label:contains(${field})`).click()
|
||
|
cy.get('.nc-fields-menu-btn').click()
|
||
|
}
|
||
|
|
||
|
sortField = (field, criteria) => {
|
||
|
cy.get('.nc-sort-menu-btn').click()
|
||
|
cy.contains('Add Sort Option').click();
|
||
|
cy.get('.nc-sort-field-select div').first().click()
|
||
|
cy.get(`.menuable__content__active .v-list-item:contains(${field})`).click()
|
||
|
cy.get('.nc-sort-dir-select div').first().click()
|
||
3 years ago
|
cy.get(`.menuable__content__active .v-list-item:contains(${criteria})`).click()
|
||
|
cy.get('.nc-sort-menu-btn').click()
|
||
3 years ago
|
}
|
||
|
|
||
|
clearSort = () => {
|
||
3 years ago
|
cy.get('.nc-sort-menu-btn').click()
|
||
3 years ago
|
cy.get('.nc-sort-item-remove-btn').click()
|
||
3 years ago
|
cy.get('.nc-sort-menu-btn').click()
|
||
3 years ago
|
}
|
||
|
|
||
|
filterField = (field, operation, value) => {
|
||
|
cy.get('.nc-filter-menu-btn').click()
|
||
|
cy.contains('Add Filter').click();
|
||
|
|
||
|
cy.get('.nc-filter-field-select').last().click();
|
||
3 years ago
|
cy.getActiveMenu().find(`.v-list-item:contains(${field})`).first().click()
|
||
3 years ago
|
cy.get('.nc-filter-operation-select').last().click();
|
||
|
cy.getActiveMenu().find(`.v-list-item:contains(${operation})`).click()
|
||
|
cy.get('.nc-filter-value-select input:text').last().type(`${value}`);
|
||
|
cy.get('.nc-filter-menu-btn').click()
|
||
|
}
|
||
|
|
||
|
filterReset = () => {
|
||
|
cy.get('.nc-filter-menu-btn').click()
|
||
|
cy.get('.nc-filter-item-remove-btn').click()
|
||
|
cy.get('.nc-filter-menu-btn').click()
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
|
// delete created views
|
||
|
//
|
||
|
deleteCreatedViews = () => {
|
||
|
cy.get('.v-navigation-drawer__content > .container')
|
||
|
.find('.v-list > .v-list-item')
|
||
|
.contains('Share View')
|
||
|
.parent().find('button.mdi-dots-vertical').click()
|
||
|
|
||
|
cy.getActiveMenu().find('.v-list-item').contains('Views List').click()
|
||
|
|
||
3 years ago
|
cy.wait(1000)
|
||
|
|
||
|
// cy.get('.container').find('button.mdi-delete-outline')
|
||
3 years ago
|
|
||
|
cy.get('th:contains("View Link")').parent().parent()
|
||
3 years ago
|
.next().find('tr').each(($tableRow) => {
|
||
|
cy.log($tableRow[0].childElementCount)
|
||
|
|
||
|
// one of the row would contain seggregation header ('other views)
|
||
|
if (4 == $tableRow[0].childElementCount) {
|
||
|
cy.wrap($tableRow).find('button').last().click()
|
||
|
cy.wait(1000)
|
||
|
}
|
||
3 years ago
|
})
|
||
|
.then(() => {
|
||
|
cy.get('.v-overlay__content > .d-flex > .v-icon').click()
|
||
|
})
|
||
|
}
|
||
3 years ago
|
}
|
||
|
|
||
|
|
||
|
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/>.
|
||
|
*
|
||
3 years ago
|
*/
|