Browse Source

test(cypress) sql view

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/843/head
Raju Udava 3 years ago
parent
commit
dfb4ad01ad
  1. 103
      scripts/cypress/integration/common/1c_sql_view.js
  2. 2
      scripts/cypress/integration/test/restTableOps.js
  3. 36
      scripts/cypress/support/commands.js
  4. 4
      scripts/docker-compose-cypress.yml

103
scripts/cypress/integration/common/1c_sql_view.js

@ -0,0 +1,103 @@
import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import { mainPage } from "../../support/page_objects/mainPage";
export const genTest = (type, xcdb) => {
if (!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} SQL Views`, () => {
// Run once before test- create project (rest/graphql)
//
before(() => {
// void
});
it(`SQL View Column operations`, () => {
// Open one of the views & verify validity of first two entries
cy.openViewsTab("ActorInfo", 25);
// Record-1 validation
mainPage.getCell(`ActorId`, 1).contains("1").should("exist");
mainPage.getCell(`FirstName`, 1).contains("PENELOPE").should("exist");
mainPage.getCell(`LastName`, 1).contains("GUINESS").should("exist");
mainPage
.getCell(`FilmInfo`, 1)
.contains("Animation: ANACONDA CONFESSIONS;")
.should("exist");
// Record-2 validation
mainPage.getCell(`ActorId`, 2).contains("2").should("exist");
mainPage.getCell(`FirstName`, 2).contains("NICK").should("exist");
mainPage.getCell(`LastName`, 2).contains("WAHLBERG").should("exist");
mainPage
.getCell(`FilmInfo`, 2)
.contains("Action: BULL SHAWSHANK; Animation: FIGHT JAWBREAKER;")
.should("exist");
// Column operations: Hide
mainPage.hideField("FilmInfo");
mainPage.unhideField("FilmInfo");
// Column operations: Sort
mainPage.sortField("FirstName", "Z -> A");
mainPage.getCell(`FirstName`, 1).contains("ZERO").should("exist");
mainPage.clearSort();
// Column operations: Filter
mainPage.filterField("FirstName", "is like", "PENELOPE");
mainPage.getCell(`FirstName`, 1).contains("PENELOPE").should("exist");
mainPage.filterReset();
cy.closeViewsTab("ActorInfo");
});
it(`SQL View List`, () => {
// confirm if other views exist
//
cy.openViewsTab("CustomerList", 25);
cy.closeViewsTab("CustomerList");
cy.openViewsTab("FilmList", 25);
cy.closeViewsTab("FilmList");
cy.openViewsTab("NicerButSlowerFilmList", 25);
cy.closeViewsTab("NicerButSlowerFilmList");
cy.openViewsTab("SalesByFilmCategory", 16);
cy.closeViewsTab("SalesByFilmCategory");
cy.openViewsTab("SalesByStore", 0);
cy.closeViewsTab("SalesByStore");
cy.openViewsTab("StaffList", 0);
cy.closeViewsTab("StaffList");
});
after(() => {
// void
});
});
};
/**
* @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/>.
*
*/

2
scripts/cypress/integration/test/restTableOps.js

@ -2,6 +2,7 @@ let t0 = require("./explicitLogin");
let t01 = require("../common/00_pre_configurations"); let t01 = require("../common/00_pre_configurations");
let t1a = require("../common/1a_table_operations"); let t1a = require("../common/1a_table_operations");
let t1b = require("../common/1b_table_column_operations"); let t1b = require("../common/1b_table_column_operations");
let t1c = require("../common/1c_sql_view");
let t2a = require("../common/2a_table_with_belongs_to_colulmn"); let t2a = require("../common/2a_table_with_belongs_to_colulmn");
let t2b = require("../common/2b_table_with_m2m_column"); let t2b = require("../common/2b_table_with_m2m_column");
let t3a = require("../common/3a_filter_sort_fields_operations"); let t3a = require("../common/3a_filter_sort_fields_operations");
@ -22,6 +23,7 @@ const nocoTestSuite = (type, xcdb) => {
t1a.genTest(type, xcdb); t1a.genTest(type, xcdb);
t1b.genTest(type, xcdb); t1b.genTest(type, xcdb);
t1c.genTest(type, xcdb);
t2a.genTest(type, xcdb); t2a.genTest(type, xcdb);
t2b.genTest(type, xcdb); t2b.genTest(type, xcdb);
t3a.genTest(type, xcdb); t3a.genTest(type, xcdb);

36
scripts/cypress/support/commands.js

@ -291,6 +291,42 @@ Cypress.Commands.add("toastWait", (msg) => {
.should("not.exist"); .should("not.exist");
}); });
// vn: view name
// rc: expected row count. validate row count if rc!=0
Cypress.Commands.add("openViewsTab", (vn, rc) => {
cy.task("log", `[openViewsTab] ${vn} ${rc}`);
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Views)", { timeout: 10000 })
.should("exist")
.first()
.click();
cy.get(".nc-project-tree")
.contains(vn, { timeout: 6000 })
.first()
.click({ force: true });
cy.get(`.project-tab`).contains(vn, { timeout: 10000 }).should("exist");
cy.get(".nc-project-tree")
.find(".v-list-item__title:contains(Views)", { timeout: 10000 })
.first()
.click();
// wait for page rendering to complete
if (rc != 0) {
cy.get(".nc-grid-row").should("have.length", rc);
}
});
Cypress.Commands.add("closeViewsTab", (vn) => {
cy.task("log", `[closeViewsTab] ${vn}`);
cy.get(`[href="#view||db||${vn}"]`)
.find("button.mdi-close")
.click({ force: true });
});
// Drag n Drop // Drag n Drop
// refer: https://stackoverflow.com/a/55409853 // refer: https://stackoverflow.com/a/55409853
/* /*

4
scripts/docker-compose-cypress.yml

@ -1,14 +1,18 @@
version: "3.5" version: "3.5"
# https://github.com/docker-library/mysql/issues/149
# disabling default sql-mode set to only_full_group_by
services: services:
xc-mysql-sakila-db: xc-mysql-sakila-db:
network_mode: host network_mode: host
image: mysql:8.0 image: mysql:8.0
command: mysqld --sql_mode=""
restart: always restart: always
environment: environment:
MYSQL_ROOT_PASSWORD: password MYSQL_ROOT_PASSWORD: password
volumes: volumes:
- ../packages/nocodb/tests/mysql-sakila-db:/docker-entrypoint-initdb.d - ../packages/nocodb/tests/mysql-sakila-db:/docker-entrypoint-initdb.d
# xc-cypress-nocodb: # xc-cypress-nocodb:
# network_mode: host # network_mode: host
# image: node:14-alpine # image: node:14-alpine

Loading…
Cancel
Save