Browse Source

feat(testing): Removed changes from cypress

pull/3848/head
Muhammed Mustafa 2 years ago
parent
commit
6bca7d4c28
  1. 2
      packages/nocodb/tests/unit/tsconfig.json
  2. 4
      scripts/cypress/cypress.json
  3. 7
      scripts/cypress/integration/common/6b_downloadCsv.js
  4. 6
      scripts/cypress/integration/common/6f_attachments.js
  5. 17
      scripts/cypress/integration/common/9b_ERD.js
  6. 51
      scripts/cypress/integration/test/pg-restMiscV2.js
  7. 30
      scripts/cypress/integration/test/restMiscV2.js
  8. 43
      scripts/cypress/support/commands.js

2
packages/nocodb/tests/unit/tsconfig.json

@ -45,7 +45,7 @@
// "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */, // "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */,
"lib": [ "lib": [
"es2017", "DOM" "es2017"
], ],
"types": [ "types": [
"mocha", "node" "mocha", "node"

4
scripts/cypress/cypress.json

@ -14,9 +14,7 @@
"test/pg-restRoles.js", "test/pg-restRoles.js",
"test/pg-restMisc.js", "test/pg-restMisc.js",
"test/quickTest.js", "test/quickTest.js",
"test/db-independent.js", "test/db-independent.js"
"test/pg-restMiscV2.js",
"test/restMiscV2.js"
], ],
"defaultCommandTimeout": 13000, "defaultCommandTimeout": 13000,
"pageLoadTimeout": 600000, "pageLoadTimeout": 600000,

7
scripts/cypress/integration/common/6b_downloadCsv.js

