Browse Source

refactor: consistent api's for api/db type

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/1167/head
Raju Udava 3 years ago
parent
commit
a461fa13eb
  1. 98
      scripts/cypress/cypress.json
  2. 47
      scripts/cypress/integration/common/00_pre_configurations.js
  3. 184
      scripts/cypress/integration/common/1a_table_operations.js
  4. 297
      scripts/cypress/integration/common/1c_sql_view.js
  5. 380
      scripts/cypress/integration/common/5a_user_role.js
  6. 28
      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. 28
      scripts/cypress/integration/test/xcdb-restViews.js
  25. 4
      scripts/cypress/support/page_objects/navigation.js
  26. 228
      scripts/cypress/support/page_objects/projectConstants.js

98
scripts/cypress/cypress.json

@ -1,52 +1,50 @@
{
"baseUrl": "http://localhost:3000/",
"testFiles": [
"test/restTableOps.js",
"test/restViews.js",
"test/restRoles.js",
"test/restMisc.js",
"test/xcdb-restTableOps.js",
"test/xcdb-restViews.js",
"test/xcdb-restRoles.js",
"test/xcdb-restMisc.js",
"test/gqlTableOps.js",
"test/gqlViews.js",
"test/gqlRoles.js",
"test/gqlMisc.js",
"test/xcdb-gqlTableOps.js",
"test/xcdb-gqlViews.js",
"test/xcdb-gqlRoles.js",
"test/xcdb-gqlMisc.js"
],
"defaultCommandTimeout": 13000,
"pageLoadTimeout": 600000,
"viewportWidth": 1980,
"viewportHeight": 1000,
"video": false,
"retries": 0,
"screenshotOnRunFailure": false,
"numTestsKeptInMemory": 0,
"env": {
"testMode": "extREST.extGQL.xcdbREST.xcdbGQL",
"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",
"screenshotsFolder": "scripts/cypress/screenshots",
"videosFolder": "scripts/cypress/videos",
"downloadsFolder": "scripts/cypress/downloads",
"supportFile": "scripts/cypress/support/index.js",
"chromeWebSecurity": false
"baseUrl": "http://localhost:3000/",
"testFiles": [
"test/restTableOps.js",
"test/restViews.js",
"test/restRoles.js",
"test/restMisc.js",
"test/xcdb-restTableOps.js",
"test/xcdb-restViews.js",
"test/xcdb-restRoles.js",
"test/xcdb-restMisc.js",
"test/gqlTableOps.js",
"test/gqlViews.js",
"test/gqlRoles.js",
"test/gqlMisc.js",
"test/xcdb-gqlTableOps.js",
"test/xcdb-gqlViews.js",
"test/xcdb-gqlRoles.js",
"test/xcdb-gqlMisc.js"
],
"defaultCommandTimeout": 13000,
"pageLoadTimeout": 600000,
"viewportWidth": 1980,
"viewportHeight": 1000,
"video": false,
"retries": 0,
"screenshotOnRunFailure": false,
"numTestsKeptInMemory": 0,
"env": {
"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"
}
},
"fixturesFolder": "scripts/cypress/fixtures",
"integrationFolder": "scripts/cypress/integration",
"pluginsFile": "scripts/cypress/plugins/index.js",
"screenshotsFolder": "scripts/cypress/screenshots",
"videosFolder": "scripts/cypress/videos",
"downloadsFolder": "scripts/cypress/downloads",
"supportFile": "scripts/cypress/support/index.js",
"chromeWebSecurity": false
}

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)
// })
};
/**

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

@ -2,98 +2,100 @@ import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import { mainPage } from "../../support/page_objects/mainPage";
export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${dbType ? "Meta - " : ""}${apiType.toUpperCase()} api - Table`, () => {
before(() => {
cy.get(".mdi-close").click({ multiple: true });
});
after(() => {
cy.get(".mdi-close").click({ multiple: true });
});
const name = "tablex";
// create a new random table
it("Create Table", () => {
cy.createTable(name);
});
// delete newly created table
it("Delete Table", () => {
cy.deleteTable(name);
});
const getAuditCell = (row, col) => {
return cy.get("table > tbody > tr").eq(row).find("td").eq(col);
};
it("Open Audit tab", () => {
mainPage.navigationDraw(mainPage.AUDIT).click();
// wait for column headers to appear
//
cy.get("thead > tr > th.caption").should("have.length", 5);
// Audit table entries
// [Header] Operation Type, Operation Sub Type, Description, User, Created
// [0] TABLE, DELETED, delete table table-x, user@nocodb.com, ...
// [1] TABLE, Created, created table table-x, user@nocodb.com, ...
getAuditCell(0, 0).contains("TABLE").should("exist");
getAuditCell(0, 1).contains("DELETED").should("exist");
getAuditCell(0, 3).contains("user@nocodb.com").should("exist");
getAuditCell(1, 0).contains("TABLE").should("exist");
getAuditCell(1, 1).contains("CREATED").should("exist");
getAuditCell(1, 3).contains("user@nocodb.com").should("exist");
});
it("Table Rename operation", () => {
cy.renameTable("City", "CityX");
// verify
// 1. Table name in project tree has changed
cy.get(".nc-project-tree").contains("CityX").should("exist");
// 2. Table tab name has changed
cy.get(`.project-tab:contains('CityX'):visible`).should("exist");
// 3. contents of the table are valid
mainPage
.getCell(`City`, 1)
.contains("A Corua (La Corua)")
.should("exist");
cy.closeTableTab("CityX");
// 4. verify linked contents in other table
// 4a. Address table, has many field
cy.openTableTab("Address", 25);
mainPage.getCell("City <= Address", 1).scrollIntoView();
mainPage
.getCell("City <= Address", 1)
.find(".name")
.contains("Lethbridge")
.should("exist");
cy.closeTableTab("Address");
// 4b. Country table, belongs to field
cy.openTableTab("Country", 25);
mainPage
.getCell("Country => City", 1)
.find(".name")
.contains("Kabul")
.should("exist");
cy.closeTableTab("Country");
// revert re-name operation to not impact rest of test suite
cy.renameTable("CityX", "City");
if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${
dbType === "xcdb" ? "Meta - " : ""
}${apiType.toUpperCase()} api - Table`, () => {
before(() => {
cy.get(".mdi-close").click({ multiple: true });
});
after(() => {
cy.get(".mdi-close").click({ multiple: true });
});
const name = "tablex";
// create a new random table
it("Create Table", () => {
cy.createTable(name);
});
// delete newly created table
it("Delete Table", () => {
cy.deleteTable(name);
});
const getAuditCell = (row, col) => {
return cy.get("table > tbody > tr").eq(row).find("td").eq(col);
};
it("Open Audit tab", () => {
mainPage.navigationDraw(mainPage.AUDIT).click();
// wait for column headers to appear
//
cy.get("thead > tr > th.caption").should("have.length", 5);
// Audit table entries
// [Header] Operation Type, Operation Sub Type, Description, User, Created
// [0] TABLE, DELETED, delete table table-x, user@nocodb.com, ...
// [1] TABLE, Created, created table table-x, user@nocodb.com, ...
getAuditCell(0, 0).contains("TABLE").should("exist");
getAuditCell(0, 1).contains("DELETED").should("exist");
getAuditCell(0, 3).contains("user@nocodb.com").should("exist");
getAuditCell(1, 0).contains("TABLE").should("exist");
getAuditCell(1, 1).contains("CREATED").should("exist");
getAuditCell(1, 3).contains("user@nocodb.com").should("exist");
});
it("Table Rename operation", () => {
cy.renameTable("City", "CityX");
// verify
// 1. Table name in project tree has changed
cy.get(".nc-project-tree").contains("CityX").should("exist");
// 2. Table tab name has changed
cy.get(`.project-tab:contains('CityX'):visible`).should("exist");
// 3. contents of the table are valid
mainPage
.getCell(`City`, 1)
.contains("A Corua (La Corua)")
.should("exist");
cy.closeTableTab("CityX");
// 4. verify linked contents in other table
// 4a. Address table, has many field
cy.openTableTab("Address", 25);
mainPage.getCell("City <= Address", 1).scrollIntoView();
mainPage
.getCell("City <= Address", 1)
.find(".name")
.contains("Lethbridge")
.should("exist");
cy.closeTableTab("Address");
// 4b. Country table, belongs to field
cy.openTableTab("Country", 25);
mainPage
.getCell("Country => City", 1)
.find(".name")
.contains("Kabul")
.should("exist");
cy.closeTableTab("Country");
// revert re-name operation to not impact rest of test suite
cy.renameTable("CityX", "City");
});
});
});
};
/**

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

@ -1,140 +1,175 @@
import {
isTestSuiteActive,
isXcdb,
isTestSuiteActive,
isXcdb,
} from "../../support/page_objects/projectConstants";
import { mainPage } from "../../support/page_objects/mainPage";
export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} SQL Views`, () => {
// Run once before test- create project (rest/graphql)
//
before(() => {
// void
});
it(`XCDB: SQL View Column operations`, () => {
// Open one of the views & verify validity of first two entries
if (isXcdb()) {
cy.openViewsTab("CustomerList", 25);
// Record-1 validation
mainPage.getCell(`ID`, 1).contains("1").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");
// Record-2 validation
mainPage.getCell(`ID`, 2).contains("2").should("exist");
mainPage
.getCell(`Name`, 2)
.contains("PATRICIA JOHNSON")
.should("exist");
mainPage
.getCell(`Address`, 2)
.contains("1121 Loja Avenue")
.should("exist");
mainPage.getCell(`ZipCode`, 2).contains("17886").should("exist");
// Column operations: Hide
mainPage.hideField(`ZipCode`);
mainPage.unhideField(`ZipCode`);
// Column operations: Sort
mainPage.sortField("Name", "Z -> A");
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.filterReset();
cy.closeViewsTab("CustomerList");
}
});
it(`SQL View Column operations`, () => {
if (!isXcdb()) {
// 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("SalesByFilmCategory", 16);
cy.closeViewsTab("SalesByFilmCategory");
if (!isXcdb()) {
cy.openViewsTab("NicerButSlowerFilmList", 25);
cy.closeViewsTab("NicerButSlowerFilmList");
// SalesByStore && StaffList contain no entries. Hence marking row count to 0
cy.openViewsTab("SalesByStore", 0);
cy.closeViewsTab("SalesByStore");
cy.openViewsTab("StaffList", 0);
cy.closeViewsTab("StaffList");
} else {
cy.openViewsTab("SalesByStore", 2);
cy.closeViewsTab("SalesByStore");
cy.openViewsTab("StaffList", 2);
cy.closeViewsTab("StaffList");
}
});
after(() => {
// void
if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} SQL Views`, () => {
// Run once before test- create project (rest/graphql)
//
before(() => {
// void
});
it(`XCDB: SQL View Column operations`, () => {
// Open one of the views & verify validity of first two entries
if (isXcdb()) {
cy.openViewsTab("CustomerList", 25);
// Record-1 validation
mainPage.getCell(`ID`, 1).contains("1").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");
// Record-2 validation
mainPage.getCell(`ID`, 2).contains("2").should("exist");
mainPage
.getCell(`Name`, 2)
.contains("PATRICIA JOHNSON")
.should("exist");
mainPage
.getCell(`Address`, 2)
.contains("1121 Loja Avenue")
.should("exist");
mainPage
.getCell(`ZipCode`, 2)
.contains("17886")
.should("exist");
// Column operations: Hide
mainPage.hideField(`ZipCode`);
mainPage.unhideField(`ZipCode`);
// Column operations: Sort
mainPage.sortField("Name", "Z -> A");
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.filterReset();
cy.closeViewsTab("CustomerList");
}
});
it(`SQL View Column operations`, () => {
if (!isXcdb()) {
// 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.skip(`SQL View List`, () => {
// confirm if other views exist
//
cy.openViewsTab("CustomerList", 25);
cy.closeViewsTab("CustomerList");
cy.openViewsTab("FilmList", 25);
cy.closeViewsTab("FilmList");
cy.openViewsTab("SalesByFilmCategory", 16);
cy.closeViewsTab("SalesByFilmCategory");
if (!isXcdb()) {
cy.openViewsTab("NicerButSlowerFilmList", 25);
cy.closeViewsTab("NicerButSlowerFilmList");
// SalesByStore && StaffList contain no entries. Hence marking row count to 0
cy.openViewsTab("SalesByStore", 0);
cy.closeViewsTab("SalesByStore");
cy.openViewsTab("StaffList", 0);
cy.closeViewsTab("StaffList");
} else {
cy.openViewsTab("SalesByStore", 2);
cy.closeViewsTab("SalesByStore");
cy.openViewsTab("StaffList", 2);
cy.closeViewsTab("StaffList");
}
});
after(() => {
// void
});
});
});
};
/**

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

@ -1,205 +1,215 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation";
import { mainPage } from "../../support/page_objects/mainPage";
import {
roles,
staticProjects,
roles,
staticProjects,
} from "../../support/page_objects/projectConstants";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import {
_advSettings,
_editSchema,
_editData,
_editComment,
_viewMenu,
_topRightMenu,
disableTableAccess,
_accessControl,
_advSettings,
_editSchema,
_editData,
_editComment,
_viewMenu,
_topRightMenu,
disableTableAccess,
_accessControl,
} from "../spec/roleValidation.spec";
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();
});
if (!isTestSuiteActive(apiType, dbType)) return;
const addUser = (user) => {
it(`RoleType: ${user.name}`, () => {
// for first project, users need to be added explicitly using "New User" button
// for subsequent projects, they will be required to just add to this project
// using ROW count to identify if its former or latter scenario
// 5 users (owner, creator, editor, viewer, commenter) + row header = 6
cy.get(`tr`).then((obj) => {
cy.log(obj.length);
if (obj.length == 6) {
mainPage.addExistingUserToProject(
user.credentials.username,
user.name
);
} else {
mainPage.addNewUserToProject(user.credentials, user.name);
}
});
});
};
addUser(roles.creator);
addUser(roles.editor);
addUser(roles.commenter);
addUser(roles.viewer);
// Access contrl list- configuration
//
it(`Access control list- configuration`, () => {
// open Project metadata tab
//
mainPage.navigationDraw(mainPage.PROJ_METADATA).click();
cy.get(".nc-exp-imp-metadata").dblclick({ force: true });
cy.get(".nc-ui-acl-tab").click({ force: true });
// validate if it has 19 entries representing tables & views
cy.get(".nc-acl-table-row").should("have.length", 19);
// disable table & view access
//
disableTableAccess("language", "editor");
disableTableAccess("language", "commenter");
disableTableAccess("language", "viewer");
disableTableAccess("customerlist", "editor");
disableTableAccess("customerlist", "commenter");
disableTableAccess("customerlist", "viewer");
});
});
const roleValidation = (roleType) => {
describe(`User role validation`, () => {
if (roleType != "owner") {
it(`[${roles[roleType].name}] SignIn, Open project`, () => {
cy.log(mainPage.roleURL[roleType]);
cy.visit(mainPage.roleURL[roleType], {
baseUrl: null,
});
// Redirected to new URL, feed details
//
cy.get('input[type="text"]')
.should("exist")
.type(roles[roleType].credentials.username);
cy.get('input[type="password"]').type(
roles[roleType].credentials.password
);
cy.get('button:contains("SIGN")').click();
cy.url({ timeout: 6000 }).should("contain", "#/project");
if (dbType) {
if ("rest" == apiType)
projectsPage.openProject(staticProjects.sampleREST.basic.name);
else projectsPage.openProject(staticProjects.sampleGQL.basic.name);
} else {
if ("rest" == apiType)
projectsPage.openProject(staticProjects.externalREST.basic.name);
else
projectsPage.openProject(staticProjects.externalGQL.basic.name);
}
if (roleType != "creator") {
cy.closeTableTab("Actor");
}
describe("Static user creations (different roles)", () => {
before(() => {
mainPage.navigationDraw(mainPage.TEAM_N_AUTH).click();
});
}
///////////////////////////////////////////////////////
// Test suite
const addUser = (user) => {
it(`RoleType: ${user.name}`, () => {
// for first project, users need to be added explicitly using "New User" button
// for subsequent projects, they will be required to just add to this project
// using ROW count to identify if its former or latter scenario
// 5 users (owner, creator, editor, viewer, commenter) + row header = 6
cy.get(`tr`).then((obj) => {
cy.log(obj.length);
if (obj.length == 6) {
mainPage.addExistingUserToProject(
user.credentials.username,
user.name
);
} else {
mainPage.addNewUserToProject(
user.credentials,
user.name
);
}
});
});
};
it(`[${roles[roleType].name}] Left navigation menu, New User add`, () => {
// project configuration settings
//
_advSettings(roleType, false);
});
addUser(roles.creator);
addUser(roles.editor);
addUser(roles.commenter);
addUser(roles.viewer);
it(`[${roles[roleType].name}] Access control`, () => {
// Access control validation
// Access contrl list- configuration
//
_accessControl(roleType, false);
});
it(`[${roles[roleType].name}] Schema: create table, add/modify/delete column`, () => {
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
_editSchema(roleType, false);
});
it(`[${roles[roleType].name}] Data: add/modify/delete row, update cell contents`, () => {
// Table data related validations
// - Add/delete/modify row
//
_editData(roleType, false);
});
it(`Access control list- configuration`, () => {
// open Project metadata tab
//
mainPage.navigationDraw(mainPage.PROJ_METADATA).click();
cy.get(".nc-exp-imp-metadata").dblclick({ force: true });
cy.get(".nc-ui-acl-tab").click({ force: true });
// validate if it has 19 entries representing tables & views
cy.get(".nc-acl-table-row").should("have.length", 19);
// disable table & view access
//
disableTableAccess("language", "editor");
disableTableAccess("language", "commenter");
disableTableAccess("language", "viewer");
disableTableAccess("customerlist", "editor");
disableTableAccess("customerlist", "commenter");
disableTableAccess("customerlist", "viewer");
});
});
it(`[${roles[roleType].name}] Comments: view/add`, () => {
// read &/ update comment
// Viewer: only allowed to read
// Everyone else: read &/ update
//
if (roleType != "viewer") _editComment(roleType, false);
});
it(`[${roles[roleType].name}] Right navigation menu, share view`, () => {
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
_viewMenu(roleType, false);
});
it(`[${roles[roleType].name}] Top Right Menu bar`, () => {
// Share button is conditional
// Rest are static/ mandatory
//
_topRightMenu(roleType, false);
});
it(`[${roles[roleType].name}] Download files`, () => {
// #ID, City, LastUpdate, City => Address, Country <= City, +
mainPage.hideField("LastUpdate");
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`City,City => Address,Country <= City`,
`A Corua (La Corua),939 Probolinggo Loop,Spain`,
`Abha,733 Mandaluyong Place,Saudi Arabia`,
`Abu Dhabi,535 Ahmadnagar Manor,United Arab Emirates`,
`Acua,1789 Saint-Denis Parkway,Mexico`,
];
for (let i = 0; i < storedRecords.length; i++) {
// cy.log(retrievedRecords[i])
expect(retrievedRecords[i]).to.be.equal(storedRecords[i]);
}
};
const roleValidation = (roleType) => {
describe(`User role validation`, () => {
if (roleType != "owner") {
it(`[${roles[roleType].name}] SignIn, Open project`, () => {
cy.log(mainPage.roleURL[roleType]);
cy.visit(mainPage.roleURL[roleType], {
baseUrl: null,
});
// Redirected to new URL, feed details
//
cy.get('input[type="text"]')
.should("exist")
.type(roles[roleType].credentials.username);
cy.get('input[type="password"]').type(
roles[roleType].credentials.password
);
cy.get('button:contains("SIGN")').click();
cy.url({ timeout: 6000 }).should("contain", "#/project");
if (dbType === "xcdb") {
if ("rest" == apiType)
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
);
else
projectsPage.openProject(
staticProjects.externalGQL.basic.name
);
}
if (roleType != "creator") {
cy.closeTableTab("Actor");
}
});
}
///////////////////////////////////////////////////////
// Test suite
it(`[${roles[roleType].name}] Left navigation menu, New User add`, () => {
// project configuration settings
//
_advSettings(roleType, false);
});
it(`[${roles[roleType].name}] Access control`, () => {
// Access control validation
//
_accessControl(roleType, false);
});
it(`[${roles[roleType].name}] Schema: create table, add/modify/delete column`, () => {
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
_editSchema(roleType, false);
});
it(`[${roles[roleType].name}] Data: add/modify/delete row, update cell contents`, () => {
// Table data related validations
// - Add/delete/modify row
//
_editData(roleType, false);
});
it(`[${roles[roleType].name}] Comments: view/add`, () => {
// read &/ update comment
// Viewer: only allowed to read
// Everyone else: read &/ update
//
if (roleType != "viewer") _editComment(roleType, false);
});
it(`[${roles[roleType].name}] Right navigation menu, share view`, () => {
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
_viewMenu(roleType, false);
});
it(`[${roles[roleType].name}] Top Right Menu bar`, () => {
// Share button is conditional
// Rest are static/ mandatory
//
_topRightMenu(roleType, false);
});
it(`[${roles[roleType].name}] Download files`, () => {
// #ID, City, LastUpdate, City => Address, Country <= City, +
mainPage.hideField("LastUpdate");
const verifyCsv = (retrievedRecords) => {
// expected output, statically configured
let storedRecords = [
`City,City => Address,Country <= City`,
`A Corua (La Corua),939 Probolinggo Loop,Spain`,
`Abha,733 Mandaluyong Place,Saudi Arabia`,
`Abu Dhabi,535 Ahmadnagar Manor,United Arab Emirates`,
`Acua,1789 Saint-Denis Parkway,Mexico`,
];
for (let i = 0; i < storedRecords.length; i++) {
// cy.log(retrievedRecords[i])
expect(retrievedRecords[i]).to.be.equal(
storedRecords[i]
);
}
};
// download & verify
mainPage.downloadAndVerifyCsv(`City_exported_1.csv`, verifyCsv);
mainPage.unhideField("LastUpdate");
});
});
};
// download & verify
mainPage.downloadAndVerifyCsv(`City_exported_1.csv`, verifyCsv);
mainPage.unhideField("LastUpdate");
});
});
};
// skip owner validation as rest of the cases pretty much cover the same
// roleValidation('owner')
roleValidation("creator");
roleValidation("editor");
roleValidation("commenter");
roleValidation("viewer");
// skip owner validation as rest of the cases pretty much cover the same
// roleValidation('owner')
roleValidation("creator");
roleValidation("editor");
roleValidation("commenter");
roleValidation("viewer");
};
/**

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

@ -2,26 +2,26 @@ 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)
//
before(() => {
loginPage.loginAndOpenProject(apiType, dbType);
describe(`${apiType.toUpperCase()} api - Login & Open project`, () => {
// Run once before test- create project (rest/graphql)
//
before(() => {
loginPage.loginAndOpenProject(apiType, dbType);
// open a table to work on views
//
// cy.openTableTab('City');
});
// open a table to work on views
//
// cy.openTableTab('City');
});
it(``, () => {
cy.log("Test-1");
it(``, () => {
cy.log("Test-1");
});
});
});
};
// 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

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

@ -7,7 +7,7 @@ let t4d = require("../common/4d_table_view_grid_locked");
let t4e = require("../common/4e_form_view_share");
let t4f = require("../common/4f_grid_view_share");
const {
setCurrentMode,
setCurrentMode,
} = require("../../support/page_objects/projectConstants");
// use 0 as mode to execute individual files (debug mode, skip pre-configs)
@ -15,22 +15,22 @@ const {
const executionMode = 1;
const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType);
if (0 == executionMode) {
t0.genTest(apiType, dbType);
} else {
t01.genTest(apiType, dbType);
}
setCurrentMode(apiType, dbType);
if (0 == executionMode) {
t0.genTest(apiType, dbType);
} else {
t01.genTest(apiType, dbType);
}
t4a.genTest(apiType, dbType);
t4b.genTest(apiType, dbType);
t4c.genTest(apiType, dbType);
t4d.genTest(apiType, dbType);
t4e.genTest(apiType, dbType);
t4f.genTest(apiType, dbType);
t4a.genTest(apiType, dbType);
t4b.genTest(apiType, dbType);
t4c.genTest(apiType, dbType);
t4d.genTest(apiType, dbType);
t4e.genTest(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);

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

@ -1,10 +1,10 @@
export const defaultDbParams = {
databaseType: 0, // MySQL
hostAddress: "localhost",
portNumber: "3306",
username: "root",
password: "password",
databaseName: "sakila",
databaseType: 0, // MySQL
hostAddress: "localhost",
portNumber: "3306",
username: "root",
password: "password",
databaseName: "sakila",
};
// database
@ -15,163 +15,123 @@ export const defaultDbParams = {
// editComment: add comment
// shareView: right navigation bar (share options)
export const roles = {
owner: {
name: "owner",
credentials: { username: "user@nocodb.com", password: "Password123." },
validations: {
advSettings: true,
editSchema: true,
editData: true,
editComment: true,
shareView: true,
owner: {
name: "owner",
credentials: { username: "user@nocodb.com", password: "Password123." },
validations: {
advSettings: true,
editSchema: true,
editData: true,
editComment: true,
shareView: true,
},
},
},
creator: {
name: "creator",
credentials: { username: "creator@nocodb.com", password: "Password123." },
validations: {
advSettings: true,
editSchema: true,
editData: true,
editComment: true,
shareView: true,
creator: {
name: "creator",
credentials: {
username: "creator@nocodb.com",
password: "Password123.",
},
validations: {
advSettings: true,
editSchema: true,
editData: true,
editComment: true,
shareView: true,
},
},
},
editor: {
name: "editor",
credentials: { username: "editor@nocodb.com", password: "Password123." },
validations: {
advSettings: false,
editSchema: false,
editData: true,
editComment: true,
shareView: false,
editor: {
name: "editor",
credentials: {
username: "editor@nocodb.com",
password: "Password123.",
},
validations: {
advSettings: false,
editSchema: false,
editData: true,
editComment: true,
shareView: false,
},
},
},
commenter: {
name: "commenter",
credentials: { username: "commenter@nocodb.com", password: "Password123." },
validations: {
advSettings: false,
editSchema: false,
editData: false,
editComment: true,
shareView: false,
commenter: {
name: "commenter",
credentials: {
username: "commenter@nocodb.com",
password: "Password123.",
},
validations: {
advSettings: false,
editSchema: false,
editData: false,
editComment: true,
shareView: false,
},
},
},
viewer: {
name: "viewer",
credentials: { username: "viewer@nocodb.com", password: "Password123." },
validations: {
advSettings: false,
editSchema: false,
editData: false,
editComment: false,
shareView: false,
viewer: {
name: "viewer",
credentials: {
username: "viewer@nocodb.com",
password: "Password123.",
},
validations: {
advSettings: false,
editSchema: false,
editData: false,
editComment: false,
shareView: false,
},
},
},
};
// default projects
//
export const staticProjects = {
sampleREST: {
basic: { dbType: "none", apiType: "REST", name: "sampleREST" },
config: {},
},
sampleGQL: {
basic: { dbType: "none", apiType: "GQL", name: "sampleGQL" },
config: {},
},
externalREST: {
basic: { dbType: "external", apiType: "REST", name: "externalREST" },
config: defaultDbParams,
},
externalGQL: {
basic: { dbType: "external", apiType: "GQL", name: "externalGQL" },
config: defaultDbParams,
},
sampleREST: {
basic: { dbType: "none", apiType: "REST", name: "sampleREST" },
config: {},
},
sampleGQL: {
basic: { dbType: "none", apiType: "GQL", name: "sampleGQL" },
config: {},
},
externalREST: {
basic: { dbType: "external", apiType: "REST", name: "externalREST" },
config: defaultDbParams,
},
externalGQL: {
basic: { dbType: "external", apiType: "GQL", name: "externalGQL" },
config: defaultDbParams,
},
};
// return TRUE if test suite specified is activated from env-variables
//
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;
}
const env = Cypress.env("testMode");
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() {
return currentTestMode;
return currentTestMode;
}
export function isXcdb() {
if (currentTestMode === "xcdbREST" || currentTestMode === "xcdbGQL")
return true;
return false;
return currentTestMode.dbType === "xcdb";
}
export function setProjectString(projStr) {
xcdbProjectString = projStr;
xcdbProjectString = projStr;
}
export function getProjectString() {
return xcdbProjectString;
return xcdbProjectString;
}

Loading…
Cancel
Save