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. 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/", "baseUrl": "http://localhost:3000/",
"testFiles": [ "testFiles": [
"test/restTableOps.js", "test/restTableOps.js",
"test/restViews.js", "test/restViews.js",
"test/restRoles.js", "test/restRoles.js",
"test/restMisc.js", "test/restMisc.js",
"test/xcdb-restTableOps.js", "test/xcdb-restTableOps.js",
"test/xcdb-restViews.js", "test/xcdb-restViews.js",
"test/xcdb-restRoles.js", "test/xcdb-restRoles.js",
"test/xcdb-restMisc.js", "test/xcdb-restMisc.js",
"test/gqlTableOps.js", "test/gqlTableOps.js",
"test/gqlViews.js", "test/gqlViews.js",
"test/gqlRoles.js", "test/gqlRoles.js",
"test/gqlMisc.js", "test/gqlMisc.js",
"test/xcdb-gqlTableOps.js", "test/xcdb-gqlTableOps.js",
"test/xcdb-gqlViews.js", "test/xcdb-gqlViews.js",
"test/xcdb-gqlRoles.js", "test/xcdb-gqlRoles.js",
"test/xcdb-gqlMisc.js" "test/xcdb-gqlMisc.js"
], ],
"defaultCommandTimeout": 13000, "defaultCommandTimeout": 13000,
"pageLoadTimeout": 600000, "pageLoadTimeout": 600000,
"viewportWidth": 1980, "viewportWidth": 1980,
"viewportHeight": 1000, "viewportHeight": 1000,
"video": false, "video": false,
"retries": 0, "retries": 0,
"screenshotOnRunFailure": false, "screenshotOnRunFailure": false,
"numTestsKeptInMemory": 0, "numTestsKeptInMemory": 0,
"env": { "env": {
"testMode": "extREST.extGQL.xcdbREST.xcdbGQL", "testMode": [
"db": { { "apiType": "rest", "dbType": "xcdb" },
"host": "127.0.0.1", { "apiType": "graphql", "dbType": "xcdb" },
"user": "root", { "apiType": "rest", "dbType": "mysql" },
"password": "password" { "apiType": "graphql", "dbType": "mysql" }
} ],
}, "db": {
"supportedOptionsForTestModes": [ "host": "127.0.0.1",
"extGQL", "user": "root",
"extREST", "password": "password"
"xcdbREST", }
"xcdbREST", },
"can configure multiple too, seperated by a . as in extREST.extGQL" "fixturesFolder": "scripts/cypress/fixtures",
], "integrationFolder": "scripts/cypress/integration",
"fixturesFolder": "scripts/cypress/fixtures", "pluginsFile": "scripts/cypress/plugins/index.js",
"integrationFolder": "scripts/cypress/integration", "screenshotsFolder": "scripts/cypress/screenshots",
"pluginsFile": "scripts/cypress/plugins/index.js", "videosFolder": "scripts/cypress/videos",
"screenshotsFolder": "scripts/cypress/screenshots", "downloadsFolder": "scripts/cypress/downloads",
"videosFolder": "scripts/cypress/videos", "supportFile": "scripts/cypress/support/index.js",
"downloadsFolder": "scripts/cypress/downloads", "chromeWebSecurity": false
"supportFile": "scripts/cypress/support/index.js",
"chromeWebSecurity": false
} }

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

