Browse Source

Merge pull request #2505 from nocodb/feat/at-sync-test-3

test: import verification tests
pull/2511/head
Raju Udava 2 years ago committed by GitHub
parent
commit
2f9e65c50c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .github/workflows/ci-cd.yml
  2. 2
      scripts/cypress/cypress.json
  3. 13
      scripts/cypress/integration/common/7b_import_from_airtable.js
  4. 122
      scripts/cypress/integration/common/9a_QuickTest.js
  5. 11
      scripts/cypress/integration/test/quickTest.js

4
.github/workflows/ci-cd.yml

@ -581,7 +581,7 @@ jobs:
npm run start:api:cache npm run start:api:cache
npm run start:web npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d docker-compose -f ./scripts/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/common/9a_QuickTest.js" spec: "./scripts/cypress/integration/test/quickTest.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js" wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200 wait-on-timeout: 1200
config-file: scripts/cypress/cypress.json config-file: scripts/cypress/cypress.json
@ -625,7 +625,7 @@ jobs:
docker-compose -f ./scripts/cypress/docker-compose-pg-cy-quick.yml up -d docker-compose -f ./scripts/cypress/docker-compose-pg-cy-quick.yml up -d
npm run start:api:cache:pg:cyquick npm run start:api:cache:pg:cyquick
npm run start:web npm run start:web
spec: "./scripts/cypress/integration/common/9a_QuickTest.js" spec: "./scripts/cypress/integration/test/quickTest.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js" wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200 wait-on-timeout: 1200
config-file: scripts/cypress/cypress.json config-file: scripts/cypress/cypress.json

2
scripts/cypress/cypress.json

@ -21,7 +21,7 @@
"test/pg-restViews.js", "test/pg-restViews.js",
"test/pg-restRoles.js", "test/pg-restRoles.js",
"test/pg-restMisc.js", "test/pg-restMisc.js",
"common/9a_QuickTest.js" "test/quickTest.js"
], ],
"defaultCommandTimeout": 13000, "defaultCommandTimeout": 13000,
"pageLoadTimeout": 600000, "pageLoadTimeout": 600000,

13
scripts/cypress/integration/common/7b_import_from_airtable.js

@ -2,6 +2,9 @@
// //
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import { projectsPage } from "../../support/page_objects/navigation";
import { mainPage } from "../../support/page_objects/mainPage";
let apiKey = "" let apiKey = ""
let sharedBase = "" let sharedBase = ""
@ -12,6 +15,11 @@ export const genTest = (apiType, dbType) => {
before(() => { before(() => {
apiKey = Cypress.env("airtable").apiKey; apiKey = Cypress.env("airtable").apiKey;
sharedBase = Cypress.env("airtable").sharedBase; sharedBase = Cypress.env("airtable").sharedBase;
mainPage.toolBarTopLeft(mainPage.HOME).click({force: true})
projectsPage.createProject({ dbType: "none", apiType: "REST", name: "importSample" }, {})
// projectsPage.openProject("importSample")
// cy.openTableTab("Film", 3)
}); });
after(() => {}); after(() => {});
@ -31,14 +39,13 @@ export const genTest = (apiType, dbType) => {
cy.getActiveModal().find(".nc-btn-airtable-import").should('exist').click() cy.getActiveModal().find(".nc-btn-airtable-import").should('exist').click()
// it will take a while for import to finish // it will take a while for import to finish
cy.getActiveModal().find(".nc-btn-go-dashboard", {timeout: 120000}).should('exist').click() cy.getActiveModal().find(".nc-btn-go-dashboard", {timeout: 180000}).should('exist').click()
}); });
it("Verify Schema", () => {});
it("Verify Data", () => {});
}); });
}; };
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @copyright Copyright (c) 2021, Xgene Cloud Ltd
* *

122
scripts/cypress/integration/common/9a_QuickTest.js

