Browse Source

refactor: test/cypress variable clean-up/2

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/1165/head
Raju Udava 3 years ago
parent
commit
8489ea7323
  1. 6
      scripts/cypress/integration/common/5b_preview_role.js
  2. 4
      scripts/cypress/support/page_objects/navigation.js
  3. 28
      scripts/cypress/support/page_objects/projectConstants.js

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

@ -16,8 +16,8 @@ import {
_accessControl, _accessControl,
} from "../spec/roleValidation.spec"; } from "../spec/roleValidation.spec";
export const genTest = (type, xcdb, roleType) => { export const genTest = (apiType, dbType, roleType) => {
if (!isTestSuiteActive(type, xcdb)) return; if (!isTestSuiteActive(apiType, dbType)) return;
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
//// Test Suite //// Test Suite
@ -25,7 +25,7 @@ export const genTest = (type, xcdb, roleType) => {
describe("Role preview validations", () => { describe("Role preview validations", () => {
// Sign in/ open project // Sign in/ open project
before(() => { before(() => {
loginPage.loginAndOpenProject(type, xcdb); loginPage.loginAndOpenProject(apiType, dbType);
cy.openTableTab("City", 25); cy.openTableTab("City", 25);
}); });

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

@ -55,10 +55,10 @@ export class _loginPage {
// standard pre-project activity // standard pre-project activity
// //
loginAndOpenProject(apiType, xcdb) { loginAndOpenProject(apiType, dbType) {
loginPage.signIn(roles.owner.credentials); loginPage.signIn(roles.owner.credentials);
if (!xcdb) { if (!dbType) {
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);

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

@ -95,17 +95,17 @@ export const staticProjects = {
// 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 = (type, xcdb) => { export const isTestSuiteActive = (apiType, dbType) => {
const env = Cypress.env("testMode"); const env = Cypress.env("testMode");
if (!xcdb) { if (!dbType) {
switch (type) { switch (apiType) {
case "rest": case "rest":
return env.includes("extREST") ? true : false; return env.includes("extREST") ? true : false;
case "graphql": case "graphql":
return env.includes("extGQL") ? true : false; return env.includes("extGQL") ? true : false;
} }
} else { } else {
switch (type) { switch (apiType) {
case "rest": case "rest":
return env.includes("xcdbREST") ? true : false; return env.includes("xcdbREST") ? true : false;
case "graphql": case "graphql":
@ -129,31 +129,31 @@ export const getPrimarySuite = () => {
} }
}; };
export const isSecondarySuite = (proj, xcdb) => { export const isSecondarySuite = (apiType, dbType) => {
if (!isTestSuiteActive(proj, xcdb)) return false; if (!isTestSuiteActive(apiType, dbType)) return false;
const env = Cypress.env("testMode").split("."); const env = Cypress.env("testMode").split(".");
switch (env[0]) { switch (env[0]) {
case "extREST": case "extREST":
return proj == "rest" && !xcdb ? false : true; return apiType == "rest" && !dbType ? false : true;
case "extGQL": case "extGQL":
return proj == "graphql" && !xcdb ? false : true; return apiType == "graphql" && !dbType ? false : true;
case "xcdbREST": case "xcdbREST":
return proj == "rest" && xcdb ? false : true; return apiType == "rest" && dbType ? false : true;
case "xcdbGQL": case "xcdbGQL":
return proj == "graphql" && xcdb ? false : true; return apiType == "graphql" && dbType ? false : true;
} }
}; };
let currentTestMode = ``; let currentTestMode = ``;
let xcdbProjectString = ``; let xcdbProjectString = ``;
export function setCurrentMode(proj, xcdb) { export function setCurrentMode(apiType, dbType) {
if (!xcdb) { if (!dbType) {
if (proj == "rest") currentTestMode = "extREST"; if (apiType == "rest") currentTestMode = "extREST";
else currentTestMode = "extGQL"; else currentTestMode = "extGQL";
} else { } else {
if (proj == "rest") currentTestMode = "xcdbREST"; if (apiType == "rest") currentTestMode = "xcdbREST";
else currentTestMode = "xcdbGQL"; else currentTestMode = "xcdbGQL";
} }
} }

Loading…
Cancel
Save