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

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

@ -55,10 +55,10 @@ export class _loginPage {
// standard pre-project activity
//
loginAndOpenProject(apiType, xcdb) {
loginAndOpenProject(apiType, dbType) {
loginPage.signIn(roles.owner.credentials);
if (!xcdb) {
if (!dbType) {
if ("rest" == apiType)
projectsPage.openProject(staticProjects.externalREST.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
//
export const isTestSuiteActive = (type, xcdb) => {
export const isTestSuiteActive = (apiType, dbType) => {
const env = Cypress.env("testMode");
if (!xcdb) {
switch (type) {
if (!dbType) {
switch (apiType) {
case "rest":
return env.includes("extREST") ? true : false;
case "graphql":
return env.includes("extGQL") ? true : false;
}
} else {
switch (type) {
switch (apiType) {
case "rest":
return env.includes("xcdbREST") ? true : false;
case "graphql":
@ -129,31 +129,31 @@ export const getPrimarySuite = () => {
}
};
export const isSecondarySuite = (proj, xcdb) => {
if (!isTestSuiteActive(proj, xcdb)) return false;
export const isSecondarySuite = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return false;
const env = Cypress.env("testMode").split(".");
switch (env[0]) {
case "extREST":
return proj == "rest" && !xcdb ? false : true;
return apiType == "rest" && !dbType ? false : true;
case "extGQL":
return proj == "graphql" && !xcdb ? false : true;
return apiType == "graphql" && !dbType ? false : true;
case "xcdbREST":
return proj == "rest" && xcdb ? false : true;
return apiType == "rest" && dbType ? false : true;
case "xcdbGQL":
return proj == "graphql" && xcdb ? false : true;
return apiType == "graphql" && dbType ? false : true;
}
};
let currentTestMode = ``;
let xcdbProjectString = ``;
export function setCurrentMode(proj, xcdb) {
if (!xcdb) {
if (proj == "rest") currentTestMode = "extREST";
export function setCurrentMode(apiType, dbType) {
if (!dbType) {
if (apiType == "rest") currentTestMode = "extREST";
else currentTestMode = "extGQL";
} else {
if (proj == "rest") currentTestMode = "xcdbREST";
if (apiType == "rest") currentTestMode = "xcdbREST";
else currentTestMode = "xcdbGQL";
}
}

Loading…
Cancel
Save