Browse Source

Merge pull request #3773 from nocodb/test/misc-suite-corrections

test(misc): re-alignment & optimizations
pull/3791/head
Raju Udava 2 years ago committed by GitHub
parent
commit
e1c26464fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 45
      .github/workflows/ci-cd.yml
  2. 3
      scripts/cypress/cypress.json
  3. 2
      scripts/cypress/integration/common/00_pre_configurations.js
  4. 9
      scripts/cypress/integration/common/4e_form_view_share.js
  5. 4
      scripts/cypress/integration/common/4f_grid_view_share.js
  6. 17
      scripts/cypress/integration/common/6d_language_validation.js
  7. 5
      scripts/cypress/integration/common/6e_project_operations.js
  8. 22
      scripts/cypress/integration/common/6f_attachments.js
  9. 14
      scripts/cypress/integration/common/6g_base_share.js
  10. 28
      scripts/cypress/integration/common/8a_webhook.js
  11. 18
      scripts/cypress/integration/test/db-independent.js
  12. 25
      scripts/cypress/integration/test/pg-restMisc.js
  13. 25
      scripts/cypress/integration/test/restMisc.js
  14. 26
      scripts/cypress/integration/test/xcdb-restMisc.js
  15. 8
      scripts/cypress/support/commands.js
  16. 7
      scripts/cypress/support/page_objects/navigation.js

45
.github/workflows/ci-cd.yml

@ -690,3 +690,48 @@ jobs:
- name: run unit tests - name: run unit tests
working-directory: ./packages/nocodb working-directory: ./packages/nocodb
run: npm run test:unit run: npm run test:unit
cypress-db-independent:
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
steps:
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 16.15.0
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Set env
run: echo "NODE_ENV=test" >> $GITHUB_ENV
- name: Cypress run
uses: cypress-io/github-action@v2
with:
start: |
npm run start:api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/db-independent.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
config-file: scripts/cypress/cypress.json
- name: Upload screenshots
if: always()
uses: actions/upload-artifact@v2
with:
name: cypress-restMisc-run-cache-snapshots
path: scripts/cypress/screenshots
retention-days: 2

3
scripts/cypress/cypress.json

@ -13,7 +13,8 @@
"test/pg-restViews.js", "test/pg-restViews.js",
"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"
], ],
"defaultCommandTimeout": 13000, "defaultCommandTimeout": 13000,
"pageLoadTimeout": 600000, "pageLoadTimeout": 600000,

2
scripts/cypress/integration/common/00_pre_configurations.js

