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.
185 lines
5.4 KiB
185 lines
5.4 KiB
3 years ago
|
import { loginPage } from "../../support/page_objects/navigation"
|
||
3 years ago
|
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
|
||
3 years ago
|
|
||
3 years ago
|
export const genTest = (type, xcdb) => {
|
||
3 years ago
|
if(!isTestSuiteActive(type, xcdb)) return;
|
||
3 years ago
|
|
||
3 years ago
|
describe(`${type.toUpperCase()} api - RollUp column`, () => {
|
||
|
|
||
|
// to retrieve few v-input nodes from their label
|
||
|
//
|
||
|
const fetchParentFromLabel = (label) => {
|
||
|
cy.get('label')
|
||
|
.contains(label)
|
||
|
.parents('.v-input')
|
||
|
.click()
|
||
|
}
|
||
|
|
||
|
// Run once before test- create project (rest/graphql)
|
||
|
//
|
||
3 years ago
|
before(() => {
|
||
3 years ago
|
// loginPage.loginAndOpenProject(type)
|
||
3 years ago
|
|
||
|
// open a table to work on views
|
||
|
//
|
||
3 years ago
|
cy.openTableTab('Country');
|
||
3 years ago
|
})
|
||
|
|
||
3 years ago
|
after(() => {
|
||
|
cy.get('[href="#table||db||Country"]').find('button.mdi-close').click()
|
||
|
})
|
||
3 years ago
|
|
||
|
// Routine to create a new look up column
|
||
|
//
|
||
|
const addLookUpColumn = (columnName, childTable, childCol, aggregateFunc) => {
|
||
3 years ago
|
|
||
3 years ago
|
// (+) icon at end of column header (to add a new column)
|
||
|
// opens up a pop up window
|
||
|
//
|
||
|
cy.get('.new-column-header').click()
|
||
3 years ago
|
|
||
3 years ago
|
// Column name
|
||
|
cy.get('.nc-column-name-input input').clear().type(`${columnName}{enter}`)
|
||
3 years ago
|
|
||
3 years ago
|
// Column data type: to be set to rollup in this context
|
||
|
// Type 'Rollup' ensures item outside view is also listed (note, rollup is at bottom of scroll list)
|
||
|
cy.get('.nc-ui-dt-dropdown').click().type('Rollup')
|
||
|
cy.getActiveMenu().contains('Rollup').click({ force: true })
|
||
3 years ago
|
|
||
3 years ago
|
// Configure Child table & column names
|
||
|
fetchParentFromLabel('Child Table')
|
||
|
cy.getActiveMenu().contains(childTable).click()
|
||
3 years ago
|
|
||
3 years ago
|
fetchParentFromLabel('Child column')
|
||
|
cy.getActiveMenu().contains(childCol).click()
|
||
3 years ago
|
|
||
3 years ago
|
fetchParentFromLabel('Aggregate function')
|
||
|
cy.getActiveMenu().contains(aggregateFunc).click()
|
||
3 years ago
|
|
||
3 years ago
|
// click on Save
|
||
3 years ago
|
cy.get('.nc-col-create-or-edit-card').contains('Save').click()
|
||
3 years ago
|
cy.wait(1000)
|
||
|
|
||
|
// Verify if column exists.
|
||
|
//
|
||
|
cy.get(`th:contains(${columnName})`)
|
||
3 years ago
|
.should('exist');
|
||
|
cy.wait(500)
|
||
|
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
// routine to delete column
|
||
|
//
|
||
|
const deleteColumnByName = (columnName) => {
|
||
3 years ago
|
|
||
3 years ago
|
// verify if column exists before delete
|
||
|
cy.get(`th:contains(${columnName})`)
|
||
|
.should('exist');
|
||
3 years ago
|
|
||
3 years ago
|
// delete opiton visible on mouse-over
|
||
|
cy.get(`th:contains(${columnName}) .mdi-menu-down`)
|
||
|
.trigger('mouseover')
|
||
|
.click()
|
||
3 years ago
|
|
||
3 years ago
|
// delete/ confirm on pop-up
|
||
|
cy.get('.nc-column-delete').click()
|
||
|
cy.getActiveModal().find('button:contains(Confirm)').click()
|
||
3 years ago
|
|
||
3 years ago
|
// validate if deleted (column shouldnt exist)
|
||
|
cy.get(`th:contains(${columnName})`)
|
||
|
.should('not.exist');
|
||
3 years ago
|
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
|
|
||
3 years ago
|
// routine to edit column
|
||
|
//
|
||
|
const editColumnByName = (oldName, newName) => {
|
||
3 years ago
|
|
||
3 years ago
|
// verify if column exists before delete
|
||
|
cy.get(`th:contains(${oldName})`)
|
||
3 years ago
|
.should('exist');
|
||
|
|
||
3 years ago
|
// delete opiton visible on mouse-over
|
||
|
cy.get(`th:contains(${oldName}) .mdi-menu-down`)
|
||
|
.trigger('mouseover')
|
||
|
.click()
|
||
3 years ago
|
|
||
3 years ago
|
// edit/ save on pop-up
|
||
|
cy.get('.nc-column-edit').click()
|
||
|
cy.get('.nc-column-name-input input').clear().type(newName)
|
||
|
cy.get('.nc-col-create-or-edit-card').contains('Save').click()
|
||
3 years ago
|
|
||
3 years ago
|
// validate if deleted (column shouldnt exist)
|
||
|
cy.get(`th:contains(${oldName})`)
|
||
|
.should('not.exist');
|
||
|
cy.get(`th:contains(${newName})`)
|
||
3 years ago
|
.should('exist');
|
||
|
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
///////////////////////////////////////////////////
|
||
|
// Test case
|
||
3 years ago
|
|
||
3 years ago
|
it('Add Rollup column (City, CityId, sum) & Delete', () => {
|
||
3 years ago
|
|
||
3 years ago
|
addLookUpColumn('RollUpCol_2', 'City', 'CityId', 'sum')
|
||
|
|
||
|
// Verify first entry, will be displayed as alias here 'childColumn (from childTable)'
|
||
|
// intentionally verifying 4th item, as initial items are being masked out by list scroll down
|
||
|
// to be fixed
|
||
|
//
|
||
|
cy.get(`tbody > :nth-child(4) > [data-col="RollUpCol_2"]`)
|
||
|
.contains('427')
|
||
|
.should('exist')
|
||
|
|
||
|
editColumnByName('RollUpCol_2', 'RollUpCol_New')
|
||
|
deleteColumnByName('RollUpCol_New')
|
||
3 years ago
|
|
||
|
})
|
||
|
|
||
3 years ago
|
it.skip('Add Rollup column (City, CountryId, count) & Delete', () => {
|
||
3 years ago
|
|
||
|
addLookUpColumn('RollUpCol_1', 'City', 'CountryId', 'count')
|
||
|
|
||
|
// Verify first entry, will be displayed as alias here 'childColumn (from childTable)'
|
||
|
cy.get(`tbody > :nth-child(4) > [data-col="RollUpCol_1"]`)
|
||
|
.contains('2')
|
||
|
.should('exist')
|
||
|
|
||
|
editColumnByName('RollUpCol_1', 'RollUpCol_New')
|
||
|
deleteColumnByName('RollUpCol_New')
|
||
|
|
||
|
})
|
||
3 years ago
|
|
||
|
});
|
||
|
}
|
||
|
|
||
3 years ago
|
// genTest('rest', false)
|
||
|
// genTest('graphql', false)
|
||
3 years ago
|
|
||
3 years ago
|
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
* @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/>.
|
||
|
*
|
||
|
*/
|
||
|
|