Browse Source

Merge pull request #1167 from nocodb/refactor/cypress-test-suite

refactor: test-cypress consistent api's for api/db type
pull/1169/head
Raju Udava 3 years ago committed by GitHub
parent
commit
36e83eab68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      scripts/cypress/cypress.json
  2. 47
      scripts/cypress/integration/common/00_pre_configurations.js
  3. 4
      scripts/cypress/integration/common/1a_table_operations.js
  4. 61
      scripts/cypress/integration/common/1c_sql_view.js
  5. 34
      scripts/cypress/integration/common/5a_user_role.js
  6. 4
      scripts/cypress/integration/test/explicitLogin.js
  7. 2
      scripts/cypress/integration/test/gqlMisc.js
  8. 2
      scripts/cypress/integration/test/gqlRoles.js
  9. 2
      scripts/cypress/integration/test/gqlTableOps.js
  10. 2
      scripts/cypress/integration/test/gqlViews.js
  11. 4
      scripts/cypress/integration/test/masterSuiteGql.js
  12. 4
      scripts/cypress/integration/test/masterSuiteRest.js
  13. 2
      scripts/cypress/integration/test/restMisc.js
  14. 2
      scripts/cypress/integration/test/restRoles.js
  15. 2
      scripts/cypress/integration/test/restTableOps.js
  16. 2
      scripts/cypress/integration/test/restViews.js
  17. 2
      scripts/cypress/integration/test/xcdb-gqlMisc.js
  18. 2
      scripts/cypress/integration/test/xcdb-gqlRoles.js
  19. 2
      scripts/cypress/integration/test/xcdb-gqlTableOps.js
  20. 2
      scripts/cypress/integration/test/xcdb-gqlViews.js
  21. 2
      scripts/cypress/integration/test/xcdb-restMisc.js
  22. 2
      scripts/cypress/integration/test/xcdb-restRoles.js
  23. 2
      scripts/cypress/integration/test/xcdb-restTableOps.js
  24. 2
      scripts/cypress/integration/test/xcdb-restViews.js
  25. 4
      scripts/cypress/support/page_objects/navigation.js
  26. 84
      scripts/cypress/support/page_objects/projectConstants.js

14
scripts/cypress/cypress.json

@ -27,20 +27,18 @@
"screenshotOnRunFailure": false,
"numTestsKeptInMemory": 0,
"env": {
"testMode": "extREST.extGQL.xcdbREST.xcdbGQL",
"testMode": [
{ "apiType": "rest", "dbType": "xcdb" },
{ "apiType": "graphql", "dbType": "xcdb" },
{ "apiType": "rest", "dbType": "mysql" },
{ "apiType": "graphql", "dbType": "mysql" }
],
"db": {
"host": "127.0.0.1",
"user": "root",
"password": "password"
}
},
"supportedOptionsForTestModes": [
"extGQL",
"extREST",
"xcdbREST",
"xcdbREST",
"can configure multiple too, seperated by a . as in extREST.extGQL"
],
"fixturesFolder": "scripts/cypress/fixtures",
"integrationFolder": "scripts/cypress/integration",
"pluginsFile": "scripts/cypress/plugins/index.js",

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