@ -7,8 +7,6 @@ import {
staticProjects, staticProjects,
roles, roles,
isTestSuiteActive, isTestSuiteActive,
getPrimarySuite,
isSecondarySuite,
getCurrentMode, getCurrentMode,
isXcdb, isXcdb,
setProjectString, setProjectString,
@ -182,7 +180,7 @@ export const genTest = (apiType, dbType) => {
projectsPage.createProject(proj.basic, proj.config); projectsPage.createProject(proj.basic, proj.config);
} }
if (dbType) { 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;
cy.url() cy.url()
@ -224,58 +222,19 @@ export const genTest = (apiType, dbType) => {
// if (isTestSuiteActive('graphql', false)) createProject(staticProjects.externalGQL) // if (isTestSuiteActive('graphql', false)) createProject(staticProjects.externalGQL)
if ("rest" == apiType) { if ("rest" == apiType) {
if (true == dbType) { if ("xcdb" === dbType) {
createProject(staticProjects.sampleREST); createProject(staticProjects.sampleREST);
} else { } else {
createProject(staticProjects.externalREST); createProject(staticProjects.externalREST);
} }
} else if ("graphql" == apiType) { } else if ("graphql" == apiType) {
if (true == dbType) { if ("xcdb" === dbType) {
createProject(staticProjects.sampleGQL); createProject(staticProjects.sampleGQL);
} else { } else {
createProject(staticProjects.externalGQL); 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"; import { mainPage } from "../../support/page_objects/mainPage";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${dbType ? "Meta - " : ""}${apiType.toUpperCase()} api - Table`, () => { describe(`${
before(() => { dbType === "xcdb" ? "Meta - " : ""
cy.get(".mdi-close").click({ multiple: true }); }${apiType.toUpperCase()} api - Table`, () => {
}); before(() => {
cy.get(".mdi-close").click({ multiple: true });
after(() => { });
cy.get(".mdi-close").click({ multiple: true });
}); after(() => {
cy.get(".mdi-close").click({ multiple: true });
const name = "tablex"; });
// create a new random table const name = "tablex";
it("Create Table", () => {
cy.createTable(name); // create a new random table
}); it("Create Table", () => {
cy.createTable(name);
// delete newly created table });
it("Delete Table", () => {
cy.deleteTable(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);
}; 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();
it("Open Audit tab", () => {
// wait for column headers to appear mainPage.navigationDraw(mainPage.AUDIT).click();
//
cy.get("thead > tr > th.caption").should("have.length", 5); // wait for column headers to appear
//
// Audit table entries cy.get("thead > tr > th.caption").should("have.length", 5);
// [Header] Operation Type, Operation Sub Type, Description, User, Created
// [0] TABLE, DELETED, delete table table-x, user@nocodb.com, ... // Audit table entries
// [1] TABLE, Created, created table table-x, user@nocodb.com, ... // [Header] Operation Type, Operation Sub Type, Description, User, Created
// [0] TABLE, DELETED, delete table table-x, user@nocodb.com, ...
getAuditCell(0, 0).contains("TABLE").should("exist"); // [1] TABLE, Created, created table table-x, user@nocodb.com, ...
getAuditCell(0, 1).contains("DELETED").should("exist");
getAuditCell(0, 3).contains("user@nocodb.com").should("exist"); getAuditCell(0, 0).contains("TABLE").should("exist");
getAuditCell(0, 1).contains("DELETED").should("exist");
getAuditCell(1, 0).contains("TABLE").should("exist"); getAuditCell(0, 3).contains("user@nocodb.com").should("exist");
getAuditCell(1, 1).contains("CREATED").should("exist");
getAuditCell(1, 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");
it("Table Rename operation", () => {
// verify cy.renameTable("City", "CityX");
// 1. Table name in project tree has changed
cy.get(".nc-project-tree").contains("CityX").should("exist"); // verify
// 1. Table name in project tree has changed
// 2. Table tab name has changed cy.get(".nc-project-tree").contains("CityX").should("exist");
cy.get(`.project-tab:contains('CityX'):visible`).should("exist");
// 2. Table tab name has changed
// 3. contents of the table are valid cy.get(`.project-tab:contains('CityX'):visible`).should("exist");
mainPage
.getCell(`City`, 1) // 3. contents of the table are valid
.contains("A Corua (La Corua)") mainPage
.should("exist"); .getCell(`City`, 1)
.contains("A Corua (La Corua)")
cy.closeTableTab("CityX"); .should("exist");
// 4. verify linked contents in other table cy.closeTableTab("CityX");
// 4a. Address table, has many field
cy.openTableTab("Address", 25); // 4. verify linked contents in other table
// 4a. Address table, has many field
mainPage.getCell("City <= Address", 1).scrollIntoView(); cy.openTableTab("Address", 25);
mainPage
.getCell("City <= Address", 1) mainPage.getCell("City <= Address", 1).scrollIntoView();
.find(".name") mainPage
.contains("Lethbridge") .getCell("City <= Address", 1)
.should("exist"); .find(".name")
cy.closeTableTab("Address"); .contains("Lethbridge")
.should("exist");
// 4b. Country table, belongs to field cy.closeTableTab("Address");
cy.openTableTab("Country", 25);
// 4b. Country table, belongs to field
mainPage cy.openTableTab("Country", 25);
.getCell("Country => City", 1)
.find(".name") mainPage
.contains("Kabul") .getCell("Country => City", 1)
.should("exist"); .find(".name")
cy.closeTableTab("Country"); .contains("Kabul")
.should("exist");
// revert re-name operation to not impact rest of test suite cy.closeTableTab("Country");
cy.renameTable("CityX", "City");
// 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 { import {
isTestSuiteActive, isTestSuiteActive,
isXcdb, isXcdb,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} SQL Views`, () => { describe(`${apiType.toUpperCase()} SQL Views`, () => {
// Run once before test- create project (rest/graphql) // Run once before test- create project (rest/graphql)
// //
before(() => { before(() => {
// void // void
}); });
it(`XCDB: SQL View Column operations`, () => { it(`XCDB: SQL View Column operations`, () => {
// Open one of the views & verify validity of first two entries // Open one of the views & verify validity of first two entries
if (isXcdb()) { if (isXcdb()) {
cy.openViewsTab("CustomerList", 25); cy.openViewsTab("CustomerList", 25);
// Record-1 validation // Record-1 validation
mainPage.getCell(`ID`, 1).contains("1").should("exist"); mainPage.getCell(`ID`, 1).contains("1").should("exist");
mainPage.getCell(`Name`, 1).contains("MARY SMITH").should("exist"); mainPage
mainPage .getCell(`Name`, 1)
.getCell(`Address`, 1) .contains("MARY SMITH")
.contains("1913 Hanoi Way") .should("exist");
.should("exist"); mainPage
mainPage.getCell(`ZipCode`, 1).contains("35200").should("exist"); .getCell(`Address`, 1)
.contains("1913 Hanoi Way")
// Record-2 validation .should("exist");
mainPage.getCell(`ID`, 2).contains("2").should("exist"); mainPage
mainPage .getCell(`ZipCode`, 1)
.getCell(`Name`, 2) .contains("35200")
.contains("PATRICIA JOHNSON") .should("exist");
.should("exist");
mainPage // Record-2 validation
.getCell(`Address`, 2) mainPage.getCell(`ID`, 2).contains("2").should("exist");
.contains("1121 Loja Avenue") mainPage
.should("exist"); .getCell(`Name`, 2)
mainPage.getCell(`ZipCode`, 2).contains("17886").should("exist"); .contains("PATRICIA JOHNSON")
.should("exist");
// Column operations: Hide mainPage
mainPage.hideField(`ZipCode`); .getCell(`Address`, 2)
mainPage.unhideField(`ZipCode`); .contains("1121 Loja Avenue")
.should("exist");
// Column operations: Sort mainPage
mainPage.sortField("Name", "Z -> A"); .getCell(`ZipCode`, 2)
mainPage.getCell(`Name`, 1).contains("ZACHARY HITE").should("exist"); .contains("17886")
mainPage.clearSort(); .should("exist");
// Column operations: Filter // Column operations: Hide
mainPage.filterField("Name", "is like", "MARY"); mainPage.hideField(`ZipCode`);
mainPage.getCell(`Name`, 1).contains("MARY SMITH").should("exist"); mainPage.unhideField(`ZipCode`);
mainPage.filterReset();
// Column operations: Sort
cy.closeViewsTab("CustomerList"); mainPage.sortField("Name", "Z -> A");
} mainPage
}); .getCell(`Name`, 1)
.contains("ZACHARY HITE")
it(`SQL View Column operations`, () => { .should("exist");
if (!isXcdb()) { mainPage.clearSort();
// Open one of the views & verify validity of first two entries
// Column operations: Filter
cy.openViewsTab("ActorInfo", 25); mainPage.filterField("Name", "is like", "MARY");
mainPage
// Record-1 validation .getCell(`Name`, 1)
mainPage.getCell(`ActorId`, 1).contains("1").should("exist"); .contains("MARY SMITH")
mainPage.getCell(`FirstName`, 1).contains("PENELOPE").should("exist"); .should("exist");
mainPage.getCell(`LastName`, 1).contains("GUINESS").should("exist"); mainPage.filterReset();
mainPage
.getCell(`FilmInfo`, 1) cy.closeViewsTab("CustomerList");
.contains("Animation: ANACONDA CONFESSIONS;") }
.should("exist"); });
// Record-2 validation it(`SQL View Column operations`, () => {
mainPage.getCell(`ActorId`, 2).contains("2").should("exist"); if (!isXcdb()) {
mainPage.getCell(`FirstName`, 2).contains("NICK").should("exist"); // Open one of the views & verify validity of first two entries
mainPage.getCell(`LastName`, 2).contains("WAHLBERG").should("exist");
mainPage cy.openViewsTab("ActorInfo", 25);
.getCell(`FilmInfo`, 2)
.contains("Action: BULL SHAWSHANK; Animation: FIGHT JAWBREAKER;") // Record-1 validation
.should("exist"); mainPage.getCell(`ActorId`, 1).contains("1").should("exist");
mainPage
// Column operations: Hide .getCell(`FirstName`, 1)
mainPage.hideField("FilmInfo"); .contains("PENELOPE")
mainPage.unhideField("FilmInfo"); .should("exist");
mainPage
// Column operations: Sort .getCell(`LastName`, 1)
mainPage.sortField("FirstName", "Z -> A"); .contains("GUINESS")
mainPage.getCell(`FirstName`, 1).contains("ZERO").should("exist"); .should("exist");
mainPage.clearSort(); mainPage
.getCell(`FilmInfo`, 1)
// Column operations: Filter .contains("Animation: ANACONDA CONFESSIONS;")
mainPage.filterField("FirstName", "is like", "PENELOPE"); .should("exist");
mainPage.getCell(`FirstName`, 1).contains("PENELOPE").should("exist");
mainPage.filterReset(); // Record-2 validation
mainPage.getCell(`ActorId`, 2).contains("2").should("exist");
cy.closeViewsTab("ActorInfo"); mainPage
} .getCell(`FirstName`, 2)
}); .contains("NICK")
.should("exist");
it(`SQL View List`, () => { mainPage
// confirm if other views exist .getCell(`LastName`, 2)
// .contains("WAHLBERG")
cy.openViewsTab("CustomerList", 25); .should("exist");
cy.closeViewsTab("CustomerList"); mainPage
.getCell(`FilmInfo`, 2)
cy.openViewsTab("FilmList", 25); .contains(
cy.closeViewsTab("FilmList"); "Action: BULL SHAWSHANK; Animation: FIGHT JAWBREAKER;"
)
cy.openViewsTab("SalesByFilmCategory", 16); .should("exist");
cy.closeViewsTab("SalesByFilmCategory");
// Column operations: Hide
if (!isXcdb()) { mainPage.hideField("FilmInfo");
cy.openViewsTab("NicerButSlowerFilmList", 25); mainPage.unhideField("FilmInfo");
cy.closeViewsTab("NicerButSlowerFilmList");
// Column operations: Sort
// SalesByStore && StaffList contain no entries. Hence marking row count to 0 mainPage.sortField("FirstName", "Z -> A");
cy.openViewsTab("SalesByStore", 0); mainPage
cy.closeViewsTab("SalesByStore"); .getCell(`FirstName`, 1)
.contains("ZERO")
cy.openViewsTab("StaffList", 0); .should("exist");
cy.closeViewsTab("StaffList"); mainPage.clearSort();
} else {
cy.openViewsTab("SalesByStore", 2); // Column operations: Filter
cy.closeViewsTab("SalesByStore"); mainPage.filterField("FirstName", "is like", "PENELOPE");
mainPage
cy.openViewsTab("StaffList", 2); .getCell(`FirstName`, 1)
cy.closeViewsTab("StaffList"); .contains("PENELOPE")
} .should("exist");
}); mainPage.filterReset();
after(() => { cy.closeViewsTab("ActorInfo");
// void }
});
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 { loginPage, projectsPage } from "../../support/page_objects/navigation";
import { mainPage } from "../../support/page_objects/mainPage"; import { mainPage } from "../../support/page_objects/mainPage";
import { import {
roles, roles,
staticProjects, staticProjects,
} from "../../support/page_objects/projectConstants"; } from "../../support/page_objects/projectConstants";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import { import {
_advSettings, _advSettings,
_editSchema, _editSchema,
_editData, _editData,
_editComment, _editComment,
_viewMenu, _viewMenu,
_topRightMenu, _topRightMenu,
disableTableAccess, disableTableAccess,
_accessControl, _accessControl,
} from "../spec/roleValidation.spec"; } from "../spec/roleValidation.spec";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; 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();
});
const addUser = (user) => { describe("Static user creations (different roles)", () => {
it(`RoleType: ${user.name}`, () => { before(() => {
// for first project, users need to be added explicitly using "New User" button mainPage.navigationDraw(mainPage.TEAM_N_AUTH).click();
// 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");
}
}); });
}
/////////////////////////////////////////////////////// const addUser = (user) => {
// Test suite 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`, () => { addUser(roles.creator);
// project configuration settings addUser(roles.editor);
// addUser(roles.commenter);
_advSettings(roleType, false); addUser(roles.viewer);
});
it(`[${roles[roleType].name}] Access control`, () => { // Access contrl list- configuration
// Access control validation
// //
_accessControl(roleType, false); it(`Access control list- configuration`, () => {
}); // open Project metadata tab
//
it(`[${roles[roleType].name}] Schema: create table, add/modify/delete column`, () => { mainPage.navigationDraw(mainPage.PROJ_METADATA).click();
// Schema related validations cy.get(".nc-exp-imp-metadata").dblclick({ force: true });
// - Add/delete table cy.get(".nc-ui-acl-tab").click({ force: true });
// - Add/Update/delete column
// // validate if it has 19 entries representing tables & views
_editSchema(roleType, false); cy.get(".nc-acl-table-row").should("have.length", 19);
});
// disable table & view access
it(`[${roles[roleType].name}] Data: add/modify/delete row, update cell contents`, () => { //
// Table data related validations disableTableAccess("language", "editor");
// - Add/delete/modify row disableTableAccess("language", "commenter");
// disableTableAccess("language", "viewer");
_editData(roleType, false);
}); disableTableAccess("customerlist", "editor");
disableTableAccess("customerlist", "commenter");
disableTableAccess("customerlist", "viewer");
});
});
it(`[${roles[roleType].name}] Comments: view/add`, () => { const roleValidation = (roleType) => {
// read &/ update comment describe(`User role validation`, () => {
// Viewer: only allowed to read if (roleType != "owner") {
// Everyone else: read &/ update it(`[${roles[roleType].name}] SignIn, Open project`, () => {
// cy.log(mainPage.roleURL[roleType]);
if (roleType != "viewer") _editComment(roleType, false); cy.visit(mainPage.roleURL[roleType], {
}); baseUrl: null,
});
it(`[${roles[roleType].name}] Right navigation menu, share view`, () => {
// right navigation menu bar // Redirected to new URL, feed details
// Editor/Viewer/Commenter : can only view 'existing' views //
// Rest: can create/edit cy.get('input[type="text"]')
_viewMenu(roleType, false); .should("exist")
}); .type(roles[roleType].credentials.username);
cy.get('input[type="password"]').type(
it(`[${roles[roleType].name}] Top Right Menu bar`, () => { roles[roleType].credentials.password
// Share button is conditional );
// Rest are static/ mandatory cy.get('button:contains("SIGN")').click();
//
_topRightMenu(roleType, false); cy.url({ timeout: 6000 }).should("contain", "#/project");
});
if (dbType === "xcdb") {
it(`[${roles[roleType].name}] Download files`, () => { if ("rest" == apiType)
// #ID, City, LastUpdate, City => Address, Country <= City, + projectsPage.openProject(
mainPage.hideField("LastUpdate"); staticProjects.sampleREST.basic.name
);
const verifyCsv = (retrievedRecords) => { else
// expected output, statically configured projectsPage.openProject(
let storedRecords = [ staticProjects.sampleGQL.basic.name
`City,City => Address,Country <= City`, );
`A Corua (La Corua),939 Probolinggo Loop,Spain`, } else if (dbType === "mysql") {
`Abha,733 Mandaluyong Place,Saudi Arabia`, if ("rest" == apiType)
`Abu Dhabi,535 Ahmadnagar Manor,United Arab Emirates`, projectsPage.openProject(
`Acua,1789 Saint-Denis Parkway,Mexico`, staticProjects.externalREST.basic.name
]; );
else
for (let i = 0; i < storedRecords.length; i++) { projectsPage.openProject(
// cy.log(retrievedRecords[i]) staticProjects.externalGQL.basic.name
expect(retrievedRecords[i]).to.be.equal(storedRecords[i]); );
} }
};
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 // skip owner validation as rest of the cases pretty much cover the same
mainPage.downloadAndVerifyCsv(`City_exported_1.csv`, verifyCsv); // roleValidation('owner')
mainPage.unhideField("LastUpdate"); 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"; import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
export const genTest = (apiType, dbType) => { export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return; // if (!isTestSuiteActive(apiType, dbType)) return;
describe(`${apiType.toUpperCase()} api - Login & Open project`, () => { describe(`${apiType.toUpperCase()} api - Login & Open project`, () => {
// Run once before test- create project (rest/graphql) // Run once before test- create project (rest/graphql)
// //
before(() => { before(() => {
loginPage.loginAndOpenProject(apiType, dbType); loginPage.loginAndOpenProject(apiType, dbType);
// open a table to work on views // open a table to work on views
// //
// cy.openTableTab('City'); // cy.openTableTab('City');
}); });
it(``, () => { it(``, () => {
cy.log("Test-1"); cy.log("Test-1");
});
}); });
});
}; };
// genTest('rest', false) // genTest("rest", "mysql");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t6e.genTest(apiType, dbType);
}; };
nocoTestSuite("graphql", false); nocoTestSuite("graphql", "mysql");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t5b.genTest(apiType, dbType);
}; };
nocoTestSuite("graphql", false); nocoTestSuite("graphql", "mysql");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t3d.genTest(apiType, dbType);
}; };
nocoTestSuite("graphql", false); nocoTestSuite("graphql", "mysql");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t4f.genTest(apiType, dbType);
}; };
nocoTestSuite("graphql", false); nocoTestSuite("graphql", "mysql");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t6e.genTest(apiType, dbType);
}; };
// nocoTestSuite('rest', false) // nocoTestSuite('rest', "mysql")
nocoTestSuite("graphql", false); nocoTestSuite("graphql", "mysql");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t6e.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", false); nocoTestSuite("rest", "mysql");
// nocoTestSuite('graphql', false) // nocoTestSuite('graphql', "mysql")
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t7a.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", false); nocoTestSuite("rest", "mysql");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t5b.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", false); nocoTestSuite("rest", "mysql");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t3d.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", false); nocoTestSuite("rest", "mysql");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t4f.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", false); nocoTestSuite("rest", "mysql");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t6e.genTest(apiType, dbType);
}; };
nocoTestSuite("graphql", true); nocoTestSuite("graphql", "xcdb");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t5b.genTest(apiType, dbType);
}; };
nocoTestSuite("graphql", true); nocoTestSuite("graphql", "xcdb");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t3d.genTest(apiType, dbType);
}; };
nocoTestSuite("graphql", true); nocoTestSuite("graphql", "xcdb");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t4f.genTest(apiType, dbType);
}; };
nocoTestSuite("graphql", true); nocoTestSuite("graphql", "xcdb");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t7a.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", true); nocoTestSuite("rest", "xcdb");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t5b.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", true); nocoTestSuite("rest", "xcdb");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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); t3d.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", true); nocoTestSuite("rest", "xcdb");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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 t4e = require("../common/4e_form_view_share");
let t4f = require("../common/4f_grid_view_share"); let t4f = require("../common/4f_grid_view_share");
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 0 as mode to execute individual files (debug mode, skip pre-configs)
@ -15,22 +15,22 @@ const {
const executionMode = 1; const executionMode = 1;
const nocoTestSuite = (apiType, dbType) => { const nocoTestSuite = (apiType, dbType) => {
setCurrentMode(apiType, dbType); setCurrentMode(apiType, dbType);
if (0 == executionMode) { if (0 == executionMode) {
t0.genTest(apiType, dbType); t0.genTest(apiType, dbType);
} else { } else {
t01.genTest(apiType, dbType); t01.genTest(apiType, dbType);
} }
t4a.genTest(apiType, dbType); t4a.genTest(apiType, dbType);
t4b.genTest(apiType, dbType); t4b.genTest(apiType, dbType);
t4c.genTest(apiType, dbType); t4c.genTest(apiType, dbType);
t4d.genTest(apiType, dbType); t4d.genTest(apiType, dbType);
t4e.genTest(apiType, dbType); t4e.genTest(apiType, dbType);
t4f.genTest(apiType, dbType); t4f.genTest(apiType, dbType);
}; };
nocoTestSuite("rest", true); nocoTestSuite("rest", "xcdb");
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @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) { loginAndOpenProject(apiType, dbType) {
loginPage.signIn(roles.owner.credentials); loginPage.signIn(roles.owner.credentials);
if (!dbType) { if (dbType === "mysql") {
if ("rest" == apiType) if ("rest" == apiType)
projectsPage.openProject(staticProjects.externalREST.basic.name); projectsPage.openProject(staticProjects.externalREST.basic.name);
else projectsPage.openProject(staticProjects.externalGQL.basic.name); else projectsPage.openProject(staticProjects.externalGQL.basic.name);
} else { } else if(dbType === "xcdb") {
if ("rest" == apiType) if ("rest" == apiType)
projectsPage.openProject(staticProjects.sampleREST.basic.name); projectsPage.openProject(staticProjects.sampleREST.basic.name);
else projectsPage.openProject(staticProjects.sampleGQL.basic.name); else projectsPage.openProject(staticProjects.sampleGQL.basic.name);

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

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

Loading…
Cancel
Save