@ -187,7 +187,7 @@ export const genTest = (apiType, dbType) => {
} }
} else { } else {
projectsPage.createProject(proj.basic, proj.config); projectsPage.createProject(proj.basic, proj.config);
cy.wait(5000); // cy.wait(5000);
if (dbType === "xcdb") { if (dbType === "xcdb") {
// store base URL- to re-visit and delete form view later // store base URL- to re-visit and delete form view later
let projId; let projId;

9
scripts/cypress/integration/common/4e_form_view_share.js

@ -92,7 +92,6 @@ export const genTest = (apiType, dbType) => {
cy.wait(2000); cy.wait(2000);
mainPage.shareView().click(); mainPage.shareView().click();
// copy link text, visit URL // copy link text, visit URL
cy.getActiveModal(".nc-modal-share-view") cy.getActiveModal(".nc-modal-share-view")
.should("exist") .should("exist")
@ -100,6 +99,11 @@ export const genTest = (apiType, dbType) => {
.contains("/nc/form/", { timeout: 10000 }) .contains("/nc/form/", { timeout: 10000 })
.should("exist") .should("exist")
.then(($obj) => { .then(($obj) => {
// http://localhost:8080/api/v1/db/public/shared-view/761f0200-e72c-487a-85bf-615d0d277054/rows?offset=0&filterArrJson=[]&sortArrJson=[]
cy.intercept("/api/v1/db/public/shared-view/**").as(
"waitForPageLoad"
);
let linkText = $obj.text().trim(); let linkText = $obj.text().trim();
cy.log(linkText); cy.log(linkText);
@ -108,7 +112,8 @@ export const genTest = (apiType, dbType) => {
cy.visit(linkText, { cy.visit(linkText, {
baseUrl: null, baseUrl: null,
}); });
cy.wait(5000); // cy.wait(5000);
cy.wait(["@waitForPageLoad"], { times: 2 });
// wait for share view page to load! // wait for share view page to load!

4
scripts/cypress/integration/common/4f_grid_view_share.js

@ -82,7 +82,9 @@ export const genTest = (apiType, dbType) => {
}); });
it(`Share ${viewType.toUpperCase()} hide, sort, filter & verify`, () => { it(`Share ${viewType.toUpperCase()} hide, sort, filter & verify`, () => {
cy.intercept("/api/v1/db/meta/audits/comments/*").as("waitForPageLoad"); cy.intercept("/api/v1/db/meta/audits/comments/**").as(
"waitForPageLoad"
);
cy.get(`.nc-view-item.nc-${viewType}-view-item`) cy.get(`.nc-view-item.nc-${viewType}-view-item`)
.contains("Grid-1") .contains("Grid-1")

17
scripts/cypress/integration/common/6d_language_validation.js

@ -1,6 +1,3 @@
const { mainPage } = require("../../support/page_objects/mainPage");
const { loginPage } = require("../../support/page_objects/navigation");
const { roles } = require("../../support/page_objects/projectConstants");
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
@ -21,18 +18,8 @@ export const genTest = (apiType, dbType) => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });
after(() => { // after(() => {
cy.restoreLocalStorage(); // });
cy.get(".nc-menu-accounts").should("exist").click();
cy.getActiveMenu(".nc-dropdown-user-accounts-menu")
.find(".ant-dropdown-menu-item")
.eq(1)
.click();
cy.wait(5000);
cy.get('button:contains("SIGN")').should("exist");
cy.saveLocalStorage();
});
const langVerification = (idx, lang) => { const langVerification = (idx, lang) => {
// pick json from the file specified // pick json from the file specified

5
scripts/cypress/integration/common/6e_project_operations.js

@ -7,9 +7,8 @@ export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
before(() => { before(() => {
cy.restoreLocalStorage(); loginPage.signIn(roles.owner.credentials);
cy.visit("/"); cy.saveLocalStorage();
cy.wait(4000);
}); });
beforeEach(() => { beforeEach(() => {

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

@ -6,11 +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(() => {
loginPage.loginAndOpenProject(apiType, dbType); // // loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("Country", 25); // });
cy.saveLocalStorage();
});
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
@ -49,6 +47,8 @@ export const genTest = (apiType, dbType) => {
}); });
it(`Add column of type attachments`, () => { it(`Add column of type attachments`, () => {
cy.openTableTab("Country", 25);
mainPage.addColumnWithType("testAttach", "Attachment", "Country"); mainPage.addColumnWithType("testAttach", "Attachment", "Country");
for (let i = 4; i <= 6; i++) { for (let i = 4; i <= 6; i++) {
@ -77,7 +77,7 @@ export const genTest = (apiType, dbType) => {
mainPage.shareView().click(); mainPage.shareView().click();
cy.wait(5000); // cy.wait(5000);
// copy link text, visit URL // copy link text, visit URL
cy.getActiveModal(".nc-modal-share-view") cy.getActiveModal(".nc-modal-share-view")
@ -85,6 +85,10 @@ export const genTest = (apiType, dbType) => {
.contains("/nc/form/", { timeout: 10000 }) .contains("/nc/form/", { timeout: 10000 })
.should("exist") .should("exist")
.then(($obj) => { .then(($obj) => {
cy.intercept("/api/v1/db/public/shared-view/**").as(
"waitForSharedViewLoad"
);
let linkText = $obj.text().trim(); let linkText = $obj.text().trim();
cy.log(linkText); cy.log(linkText);
@ -93,10 +97,12 @@ export const genTest = (apiType, dbType) => {
cy.visit(linkText, { cy.visit(linkText, {
baseUrl: null, baseUrl: null,
}); });
cy.wait(5000); // cy.wait(5000);
cy.wait(["@waitForSharedViewLoad"]);
// wait for share view page to load! // wait for share view page to load!
cy.get(".nc-form").should("exist"); cy.get(".nc-form").should("exist");
cy.get("button:contains(Submit)").should("exist");
// fill form // fill form
// 0: Country // 0: Country
@ -128,7 +134,7 @@ export const genTest = (apiType, dbType) => {
// projectsPage.openConfiguredProject(apiType, dbType); // projectsPage.openConfiguredProject(apiType, dbType);
cy.openTableTab("Country", 25); cy.openTableTab("Country", 25);
cy.wait(1000); // cy.wait(1000);
mainPage.filterField("testAttach", "is not null", null); mainPage.filterField("testAttach", "is not null", null);
mainPage.hideField("LastUpdate"); mainPage.hideField("LastUpdate");

14
scripts/cypress/integration/common/6g_base_share.js

@ -56,12 +56,12 @@ export const genTest = (apiType, dbType) => {
}; };
describe(`${apiType.toUpperCase()} Base VIEW share`, () => { describe(`${apiType.toUpperCase()} Base VIEW share`, () => {
before(() => { // before(() => {
// loginPage.loginAndOpenProject(apiType, dbType); // // loginPage.loginAndOpenProject(apiType, dbType);
cy.restoreLocalStorage(); // cy.restoreLocalStorage();
cy.openTableTab("Country", 25); // cy.openTableTab("Country", 25);
cy.saveLocalStorage(); // cy.saveLocalStorage();
}); // });
beforeEach(() => { beforeEach(() => {
cy.restoreLocalStorage(); cy.restoreLocalStorage();
@ -72,6 +72,8 @@ export const genTest = (apiType, dbType) => {
}); });
it(`Generate base share URL`, () => { it(`Generate base share URL`, () => {
cy.openTableTab("Country", 25);
// click SHARE // click SHARE
cy.get(".nc-share-base:visible").should("exist").click(); cy.get(".nc-share-base:visible").should("exist").click();

28
scripts/cypress/integration/common/8a_webhook.js

@ -26,24 +26,13 @@ function createWebhook(hook, test) {
cy.get(".nc-input-hook-header-key") cy.get(".nc-input-hook-header-key")
.should("exist") .should("exist")
.click() .click()
.type("{downarrow}") .type("Content-Type{enter}");
.type("{downarrow}")
.type("{downarrow}") // cy.getActiveSelection(".nc-dropdown-webhook-header")
.type("{downarrow}") // .find(".ant-select-item-option-content")
.type("{downarrow}") // .contains("Content-Type")
.type("{downarrow}") // .should("exist")
.type("{downarrow}") // .click();
.type("{downarrow}")
.type("{downarrow}")
.type("{downarrow}")
.type("{downarrow}")
.type("{downarrow}");
cy.getActiveSelection(".nc-dropdown-webhook-header")
.find(".ant-select-item-option-content")
.contains("Content-Type")
.should("exist")
.click();
cy.get("input.nc-input-hook-header-value") cy.get("input.nc-input-hook-header-value")
.should("exist") .should("exist")
@ -246,7 +235,8 @@ export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`Webhook`, () => { describe(`Webhook`, () => {
before(() => { before(() => {
loginPage.loginAndOpenProject(apiType, dbType); // loginPage.loginAndOpenProject(apiType, dbType);
cy.restoreLocalStorage();
cy.createTable("Temp"); cy.createTable("Temp");
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });

18
scripts/cypress/integration/test/db-independent.js

@ -0,0 +1,18 @@
let t6d = require("../common/6d_language_validation");
const {
setCurrentMode,
} = require("../../support/page_objects/projectConstants");
const t01 = require("../common/00_pre_configurations");
const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType);
// Sakila Ext DB project creation
t01.genTest(apiType, dbType);
// i18n
t6d.genTest(apiType, dbType);
};
nocoTestSuite("rest", "mysql");

25
scripts/cypress/integration/test/pg-restMisc.js

@ -14,22 +14,35 @@ const t8a = require("../common/8a_webhook");
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
// Sakila Ext DB project creation
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
// Download CSV
t6b.genTest(apiType, dbType); t6b.genTest(apiType, dbType);
t6d.genTest(apiType, dbType);
// i18n: language validation suffice to be done in REST MySQL suite
// t6d.genTest(apiType, dbType);
// Swagger API
// exclude@ncv2 t6c.genTest(apiType, dbType); // exclude@ncv2 t6c.genTest(apiType, dbType);
// Attachment cell
t6f.genTest(apiType, dbType); t6f.genTest(apiType, dbType);
t6g.genTest(apiType, dbType);
// webhook tests // ERD:
// t9b.genTest(apiType, dbType);
// Webhook tests
t8a.genTest(apiType, dbType); t8a.genTest(apiType, dbType);
// **deletes created project, hence place it @ end // Base share (viewer, editor), iFrame tests
t6g.genTest(apiType, dbType);
// Project operations: Delete
t6e.genTest(apiType, dbType); t6e.genTest(apiType, dbType);
// intended to keep this after earlier project deletion // Create project from Excel
// creates project using excel & deletes it
t7a.genTest(apiType, dbType); t7a.genTest(apiType, dbType);
}; };

25
scripts/cypress/integration/test/restMisc.js

@ -2,7 +2,6 @@ let t0 = require("./explicitLogin");
let t01 = require("../common/00_pre_configurations"); let t01 = require("../common/00_pre_configurations");
let t6b = require("../common/6b_downloadCsv"); let t6b = require("../common/6b_downloadCsv");
let t6c = require("../common/6c_swagger_api"); let t6c = require("../common/6c_swagger_api");
let t6d = require("../common/6d_language_validation");
let t6e = require("../common/6e_project_operations"); let t6e = require("../common/6e_project_operations");
let t6f = require("../common/6f_attachments"); let t6f = require("../common/6f_attachments");
let t6g = require("../common/6g_base_share"); let t6g = require("../common/6g_base_share");
@ -15,25 +14,35 @@ const {
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
// Sakila Ext DB project creation
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
// Download CSV
t6b.genTest(apiType, dbType); t6b.genTest(apiType, dbType);
t6d.genTest(apiType, dbType);
// // i18n
// t6d.genTest(apiType, dbType);
// Swagger API
// exclude@ncv2 t6c.genTest(apiType, dbType); // exclude@ncv2 t6c.genTest(apiType, dbType);
// Attachment cell
t6f.genTest(apiType, dbType); t6f.genTest(apiType, dbType);
// ERD
t9b.genTest(apiType, dbType); t9b.genTest(apiType, dbType);
t6g.genTest(apiType, dbType); // Webhook tests
// webhook tests
t8a.genTest(apiType, dbType); t8a.genTest(apiType, dbType);
// **deletes created project, hence place it @ end // Base share (viewer, editor), iFrame tests
t6g.genTest(apiType, dbType);
// Project operations: Delete
t6e.genTest(apiType, dbType); t6e.genTest(apiType, dbType);
// intended to keep this after earlier project deletion // Create project from Excel
// creates project using excel & deletes it
t7a.genTest(apiType, dbType); t7a.genTest(apiType, dbType);
}; };

26
scripts/cypress/integration/test/xcdb-restMisc.js

@ -12,25 +12,39 @@ let t8a = require("../common/8a_webhook");
const { const {
setCurrentMode, setCurrentMode,
} = require("../../support/page_objects/projectConstants"); } = require("../../support/page_objects/projectConstants");
const t9b = require("../common/9b_ERD");
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
// Sakila Ext DB project creation
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
// Download CSV
t6b.genTest(apiType, dbType); t6b.genTest(apiType, dbType);
t6d.genTest(apiType, dbType);
// i18n: language validation suffice to be done in REST MySQL suite
// t6d.genTest(apiType, dbType);
// Swagger API
// exclude@ncv2 t6c.genTest(apiType, dbType); // exclude@ncv2 t6c.genTest(apiType, dbType);
// Attachment cell
t6f.genTest(apiType, dbType); t6f.genTest(apiType, dbType);
t6g.genTest(apiType, dbType);
// webhook tests // ERD:
// t9b.genTest(apiType, dbType);
// Webhook tests
t8a.genTest(apiType, dbType); t8a.genTest(apiType, dbType);
// **deletes created project, hence place it @ end // Base share (viewer, editor), iFrame tests
t6g.genTest(apiType, dbType);
// Project operations: Delete
t6e.genTest(apiType, dbType); t6e.genTest(apiType, dbType);
// intended to keep this after earlier project deletion // Create project from Excel
// creates project using excel & deletes it
t7a.genTest(apiType, dbType); t7a.genTest(apiType, dbType);
}; };

8
scripts/cypress/support/commands.js

@ -149,7 +149,9 @@ Cypress.Commands.add("openTableTab", (tn, rc) => {
// .contains(tn) // .contains(tn)
// .should('exist') // .should('exist')
// .click(); // .click();
cy.wait(3000);
// for some tables, linked records are not available immediately
cy.wait(1000);
cy.get(".xc-row-table.nc-grid").should("exist"); cy.get(".xc-row-table.nc-grid").should("exist");
@ -480,8 +482,8 @@ Cypress.Commands.add("signOut", () => {
.eq(1) .eq(1)
.click(); .click();
cy.wait(5000); // cy.wait(5000);
cy.get('button:contains("SIGN")').should("exist"); cy.get('button:contains("SIGN IN")').should("exist");
}); });
// Drag n Drop // Drag n Drop

7
scripts/cypress/support/page_objects/navigation.js

@ -97,6 +97,9 @@ export class _projectsPage {
// for external database, {databaseType, hostAddress, portNumber, username, password, databaseName} // for external database, {databaseType, hostAddress, portNumber, username, password, databaseName}
openConfiguredProject(apiType, dbType) { openConfiguredProject(apiType, dbType) {
// http://localhost:8080/api/v1/db/meta/projects/p_kfxgmcd5jpyrje/users?limit=10&offset=0&query=
cy.intercept("/**/users?limit=*&offset=*&query=*").as("waitForPageLoad");
if (dbType === "mysql") { if (dbType === "mysql") {
projectsPage.openProject(staticProjects.externalREST.basic.name); projectsPage.openProject(staticProjects.externalREST.basic.name);
} else if (dbType === "xcdb") { } else if (dbType === "xcdb") {
@ -106,7 +109,9 @@ export class _projectsPage {
} }
// kludge: wait for page load to finish // kludge: wait for page load to finish
cy.wait(4000); // cy.wait(4000);
cy.wait("@waitForPageLoad");
// close team & auth tab // close team & auth tab
cy.get("button.ant-tabs-tab-remove").should("exist").click(); cy.get("button.ant-tabs-tab-remove").should("exist").click();
cy.wait(1000); cy.wait(1000);

Loading…
Cancel
Save