diff --git a/cypress/support/constants.ts b/cypress/support/constants.ts index 189af78c36..81701ade31 100644 --- a/cypress/support/constants.ts +++ b/cypress/support/constants.ts @@ -2,6 +2,11 @@ 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 { Repository } from '../../frontend/hub/administration/repositories/Repository'; +import { HubNamespace } from '../../frontend/hub/namespaces/HubNamespace'; +import { HubRemote } from '../../frontend/hub/administration/remotes/Remotes'; +import { randomString } from '../../framework/utils/random-string'; +import { ContentTypeEnum } from '../../frontend/hub/interfaces/expanded/ContentType'; export enum SERVER_NAME { AWX_SERVER = 'AWX Ansible Server', @@ -57,3 +62,42 @@ export const user_team_access_tab_resources: AccessTabResource[] = [ role: 'Eda Credential Admin', }, ]; + +const testSignature: string = randomString(5, undefined, { isLowercase: true }); +function generateRemoteName(): string { + return `test-${testSignature}-remote-${randomString(5, undefined, { isLowercase: true })}`; +} + +type ResourceObjectHub = HubNamespace | Repository | HubRemote; + +export interface HubResource { + name: string; + creation: (() => Cypress.Chainable) | null; + deletion: ((resourceObjectHub: ResourceObjectHub) => Cypress.Chainable) | null; + content_type: ContentTypeEnum; + permission: string; +} + +export const hub_resources_roles_tab: HubResource[] = [ + { + name: 'Repository', + creation: () => cy.createHubRepository() as Cypress.Chainable, + deletion: (resourceObjectHub) => cy.deleteHubRepository(resourceObjectHub as Repository), + content_type: ContentTypeEnum.Repository, + permission: 'galaxy.view_ansiblerepository', + }, + { + name: 'Remote', + creation: () => cy.createRemote(generateRemoteName()) as Cypress.Chainable, + deletion: null, + content_type: ContentTypeEnum.CollectionRemote, + permission: 'galaxy.view_collectionremote', + }, + { + name: 'Namespace', + creation: () => cy.createHubNamespace() as Cypress.Chainable, + deletion: (resourceObject) => cy.deleteHubNamespace(resourceObject as HubNamespace), + content_type: ContentTypeEnum.Namespace, + permission: 'galaxy.view_namespace', + }, +];