@ -7,8 +7,6 @@ import {
staticProjects,
roles,
isTestSuiteActive,
getPrimarySuite,
isSecondarySuite,
getCurrentMode,
isXcdb,
setProjectString,
@ -182,7 +180,7 @@ export const genTest = (apiType, dbType) => {
projectsPage.createProject(proj.basic, proj.config);
}
if (dbType) {
if (dbType === "xcdb") {
// store base URL- to re-visit and delete form view later
let projId;
cy.url()
@ -224,58 +222,19 @@ export const genTest = (apiType, dbType) => {
// if (isTestSuiteActive('graphql', false)) createProject(staticProjects.externalGQL)
if ("rest" == apiType) {
if (true == dbType) {
if ("xcdb" === dbType) {
createProject(staticProjects.sampleREST);
} else {
createProject(staticProjects.externalREST);
}
} else if ("graphql" == apiType) {
if (true == dbType) {
if ("xcdb" === dbType) {
createProject(staticProjects.sampleGQL);
} else {
createProject(staticProjects.externalGQL);
}
}
});
// describe('Static user creations (different roles)', () => {
// beforeEach(() => {
// loginPage.signIn(roles.owner.credentials)
// projectsPage.openProject(getPrimarySuite().basic.name)
// })
// const addUser = (user) => {
// it(`RoleType: ${user.name}`, () => {
// mainPage.addNewUserToProject(user.credentials, user.name)
// })
// }
// addUser(roles.creator)
// addUser(roles.editor)
// addUser(roles.commenter)
// addUser(roles.viewer)
// })
// describe('Static users- add to other static projects', () => {
// const addUserToProject = (proj) => {
// it(`Add users to ${proj.basic.name}`, () => {
// loginPage.signIn(roles.owner.credentials)
// projectsPage.openProject(proj.basic.name)
// mainPage.addExistingUserToProject(roles.creator.credentials.username, roles.creator.name)
// mainPage.addExistingUserToProject(roles.editor.credentials.username, roles.editor.name)
// mainPage.addExistingUserToProject(roles.commenter.credentials.username, roles.commenter.name)
// mainPage.addExistingUserToProject(roles.viewer.credentials.username, roles.viewer.name)
// })
// }
// if (isSecondarySuite('rest', true)) addUserToProject(staticProjects.sampleREST)
// if (isSecondarySuite('graphql', true)) addUserToProject(staticProjects.sampleGQL)
// if (isSecondarySuite('rest', false)) addUserToProject(staticProjects.externalREST)
// if (isSecondarySuite('graphql', false)) addUserToProject(staticProjects.externalGQL)
// })
};
/**

4
scripts/cypress/integration/common/1a_table_operations.js

@ -4,7 +4,9 @@ import { mainPage } from "../../support/page_objects/mainPage";
export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${dbType ? "Meta - " : ""}${apiType.toUpperCase()} api - Table`, () => {
describe(`${
dbType === "xcdb" ? "Meta - " : ""
}${apiType.toUpperCase()} api - Table`, () => {
before(() => {
cy.get(".mdi-close").click({ multiple: true });
});

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

@ -21,12 +21,18 @@ export const genTest = (apiType, dbType) => {
// Record-1 validation
mainPage.getCell(`ID`, 1).contains("1").should("exist");
mainPage.getCell(`Name`, 1).contains("MARY SMITH").should("exist");
mainPage
.getCell(`Name`, 1)
.contains("MARY SMITH")
.should("exist");
mainPage
.getCell(`Address`, 1)
.contains("1913 Hanoi Way")
.should("exist");
mainPage.getCell(`ZipCode`, 1).contains("35200").should("exist");
mainPage
.getCell(`ZipCode`, 1)
.contains("35200")
.should("exist");
// Record-2 validation
mainPage.getCell(`ID`, 2).contains("2").should("exist");
@ -38,7 +44,10 @@ export const genTest = (apiType, dbType) => {
.getCell(`Address`, 2)
.contains("1121 Loja Avenue")
.should("exist");
mainPage.getCell(`ZipCode`, 2).contains("17886").should("exist");
mainPage
.getCell(`ZipCode`, 2)
.contains("17886")
.should("exist");
// Column operations: Hide
mainPage.hideField(`ZipCode`);
@ -46,12 +55,18 @@ export const genTest = (apiType, dbType) => {
// Column operations: Sort
mainPage.sortField("Name", "Z -> A");
mainPage.getCell(`Name`, 1).contains("ZACHARY HITE").should("exist");
mainPage
.getCell(`Name`, 1)
.contains("ZACHARY HITE")
.should("exist");
mainPage.clearSort();
// Column operations: Filter
mainPage.filterField("Name", "is like", "MARY");
mainPage.getCell(`Name`, 1).contains("MARY SMITH").should("exist");
mainPage
.getCell(`Name`, 1)
.contains("MARY SMITH")
.should("exist");
mainPage.filterReset();
cy.closeViewsTab("CustomerList");
@ -66,8 +81,14 @@ export const genTest = (apiType, dbType) => {
// 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(`FirstName`, 1)
.contains("PENELOPE")
.should("exist");
mainPage
.getCell(`LastName`, 1)
.contains("GUINESS")
.should("exist");
mainPage
.getCell(`FilmInfo`, 1)
.contains("Animation: ANACONDA CONFESSIONS;")
@ -75,11 +96,19 @@ export const genTest = (apiType, dbType) => {
// 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(`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;")
.contains(
"Action: BULL SHAWSHANK; Animation: FIGHT JAWBREAKER;"
)
.should("exist");
// Column operations: Hide
@ -88,19 +117,25 @@ export const genTest = (apiType, dbType) => {
// Column operations: Sort
mainPage.sortField("FirstName", "Z -> A");
mainPage.getCell(`FirstName`, 1).contains("ZERO").should("exist");
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
.getCell(`FirstName`, 1)
.contains("PENELOPE")
.should("exist");
mainPage.filterReset();
cy.closeViewsTab("ActorInfo");
}
});
it(`SQL View List`, () => {
it.skip(`SQL View List`, () => {
// confirm if other views exist
//
cy.openViewsTab("CustomerList", 25);

34
scripts/cypress/integration/common/5a_user_role.js

@ -20,10 +20,6 @@ export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return;
describe("Static user creations (different roles)", () => {
// beforeEach(() => {
// loginPage.signIn(roles.owner.credentials)
// projectsPage.openProject(getPrimarySuite().basic.name)
// })
before(() => {
mainPage.navigationDraw(mainPage.TEAM_N_AUTH).click();
});
@ -42,7 +38,10 @@ export const genTest = (apiType, dbType) => {
user.name
);
} else {
mainPage.addNewUserToProject(user.credentials, user.name);
mainPage.addNewUserToProject(
user.credentials,
user.name
);
}
});
});
@ -98,15 +97,24 @@ export const genTest = (apiType, dbType) => {
cy.url({ timeout: 6000 }).should("contain", "#/project");
if (dbType) {
if (dbType === "xcdb") {
if ("rest" == apiType)
projectsPage.openProject(staticProjects.sampleREST.basic.name);
else projectsPage.openProject(staticProjects.sampleGQL.basic.name);
} else {
projectsPage.openProject(
staticProjects.sampleREST.basic.name
);
else
projectsPage.openProject(
staticProjects.sampleGQL.basic.name
);
} else if (dbType === "mysql") {
if ("rest" == apiType)
projectsPage.openProject(staticProjects.externalREST.basic.name);
projectsPage.openProject(
staticProjects.externalREST.basic.name
);
else
projectsPage.openProject(staticProjects.externalGQL.basic.name);
projectsPage.openProject(
staticProjects.externalGQL.basic.name
);
}
if (roleType != "creator") {
@ -183,7 +191,9 @@ export const genTest = (apiType, dbType) => {
for (let i = 0; i < storedRecords.length; i++) {
// cy.log(retrievedRecords[i])
expect(retrievedRecords[i]).to.be.equal(storedRecords[i]);
expect(retrievedRecords[i]).to.be.equal(
storedRecords[i]
);
}
};

4
scripts/cypress/integration/test/explicitLogin.js

@ -2,7 +2,7 @@ import { loginPage } from "../../support/page_objects/navigation";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return;
// if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} api - Login & Open project`, () => {
// Run once before test- create project (rest/graphql)
@ -21,7 +21,7 @@ export const genTest = (apiType, dbType) => {
});
};
// genTest('rest', false)
// genTest("rest", "mysql");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

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

@ -31,7 +31,7 @@ const nocoTestSuite = (apiType, dbType) => {
t6e.genTest(apiType, dbType);
};
nocoTestSuite("graphql", false);
nocoTestSuite("graphql", "mysql");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

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

@ -22,7 +22,7 @@ const nocoTestSuite = (apiType, dbType) => {
t5b.genTest(apiType, dbType);
};
nocoTestSuite("graphql", false);
nocoTestSuite("graphql", "mysql");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

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

@ -40,7 +40,7 @@ const nocoTestSuite = (apiType, dbType) => {
t3d.genTest(apiType, dbType);
};
nocoTestSuite("graphql", false);
nocoTestSuite("graphql", "mysql");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

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

@ -30,7 +30,7 @@ const nocoTestSuite = (apiType, dbType) => {
t4f.genTest(apiType, dbType);
};
nocoTestSuite("graphql", false);
nocoTestSuite("graphql", "mysql");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

4
scripts/cypress/integration/test/masterSuiteGql.js

@ -57,8 +57,8 @@ const nocoTestSuite = (apiType, dbType) => {
t6e.genTest(apiType, dbType);
};
// nocoTestSuite('rest', false)
nocoTestSuite("graphql", false);
// nocoTestSuite('rest', "mysql")
nocoTestSuite("graphql", "mysql");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

4
scripts/cypress/integration/test/masterSuiteRest.js

@ -57,8 +57,8 @@ const nocoTestSuite = (apiType, dbType) => {
t6e.genTest(apiType, dbType);
};
nocoTestSuite("rest", false);
// nocoTestSuite('graphql', false)
nocoTestSuite("rest", "mysql");
// nocoTestSuite('graphql', "mysql")
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

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

@ -36,7 +36,7 @@ const nocoTestSuite = (apiType, dbType) => {
t7a.genTest(apiType, dbType);
};
nocoTestSuite("rest", false);
nocoTestSuite("rest", "mysql");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

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

@ -22,7 +22,7 @@ const nocoTestSuite = (apiType, dbType) => {
t5b.genTest(apiType, dbType);
};
nocoTestSuite("rest", false);
nocoTestSuite("rest", "mysql");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

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

@ -40,7 +40,7 @@ const nocoTestSuite = (apiType, dbType) => {
t3d.genTest(apiType, dbType);
};
nocoTestSuite("rest", false);
nocoTestSuite("rest", "mysql");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

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

@ -30,7 +30,7 @@ const nocoTestSuite = (apiType, dbType) => {
t4f.genTest(apiType, dbType);
};
nocoTestSuite("rest", false);
nocoTestSuite("rest", "mysql");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

2
scripts/cypress/integration/test/xcdb-gqlMisc.js

@ -31,7 +31,7 @@ const nocoTestSuite = (apiType, dbType) => {
t6e.genTest(apiType, dbType);
};
nocoTestSuite("graphql", true);
nocoTestSuite("graphql", "xcdb");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

2
scripts/cypress/integration/test/xcdb-gqlRoles.js

@ -22,7 +22,7 @@ const nocoTestSuite = (apiType, dbType) => {
t5b.genTest(apiType, dbType);
};
nocoTestSuite("graphql", true);
nocoTestSuite("graphql", "xcdb");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

2
scripts/cypress/integration/test/xcdb-gqlTableOps.js

@ -40,7 +40,7 @@ const nocoTestSuite = (apiType, dbType) => {
t3d.genTest(apiType, dbType);
};
nocoTestSuite("graphql", true);
nocoTestSuite("graphql", "xcdb");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

2
scripts/cypress/integration/test/xcdb-gqlViews.js

@ -30,7 +30,7 @@ const nocoTestSuite = (apiType, dbType) => {
t4f.genTest(apiType, dbType);
};
nocoTestSuite("graphql", true);
nocoTestSuite("graphql", "xcdb");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

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

@ -36,7 +36,7 @@ const nocoTestSuite = (apiType, dbType) => {
t7a.genTest(apiType, dbType);
};
nocoTestSuite("rest", true);
nocoTestSuite("rest", "xcdb");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

2
scripts/cypress/integration/test/xcdb-restRoles.js

@ -22,7 +22,7 @@ const nocoTestSuite = (apiType, dbType) => {
t5b.genTest(apiType, dbType);
};
nocoTestSuite("rest", true);
nocoTestSuite("rest", "xcdb");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

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

@ -40,7 +40,7 @@ const nocoTestSuite = (apiType, dbType) => {
t3d.genTest(apiType, dbType);
};
nocoTestSuite("rest", true);
nocoTestSuite("rest", "xcdb");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

2
scripts/cypress/integration/test/xcdb-restViews.js

@ -30,7 +30,7 @@ const nocoTestSuite = (apiType, dbType) => {
t4f.genTest(apiType, dbType);
};
nocoTestSuite("rest", true);
nocoTestSuite("rest", "xcdb");
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

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

@ -58,11 +58,11 @@ export class _loginPage {
loginAndOpenProject(apiType, dbType) {
loginPage.signIn(roles.owner.credentials);
if (!dbType) {
if (dbType === "mysql") {
if ("rest" == apiType)
projectsPage.openProject(staticProjects.externalREST.basic.name);
else projectsPage.openProject(staticProjects.externalGQL.basic.name);
} else {
} else if(dbType === "xcdb") {
if ("rest" == apiType)
projectsPage.openProject(staticProjects.sampleREST.basic.name);
else projectsPage.openProject(staticProjects.sampleGQL.basic.name);

84
scripts/cypress/support/page_objects/projectConstants.js

@ -28,7 +28,10 @@ export const roles = {
},
creator: {
name: "creator",
credentials: { username: "creator@nocodb.com", password: "Password123." },
credentials: {
username: "creator@nocodb.com",
password: "Password123.",
},
validations: {
advSettings: true,
editSchema: true,
@ -39,7 +42,10 @@ export const roles = {
},
editor: {
name: "editor",
credentials: { username: "editor@nocodb.com", password: "Password123." },
credentials: {
username: "editor@nocodb.com",
password: "Password123.",
},
validations: {
advSettings: false,
editSchema: false,
@ -50,7 +56,10 @@ export const roles = {
},
commenter: {
name: "commenter",
credentials: { username: "commenter@nocodb.com", password: "Password123." },
credentials: {
username: "commenter@nocodb.com",
password: "Password123.",
},
validations: {
advSettings: false,
editSchema: false,
@ -61,7 +70,10 @@ export const roles = {
},
viewer: {
name: "viewer",
credentials: { username: "viewer@nocodb.com", password: "Password123." },
credentials: {
username: "viewer@nocodb.com",
password: "Password123.",
},
validations: {
advSettings: false,
editSchema: false,
@ -97,65 +109,15 @@ export const staticProjects = {
//
export const isTestSuiteActive = (apiType, dbType) => {
const env = Cypress.env("testMode");
if (!dbType) {
switch (apiType) {
case "rest":
return env.includes("extREST") ? true : false;
case "graphql":
return env.includes("extGQL") ? true : false;
}
} else {
switch (apiType) {
case "rest":
return env.includes("xcdbREST") ? true : false;
case "graphql":
return env.includes("xcdbGQL") ? true : false;
}
}
};
// expecting different modes to be seperated by a .
export const getPrimarySuite = () => {
const env = Cypress.env("testMode").split(".");
switch (env[0]) {
case "extREST":
return staticProjects.externalREST;
case "extGQL":
return staticProjects.externalGQL;
case "xcdbREST":
return staticProjects.sampleREST;
case "xcdbGQL":
return staticProjects.sampleGQL;
}
};
export const isSecondarySuite = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return false;
const env = Cypress.env("testMode").split(".");
switch (env[0]) {
case "extREST":
return apiType == "rest" && !dbType ? false : true;
case "extGQL":
return apiType == "graphql" && !dbType ? false : true;
case "xcdbREST":
return apiType == "rest" && dbType ? false : true;
case "xcdbGQL":
return apiType == "graphql" && dbType ? false : true;
}
return env.some(
(element) => element.apiType === apiType && element.dbType === dbType
);
};
let currentTestMode = ``;
let currentTestMode = { apiType: null, dbType: null };
let xcdbProjectString = ``;
export function setCurrentMode(apiType, dbType) {
if (!dbType) {
if (apiType == "rest") currentTestMode = "extREST";
else currentTestMode = "extGQL";
} else {
if (apiType == "rest") currentTestMode = "xcdbREST";
else currentTestMode = "xcdbGQL";
}
currentTestMode = { apiType: apiType, dbType: dbType };
}
export function getCurrentMode() {
@ -163,9 +125,7 @@ export function getCurrentMode() {
}
export function isXcdb() {
if (currentTestMode === "xcdbREST" || currentTestMode === "xcdbGQL")
return true;
return false;
return currentTestMode.dbType === "xcdb";
}
export function setProjectString(projStr) {

Loading…
Cancel
Save