Skip to content

Commit

Permalink
resolution of lint/ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vidyanambiar committed May 9, 2024
1 parent c5596c8 commit 8971fdb
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 50 deletions.
42 changes: 20 additions & 22 deletions cypress/e2e/eda/Access-Management/team-access.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ import { edaAPI } from '../../../support/formatApiPathForEDA';
import { EdaCredentialType } from '../../../../frontend/eda/interfaces/EdaCredentialType';
import { user_team_access_tab_resources } from '../../../support/constants';

type ResourceObject =
| EdaProject
| EdaDecisionEnvironment
| EdaRulebookActivation
| EdaCredential
| EdaCredentialType;

user_team_access_tab_resources.forEach((resource) => {
describe(`Team Access Tab for ${resource.name} - Add team`, () => {
let edaTeam: EdaTeam;
let resource_object:
| EdaProject
| EdaDecisionEnvironment
| EdaRulebookActivation
| EdaCredential
| EdaCredentialType;
let resource_object: ResourceObject;
before(() => {
cy.edaLogin();
// If the resource is a RBA, create all dependency resources, else just the one resource
if (resource.name == 'rulebook-activations') {
if (resource.name === 'rulebook-activations') {
let edaProject: EdaProject;
let edaDecisionEnvironment: EdaDecisionEnvironment;
let edaRuleBook: EdaRulebook;
cy.createEdaProject().then((project) => {
edaProject = project;
cy.waitEdaProjectSync(project);
cy.getEdaRulebooks(edaProject, 'hello_echo.yml').then((edaRuleBooks) => {
edaRuleBook = edaRuleBooks[0];
cy.createEdaDecisionEnvironment().then((decisionEnvironment) => {
edaDecisionEnvironment = decisionEnvironment;
cy.createEdaRulebookActivation({
rulebook_id: edaRuleBook.id,
decision_environment_id: decisionEnvironment.id,
Expand All @@ -45,11 +45,11 @@ user_team_access_tab_resources.forEach((resource) => {
});
});
});
} else {
resource.creation().then((resource_instance) => {
} else if (resource.creation !== null) {
resource.creation().then((resource_instance: ResourceObject) => {
resource_object = resource_instance;
if (resource.name == 'projects') {
cy.waitEdaProjectSync(resource_instance);
if (resource.name === 'projects') {
cy.waitEdaProjectSync(resource_instance as EdaProject);
}
});
}
Expand All @@ -67,7 +67,7 @@ user_team_access_tab_resources.forEach((resource) => {
cy.navigateTo('eda', resource.name);
// filter resource by name not available for decision environment
// or credential type
if (resource.name == 'decision-environments' || resource.name == 'credential-types') {
if (resource.name === 'decision-environments' || resource.name === 'credential-types') {
cy.get('[data-cy="table-view"]').click();
cy.clickTableRow(resource_object.name, false);
} else {
Expand Down Expand Up @@ -106,17 +106,15 @@ user_team_access_tab_resources.forEach((resource) => {
before(() => {
cy.edaLogin();
// If the resource is a RBA, create all dependency resources, else just the one resource
if (resource.name == 'rulebook-activations') {
if (resource.name === 'rulebook-activations') {
let edaProject: EdaProject;
let edaDecisionEnvironment: EdaDecisionEnvironment;
let edaRuleBook: EdaRulebook;
cy.createEdaProject().then((project) => {
edaProject = project;
cy.waitEdaProjectSync(project);
cy.getEdaRulebooks(edaProject, 'hello_echo.yml').then((edaRuleBooks) => {
edaRuleBook = edaRuleBooks[0];
cy.createEdaDecisionEnvironment().then((decisionEnvironment) => {
edaDecisionEnvironment = decisionEnvironment;
cy.createEdaRulebookActivation({
rulebook_id: edaRuleBook.id,
decision_environment_id: decisionEnvironment.id,
Expand All @@ -128,11 +126,11 @@ user_team_access_tab_resources.forEach((resource) => {
});
});
});
} else {
} else if (resource.creation !== null) {
resource.creation().then((resource_instance) => {
resource_object = resource_instance;
if (resource.name == 'projects') {
cy.waitEdaProjectSync(resource_object);
if (resource.name === 'projects') {
cy.waitEdaProjectSync(resource_object as EdaProject);
}
});
}
Expand Down Expand Up @@ -182,7 +180,7 @@ user_team_access_tab_resources.forEach((resource) => {
cy.navigateTo('eda', resource.name);
// filter resource by name not available for decision environment
// or credential type
if (resource.name == 'decision-environments' || resource.name == 'credential-types') {
if (resource.name === 'decision-environments' || resource.name === 'credential-types') {
cy.get('[data-cy="table-view"]').click();
cy.clickTableRow(resource_object.name, false);
} else {
Expand All @@ -203,7 +201,7 @@ user_team_access_tab_resources.forEach((resource) => {
cy.navigateTo('eda', resource.name);
// filter resource by name not available for decision environment
// or credential type
if (resource.name == 'decision-environments' || resource.name == 'credential-types') {
if (resource.name === 'decision-environments' || resource.name === 'credential-types') {
cy.get('[data-cy="table-view"]').click();
cy.clickTableRow(resource_object.name, false);
} else {
Expand Down
29 changes: 13 additions & 16 deletions cypress/e2e/eda/Access-Management/user-access.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,15 @@ user_team_access_tab_resources.forEach((resource) => {
before(() => {
cy.edaLogin();
// If the resource is a RBA, create all dependency resources, else just the one resource
if (resource.name == 'rulebook-activations') {
if (resource.name === 'rulebook-activations') {
let edaProject: EdaProject;
let edaDecisionEnvironment: EdaDecisionEnvironment;
let edaRuleBook: EdaRulebook;
cy.createEdaProject().then((project) => {
edaProject = project;
cy.waitEdaProjectSync(project);
cy.getEdaRulebooks(edaProject, 'hello_echo.yml').then((edaRuleBooks) => {
edaRuleBook = edaRuleBooks[0];
cy.createEdaDecisionEnvironment().then((decisionEnvironment) => {
edaDecisionEnvironment = decisionEnvironment;
cy.createEdaRulebookActivation({
rulebook_id: edaRuleBook.id,
decision_environment_id: decisionEnvironment.id,
Expand All @@ -45,11 +43,11 @@ user_team_access_tab_resources.forEach((resource) => {
});
});
});
} else {
} else if (resource.creation !== null) {
resource.creation().then((resource_instance) => {
resource_object = resource_instance;
if (resource.name == 'projects') {
cy.waitEdaProjectSync(resource_instance);
if (resource.name === 'projects') {
cy.waitEdaProjectSync(resource_instance as EdaProject);
}
});
}
Expand All @@ -67,7 +65,7 @@ user_team_access_tab_resources.forEach((resource) => {
cy.navigateTo('eda', resource.name);
// filter resource by name not available for decision environment
// or credential type
if (resource.name == 'decision-environments' || resource.name == 'credential-types') {
if (resource.name === 'decision-environments' || resource.name === 'credential-types') {
cy.get('[data-cy="table-view"]').click();
cy.clickTableRow(resource_object.name, false);
} else {
Expand Down Expand Up @@ -99,24 +97,23 @@ user_team_access_tab_resources.forEach((resource) => {
| EdaProject
| EdaDecisionEnvironment
| EdaRulebookActivation
| EdaCredential;
| EdaCredential
| EdaCredentialType;
let edaUser1: EdaUser;
let edaUser2: EdaUser;
let edaUser3: EdaUser;
before(() => {
cy.edaLogin();
// If the resource is a RBA, create all dependency resources, else just the one resource
if (resource.name == 'rulebook-activations') {
if (resource.name === 'rulebook-activations') {
let edaProject: EdaProject;
let edaDecisionEnvironment: EdaDecisionEnvironment;
let edaRuleBook: EdaRulebook;
cy.createEdaProject().then((project) => {
edaProject = project;
cy.waitEdaProjectSync(project);
cy.getEdaRulebooks(edaProject, 'hello_echo.yml').then((edaRuleBooks) => {
edaRuleBook = edaRuleBooks[0];
cy.createEdaDecisionEnvironment().then((decisionEnvironment) => {
edaDecisionEnvironment = decisionEnvironment;
cy.createEdaRulebookActivation({
rulebook_id: edaRuleBook.id,
decision_environment_id: decisionEnvironment.id,
Expand All @@ -128,11 +125,11 @@ user_team_access_tab_resources.forEach((resource) => {
});
});
});
} else {
} else if (resource.creation !== null) {
resource.creation().then((resource_instance) => {
resource_object = resource_instance;
if (resource.name == 'projects') {
cy.waitEdaProjectSync(resource_object);
if (resource.name === 'projects') {
cy.waitEdaProjectSync(resource_object as EdaProject);
}
});
}
Expand Down Expand Up @@ -183,7 +180,7 @@ user_team_access_tab_resources.forEach((resource) => {
cy.navigateTo('eda', resource.name);
// filter resource by name not available for decision environment
// or credential type
if (resource.name == 'decision-environments' || resource.name == 'credential-types') {
if (resource.name === 'decision-environments' || resource.name === 'credential-types') {
cy.get('[data-cy="table-view"]').click();
cy.clickTableRow(resource_object.name, false);
} else {
Expand All @@ -204,7 +201,7 @@ user_team_access_tab_resources.forEach((resource) => {
cy.navigateTo('eda', resource.name);
// filter resource by name not available for decision environment
// or credential type
if (resource.name == 'decision-environments' || resource.name == 'credential-types') {
if (resource.name === 'decision-environments' || resource.name === 'credential-types') {
cy.get('[data-cy="table-view"]').click();
cy.clickTableRow(resource_object.name, false);
} else {
Expand Down
3 changes: 2 additions & 1 deletion cypress/support/commands.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
import { EdaUser, EdaUserCreateUpdate } from '../../frontend/eda/interfaces/EdaUser';
import { EdaTeam } from '../../frontend/eda/interfaces/EdaTeam';
import { RoleDetail } from '../../frontend/eda/interfaces/EdaRole';
import { EdaRbacRole } from '../../frontend/eda/interfaces/EdaRbacRole';
import { Role as HubRole } from '../../frontend/hub/access/roles/Role';
import { RemoteRegistry } from '../../frontend/hub/administration/remote-registries/RemoteRegistry';
import { HubRemote } from '../../frontend/hub/administration/remotes/Remotes';
Expand Down Expand Up @@ -1318,7 +1319,7 @@ declare global {
*/
deleteEdaCredentialType(delete_cred_type: EdaCredentialType): Chainable<void>;

getEdaRoles(content_type__model?: string): Chainable<EdaRole[]>;
getEdaRoles(content_type__model?: string): Chainable<EdaRbacRole[]>;
/**
* Creates an EDA user and returns the same.
*
Expand Down
44 changes: 33 additions & 11 deletions cypress/support/constants.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,66 @@
import { EdaCredential } from '../../frontend/eda/interfaces/EdaCredential';
import { EdaDecisionEnvironment } from '../../frontend/eda/interfaces/EdaDecisionEnvironment';
import { EdaProject } from '../../frontend/eda/interfaces/EdaProject';
import { EdaRulebookActivation } from '../../frontend/eda/interfaces/EdaRulebookActivation';
import { EdaCredentialType } from '../../frontend/eda/interfaces/EdaCredentialType';

export enum SERVER_NAME {
AWX_SERVER = 'AWX Ansible Server',
EDA_SERVER = 'Event Driven Automation Server',
HUB_SERVER = 'Automation Hub',
GALAXY_SERVER = 'Galaxy Server',
}

export const user_team_access_tab_resources = [
type ResourceObject =
| EdaProject
| EdaDecisionEnvironment
| EdaRulebookActivation
| EdaCredential
| EdaCredentialType;

export interface AccessTabResource {
name: string;
content_type: string;
creation: (() => Cypress.Chainable<ResourceObject>) | null;
deletion: (resourceObject: ResourceObject) => Cypress.Chainable<void>;
role: string;
}
export const user_team_access_tab_resources: AccessTabResource[] = [
{
name: 'projects',
content_type: 'eda.project',
creation: cy.createEdaProject,
deletion: cy.deleteEdaProject,
creation: () => cy.createEdaProject() as Cypress.Chainable<ResourceObject>,
deletion: (resourceObject) => cy.deleteEdaProject(resourceObject as EdaProject),
role: 'Project Admin',
},
{
name: 'decision-environments',
content_type: 'eda.project',
creation: cy.createEdaDecisionEnvironment,
deletion: cy.deleteEdaDecisionEnvironment,
creation: () => cy.createEdaDecisionEnvironment() as Cypress.Chainable<ResourceObject>,
deletion: (resourceObject) =>
cy.deleteEdaDecisionEnvironment(resourceObject as EdaDecisionEnvironment),
role: 'Decision Environment Admin',
},
{
name: 'rulebook-activations',
content_type: 'eda.activation',
creation: cy.createEdaRulebookActivation,
deletion: cy.deleteEdaRulebookActivation,
creation: null,
deletion: (resourceObject) =>
cy.deleteEdaRulebookActivation(resourceObject as EdaRulebookActivation),
role: 'Activation Admin',
},
{
name: 'credentials',
content_type: 'eda.edacredential',
creation: cy.createEdaCredential,
deletion: cy.deleteEdaCredential,
creation: () => cy.createEdaCredential() as Cypress.Chainable<ResourceObject>,
deletion: (resourceObject) => cy.deleteEdaCredential(resourceObject as EdaCredential),
role: 'Eda Credential Admin',
},
{
name: 'credential-types',
content_type: 'eda.credentialtype',
creation: cy.createEdaCredentialType,
deletion: cy.deleteEdaCredentialType,
creation: () => cy.createEdaCredentialType() as Cypress.Chainable<ResourceObject>,
deletion: (resourceObject) => cy.deleteEdaCredentialType(resourceObject as EdaCredentialType),
role: 'Credential Type Admin',
},
];
Empty file added cypress/support/interfaces.ts
Empty file.

0 comments on commit 8971fdb

Please sign in to comment.