@ -9,9 +9,10 @@ export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} Upload/ Download CSV`, () => { describe(`${apiType.toUpperCase()} Upload/ Download CSV`, () => {
before(() => { // before(() => {
cy.setup({ dbType }) // // standalone test
}); // // loginPage.loginAndOpenProject(apiType, dbType);
// });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();

6
scripts/cypress/integration/common/6f_attachments.js

@ -6,9 +6,9 @@ export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} Columns of type attachment`, () => { describe(`${apiType.toUpperCase()} Columns of type attachment`, () => {
before(() => { // before(() => {
cy.setup({ dbType }) // // loginPage.loginAndOpenProject(apiType, dbType);
}); // });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();

17
scripts/cypress/integration/common/9b_ERD.js

@ -15,10 +15,11 @@ export const genTest = (apiType, dbType) => {
before(() => { before(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
cy.setup({ dbType }).then(({project}) => { // loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("Country", 25);
projectId = project.id cy.openTableTab("Country", 25);
projectId = getProjectString()
cy.log('erd:getProjectString' + projectId)
if (dbType === "postgres") { if (dbType === "postgres") {
sakilaTables = pgSakilaTables; sakilaTables = pgSakilaTables;
sakilaSqlViews = pgSakilaSqlViews; sakilaSqlViews = pgSakilaSqlViews;
@ -30,8 +31,6 @@ export const genTest = (apiType, dbType) => {
sakilaSqlViews = sqliteSakilaSqlViews.map((viewName) => `${projectId}${viewName}`); sakilaSqlViews = sqliteSakilaSqlViews.map((viewName) => `${projectId}${viewName}`);
} }
cy.saveLocalStorage(); cy.saveLocalStorage();
})
}); });
beforeEach(() => { beforeEach(() => {
@ -42,10 +41,16 @@ export const genTest = (apiType, dbType) => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}) })
after(() => {
cy.restoreLocalStorage();
cy.closeTableTab("Country");
cy.saveLocalStorage();
});
// Test cases // Test cases
it(`Enable MM setting Open Table ERD`, () => { it(`Enable MM setting Open Table ERD`, () => {
cy.openTableTab("Country", 25); // cy.openTableTab("Country", 25);
mainPage.toggleShowMMSetting(); mainPage.toggleShowMMSetting();
mainPage.openErdTab(); mainPage.openErdTab();

51
scripts/cypress/integration/test/pg-restMiscV2.js

@ -1,51 +0,0 @@
// let t0 = require("./explicitLogin");
// let t01 = require("../common/00_pre_configurations");
let t6b = require("../common/6b_downloadCsv");
// let t6c = require("../common/6c_swagger_api");
// let t6d = require("../common/6d_language_validation");
// let t6e = require("../common/6e_project_operations");
let t6f = require("../common/6f_attachments");
// let t6g = require("../common/6g_base_share");
// let t7a = require("../common/7a_create_project_from_excel");
const {
setCurrentMode,
} = require("../../support/page_objects/projectConstants");
// const t8a = require("../common/8a_webhook");
const t9b = require("../common/9b_ERD");
const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType);
// Download CSV
t6b.genTest(apiType, dbType);
// Attachment cell
t6f.genTest(apiType, dbType);
// ERD:
t9b.genTest(apiType, dbType);
};
nocoTestSuite("rest", "postgres");
/**
* @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/>.
*
*/

30
scripts/cypress/integration/test/restMiscV2.js

@ -1,30 +0,0 @@
// let t0 = require("./explicitLogin");
// let t01 = require("../common/00_pre_configurations");
let t6b = require("../common/6b_downloadCsv");
// let t6c = require("../common/6c_swagger_api");
// let t6d = require("../common/6d_language_validation");
// let t6e = require("../common/6e_project_operations");
let t6f = require("../common/6f_attachments");
// let t6g = require("../common/6g_base_share");
// let t7a = require("../common/7a_create_project_from_excel");
const {
setCurrentMode,
} = require("../../support/page_objects/projectConstants");
// const t8a = require("../common/8a_webhook");
const t9b = require("../common/9b_ERD");
const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType);
// Download CSV
t6b.genTest(apiType, dbType);
// Attachment cell
t6f.genTest(apiType, dbType);
// ERD:
t9b.genTest(apiType, dbType);
};
nocoTestSuite("rest", "mysql");

43
scripts/cypress/support/commands.js

@ -29,46 +29,6 @@ import { isXcdb, isPostgres } from "./page_objects/projectConstants";
require("@4tw/cypress-drag-drop"); require("@4tw/cypress-drag-drop");
let LOCAL_STORAGE_MEMORY = {};
let LOCAL_STORAGE_MEMORY_v2 = {};
Cypress.Commands.add('setup', ({ dbType }) => {
cy.request('GET', 'http://localhost:8080/api/v1/meta/test/reset').then((response) => {
LOCAL_STORAGE_MEMORY = {
"nocodb-gui-v2": JSON.stringify({
"token": response.body.token,
darkMode: false,
})
}
cy.restoreLocalStorage().then(() => {
console.log('setup done', localStorage.getItem('nocodb-gui-v2'))
Cypress.LocalStorage.clear = () => {};
let project;
if(dbType === "postgres") {
project = response.body.projects.find((project) => project.title === 'pgExtREST');
}
if(dbType === "mysql") {
project = response.body.projects.find((project) => project.title === 'externalREST');
}
cy.visit(`http://localhost:3000/#/nc/${project.id}/auth`, {
retryOnNetworkFailure: true,
timeout: 1200000,
headers: {
"Accept-Encoding": "gzip, deflate",
}
})
.getSettled('.nc-noco-brand-icon', {delay: 100}).should('be.visible')
.then(() => {
return {token: response.body.token, project}
});
})
})
});
// recursively gets an element, returning only after it's determined to be attached to the DOM for good // recursively gets an element, returning only after it's determined to be attached to the DOM for good
Cypress.Commands.add("getSettled", (selector, opts = {}) => { Cypress.Commands.add("getSettled", (selector, opts = {}) => {
@ -284,6 +244,9 @@ Cypress.Commands.add("openOrCreateGqlProject", (_args) => {
cy.url({ timeout: 20000 }).should("contain", "#/nc/"); cy.url({ timeout: 20000 }).should("contain", "#/nc/");
}); });
let LOCAL_STORAGE_MEMORY = {};
let LOCAL_STORAGE_MEMORY_v2 = {};
Cypress.Commands.add("saveLocalStorage", (name) => { Cypress.Commands.add("saveLocalStorage", (name) => {
LOCAL_STORAGE_MEMORY = {}; LOCAL_STORAGE_MEMORY = {};
Object.keys(localStorage).forEach((key) => { Object.keys(localStorage).forEach((key) => {

Loading…
Cancel
Save