@ -32,6 +32,12 @@ let records2 = {
Producer: ["P1", "P2"] Producer: ["P1", "P2"]
}; };
let tn = [ "Film", "Actor", "Producer", ]
let cn = [ "Name", "Notes", "Status", "Tags", "Done", "Date", "Phone",
"Email", "URL", "Number", "Percent", "Duration", "Rating",
"Actor", "Status (from Actor)", "RollUp", "Computation", "Producer" ]
function openWebhook(index) { function openWebhook(index) {
cy.get(".nc-btn-webhook").should("exist").click(); cy.get(".nc-btn-webhook").should("exist").click();
cy.get(".nc-hook").eq(index).click({ force: true }); cy.get(".nc-hook").eq(index).click({ force: true });
@ -62,99 +68,125 @@ function verifyWebhook(config) {
cy.get(".nc-icon-hook-navigate-left").click({force:true}) cy.get(".nc-icon-hook-navigate-left").click({force:true})
} }
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType, testMode) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`Webhook`, () => { describe(`Quick Tests`, () => {
let cellIdx = 1;
let columnCount = cn.length
if(testMode === 'AT_IMPORT') {
cellIdx = 3;
columnCount -= 3;
}
before(() => { before(() => {
if( testMode === 'CY_QUICK') {
// cy.task("copyFile") // cy.task("copyFile")
loginPage.signIn(roles.owner.credentials); loginPage.signIn(roles.owner.credentials);
projectsPage.openProject("sample"); projectsPage.openProject("sample");
}
}); });
after(() => {}); after(() => {});
it("Verify Schema", () => {
cy.openTableTab("Film", 3)
// verify if all tables exist
for(let i=0; i<tn.length; i++)
cy.get(".nc-project-tree").contains(tn[i]).should('exist')
// for Film table, verify columns
for(let i=0; i<columnCount; i++)
cy.get(".nc-grid-header-row").find(`[data-col="${cn[i]}"]`).should('exist')
});
it("Verify Data types", () => { it("Verify Data types", () => {
cy.openTableTab("Film", 3); cy.openTableTab("Film", 3);
// normal cells // normal cells
for (let [key, value] of Object.entries(records)) { for (let [key, value] of Object.entries(records)) {
mainPage.getCell(key, 1).contains(value).should("exist"); mainPage.getCell(key, cellIdx).contains(value).should("exist");
} }
// checkbox // checkbox
mainPage mainPage
.getCell("Done", 1) .getCell("Done", cellIdx)
.find(".mdi-check-circle-outline") .find(".mdi-check-circle-outline")
.should(records2.Done ? "exist" : "not.exist"); .should(records2.Done ? "exist" : "not.exist");
// date // date
// duration // duration
mainPage.getCell("Duration", 1).find('input').then(($e) => { mainPage.getCell("Duration", cellIdx).find('input').then(($e) => {
expect($e[0].value).to.equal(records2.Duration) expect($e[0].value).to.equal(records2.Duration)
}) })
// rating // rating
mainPage mainPage
.getCell("Rating", 1) .getCell("Rating", cellIdx)
.find("button.mdi-star") .find("button.mdi-star")
.should("have.length", records2.Rating); .should("have.length", records2.Rating);
// verifying only one instance as its different for PG & SQLite
// for PG: its Actor1, Actor1
// for SQLite: its Actor1, Actor2
// LinkToAnotherRecord // LinkToAnotherRecord
mainPage.getCell("Actor", 1).scrollIntoView(); mainPage.getCell("Actor", cellIdx).scrollIntoView();
cy.get( cy.get(
':nth-child(1) > [data-col="Actor"] > .nc-virtual-cell > .v-lazy > .d-100 > .chips > :nth-child(1) > .v-chip__content > .name' `:nth-child(${cellIdx}) > [data-col="Actor"] > .nc-virtual-cell > .v-lazy > .d-100 > .chips > :nth-child(1) > .v-chip__content > .name`
) )
.contains(records2.Actor[0]) .contains(records2.Actor[0])
.should("exist"); .should("exist");
cy.get( // cy.get(
':nth-child(1) > [data-col="Actor"] > .nc-virtual-cell > .v-lazy > .d-100 > .chips > :nth-child(2) > .v-chip__content > .name' // `:nth-child(${cellIdx}) > [data-col="Actor"] > .nc-virtual-cell > .v-lazy > .d-100 > .chips > :nth-child(2) > .v-chip__content > .name`
) // )
.contains(records2.Actor[1]) // .contains(records2.Actor[1])
.should("exist"); // .should("exist");
// mainPage.getCell("Actor", 1).find(".nc-virtual-cell > .v-lazy > .d-100 > .chips").eq(0).contains("Actor1").should('exist')
// mainPage.getCell("Actor", 1).find(".nc-virtual-cell > .v-lazy > .d-100 > .chips").eq(1).contains("Actor2").should('exist')
// lookup // lookup
mainPage.getCell("Status (from Actor)", 1).scrollIntoView(); mainPage.getCell("Status (from Actor)", cellIdx).scrollIntoView();
cy.get( cy.get(
':nth-child(1) > [data-col="Status (from Actor)"] > .nc-virtual-cell > .v-lazy > .d-flex > :nth-child(1) > .v-chip__content > div > .set-item' `:nth-child(${cellIdx}) > [data-col="Status (from Actor)"] > .nc-virtual-cell > .v-lazy > .d-flex > :nth-child(1) > .v-chip__content > div > .set-item`
) )
.contains(records2["Status (from Actor)"][0]) .contains(records2["Status (from Actor)"][0])
.should("exist"); .should("exist");
cy.get( // cy.get(
':nth-child(1) > [data-col="Status (from Actor)"] > .nc-virtual-cell > .v-lazy > .d-flex > :nth-child(2) > .v-chip__content > div > .set-item' // `:nth-child(${cellIdx}) > [data-col="Status (from Actor)"] > .nc-virtual-cell > .v-lazy > .d-flex > :nth-child(2) > .v-chip__content > div > .set-item`
) // )
.contains(records2["Status (from Actor)"][1]) // .contains(records2["Status (from Actor)"][1])
.should("exist"); // .should("exist");
// rollup // rollup
mainPage.getCell("RollUp", 1).scrollIntoView(); if( testMode === 'CY_QUICK') {
// cy.get(':nth-child(1) > [data-col="RollUp"] > .nc-virtual-cell > .v-lazy > span').contains(records2.RollUp).should('exist')
cy.get(`:nth-child(1) > [data-col="RollUp"] > .nc-virtual-cell`) mainPage.getCell("RollUp", cellIdx).scrollIntoView();
cy.get(`:nth-child(${cellIdx}) > [data-col="RollUp"] > .nc-virtual-cell`)
.contains(records2.RollUp) .contains(records2.RollUp)
.should("exist"); .should("exist");
// formula // formula
mainPage.getCell("Computation", 1).scrollIntoView(); mainPage.getCell("Computation", cellIdx).scrollIntoView();
cy.get( cy.get(
`:nth-child(1) > [data-col="Computation"] > .nc-virtual-cell` `:nth-child(${cellIdx}) > [data-col="Computation"] > .nc-virtual-cell`
) )
.contains(records2.Computation) .contains(records2.Computation)
.should("exist"); .should("exist");
// ltar hm relation // ltar hm relation
mainPage.getCell("Producer", 1).scrollIntoView(); mainPage.getCell("Producer", cellIdx).scrollIntoView();
cy.get( cy.get(
':nth-child(1) > [data-col="Producer"] > .nc-virtual-cell > .v-lazy > .d-100 > .chips > :nth-child(1) > .v-chip__content > .name' `:nth-child(${cellIdx}) > [data-col="Producer"] > .nc-virtual-cell > .v-lazy > .d-100 > .chips > :nth-child(1) > .v-chip__content > .name`
) )
.contains(records2.Producer[0]) .contains(records2.Producer[0])
.should("exist"); .should("exist");
cy.get( cy.get(
':nth-child(1) > [data-col="Producer"] > .nc-virtual-cell > .v-lazy > .d-100 > .chips > :nth-child(2) > .v-chip__content > .name' `:nth-child(${cellIdx}) > [data-col="Producer"] > .nc-virtual-cell > .v-lazy > .d-100 > .chips > :nth-child(2) > .v-chip__content > .name`
) )
.contains(records2.Producer[1]) .contains(records2.Producer[1])
.should("exist"); .should("exist");
}
cy.closeTableTab("Film"); cy.closeTableTab("Film");
}); });
@ -215,6 +247,7 @@ export const genTest = (apiType, dbType) => {
}); });
it("Verify Webhooks", () => { it("Verify Webhooks", () => {
if( testMode === 'CY_QUICK') {
cy.openTableTab("Actor", 25); cy.openTableTab("Actor", 25);
openWebhook(0) openWebhook(0)
verifyWebhook({ verifyWebhook({
@ -250,7 +283,7 @@ export const genTest = (apiType, dbType) => {
cy.get("body").type("{esc}"); cy.get("body").type("{esc}");
cy.closeTableTab("Actor"); cy.closeTableTab("Actor");
}
}); });
it("Pagination", () => { it("Pagination", () => {
@ -279,7 +312,8 @@ export const genTest = (apiType, dbType) => {
cy.get(".nc-grid-header-cell").contains('Name').should("be.visible"); cy.get(".nc-grid-header-cell").contains('Name').should("be.visible");
cy.get(".nc-grid-header-cell").contains('Notes').should("be.visible"); cy.get(".nc-grid-header-cell").contains('Notes').should("be.visible");
cy.get(".nc-grid-header-cell").contains('Attachments').should("not.be.visible"); // fix me!
if(testMode !== 'AT_IMPORT') cy.get(".nc-grid-header-cell").contains('Attachments').should("not.be.visible");
cy.get(".nc-grid-header-cell").contains('Status').should("be.visible"); cy.get(".nc-grid-header-cell").contains('Status').should("be.visible");
cy.get(".nc-grid-header-cell").contains('Film').should("be.visible"); cy.get(".nc-grid-header-cell").contains('Film').should("be.visible");
@ -320,6 +354,8 @@ export const genTest = (apiType, dbType) => {
}); });
it("Views, bt relation", () => { it("Views, bt relation", () => {
if( testMode === 'CY_QUICK') {
cy.openTableTab("Producer", 3) cy.openTableTab("Producer", 3)
cy.get('.nc-grid-view-item').should('have.length', 4) cy.get('.nc-grid-view-item').should('have.length', 4)
cy.get('.nc-form-view-item').should('have.length', 4) cy.get('.nc-form-view-item').should('have.length', 4)
@ -334,11 +370,31 @@ export const genTest = (apiType, dbType) => {
.should("exist"); .should("exist");
cy.closeTableTab("Producer") cy.closeTableTab("Producer")
}
})
it("Delete Project", () => {
if( testMode === 'AT_IMPORT') {
mainPage.toolBarTopLeft(mainPage.HOME).click({force:true})
cy.get(`.mdi-delete-outline`, {
timeout: 10000,
}) })
.should("exist")
.last()
.click();
cy.getActiveModal()
.find("button")
.contains("Submit")
.should("exist")
.click();
cy.toastWait("deleted successfully");
}
});
}); });
}; };
genTest("rest", "xcdb"); // genTest("rest", "xcdb");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @copyright Copyright (c) 2021, Xgene Cloud Ltd

11
scripts/cypress/integration/test/quickTest.js

@ -1,14 +1,17 @@
let t7b = require("../common/7b_import_from_airtable");
let t9a = require("../common/9a_QuickTest"); let t9a = require("../common/9a_QuickTest");
const { const {
setCurrentMode, setCurrentMode,
} = require("../../support/page_objects/projectConstants"); } = require("../../support/page_objects/projectConstants");
// use 0 as mode to execute individual files (debug mode, skip pre-configs)
// use 1 mode if noco.db doesnt contain user credentials (full run over GIT)
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
t9a.genTest(apiType, dbType); // CY Migration verification / Quick test
t9a.genTest(apiType, dbType, "CY_QUICK");
// AT Import verification
t7b.genTest(apiType, dbType)
t9a.genTest(apiType, dbType, "AT_IMPORT");
}; };
nocoTestSuite("rest", "xcdb"); nocoTestSuite("rest", "xcdb");

Loading…
Cancel
Save