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.
156 lines
5.5 KiB
156 lines
5.5 KiB
import { mainPage } from "../../support/page_objects/mainPage"; |
|
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; |
|
|
|
export const genTest = (apiType, dbType) => { |
|
if (!isTestSuiteActive(apiType, dbType)) return; |
|
|
|
describe(`${apiType.toUpperCase()} api - RollUp column`, () => { |
|
// to retrieve few v-input nodes from their label |
|
// |
|
const fetchParentFromLabel = (label) => { |
|
cy.get("label").contains(label).parents(".ant-row").click(); |
|
cy.wait(500); |
|
}; |
|
|
|
// Run once before test- create project (rest/graphql) |
|
// |
|
before(() => { |
|
cy.fileHook(); |
|
mainPage.tabReset(); |
|
|
|
// // kludge: wait for page load to finish |
|
// cy.wait(1000); |
|
// // close team & auth tab |
|
// cy.get('button.ant-tabs-tab-remove').should('exist').click(); |
|
// cy.wait(1000); |
|
|
|
// open a table to work on views |
|
// |
|
cy.openTableTab("Country", 25); |
|
}); |
|
|
|
beforeEach(() => { |
|
cy.fileHook(); |
|
}); |
|
|
|
after(() => { |
|
cy.closeTableTab("Country"); |
|
}); |
|
|
|
// Routine to create a new look up column |
|
// |
|
const addRollUpColumn = ( |
|
columnName, |
|
childTable, |
|
childCol, |
|
aggregateFunc |
|
) => { |
|
|
|
cy.get(".nc-grid tr > th:last .nc-icon").click({ |
|
force: true, |
|
}); |
|
|
|
cy.getActiveMenu().find('input.nc-column-name-input', { timeout: 3000 }) |
|
.should('exist') |
|
.clear() |
|
.type(columnName); |
|
cy.get(".nc-column-type-input").last().click().type("RollUp"); |
|
cy.getActiveSelection().find('.ant-select-item-option').contains("Rollup").click(); |
|
|
|
// Configure Child table & column names |
|
fetchParentFromLabel("Child table"); |
|
cy.getActiveSelection().find('.ant-select-item-option').contains(childTable).click(); |
|
|
|
fetchParentFromLabel("Child column"); |
|
cy.getActiveSelection().find('.ant-select-item-option').contains(childCol).click(); |
|
|
|
fetchParentFromLabel("Aggregate function"); |
|
cy.getActiveSelection().find('.ant-select-item-option').contains(aggregateFunc).click(); |
|
|
|
cy.get(".ant-btn-primary").contains("Save").should('exist').click(); |
|
cy.toastWait(`Column created`); |
|
|
|
cy.get(`th[data-title="${columnName}"]`).should("exist"); |
|
}; |
|
|
|
// routine to delete column |
|
// |
|
const deleteColumnByName = (columnName) => { |
|
mainPage.deleteColumn(columnName); |
|
}; |
|
|
|
// routine to edit column |
|
// |
|
const editColumnByName = (oldName, newName) => { |
|
// verify if column exists before delete |
|
cy.get(`th:contains(${oldName})`).should("exist"); |
|
|
|
// delete opiton visible on mouse-over |
|
cy.get(`th:contains(${oldName}) .mdi-menu-down`) |
|
.trigger("mouseover") |
|
.click(); |
|
|
|
// 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(); |
|
|
|
cy.toastWait("Successfully updated alias"); |
|
|
|
// validate if deleted (column shouldnt exist) |
|
cy.get(`th:contains(${oldName})`).should("not.exist"); |
|
cy.get(`th:contains(${newName})`).should("exist"); |
|
}; |
|
|
|
/////////////////////////////////////////////////// |
|
// Test case |
|
|
|
it("Add Rollup column (City, City, count) & Delete", () => { |
|
addRollUpColumn("RollUpCol", "City", "City", "count"); |
|
|
|
// 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 |
|
mainPage.getCell("RollUpCol", 4) |
|
.contains("2") |
|
.should("exist"); |
|
|
|
// editColumnByName("RollUpCol_2", "RollUpCol_New"); |
|
deleteColumnByName("RollUpCol"); |
|
}); |
|
|
|
it.skip("Add Rollup column (City, CountryId, count) & Delete", () => { |
|
addRollUpColumn("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"); |
|
}); |
|
}); |
|
}; |
|
|
|
/** |
|
* @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/>. |
|
* |
|
*/
|
|
|