diff --git a/cypress/e2e/awx/access/teams/teams.cy.ts b/cypress/e2e/awx/access/teams/teams.cy.ts index c769ca3c6a..e0b013e0ca 100644 --- a/cypress/e2e/awx/access/teams/teams.cy.ts +++ b/cypress/e2e/awx/access/teams/teams.cy.ts @@ -2,299 +2,295 @@ import { randomString } from '../../../../../framework/utils/random-string'; import { Organization } from '../../../../../frontend/awx/interfaces/Organization'; import { Team } from '../../../../../frontend/awx/interfaces/Team'; import { AwxUser } from '../../../../../frontend/awx/interfaces/User'; -import { cyLabel } from '../../../../support/cyLabel'; import { awxAPI } from '../../../../support/formatApiPathForAwx'; -cyLabel(['upstream'], () => { - describe('Teams: Create', () => { - let organization: Organization; +describe('Teams: Create', () => { + let organization: Organization; - beforeEach(() => { - cy.createAwxOrganization().then((org) => { - organization = org; - }); - cy.navigateTo('awx', 'teams'); - cy.verifyPageTitle('Teams'); + beforeEach(() => { + cy.createAwxOrganization().then((org) => { + organization = org; }); + cy.navigateTo('awx', 'teams'); + cy.verifyPageTitle('Teams'); + }); - afterEach(() => { - cy.deleteAwxOrganization(organization, { failOnStatusCode: false }); - }); + afterEach(() => { + cy.deleteAwxOrganization(organization, { failOnStatusCode: false }); + }); - it('can create a basic team, assert details page and then delete team', () => { - const teamName = 'E2E Team ' + randomString(4); - cy.intercept('POST', awxAPI`/teams/`).as('newTeam'); - cy.getByDataCy('create-team').click(); - cy.getByDataCy('name').type(teamName); - cy.singleSelectByDataCy('organization', organization.name); - cy.getByDataCy('Submit').click(); - cy.wait('@newTeam') - .its('response.body') - .then((thisTeam: Team) => { - cy.verifyPageTitle(thisTeam.name); - cy.url().then((currentUrl) => { - expect(currentUrl.includes(`/access/teams/${thisTeam.id.toString()}/details`)).to.be - .true; - }); - cy.hasDetail('Name', thisTeam.name); - cy.hasDetail('Organization', organization.name); - cy.intercept('DELETE', awxAPI`/teams/${thisTeam.id.toString()}/`).as('deleted'); - cy.selectDetailsPageKebabAction('delete-team'); - cy.wait('@deleted') - .its('response') - .then((response) => { - expect(response?.statusCode).to.eql(204); - }); + it('can create a basic team, assert details page and then delete team', () => { + const teamName = 'E2E Team ' + randomString(4); + cy.intercept('POST', awxAPI`/teams/`).as('newTeam'); + cy.getByDataCy('create-team').click(); + cy.getByDataCy('name').type(teamName); + cy.singleSelectByDataCy('organization', organization.name); + cy.getByDataCy('Submit').click(); + cy.wait('@newTeam') + .its('response.body') + .then((thisTeam: Team) => { + cy.verifyPageTitle(thisTeam.name); + cy.url().then((currentUrl) => { + expect(currentUrl.includes(`/access/teams/${thisTeam.id.toString()}/details`)).to.be.true; }); - }); + cy.hasDetail('Name', thisTeam.name); + cy.hasDetail('Organization', organization.name); + cy.intercept('DELETE', awxAPI`/teams/${thisTeam.id.toString()}/`).as('deleted'); + cy.selectDetailsPageKebabAction('delete-team'); + cy.wait('@deleted') + .its('response') + .then((response) => { + expect(response?.statusCode).to.eql(204); + }); + }); }); +}); - describe('Teams: Edit and Delete', () => { - let team: Team; - let organization: Organization; +describe('Teams: Edit and Delete', () => { + let team: Team; + let organization: Organization; - beforeEach(() => { - cy.createAwxOrganization().then((org) => { - organization = org; - cy.createAwxTeam({ organization: organization.id }).then((createdTeam) => { - team = createdTeam; - }); + beforeEach(() => { + cy.createAwxOrganization().then((org) => { + organization = org; + cy.createAwxTeam({ organization: organization.id }).then((createdTeam) => { + team = createdTeam; }); - - cy.navigateTo('awx', 'teams'); - cy.verifyPageTitle('Teams'); }); - afterEach(() => { - cy.deleteAwxTeam(team, { failOnStatusCode: false }); - cy.deleteAwxOrganization(organization, { failOnStatusCode: false }); - }); + cy.navigateTo('awx', 'teams'); + cy.verifyPageTitle('Teams'); + }); - it('can edit a team from the details page', () => { - cy.filterTableBySingleSelect('name', team.name); - cy.clickTableRowLink('name', team.name, { disableFilter: true }); - cy.verifyPageTitle(team.name); - cy.hasDetail('Name', team.name); - cy.hasDetail('Organization', organization.name); - cy.clickButton(/^Edit team$/); - cy.verifyPageTitle(`Edit ${team.name}`); - cy.get('[data-cy="name"]') - .clear() - .type(team.name + '-edited'); - cy.intercept('PATCH', awxAPI`/teams/*/`).as('editTeam'); - cy.clickButton(/^Save team$/); - cy.wait('@editTeam') - .its('response.statusCode') - .then((statusCode) => { - expect(statusCode).to.eql(200); - }); - cy.verifyPageTitle(`${team.name}-edited`); - }); + afterEach(() => { + cy.deleteAwxTeam(team, { failOnStatusCode: false }); + cy.deleteAwxOrganization(organization, { failOnStatusCode: false }); + }); - it('can navigate to the edit form from the team list row item', () => { - cy.filterTableBySingleSelect('name', team.name); - cy.clickTableRowAction('name', team.name, 'edit-team', { disableFilter: true }); - cy.verifyPageTitle(`Edit ${team.name}`); - cy.get('[data-cy="name"]') - .clear() - .type(team.name + '-edited'); - cy.intercept('PATCH', awxAPI`/teams/*/`).as('editTeam'); - cy.clickButton(/^Save team$/); - cy.wait('@editTeam') - .its('response.statusCode') - .then((statusCode) => { - expect(statusCode).to.eql(200); - }); - cy.clearAllFilters(); - cy.filterTableBySingleSelect('name', `${team.name}-edited`); - }); + it('can edit a team from the details page', () => { + cy.filterTableBySingleSelect('name', team.name); + cy.clickTableRowLink('name', team.name, { disableFilter: true }); + cy.verifyPageTitle(team.name); + cy.hasDetail('Name', team.name); + cy.hasDetail('Organization', organization.name); + cy.clickButton(/^Edit team$/); + cy.verifyPageTitle(`Edit ${team.name}`); + cy.get('[data-cy="name"]') + .clear() + .type(team.name + '-edited'); + cy.intercept('PATCH', awxAPI`/teams/*/`).as('editTeam'); + cy.clickButton(/^Save team$/); + cy.wait('@editTeam') + .its('response.statusCode') + .then((statusCode) => { + expect(statusCode).to.eql(200); + }); + cy.verifyPageTitle(`${team.name}-edited`); + }); - it('can delete a team from the details page', () => { - cy.filterTableBySingleSelect('name', team.name); - cy.clickTableRowLink('name', team.name, { disableFilter: true }); - cy.verifyPageTitle(team.name); - cy.clickPageAction('delete-team'); - cy.intercept('DELETE', awxAPI`/teams/${team.id.toString()}/`).as('deleted'); - cy.get('#confirm').click(); - cy.clickButton(/^Delete team/); - cy.wait('@deleted') - .its('response') - .then((response) => { - expect(response?.statusCode).to.eql(204); - cy.verifyPageTitle('Teams'); - }); - }); + it('can navigate to the edit form from the team list row item', () => { + cy.filterTableBySingleSelect('name', team.name); + cy.clickTableRowAction('name', team.name, 'edit-team', { disableFilter: true }); + cy.verifyPageTitle(`Edit ${team.name}`); + cy.get('[data-cy="name"]') + .clear() + .type(team.name + '-edited'); + cy.intercept('PATCH', awxAPI`/teams/*/`).as('editTeam'); + cy.clickButton(/^Save team$/); + cy.wait('@editTeam') + .its('response.statusCode') + .then((statusCode) => { + expect(statusCode).to.eql(200); + }); + cy.clearAllFilters(); + cy.filterTableBySingleSelect('name', `${team.name}-edited`); + }); - it('can delete a team from the teams list row item', () => { - cy.filterTableBySingleSelect('name', team.name); - cy.clickTableRowAction('name', team.name, 'delete-team', { - disableFilter: true, - inKebab: true, + it('can delete a team from the details page', () => { + cy.filterTableBySingleSelect('name', team.name); + cy.clickTableRowLink('name', team.name, { disableFilter: true }); + cy.verifyPageTitle(team.name); + cy.clickPageAction('delete-team'); + cy.intercept('DELETE', awxAPI`/teams/${team.id.toString()}/`).as('deleted'); + cy.get('#confirm').click(); + cy.clickButton(/^Delete team/); + cy.wait('@deleted') + .its('response') + .then((response) => { + expect(response?.statusCode).to.eql(204); + cy.verifyPageTitle('Teams'); }); - cy.get('#confirm').click(); - cy.intercept('DELETE', awxAPI`/teams/${team.id.toString()}/`).as('deleted'); - cy.clickButton(/^Delete team/); - cy.wait('@deleted') - .its('response') - .then((response) => { - expect(response?.statusCode).to.eql(204); - cy.contains(/^Success$/); - cy.clickButton(/^Close$/); - cy.clearAllFilters(); - }); + }); + + it('can delete a team from the teams list row item', () => { + cy.filterTableBySingleSelect('name', team.name); + cy.clickTableRowAction('name', team.name, 'delete-team', { + disableFilter: true, + inKebab: true, }); + cy.get('#confirm').click(); + cy.intercept('DELETE', awxAPI`/teams/${team.id.toString()}/`).as('deleted'); + cy.clickButton(/^Delete team/); + cy.wait('@deleted') + .its('response') + .then((response) => { + expect(response?.statusCode).to.eql(204); + cy.contains(/^Success$/); + cy.clickButton(/^Close$/); + cy.clearAllFilters(); + }); }); +}); - describe('Teams: Add and Remove users', () => { - let team: Team; - let user1: AwxUser; - let organization: Organization; +describe('Teams: Add and Remove users', () => { + let team: Team; + let user1: AwxUser; + let organization: Organization; - beforeEach(() => { - cy.createAwxOrganization().then((o) => { - organization = o; - cy.createAwxUser({ organization: organization.id }).then((user) => { - user1 = user; - cy.createAwxTeam({ organization: organization.id }).then((createdTeam) => { - team = createdTeam; - cy.giveUserTeamAccess(team.name, user1.id, 'Read'); - }); + beforeEach(() => { + cy.createAwxOrganization().then((o) => { + organization = o; + cy.createAwxUser({ organization: organization.id }).then((user) => { + user1 = user; + cy.createAwxTeam({ organization: organization.id }).then((createdTeam) => { + team = createdTeam; + cy.giveUserTeamAccess(team.name, user1.id, 'Read'); }); }); - cy.navigateTo('awx', 'teams'); - cy.verifyPageTitle('Teams'); }); + cy.navigateTo('awx', 'teams'); + cy.verifyPageTitle('Teams'); + }); - afterEach(() => { - cy.deleteAwxUser(user1, { failOnStatusCode: false }); - cy.deleteAwxTeam(team, { failOnStatusCode: false }); - cy.deleteAwxOrganization(organization, { failOnStatusCode: false }); - }); + afterEach(() => { + cy.deleteAwxUser(user1, { failOnStatusCode: false }); + cy.deleteAwxTeam(team, { failOnStatusCode: false }); + cy.deleteAwxOrganization(organization, { failOnStatusCode: false }); + }); - it('can remove users from the team via the teams list row item', () => { - cy.requestPost(awxAPI`/users/${user1.id.toString()}/roles/`, { - id: team.summary_fields.object_roles.member_role.id, - }); - cy.filterTableBySingleSelect('name', team.name); - cy.clickTableRowAction('name', team.name, 'remove-users-from-teams', { - inKebab: true, - disableFilter: true, - }); - cy.getModal().within(() => { - cy.selectTableRowByCheckbox('username', user1.username); - cy.get('#submit').click(); - }); - cy.getModal().within(() => { - cy.get('#confirm').click(); - cy.get('#submit').click(); - cy.contains(/^Success$/).should('be.visible'); - cy.containsBy('button', /^Close$/).click(); - }); - cy.getModal().should('not.exist'); + it('can remove users from the team via the teams list row item', () => { + cy.requestPost(awxAPI`/users/${user1.id.toString()}/roles/`, { + id: team.summary_fields.object_roles.member_role.id, }); - - it('can add users to the team via the team access tab toolbar', () => { - cy.filterTableBySingleSelect('name', team.name); - cy.clickTableRowLink('name', team.name, { disableFilter: true }); - cy.verifyPageTitle(team.name); - cy.clickTab(/^Users$/, true); - cy.get('[data-cy="add-users"]').click(); - cy.getTableRow('username', `${user1.username}`).within(() => { - cy.get('input[type="checkbox"]').click({ force: true }); - }); - cy.clickButton(/^Next$/); - cy.getTableRow('name', 'Team Admin', { - disableFilter: true, - disableFilterSelection: true, - }).within(() => { - cy.get('input[type="checkbox"]').click({ force: true }); - }); - cy.clickButton(/^Next$/); - cy.clickButton(/^Finish$/); - cy.clickModalButton('Close'); - cy.getTableRow('username', user1.username, { - disableFilter: true, - disableFilterSelection: true, - }).should('be.visible'); + cy.filterTableBySingleSelect('name', team.name); + cy.clickTableRowAction('name', team.name, 'remove-users-from-teams', { + inKebab: true, + disableFilter: true, }); - - it('can remove users from the team via the team access tab toolbar', () => { - cy.requestPost(awxAPI`/users/${user1.id.toString()}/roles/`, { - id: team.summary_fields.object_roles.member_role.id, - }); - cy.filterTableBySingleSelect('name', team.name); - cy.clickTableRowLink('name', team.name, { disableFilter: true }); - cy.verifyPageTitle(team.name); - cy.clickTab(/^Users$/, true); - cy.getTableRow('username', `${user1.username}`).within(() => { - cy.get('input[type="checkbox"]').click({ force: true }); - }); - cy.clickToolbarKebabAction('remove-roles'); + cy.getModal().within(() => { + cy.selectTableRowByCheckbox('username', user1.username); + cy.get('#submit').click(); + }); + cy.getModal().within(() => { cy.get('#confirm').click(); - cy.clickButton(/^Remove user/); - cy.contains(/^Success$/); - cy.clickButton(/^Close$/); - cy.get(`tr[data-cy=row-id-${user1.id}]`).should('not.exist'); + cy.get('#submit').click(); + cy.contains(/^Success$/).should('be.visible'); + cy.containsBy('button', /^Close$/).click(); }); + cy.getModal().should('not.exist'); + }); - it('can remove a role from a user via the team access tab row action', () => { - cy.filterTableBySingleSelect('name', team.name); - cy.clickTableRowLink('name', team.name, { disableFilter: true }); - cy.verifyPageTitle(team.name); - cy.clickTab(/^Users$/, true); - cy.getTableRow('username', user1.username).within(() => { - cy.get(`button[data-cy="remove-role"]`).click(); - }); - cy.contains('Remove users'); - cy.clickModalConfirmCheckbox(); - cy.clickButton('Remove users'); - cy.clickModalButton('Close'); - cy.get('tbody').within(() => { - cy.get('tr').should('not.have.length'); - }); + it('can add users to the team via the team access tab toolbar', () => { + cy.filterTableBySingleSelect('name', team.name); + cy.clickTableRowLink('name', team.name, { disableFilter: true }); + cy.verifyPageTitle(team.name); + cy.clickTab(/^Users$/, true); + cy.get('[data-cy="add-users"]').click(); + cy.getTableRow('username', `${user1.username}`).within(() => { + cy.get('input[type="checkbox"]').click({ force: true }); }); + cy.clickButton(/^Next$/); + cy.getTableRow('name', 'Team Admin', { + disableFilter: true, + disableFilterSelection: true, + }).within(() => { + cy.get('input[type="checkbox"]').click({ force: true }); + }); + cy.clickButton(/^Next$/); + cy.clickButton(/^Finish$/); + cy.clickModalButton('Close'); + cy.getTableRow('username', user1.username, { + disableFilter: true, + disableFilterSelection: true, + }).should('be.visible'); }); - describe('Teams: Bulk delete', () => { - let team: Team; - let organization: Organization; - const arrayOfElementText: string[] = []; - - beforeEach(() => { - cy.createAwxOrganization().then((org) => { - organization = org; - for (let i = 0; i < 5; i++) { - cy.createAwxTeam({ organization: organization.id }).then((createdTeam) => { - team = createdTeam; - arrayOfElementText.push(team.name); - }); - } - }); - - cy.navigateTo('awx', 'teams'); - cy.verifyPageTitle('Teams'); + it('can remove users from the team via the team access tab toolbar', () => { + cy.requestPost(awxAPI`/users/${user1.id.toString()}/roles/`, { + id: team.summary_fields.object_roles.member_role.id, }); + cy.filterTableBySingleSelect('name', team.name); + cy.clickTableRowLink('name', team.name, { disableFilter: true }); + cy.verifyPageTitle(team.name); + cy.clickTab(/^Users$/, true); + cy.getTableRow('username', `${user1.username}`).within(() => { + cy.get('input[type="checkbox"]').click({ force: true }); + }); + cy.clickToolbarKebabAction('remove-roles'); + cy.get('#confirm').click(); + cy.clickButton(/^Remove user/); + cy.contains(/^Success$/); + cy.clickButton(/^Close$/); + cy.get(`tr[data-cy=row-id-${user1.id}]`).should('not.exist'); + }); - afterEach(() => { - cy.deleteAwxOrganization(organization, { failOnStatusCode: false }); + it('can remove a role from a user via the team access tab row action', () => { + cy.filterTableBySingleSelect('name', team.name); + cy.clickTableRowLink('name', team.name, { disableFilter: true }); + cy.verifyPageTitle(team.name); + cy.clickTab(/^Users$/, true); + cy.getTableRow('username', user1.username).within(() => { + cy.get(`button[data-cy="remove-role"]`).click(); }); + cy.contains('Remove users'); + cy.clickModalConfirmCheckbox(); + cy.clickButton('Remove users'); + cy.clickModalButton('Close'); + cy.get('tbody').within(() => { + cy.get('tr').should('not.have.length'); + }); + }); +}); - it('can bulk delete teams from the teams list toolbar', () => { - cy.filterTableByMultiSelect('name', arrayOfElementText); - cy.get('tbody tr').should('have.length', 5); - cy.getByDataCy('select-all').click(); - cy.clickToolbarKebabAction('delete-teams'); - cy.get('#confirm').click(); - cy.intercept('DELETE', awxAPI`/teams/*/`).as('deleted'); - cy.clickButton(/^Delete team/); - cy.wait('@deleted') - .its('response') - .then((response) => { - expect(response?.statusCode).to.eql(204); - cy.contains(/^Success$/); - cy.clickButton(/^Close$/); - cy.clearAllFilters(); +describe('Teams: Bulk delete', () => { + let team: Team; + let organization: Organization; + const arrayOfElementText: string[] = []; + + beforeEach(() => { + cy.createAwxOrganization().then((org) => { + organization = org; + for (let i = 0; i < 5; i++) { + cy.createAwxTeam({ organization: organization.id }).then((createdTeam) => { + team = createdTeam; + arrayOfElementText.push(team.name); }); + } }); + + cy.navigateTo('awx', 'teams'); + cy.verifyPageTitle('Teams'); + }); + + afterEach(() => { + cy.deleteAwxOrganization(organization, { failOnStatusCode: false }); + }); + + it('can bulk delete teams from the teams list toolbar', () => { + cy.filterTableByMultiSelect('name', arrayOfElementText); + cy.get('tbody tr').should('have.length', 5); + cy.getByDataCy('select-all').click(); + cy.clickToolbarKebabAction('delete-teams'); + cy.get('#confirm').click(); + cy.intercept('DELETE', awxAPI`/teams/*/`).as('deleted'); + cy.clickButton(/^Delete team/); + cy.wait('@deleted') + .its('response') + .then((response) => { + expect(response?.statusCode).to.eql(204); + cy.contains(/^Success$/); + cy.clickButton(/^Close$/); + cy.clearAllFilters(); + }); }); }); diff --git a/cypress/e2e/awx/cleanup/awx-cleanup.cy.ts b/cypress/e2e/awx/cleanup/awx-cleanup.cy.ts index 80478fd2e6..d9f606856c 100644 --- a/cypress/e2e/awx/cleanup/awx-cleanup.cy.ts +++ b/cypress/e2e/awx/cleanup/awx-cleanup.cy.ts @@ -7,97 +7,94 @@ import { Project } from '../../../../frontend/awx/interfaces/Project'; import { AwxUser } from '../../../../frontend/awx/interfaces/User'; import { WorkflowApproval } from '../../../../frontend/awx/interfaces/WorkflowApproval'; import { getJobsAPIUrl } from '../../../../frontend/awx/views/jobs/jobUtils'; -import { cyLabel } from '../../../support/cyLabel'; import { awxAPI } from '../../../support/formatApiPathForAwx'; const twoHoursAgo = new Date(Date.now() - 2 * 60 * 60 * 1000).toISOString(); -cyLabel(['upstream'], () => { - describe('AWX Cleanup', () => { - it('cleanup projects', () => { - cy.requestGet>( - awxAPI`/projects?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` - ).then((result) => { - for (const resource of result.results ?? []) { - cy.deleteAwxProject(resource, { failOnStatusCode: false }); - } - }); +describe('AWX Cleanup', () => { + it('cleanup projects', () => { + cy.requestGet>( + awxAPI`/projects?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` + ).then((result) => { + for (const resource of result.results ?? []) { + cy.deleteAwxProject(resource, { failOnStatusCode: false }); + } }); + }); - it('cleanup inventories', () => { - cy.requestGet>( - awxAPI`/inventories?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` - ).then((result) => { - for (const resource of result.results ?? []) { - cy.deleteAwxInventory(resource, { failOnStatusCode: false }); - } - }); + it('cleanup inventories', () => { + cy.requestGet>( + awxAPI`/inventories?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` + ).then((result) => { + for (const resource of result.results ?? []) { + cy.deleteAwxInventory(resource, { failOnStatusCode: false }); + } }); + }); - it('cleanup organizations', () => { - cy.requestGet>( - awxAPI`/organizations?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` - ).then((result) => { - for (const resource of result.results ?? []) { - cy.deleteAwxOrganization(resource, { failOnStatusCode: false }); - } - }); + it('cleanup organizations', () => { + cy.requestGet>( + awxAPI`/organizations?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` + ).then((result) => { + for (const resource of result.results ?? []) { + cy.deleteAwxOrganization(resource, { failOnStatusCode: false }); + } }); + }); - it('cleanup users', () => { - cy.requestGet>( - awxAPI`/users?username__startswith=e2e-&page=1&page_size=200&created__lt=${twoHoursAgo}` - ).then((result) => { - for (const resource of result.results ?? []) { - cy.deleteAwxUser(resource, { failOnStatusCode: false }); - } - }); + it('cleanup users', () => { + cy.requestGet>( + awxAPI`/users?username__startswith=e2e-&page=1&page_size=200&created__lt=${twoHoursAgo}` + ).then((result) => { + for (const resource of result.results ?? []) { + cy.deleteAwxUser(resource, { failOnStatusCode: false }); + } }); + }); - it('cleanup templates', () => { - cy.requestGet>( - awxAPI`/unified_job_templates/?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` - ).then((result) => { - for (const resource of result.results ?? []) { - cy.deleteAwxJobTemplate(resource, { failOnStatusCode: false }); - } - }); + it('cleanup templates', () => { + cy.requestGet>( + awxAPI`/unified_job_templates/?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` + ).then((result) => { + for (const resource of result.results ?? []) { + cy.deleteAwxJobTemplate(resource, { failOnStatusCode: false }); + } }); + }); - it('cleanup jobs', () => { - cy.requestGet>( - awxAPI`/unified_jobs/?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` - ).then((result) => { - for (const resource of result.results ?? []) { - const url = getJobsAPIUrl(resource.job_type ?? ''); - cy.requestDelete(`${url}${resource.id}/`, { failOnStatusCode: false }); - } - }); + it('cleanup jobs', () => { + cy.requestGet>( + awxAPI`/unified_jobs/?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` + ).then((result) => { + for (const resource of result.results ?? []) { + const url = getJobsAPIUrl(resource.job_type ?? ''); + cy.requestDelete(`${url}${resource.id}/`, { failOnStatusCode: false }); + } }); + }); - it('cleanup instance groups', () => { - cy.requestGet>( - awxAPI`/instance_groups/?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` - ).then((result) => { - for (const resource of result.results ?? []) { - cy.requestDelete(awxAPI`/instance_groups/${resource.id.toString()}/`, { - failOnStatusCode: false, - }); - } - }); + it('cleanup instance groups', () => { + cy.requestGet>( + awxAPI`/instance_groups/?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` + ).then((result) => { + for (const resource of result.results ?? []) { + cy.requestDelete(awxAPI`/instance_groups/${resource.id.toString()}/`, { + failOnStatusCode: false, + }); + } }); + }); - it('cleanup workflow approvals', () => { - cy.requestGet>( - awxAPI`/workflow_approvals/?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` - ).then((result) => { - for (const resource of result.results ?? []) { - cy.requestPost(awxAPI`/workflow_approvals/${resource.id.toString()}/deny/`, {}, false); - cy.requestDelete(awxAPI`/workflow_approvals/${resource.id.toString()}/`, { - failOnStatusCode: false, - }); - } - }); + it('cleanup workflow approvals', () => { + cy.requestGet>( + awxAPI`/workflow_approvals/?name__startswith=E2E&page=1&page_size=200&created__lt=${twoHoursAgo}` + ).then((result) => { + for (const resource of result.results ?? []) { + cy.requestPost(awxAPI`/workflow_approvals/${resource.id.toString()}/deny/`, {}, false); + cy.requestDelete(awxAPI`/workflow_approvals/${resource.id.toString()}/`, { + failOnStatusCode: false, + }); + } }); }); }); diff --git a/cypress/e2e/awx/overview/awx-overview.cy.ts b/cypress/e2e/awx/overview/awx-overview.cy.ts index 76f81c148a..aabf2b1cb3 100644 --- a/cypress/e2e/awx/overview/awx-overview.cy.ts +++ b/cypress/e2e/awx/overview/awx-overview.cy.ts @@ -2,208 +2,172 @@ import { AwxItemsResponse } from '../../../../frontend/awx/common/AwxItemsRespon import { Inventory } from '../../../../frontend/awx/interfaces/Inventory'; import { Job } from '../../../../frontend/awx/interfaces/Job'; import { Project } from '../../../../frontend/awx/interfaces/Project'; -import { cyLabel } from '../../../support/cyLabel'; import { awxAPI } from '../../../support/formatApiPathForAwx'; -cyLabel(['upstream'], () => { - describe('AWX Overview', () => { - it('clicking on Cog icon opens the Manage Dashboard modal', () => { - cy.navigateTo('awx', 'overview'); - cy.clickButton('Manage view'); - cy.get('.pf-v5-c-modal-box__title-text').should('contain', 'Manage view'); - cy.get('[aria-label="Close"]').click(); - }); - - it('within the Manage Dashboard modal, unchecking a resource should hide the resource', () => { - cy.navigateTo('awx', 'overview'); - cy.clickButton('Manage view'); - cy.get('.pf-v5-c-modal-box__title-text').should('contain', 'Manage view'); - cy.contains('tr', 'Resource counts').find('input').uncheck(); - cy.clickModalButton('Apply'); - cy.contains('.pf-v5-c-title', 'Hosts').should('not.exist'); - cy.clickButton('Manage view'); - cy.get('.pf-v5-c-modal-box__title-text').should('contain', 'Manage view'); - cy.contains('tr', 'Resource counts').find('input').check(); - cy.clickModalButton('Apply'); - cy.contains('.pf-v5-c-title', 'Hosts').should('be.visible'); - }); +describe('AWX Overview', () => { + it('clicking on Cog icon opens the Manage Dashboard modal', () => { + cy.navigateTo('awx', 'overview'); + cy.clickButton('Manage view'); + cy.get('.pf-v5-c-modal-box__title-text').should('contain', 'Manage view'); + cy.get('[aria-label="Close"]').click(); + }); - it('within the Manage Dashboard modal, clicking the Cancel button should revert any changes', () => { - cy.navigateTo('awx', 'overview'); - cy.clickButton('Manage view'); - cy.get('.pf-v5-c-modal-box__title-text').should('contain', 'Manage view'); - cy.contains('tr', 'Resource counts').find('input').uncheck(); - cy.clickModalButton('Cancel'); - cy.contains('.pf-v5-c-title', 'Hosts').should('be.visible'); - }); + it('within the Manage Dashboard modal, unchecking a resource should hide the resource', () => { + cy.navigateTo('awx', 'overview'); + cy.clickButton('Manage view'); + cy.get('.pf-v5-c-modal-box__title-text').should('contain', 'Manage view'); + cy.contains('tr', 'Resource counts').find('input').uncheck(); + cy.clickModalButton('Apply'); + cy.contains('.pf-v5-c-title', 'Hosts').should('not.exist'); + cy.clickButton('Manage view'); + cy.get('.pf-v5-c-modal-box__title-text').should('contain', 'Manage view'); + cy.contains('tr', 'Resource counts').find('input').check(); + cy.clickModalButton('Apply'); + cy.contains('.pf-v5-c-title', 'Hosts').should('be.visible'); + }); - it('within the Manage Dashboard modal, clicking the Close button should revert any changes', () => { - cy.navigateTo('awx', 'overview'); - cy.clickButton('Manage view'); - cy.get('.pf-v5-c-modal-box__title-text').should('contain', 'Manage view'); - cy.contains('tr', 'Resource counts').find('input').uncheck(); - cy.get('[aria-label="Close"]').click(); - cy.contains('.pf-v5-c-title', 'Hosts').should('be.visible'); - }); + it('within the Manage Dashboard modal, clicking the Cancel button should revert any changes', () => { + cy.navigateTo('awx', 'overview'); + cy.clickButton('Manage view'); + cy.get('.pf-v5-c-modal-box__title-text').should('contain', 'Manage view'); + cy.contains('tr', 'Resource counts').find('input').uncheck(); + cy.clickModalButton('Cancel'); + cy.contains('.pf-v5-c-title', 'Hosts').should('be.visible'); + }); - // Manage Dashboard modal table does not currently support keyboard input to reorder items, use drag & drop - it('within the Manage Dashboard modal, dragging a resource should reorder the resource', () => { - let initialArray: string[]; - let editedArray: string[]; - cy.navigateTo('awx', 'overview'); + it('within the Manage Dashboard modal, clicking the Close button should revert any changes', () => { + cy.navigateTo('awx', 'overview'); + cy.clickButton('Manage view'); + cy.get('.pf-v5-c-modal-box__title-text').should('contain', 'Manage view'); + cy.contains('tr', 'Resource counts').find('input').uncheck(); + cy.get('[aria-label="Close"]').click(); + cy.contains('.pf-v5-c-title', 'Hosts').should('be.visible'); + }); - cy.get('.pf-v5-c-card__header').then((headers) => { - initialArray = Array.from(headers, (title) => title.innerText.split('\n')[0]); - cy.clickButton('Manage view'); - cy.get('.pf-v5-c-modal-box__title-text').should('contain', 'Manage view'); - cy.get('#draggable-row-recent_jobs').drag('#draggable-row-recent_job_activity'); - cy.clickModalButton('Apply'); - }); - cy.get('.pf-v5-c-card__header').then((headers) => { - editedArray = Array.from(headers, (title) => title.innerText.split('\n')[0]); - expect(initialArray).to.not.eql(editedArray); - }); - }); + // Manage Dashboard modal table does not currently support keyboard input to reorder items, use drag & drop + it('within the Manage Dashboard modal, dragging a resource should reorder the resource', () => { + let initialArray: string[]; + let editedArray: string[]; + cy.navigateTo('awx', 'overview'); - it('checks jobs count and the max # of jobs in the table', () => { - cy.intercept('GET', awxAPI`/unified_jobs/?order_by=-finished&page=1&page_size=10`).as( - 'getJobs' - ); - cy.navigateTo('awx', 'overview'); - cy.get('[data-cy="jobs"]').should('contain', 'Jobs'); - cy.checkAnchorLinks('View all Jobs'); - cy.wait('@getJobs') - .its('response.body.results') - .then((results: AwxItemsResponse) => { - if (results.count === 0) { - cy.log('empty state check'); - cy.get('[data-cy="There are currently no jobs"]').should( - 'contain', - 'There are currently no jobs' - ); - cy.contains( - 'div.pf-v5-c-empty-state__body', - 'Create a job by clicking the button below.' - ); - cy.clickButton(/^Create job$/); - cy.get('[data-cy="Create Job Template"]').should('contain', 'Create Job Template'); - } else if (results.count >= 1) { - cy.log('non empty state check'); - cy.contains('h3', 'Jobs') - .parents('.pf-v5-c-card') - .within(() => { - cy.get('tbody tr') - .should('have.lengthOf.at.least', 1) - .and('have.lengthOf.lessThan', 8); - }); - } - }); + cy.get('.pf-v5-c-card__header').then((headers) => { + initialArray = Array.from(headers, (title) => title.innerText.split('\n')[0]); + cy.clickButton('Manage view'); + cy.get('.pf-v5-c-modal-box__title-text').should('contain', 'Manage view'); + cy.get('#draggable-row-recent_jobs').drag('#draggable-row-recent_job_activity'); + cy.clickModalButton('Apply'); }); - - it('checks projects count and the max # of projects in the table', () => { - cy.intercept('GET', awxAPI`/projects/?order_by=-modified&page=1&page_size=10`).as( - 'getProjects' - ); - cy.navigateTo('awx', 'overview'); - cy.get('[data-cy="projects"]').should('contain', 'Projects'); - cy.checkAnchorLinks('View all Projects'); - cy.wait('@getProjects') - .its('response.body.results') - .then((results: AwxItemsResponse) => { - if (results.count === 0) { - cy.log('empty state check'); - cy.get('[data-cy="There are currently no projects"]').should( - 'contain', - 'There are currently no projects' - ); - cy.contains( - 'div.pf-v5-c-empty-state__body', - 'Create a job by clicking the button below.' - ); - cy.clickButton(/^Create project$/); - cy.verifyPageTitle('Create Project'); - } else if (results.count >= 1) { - cy.log('non empty state check'); - cy.contains('small', 'Recently updated projects') - .prev() - .should('have.text', 'Projects') - .scrollIntoView() - .parents('.pf-v5-c-card') - .within(() => { - cy.get('tbody tr') - .should('have.lengthOf.at.least', 1) - .and('have.lengthOf.lessThan', 8); - }); - } - }); + cy.get('.pf-v5-c-card__header').then((headers) => { + editedArray = Array.from(headers, (title) => title.innerText.split('\n')[0]); + expect(initialArray).to.not.eql(editedArray); }); + }); - it('checks inventories count and the max # of inventories in the table', () => { - cy.intercept('GET', awxAPI`/inventories/?order_by=-modified&page=1&page_size=10`).as( - 'getInventories' - ); - cy.navigateTo('awx', 'overview'); - cy.get('[data-cy="inventories"]').should('contain', 'Inventories'); - cy.checkAnchorLinks('View all Inventories'); - cy.wait('@getInventories') - .its('response.body.results') - .then((results: AwxItemsResponse) => { - if (results.count === 0) { - cy.log('empty state check'); - cy.get('[data-cy="There are currently no inventories"]').should( - 'contain', - 'There are currently no inventories' - ); - cy.contains( - 'div.pf-v5-c-empty-state__body', - 'Create an inventory by clicking the button below.' - ); - cy.clickButton(/^Create inventory$/); - cy.verifyPageTitle('Create Inventory$'); - } else if (results.count >= 1) { - cy.log('non empty state check'); - cy.contains('h3', 'Inventories') - .parents('.pf-v5-c-card') - .within(() => { - cy.get('tbody tr') - .should('have.lengthOf.at.least', 1) - .and('have.lengthOf.lessThan', 8); - }); - } - }); - }); + it('checks jobs count and the max # of jobs in the table', () => { + cy.intercept('GET', awxAPI`/unified_jobs/?order_by=-finished&page=1&page_size=10`).as( + 'getJobs' + ); + cy.navigateTo('awx', 'overview'); + cy.get('[data-cy="jobs"]').should('contain', 'Jobs'); + cy.checkAnchorLinks('View all Jobs'); + cy.wait('@getJobs') + .its('response.body.results') + .then((results: AwxItemsResponse) => { + if (results.count === 0) { + cy.log('empty state check'); + cy.get('[data-cy="There are currently no jobs"]').should( + 'contain', + 'There are currently no jobs' + ); + cy.contains( + 'div.pf-v5-c-empty-state__body', + 'Create a job by clicking the button below.' + ); + cy.clickButton(/^Create job$/); + cy.get('[data-cy="Create Job Template"]').should('contain', 'Create Job Template'); + } else if (results.count >= 1) { + cy.log('non empty state check'); + cy.contains('h3', 'Jobs') + .parents('.pf-v5-c-card') + .within(() => { + cy.get('tbody tr') + .should('have.lengthOf.at.least', 1) + .and('have.lengthOf.lessThan', 8); + }); + } + }); + }); - // This should be a component test - it('admin users see default empty state with Create {resource} button', () => { - cy.navigateTo('awx', 'overview'); - cy.intercept({ method: 'GET', url: awxAPI`/projects/*` }, { fixture: 'emptyList.json' }); - cy.intercept({ method: 'GET', url: awxAPI`/inventories/*` }, { fixture: 'emptyList.json' }); - cy.intercept({ method: 'GET', url: awxAPI`/unified_jobs/*` }, { fixture: 'emptyList.json' }); - cy.reload(); - cy.contains('There are currently no jobs').should('exist'); - cy.contains('There are currently no projects').should('exist'); - cy.contains('There are currently no inventories').should('exist'); - cy.contains('button', 'Create job').should('exist'); - cy.contains('button', 'Create project').should('exist'); - cy.contains('button', 'Create inventory').should('exist'); - }); + it('checks projects count and the max # of projects in the table', () => { + cy.intercept('GET', awxAPI`/projects/?order_by=-modified&page=1&page_size=10`).as( + 'getProjects' + ); + cy.navigateTo('awx', 'overview'); + cy.get('[data-cy="projects"]').should('contain', 'Projects'); + cy.checkAnchorLinks('View all Projects'); + cy.wait('@getProjects') + .its('response.body.results') + .then((results: AwxItemsResponse) => { + if (results.count === 0) { + cy.log('empty state check'); + cy.get('[data-cy="There are currently no projects"]').should( + 'contain', + 'There are currently no projects' + ); + cy.contains( + 'div.pf-v5-c-empty-state__body', + 'Create a job by clicking the button below.' + ); + cy.clickButton(/^Create project$/); + cy.verifyPageTitle('Create Project'); + } else if (results.count >= 1) { + cy.log('non empty state check'); + cy.contains('small', 'Recently updated projects') + .prev() + .should('have.text', 'Projects') + .scrollIntoView() + .parents('.pf-v5-c-card') + .within(() => { + cy.get('tbody tr') + .should('have.lengthOf.at.least', 1) + .and('have.lengthOf.lessThan', 8); + }); + } + }); + }); - // This should be a component test - // Normal users might still be able to create resources f they have the right permissions - // this is not a valid test. - // it('non-admin users see default empty state without Create {resource} button', () => { - // cy.navigateTo('awx', 'overview'); - // cy.intercept({ method: 'GET', url: awxAPI`/projects/*` }, { fixture: 'emptyList.json' }); - // cy.intercept({ method: 'GET', url: awxAPI`/inventories/*` }, { fixture: 'emptyList.json' }); - // cy.intercept({ method: 'GET', url: awxAPI`/unified_jobs/*` }, { fixture: 'emptyList.json' }); - // cy.intercept({ method: 'GET', url: awxAPI`/me` }, { fixture: 'normalUser.json' }); - // cy.reload(); - // cy.verifyPageTitle('There are currently no jobs'); - // cy.verifyPageTitle('There are currently no projects'); - // cy.verifyPageTitle('There are currently no inventories'); - // cy.contains('button', 'Create job').should('not.exist'); - // cy.contains('button', 'Create project').should('not.exist'); - // cy.contains('button', 'Create inventory').should('not.exist'); - // }); + it('checks inventories count and the max # of inventories in the table', () => { + cy.intercept('GET', awxAPI`/inventories/?order_by=-modified&page=1&page_size=10`).as( + 'getInventories' + ); + cy.navigateTo('awx', 'overview'); + cy.get('[data-cy="inventories"]').should('contain', 'Inventories'); + cy.checkAnchorLinks('View all Inventories'); + cy.wait('@getInventories') + .its('response.body.results') + .then((results: AwxItemsResponse) => { + if (results.count === 0) { + cy.log('empty state check'); + cy.get('[data-cy="There are currently no inventories"]').should( + 'contain', + 'There are currently no inventories' + ); + cy.contains( + 'div.pf-v5-c-empty-state__body', + 'Create an inventory by clicking the button below.' + ); + cy.clickButton(/^Create inventory$/); + cy.verifyPageTitle('Create Inventory$'); + } else if (results.count >= 1) { + cy.log('non empty state check'); + cy.contains('h3', 'Inventories') + .parents('.pf-v5-c-card') + .within(() => { + cy.get('tbody tr') + .should('have.lengthOf.at.least', 1) + .and('have.lengthOf.lessThan', 8); + }); + } + }); }); }); diff --git a/cypress/e2e/eda/Access-Management/team-access.cy.ts b/cypress/e2e/eda/Access-Management/team-access.cy.ts index 373a4423ab..9997ad2a41 100644 --- a/cypress/e2e/eda/Access-Management/team-access.cy.ts +++ b/cypress/e2e/eda/Access-Management/team-access.cy.ts @@ -7,251 +7,241 @@ import { EdaRulebookActivation } from '../../../../frontend/eda/interfaces/EdaRu import { EdaTeam } from '../../../../frontend/eda/interfaces/EdaTeam'; import { LogLevelEnum } from '../../../../frontend/eda/interfaces/generated/eda-api'; import { user_team_access_tab_resources } from '../../../support/constants'; -import { cyLabel } from '../../../support/cyLabel'; import { edaAPI } from '../../../support/formatApiPathForEDA'; import { EdaOrganization } from '../../../../frontend/eda/interfaces/EdaOrganization'; type ResourceObject = EdaProject | EdaDecisionEnvironment | EdaRulebookActivation | EdaCredential; -cyLabel(['upstream'], () => { - user_team_access_tab_resources.forEach((resource) => { - describe(`Team Access Tab for ${resource.name} - Add team`, () => { - let edaTeam: EdaTeam; - let resource_object: ResourceObject; - let edaProject: EdaProject; - let edaRuleBook: EdaRulebook; - let edaOrg: EdaOrganization; +user_team_access_tab_resources.forEach((resource) => { + describe(`Team Access Tab for ${resource.name} - Add team`, () => { + let edaTeam: EdaTeam; + let resource_object: ResourceObject; + let edaProject: EdaProject; + let edaRuleBook: EdaRulebook; + let edaOrg: EdaOrganization; - before(() => { - // If the resource is a RBA, create all dependency resources, else just the one resource - if (resource.name === 'rulebook-activations') { - cy.createEdaOrganization().then((organization) => { - edaOrg = organization; - cy.createEdaProject(organization?.id).then((project) => { - edaProject = project; - cy.waitEdaProjectSync(project); - cy.getEdaRulebooks(edaProject, 'hello_echo.yml').then((edaRuleBooks) => { - edaRuleBook = edaRuleBooks[0]; - cy.createEdaDecisionEnvironment(organization?.id).then((decisionEnvironment) => { - cy.createEdaRulebookActivation( - { - rulebook_id: edaRuleBook.id, - decision_environment_id: decisionEnvironment.id, - k8s_service_name: 'sample', - log_level: LogLevelEnum.Error, - }, - edaOrg - ).then((edaRulebookActivation) => { - resource_object = edaRulebookActivation; - }); + before(() => { + // If the resource is a RBA, create all dependency resources, else just the one resource + if (resource.name === 'rulebook-activations') { + cy.createEdaOrganization().then((organization) => { + edaOrg = organization; + cy.createEdaProject(organization?.id).then((project) => { + edaProject = project; + cy.waitEdaProjectSync(project); + cy.getEdaRulebooks(edaProject, 'hello_echo.yml').then((edaRuleBooks) => { + edaRuleBook = edaRuleBooks[0]; + cy.createEdaDecisionEnvironment(organization?.id).then((decisionEnvironment) => { + cy.createEdaRulebookActivation( + { + rulebook_id: edaRuleBook.id, + decision_environment_id: decisionEnvironment.id, + k8s_service_name: 'sample', + log_level: LogLevelEnum.Error, + }, + edaOrg + ).then((edaRulebookActivation) => { + resource_object = edaRulebookActivation; }); }); }); }); - } else if (resource.creation !== null) { - resource.creation(edaOrg?.id).then((resource_instance: ResourceObject) => { - resource_object = resource_instance; - if (resource.name === 'projects') { - cy.waitEdaProjectSync(resource_instance as EdaProject); - } - }); - } - cy.createEdaTeam().then((team) => { - edaTeam = team; }); + } else if (resource.creation !== null) { + resource.creation(edaOrg?.id).then((resource_instance: ResourceObject) => { + resource_object = resource_instance; + if (resource.name === 'projects') { + cy.waitEdaProjectSync(resource_instance as EdaProject); + } + }); + } + cy.createEdaTeam().then((team) => { + edaTeam = team; }); + }); - after(() => { - resource.deletion(resource_object); - cy.deleteEdaTeam(edaTeam); - if (edaOrg) { - cy.deleteEdaOrganization(edaOrg); - } - }); - - it('can add teams via team access tab', () => { - cy.navigateTo('eda', resource.name); - // filter resource by name not available for decision environment - // or credential type - if (resource.name === 'decision-environments') { - cy.get('[data-cy="table-view"]').click(); - cy.filterTableByTextFilter('name', resource_object.name, { - disableFilterSelection: true, - }); - cy.contains('td', resource_object.name).within(() => { - cy.get('a').click(); - }); - } else { - cy.clickTableRow(resource_object.name, true); - } + after(() => { + resource.deletion(resource_object); + cy.deleteEdaTeam(edaTeam); + if (edaOrg) { + cy.deleteEdaOrganization(edaOrg); + } + }); - cy.contains('h1', resource_object.name).should('be.visible'); - cy.contains('li', 'Team Access').click(); - cy.get('a[data-cy="add-roles"]').click(); - cy.selectTableRow(edaTeam.name, true); - cy.clickButton(/^Next$/); - cy.selectTableRow(resource.role, false); - cy.clickButton(/^Next$/); - cy.intercept('POST', edaAPI`/role_team_assignments/`).as('assignment'); - cy.clickButton(/^Finish$/); - cy.assertModalSuccess(); - cy.clickButton(/^Close$/); - cy.wait('@assignment').then((assignment) => { - expect(assignment?.response?.statusCode).to.eql(201); - cy.contains('div', edaTeam.name); + it('can add teams via team access tab', () => { + cy.navigateTo('eda', resource.name); + if (resource.name === 'decision-environments') { + cy.get('[data-cy="table-view"]').click(); + cy.filterTableByTextFilter('name', resource_object.name, { + disableFilterSelection: true, + }); + cy.contains('td', resource_object.name).within(() => { + cy.get('a').click(); }); + } else { + cy.clickTableRow(resource_object.name, true); + } + cy.contains('h1', resource_object.name).should('be.visible'); + cy.contains('li', 'Team Access').click(); + cy.get('a[data-cy="add-roles"]').click(); + cy.selectTableRow(edaTeam.name, true); + cy.clickButton(/^Next$/); + cy.selectTableRow(resource.role, false); + cy.clickButton(/^Next$/); + cy.intercept('POST', edaAPI`/role_team_assignments/`).as('assignment'); + cy.clickButton(/^Finish$/); + cy.assertModalSuccess(); + cy.clickButton(/^Close$/); + cy.wait('@assignment').then((assignment) => { + expect(assignment?.response?.statusCode).to.eql(201); + cy.contains('div', edaTeam.name); }); }); + }); - describe(`Team Access Tab for ${resource.name} - actions`, () => { - let roleIDs: { [key: string]: number }; - let RoleID: number; - let resource_object: - | EdaProject - | EdaDecisionEnvironment - | EdaRulebookActivation - | EdaCredential; - let edaTeam1: EdaTeam; - let edaTeam2: EdaTeam; - let edaTeam3: EdaTeam; - - let edaProject: EdaProject; - let edaRuleBook: EdaRulebook; - let edaOrganization: EdaOrganization; + describe(`Team Access Tab for ${resource.name} - actions`, () => { + let roleIDs: { [key: string]: number }; + let RoleID: number; + let resource_object: + | EdaProject + | EdaDecisionEnvironment + | EdaRulebookActivation + | EdaCredential; + let edaTeam1: EdaTeam; + let edaTeam2: EdaTeam; + let edaTeam3: EdaTeam; + let edaProject: EdaProject; + let edaRuleBook: EdaRulebook; + let edaOrganization: EdaOrganization; - before(() => { - // If the resource is a RBA, create all dependency resources, else just the one resource - if (resource.name === 'rulebook-activations') { - cy.createEdaOrganization().then((org) => { - edaOrganization = org; - cy.createEdaProject(edaOrganization?.id).then((project) => { - edaProject = project; - cy.waitEdaProjectSync(project); - cy.getEdaRulebooks(edaProject, 'hello_echo.yml').then((edaRuleBooks) => { - edaRuleBook = edaRuleBooks[0]; - cy.createEdaDecisionEnvironment(edaOrganization?.id).then((decisionEnvironment) => { - cy.createEdaRulebookActivation( - { - rulebook_id: edaRuleBook.id, - decision_environment_id: decisionEnvironment.id, - k8s_service_name: 'sample', - log_level: LogLevelEnum.Error, - }, - edaOrganization - ).then((edaRulebookActivation) => { - resource_object = edaRulebookActivation; - }); + before(() => { + // If the resource is a RBA, create all dependency resources, else just the one resource + if (resource.name === 'rulebook-activations') { + cy.createEdaOrganization().then((org) => { + edaOrganization = org; + cy.createEdaProject(edaOrganization?.id).then((project) => { + edaProject = project; + cy.waitEdaProjectSync(project); + cy.getEdaRulebooks(edaProject, 'hello_echo.yml').then((edaRuleBooks) => { + edaRuleBook = edaRuleBooks[0]; + cy.createEdaDecisionEnvironment(edaOrganization?.id).then((decisionEnvironment) => { + cy.createEdaRulebookActivation( + { + rulebook_id: edaRuleBook.id, + decision_environment_id: decisionEnvironment.id, + k8s_service_name: 'sample', + log_level: LogLevelEnum.Error, + }, + edaOrganization + ).then((edaRulebookActivation) => { + resource_object = edaRulebookActivation; }); }); }); }); - } else if (resource.creation !== null) { - resource.creation(edaOrganization?.id).then((resource_instance) => { - resource_object = resource_instance; - if (resource.name === 'projects') { - cy.waitEdaProjectSync(resource_object as EdaProject); - } - }); - } - cy.createEdaTeam().then((team1) => { - edaTeam1 = team1; - cy.createEdaTeam().then((team2) => { - edaTeam2 = team2; - cy.createEdaTeam().then((team3) => { - edaTeam3 = team3; - cy.getEdaRoles().then((rolesArray) => { - roleIDs = rolesArray.reduce((acc, role) => { - const { name, id } = role; - return { ...acc, [name]: id }; - }, {}); - RoleID = roleIDs[resource.role]; - cy.createRoleTeamAssignments( - resource_object.id.toString(), - RoleID, - team1.id, - resource.content_type - ); - cy.createRoleTeamAssignments( - resource_object.id.toString(), - RoleID, - team2.id, - resource.content_type - ); - cy.createRoleTeamAssignments( - resource_object.id.toString(), - RoleID, - team3.id, - resource.content_type - ); - }); + }); + } else if (resource.creation !== null) { + resource.creation(edaOrganization?.id).then((resource_instance) => { + resource_object = resource_instance; + if (resource.name === 'projects') { + cy.waitEdaProjectSync(resource_object as EdaProject); + } + }); + } + cy.createEdaTeam().then((team1) => { + edaTeam1 = team1; + cy.createEdaTeam().then((team2) => { + edaTeam2 = team2; + cy.createEdaTeam().then((team3) => { + edaTeam3 = team3; + cy.getEdaRoles().then((rolesArray) => { + roleIDs = rolesArray.reduce((acc, role) => { + const { name, id } = role; + return { ...acc, [name]: id }; + }, {}); + RoleID = roleIDs[resource.role]; + cy.createRoleTeamAssignments( + resource_object.id.toString(), + RoleID, + team1.id, + resource.content_type + ); + cy.createRoleTeamAssignments( + resource_object.id.toString(), + RoleID, + team2.id, + resource.content_type + ); + cy.createRoleTeamAssignments( + resource_object.id.toString(), + RoleID, + team3.id, + resource.content_type + ); }); }); }); }); - after(() => { - resource.deletion(resource_object); - cy.deleteEdaTeam(edaTeam1); - cy.deleteEdaTeam(edaTeam2); - cy.deleteEdaTeam(edaTeam3); - if (edaOrganization) { - cy.deleteEdaOrganization(edaOrganization); - } - }); + }); - it('can remove team from row', () => { - cy.navigateTo('eda', resource.name); - // filter resource by name not available for decision environment - // or credential type - if (resource.name === 'decision-environments') { - cy.log('in DE'); - cy.get('[data-cy="table-view"]').click(); - cy.filterTableByTextFilter('name', resource_object.name, { - disableFilterSelection: true, - }); - cy.contains('td', resource_object.name).within(() => { - cy.get('a').click(); - }); - } else { - cy.log('in Else'); - cy.clickTableRow(resource_object.name, true); - } - cy.contains('h1', resource_object.name).should('be.visible'); - cy.contains('li', 'Team Access').click(); - cy.getTableRowByText(`${edaTeam1.name}`, false).within(() => { - cy.get('[data-cy="remove-role"]').click(); + after(() => { + resource.deletion(resource_object); + cy.deleteEdaTeam(edaTeam1); + cy.deleteEdaTeam(edaTeam2); + cy.deleteEdaTeam(edaTeam3); + if (edaOrganization) { + cy.deleteEdaOrganization(edaOrganization); + } + }); + + it('can remove team from row', () => { + cy.navigateTo('eda', resource.name); + if (resource.name === 'decision-environments') { + cy.log('in DE'); + cy.get('[data-cy="table-view"]').click(); + cy.filterTableByTextFilter('name', resource_object.name, { + disableFilterSelection: true, }); - cy.clickModalConfirmCheckbox(); - cy.clickModalButton('Remove role'); - cy.clickButton(/^Close$/); - cy.contains(edaTeam1.name).should('not.exist'); + cy.contains('td', resource_object.name).within(() => { + cy.get('a').click(); + }); + } else { + cy.log('in Else'); + cy.clickTableRow(resource_object.name, true); + } + cy.contains('h1', resource_object.name).should('be.visible'); + cy.contains('li', 'Team Access').click(); + cy.getTableRowByText(`${edaTeam1.name}`, false).within(() => { + cy.get('[data-cy="remove-role"]').click(); }); + cy.clickModalConfirmCheckbox(); + cy.clickModalButton('Remove role'); + cy.clickButton(/^Close$/); + cy.contains(edaTeam1.name).should('not.exist'); + }); - it('can bulk remove team assignments', () => { - cy.navigateTo('eda', resource.name); - // filter resource by name not available for decision environment - // or credential type - if (resource.name === 'decision-environments') { - cy.get('[data-cy="table-view"]').click(); - cy.filterTableByTextFilter('name', resource_object.name, { - disableFilterSelection: true, - }); - cy.contains('td', resource_object.name).within(() => { - cy.get('a').click(); - }); - } else { - cy.clickTableRow(resource_object.name, true); - } - cy.contains('h1', resource_object.name).should('be.visible'); - cy.contains('li', 'Team Access').click(); - cy.selectTableRow(`${edaTeam2.name}`, false); - cy.selectTableRow(`${edaTeam3.name}`, false); - cy.clickToolbarKebabAction('remove-roles'); - cy.clickModalConfirmCheckbox(); - cy.clickModalButton('Remove role'); - cy.clickButton(/^Close$/); - cy.contains(edaTeam2.name).should('not.exist'); - cy.contains(edaTeam3.name).should('not.exist'); - }); + it('can bulk remove team assignments', () => { + cy.navigateTo('eda', resource.name); + if (resource.name === 'decision-environments') { + cy.get('[data-cy="table-view"]').click(); + cy.filterTableByTextFilter('name', resource_object.name, { + disableFilterSelection: true, + }); + cy.contains('td', resource_object.name).within(() => { + cy.get('a').click(); + }); + } else { + cy.clickTableRow(resource_object.name, true); + } + cy.contains('h1', resource_object.name).should('be.visible'); + cy.contains('li', 'Team Access').click(); + cy.selectTableRow(`${edaTeam2.name}`, false); + cy.selectTableRow(`${edaTeam3.name}`, false); + cy.clickToolbarKebabAction('remove-roles'); + cy.clickModalConfirmCheckbox(); + cy.clickModalButton('Remove role'); + cy.clickButton(/^Close$/); + cy.contains(edaTeam2.name).should('not.exist'); + cy.contains(edaTeam3.name).should('not.exist'); }); }); }); diff --git a/cypress/e2e/eda/Access-Management/user-access.cy.ts b/cypress/e2e/eda/Access-Management/user-access.cy.ts index 66ed9bb403..92104bdde2 100644 --- a/cypress/e2e/eda/Access-Management/user-access.cy.ts +++ b/cypress/e2e/eda/Access-Management/user-access.cy.ts @@ -7,252 +7,242 @@ import { EdaRulebookActivation } from '../../../../frontend/eda/interfaces/EdaRu import { EdaUser } from '../../../../frontend/eda/interfaces/EdaUser'; import { LogLevelEnum } from '../../../../frontend/eda/interfaces/generated/eda-api'; import { user_team_access_tab_resources } from '../../../support/constants'; -import { cyLabel } from '../../../support/cyLabel'; import { edaAPI } from '../../../support/formatApiPathForEDA'; import { EdaOrganization } from '../../../../frontend/eda/interfaces/EdaOrganization'; -cyLabel(['upstream'], () => { - user_team_access_tab_resources.forEach((resource) => { - describe(`User Access Tab for ${resource.name} - Add User`, () => { - let edaUser: EdaUser; - let resource_object: - | EdaProject - | EdaDecisionEnvironment - | EdaRulebookActivation - | EdaCredential; +user_team_access_tab_resources.forEach((resource) => { + describe(`User Access Tab for ${resource.name} - Add User`, () => { + let edaUser: EdaUser; + let resource_object: + | EdaProject + | EdaDecisionEnvironment + | EdaRulebookActivation + | EdaCredential; + let edaProject: EdaProject; + let edaRuleBook: EdaRulebook; + let edaOrg: EdaOrganization; - let edaProject: EdaProject; - let edaRuleBook: EdaRulebook; - let edaOrg: EdaOrganization; - - before(() => { - // If the resource is a RBA, create all dependency resources, else just the one resource - if (resource.name === 'rulebook-activations') { - cy.createEdaOrganization().then((organization) => { - edaOrg = organization; - cy.createEdaProject(edaOrg?.id).then((project) => { - edaProject = project; - cy.waitEdaProjectSync(project); - cy.getEdaRulebooks(edaProject, 'hello_echo.yml').then((edaRuleBooks) => { - edaRuleBook = edaRuleBooks[0]; - cy.createEdaDecisionEnvironment(edaOrg?.id).then((decisionEnvironment) => { - cy.createEdaRulebookActivation( - { - rulebook_id: edaRuleBook.id, - decision_environment_id: decisionEnvironment.id, - k8s_service_name: 'sample', - log_level: LogLevelEnum.Error, - }, - edaOrg - ).then((edaRulebookActivation) => { - resource_object = edaRulebookActivation; - }); + before(() => { + // If the resource is a RBA, create all dependency resources, else just the one resource + if (resource.name === 'rulebook-activations') { + cy.createEdaOrganization().then((organization) => { + edaOrg = organization; + cy.createEdaProject(edaOrg?.id).then((project) => { + edaProject = project; + cy.waitEdaProjectSync(project); + cy.getEdaRulebooks(edaProject, 'hello_echo.yml').then((edaRuleBooks) => { + edaRuleBook = edaRuleBooks[0]; + cy.createEdaDecisionEnvironment(edaOrg?.id).then((decisionEnvironment) => { + cy.createEdaRulebookActivation( + { + rulebook_id: edaRuleBook.id, + decision_environment_id: decisionEnvironment.id, + k8s_service_name: 'sample', + log_level: LogLevelEnum.Error, + }, + edaOrg + ).then((edaRulebookActivation) => { + resource_object = edaRulebookActivation; }); }); }); }); - } else if (resource.creation !== null) { - resource.creation(edaOrg?.id).then((resource_instance) => { - resource_object = resource_instance; - if (resource.name === 'projects') { - cy.waitEdaProjectSync(resource_instance as EdaProject); - } - }); - } - cy.createEdaUser().then((user) => { - edaUser = user; }); + } else if (resource.creation !== null) { + resource.creation(edaOrg?.id).then((resource_instance) => { + resource_object = resource_instance; + if (resource.name === 'projects') { + cy.waitEdaProjectSync(resource_instance as EdaProject); + } + }); + } + cy.createEdaUser().then((user) => { + edaUser = user; }); + }); - after(() => { - resource.deletion(resource_object); - cy.deleteEdaUser(edaUser); - if (edaOrg) { - cy.deleteEdaOrganization(edaOrg); - } - }); + after(() => { + resource.deletion(resource_object); + cy.deleteEdaUser(edaUser); + if (edaOrg) { + cy.deleteEdaOrganization(edaOrg); + } + }); - it('can add users via user access tab', () => { - cy.navigateTo('eda', resource.name); - // filter resource by name not available for decision environment - // or credential type - if (resource.name === 'decision-environments') { - cy.get('[data-cy="table-view"]').click(); - cy.filterTableByTextFilter('name', resource_object.name, { - disableFilterSelection: true, - }); - cy.contains('td', resource_object.name).within(() => { - cy.get('a').click(); - }); - } else { - cy.clickTableRow(resource_object.name, true); - } - cy.contains('h1', resource_object.name).should('be.visible'); - cy.contains('li', 'User Access').click(); - cy.get('a[data-cy="add-roles"]').click(); - cy.selectTableRow(edaUser.username, true); - cy.clickButton(/^Next$/); - cy.selectTableRow(resource.role, false); - cy.clickButton(/^Next$/); - cy.intercept('POST', edaAPI`/role_user_assignments/`).as('assignment'); - cy.clickButton(/^Finish$/); - cy.assertModalSuccess(); - cy.clickButton(/^Close$/); - cy.wait('@assignment').then((assignment) => { - expect(assignment?.response?.statusCode).to.eql(201); - cy.contains('div', edaUser.username); + it('can add users via user access tab', () => { + cy.navigateTo('eda', resource.name); + if (resource.name === 'decision-environments') { + cy.get('[data-cy="table-view"]').click(); + cy.filterTableByTextFilter('name', resource_object.name, { + disableFilterSelection: true, + }); + cy.contains('td', resource_object.name).within(() => { + cy.get('a').click(); }); - cy.deleteEdaUser(edaUser); + } else { + cy.clickTableRow(resource_object.name, true); + } + cy.contains('h1', resource_object.name).should('be.visible'); + cy.contains('li', 'User Access').click(); + cy.get('a[data-cy="add-roles"]').click(); + cy.selectTableRow(edaUser.username, true); + cy.clickButton(/^Next$/); + cy.selectTableRow(resource.role, false); + cy.clickButton(/^Next$/); + cy.intercept('POST', edaAPI`/role_user_assignments/`).as('assignment'); + cy.clickButton(/^Finish$/); + cy.assertModalSuccess(); + cy.clickButton(/^Close$/); + cy.wait('@assignment').then((assignment) => { + expect(assignment?.response?.statusCode).to.eql(201); + cy.contains('div', edaUser.username); }); + cy.deleteEdaUser(edaUser); }); + }); - describe(`User Access Tab for ${resource.name} - actions`, () => { - let roleIDs: { [key: string]: number }; - let RoleID: number; - let resource_object: - | EdaProject - | EdaDecisionEnvironment - | EdaRulebookActivation - | EdaCredential; - let edaUser1: EdaUser; - let edaUser2: EdaUser; - let edaUser3: EdaUser; - let edaProject: EdaProject; - let edaRuleBook: EdaRulebook; - let edaOrg: EdaOrganization; + describe(`User Access Tab for ${resource.name} - actions`, () => { + let roleIDs: { [key: string]: number }; + let RoleID: number; + let resource_object: + | EdaProject + | EdaDecisionEnvironment + | EdaRulebookActivation + | EdaCredential; + let edaUser1: EdaUser; + let edaUser2: EdaUser; + let edaUser3: EdaUser; + let edaProject: EdaProject; + let edaRuleBook: EdaRulebook; + let edaOrg: EdaOrganization; - before(() => { - // If the resource is a RBA, create all dependency resources, else just the one resource - if (resource.name === 'rulebook-activations') { - cy.createEdaOrganization().then((organization) => { - edaOrg = organization; - cy.createEdaProject(edaOrg?.id).then((project) => { - edaProject = project; - cy.waitEdaProjectSync(project); - cy.getEdaRulebooks(edaProject, 'hello_echo.yml').then((edaRuleBooks) => { - edaRuleBook = edaRuleBooks[0]; - cy.createEdaDecisionEnvironment(edaOrg?.id).then((decisionEnvironment) => { - cy.createEdaRulebookActivation( - { - rulebook_id: edaRuleBook.id, - decision_environment_id: decisionEnvironment.id, - k8s_service_name: 'sample', - log_level: LogLevelEnum.Error, - }, - edaOrg - ).then((edaRulebookActivation) => { - resource_object = edaRulebookActivation; - }); + before(() => { + // If the resource is a RBA, create all dependency resources, else just the one resource + if (resource.name === 'rulebook-activations') { + cy.createEdaOrganization().then((organization) => { + edaOrg = organization; + cy.createEdaProject(edaOrg?.id).then((project) => { + edaProject = project; + cy.waitEdaProjectSync(project); + cy.getEdaRulebooks(edaProject, 'hello_echo.yml').then((edaRuleBooks) => { + edaRuleBook = edaRuleBooks[0]; + cy.createEdaDecisionEnvironment(edaOrg?.id).then((decisionEnvironment) => { + cy.createEdaRulebookActivation( + { + rulebook_id: edaRuleBook.id, + decision_environment_id: decisionEnvironment.id, + k8s_service_name: 'sample', + log_level: LogLevelEnum.Error, + }, + edaOrg + ).then((edaRulebookActivation) => { + resource_object = edaRulebookActivation; }); }); }); }); - } else if (resource.creation !== null) { - resource.creation(edaOrg?.id).then((resource_instance) => { - resource_object = resource_instance; - if (resource.name === 'projects') { - cy.waitEdaProjectSync(resource_object as EdaProject); - } - }); - } - cy.createEdaUser().then((user1) => { - edaUser1 = user1; - cy.createEdaUser().then((user2) => { - edaUser2 = user2; - cy.createEdaUser().then((user3) => { - edaUser3 = user3; - cy.getEdaRoles().then((rolesArray) => { - roleIDs = rolesArray.reduce((acc, role) => { - const { name, id } = role; - return { ...acc, [name]: id }; - }, {}); - RoleID = roleIDs[resource.role]; - cy.createRoleUserAssignments( - resource_object.id.toString(), - RoleID, - user1.id, - resource.content_type - ); - cy.createRoleUserAssignments( - resource_object.id.toString(), - RoleID, - user2.id, - resource.content_type - ); - cy.createRoleUserAssignments( - resource_object.id.toString(), - RoleID, - user3.id, - resource.content_type - ); - }); + }); + } else if (resource.creation !== null) { + resource.creation(edaOrg?.id).then((resource_instance) => { + resource_object = resource_instance; + if (resource.name === 'projects') { + cy.waitEdaProjectSync(resource_object as EdaProject); + } + }); + } + cy.createEdaUser().then((user1) => { + edaUser1 = user1; + cy.createEdaUser().then((user2) => { + edaUser2 = user2; + cy.createEdaUser().then((user3) => { + edaUser3 = user3; + cy.getEdaRoles().then((rolesArray) => { + roleIDs = rolesArray.reduce((acc, role) => { + const { name, id } = role; + return { ...acc, [name]: id }; + }, {}); + RoleID = roleIDs[resource.role]; + cy.createRoleUserAssignments( + resource_object.id.toString(), + RoleID, + user1.id, + resource.content_type + ); + cy.createRoleUserAssignments( + resource_object.id.toString(), + RoleID, + user2.id, + resource.content_type + ); + cy.createRoleUserAssignments( + resource_object.id.toString(), + RoleID, + user3.id, + resource.content_type + ); }); }); }); }); + }); - after(() => { - resource.deletion(resource_object); - cy.deleteEdaUser(edaUser1); - cy.deleteEdaUser(edaUser2); - cy.deleteEdaUser(edaUser3); - if (edaOrg) { - cy.deleteEdaOrganization(edaOrg); - } - }); + after(() => { + resource.deletion(resource_object); + cy.deleteEdaUser(edaUser1); + cy.deleteEdaUser(edaUser2); + cy.deleteEdaUser(edaUser3); + if (edaOrg) { + cy.deleteEdaOrganization(edaOrg); + } + }); - it('can remove user from row', () => { - cy.navigateTo('eda', resource.name); - // filter resource by name not available for decision environment - // or credential type - if (resource.name === 'decision-environments') { - cy.get('[data-cy="table-view"]').click(); - cy.filterTableByTextFilter('name', resource_object.name, { - disableFilterSelection: true, - }); - cy.contains('td', resource_object.name).within(() => { - cy.get('a').click(); - }); - } else { - cy.clickTableRow(resource_object.name, true); - } - cy.contains('h1', resource_object.name).should('be.visible'); - cy.contains('li', 'User Access').click(); - cy.getTableRowByText(`${edaUser1.username}`, false).within(() => { - cy.get('[data-cy="remove-role"]').click(); + it('can remove user from row', () => { + cy.navigateTo('eda', resource.name); + if (resource.name === 'decision-environments') { + cy.get('[data-cy="table-view"]').click(); + cy.filterTableByTextFilter('name', resource_object.name, { + disableFilterSelection: true, + }); + cy.contains('td', resource_object.name).within(() => { + cy.get('a').click(); }); - cy.clickModalConfirmCheckbox(); - cy.clickModalButton('Remove role'); - cy.clickButton(/^Close$/); - cy.contains(edaUser1.username).should('not.exist'); + } else { + cy.clickTableRow(resource_object.name, true); + } + cy.contains('h1', resource_object.name).should('be.visible'); + cy.contains('li', 'User Access').click(); + cy.getTableRowByText(`${edaUser1.username}`, false).within(() => { + cy.get('[data-cy="remove-role"]').click(); }); + cy.clickModalConfirmCheckbox(); + cy.clickModalButton('Remove role'); + cy.clickButton(/^Close$/); + cy.contains(edaUser1.username).should('not.exist'); + }); - it('can bulk remove user assignments', () => { - cy.navigateTo('eda', resource.name); - // filter resource by name not available for decision environment - // or credential type - if (resource.name === 'decision-environments') { - cy.get('[data-cy="table-view"]').click(); - cy.filterTableByTextFilter('name', resource_object.name, { - disableFilterSelection: true, - }); - cy.contains('td', resource_object.name).within(() => { - cy.get('a').click(); - }); - } else { - cy.clickTableRow(resource_object.name, true); - } - cy.contains('h1', resource_object.name).should('be.visible'); - cy.contains('li', 'User Access').click(); - cy.selectTableRow(`${edaUser2.username}`, false); - cy.selectTableRow(`${edaUser3.username}`, false); - cy.clickToolbarKebabAction('remove-roles'); - cy.clickModalConfirmCheckbox(); - cy.clickModalButton('Remove role'); - cy.clickButton(/^Close$/); - cy.contains(edaUser2.username).should('not.exist'); - cy.contains(edaUser3.username).should('not.exist'); - }); + it('can bulk remove user assignments', () => { + cy.navigateTo('eda', resource.name); + if (resource.name === 'decision-environments') { + cy.get('[data-cy="table-view"]').click(); + cy.filterTableByTextFilter('name', resource_object.name, { + disableFilterSelection: true, + }); + cy.contains('td', resource_object.name).within(() => { + cy.get('a').click(); + }); + } else { + cy.clickTableRow(resource_object.name, true); + } + cy.contains('h1', resource_object.name).should('be.visible'); + cy.contains('li', 'User Access').click(); + cy.selectTableRow(`${edaUser2.username}`, false); + cy.selectTableRow(`${edaUser3.username}`, false); + cy.clickToolbarKebabAction('remove-roles'); + cy.clickModalConfirmCheckbox(); + cy.clickModalButton('Remove role'); + cy.clickButton(/^Close$/); + cy.contains(edaUser2.username).should('not.exist'); + cy.contains(edaUser3.username).should('not.exist'); }); }); }); diff --git a/cypress/e2e/eda/General-UI/resource-toolbar.cy.ts b/cypress/e2e/eda/General-UI/resource-toolbar.cy.ts index c47dc6caff..9284537e24 100644 --- a/cypress/e2e/eda/General-UI/resource-toolbar.cy.ts +++ b/cypress/e2e/eda/General-UI/resource-toolbar.cy.ts @@ -1,80 +1,76 @@ //Tests a user's ability to perform certain actions on the Resources toolbar in the EDA UI. -import { cyLabel } from '../../../support/cyLabel'; - -cyLabel(['upstream'], () => { - describe('EDA Resource Toolbar Functionality', () => { - it('can visit the dashboard page and assert the data there', () => { - cy.get('[data-cy="eda-overview"]').contains('Overview'); - cy.verifyPageTitle('Welcome to Event Driven Automation'); - }); +describe('EDA Resource Toolbar Functionality', () => { + it('can visit the dashboard page and assert the data there', () => { + cy.get('[data-cy="eda-overview"]').contains('Overview'); + cy.verifyPageTitle('Welcome to Event Driven Automation'); + }); - it('can visit the rule audits page and assert the data there', () => { - cy.get('[data-cy="eda-rule-audits"]').contains('Rule Audit').click(); - cy.verifyPageTitle('Rule Audit'); - cy.get('[data-cy="app-description"]').should( - 'have.text', - 'Rule audit allows for monitoring and reviewing the execution of defined rules which have been triggered by incoming events.' - ); - }); + it('can visit the rule audits page and assert the data there', () => { + cy.get('[data-cy="eda-rule-audits"]').contains('Rule Audit').click(); + cy.verifyPageTitle('Rule Audit'); + cy.get('[data-cy="app-description"]').should( + 'have.text', + 'Rule audit allows for monitoring and reviewing the execution of defined rules which have been triggered by incoming events.' + ); + }); - it('can visit the rulebook activations page and assert the data there', () => { - cy.get('[data-cy="eda-rulebook-activations"]').contains('Rulebook Activations').click(); - cy.verifyPageTitle('Rulebook Activations'); - cy.get('[data-cy="app-description"]').should( - 'have.text', - 'Rulebook activations manage the configuration and enabling of rulebooks that govern automation logic triggered by events.' - ); - cy.contains('button', 'Create rulebook activation').should('exist'); - }); + it('can visit the rulebook activations page and assert the data there', () => { + cy.get('[data-cy="eda-rulebook-activations"]').contains('Rulebook Activations').click(); + cy.verifyPageTitle('Rulebook Activations'); + cy.get('[data-cy="app-description"]').should( + 'have.text', + 'Rulebook activations manage the configuration and enabling of rulebooks that govern automation logic triggered by events.' + ); + cy.contains('button', 'Create rulebook activation').should('exist'); + }); - it('can visit the projects page and assert the data there', () => { - cy.get('[data-cy="eda-projects"]').contains('Projects').click(); - cy.verifyPageTitle('Projects'); - cy.get('[data-cy="app-description"]').should( - 'have.text', - 'A project is a logical collection of rulebooks.' - ); - cy.contains('button', 'Create project').should('exist'); - }); + it('can visit the projects page and assert the data there', () => { + cy.get('[data-cy="eda-projects"]').contains('Projects').click(); + cy.verifyPageTitle('Projects'); + cy.get('[data-cy="app-description"]').should( + 'have.text', + 'A project is a logical collection of rulebooks.' + ); + cy.contains('button', 'Create project').should('exist'); + }); - it('can visit the decision environment page and assert the data there', () => { - cy.get('[data-cy="eda-decision-environments"]').contains('Decision Environments').click(); - cy.verifyPageTitle('Decision Environments'); - cy.get('[data-cy="app-description"]').should( - 'have.text', - 'Decision environments are a container image to run Ansible rulebooks.' - ); - cy.contains('button', 'Create decision environment').should('exist'); - }); + it('can visit the decision environment page and assert the data there', () => { + cy.get('[data-cy="eda-decision-environments"]').contains('Decision Environments').click(); + cy.verifyPageTitle('Decision Environments'); + cy.get('[data-cy="app-description"]').should( + 'have.text', + 'Decision environments are a container image to run Ansible rulebooks.' + ); + cy.contains('button', 'Create decision environment').should('exist'); + }); - it('can visit the users page and assert the data there', () => { - cy.get('[data-cy="eda-users"]').contains('Users').click(); - cy.verifyPageTitle('Users'); - cy.get('[data-cy="app-description"]').should( - 'have.text', - 'A user is someone who has access to Event Driven Automation with associated permissions and credentials.' - ); - cy.contains('button', 'Create user').should('exist'); - }); + it('can visit the users page and assert the data there', () => { + cy.get('[data-cy="eda-users"]').contains('Users').click(); + cy.verifyPageTitle('Users'); + cy.get('[data-cy="app-description"]').should( + 'have.text', + 'A user is someone who has access to Event Driven Automation with associated permissions and credentials.' + ); + cy.contains('button', 'Create user').should('exist'); + }); - it('can visit the roles page and assert the data there', () => { - cy.get('[data-cy="eda-roles"]').contains('Roles').click(); - cy.verifyPageTitle('Roles'); - cy.get('[data-cy="app-description"]').should( - 'have.text', - 'A role represents a set of actions that a team or user may perform on a resource or set of resources.' - ); - }); + it('can visit the roles page and assert the data there', () => { + cy.get('[data-cy="eda-roles"]').contains('Roles').click(); + cy.verifyPageTitle('Roles'); + cy.get('[data-cy="app-description"]').should( + 'have.text', + 'A role represents a set of actions that a team or user may perform on a resource or set of resources.' + ); + }); - it('can visit the credentials page and assert the data there', () => { - cy.get('[data-cy="eda-credentials"]').contains('Credentials').click(); - cy.verifyPageTitle('Credentials'); - cy.get('[data-cy="app-description"]').should( - 'have.text', - 'Credentials are utilized by Event Driven Automation for authentication when launching rulebooks.' - ); - cy.contains('button', 'Create credential').should('exist'); - }); + it('can visit the credentials page and assert the data there', () => { + cy.get('[data-cy="eda-credentials"]').contains('Credentials').click(); + cy.verifyPageTitle('Credentials'); + cy.get('[data-cy="app-description"]').should( + 'have.text', + 'Credentials are utilized by Event Driven Automation for authentication when launching rulebooks.' + ); + cy.contains('button', 'Create credential').should('exist'); }); }); diff --git a/cypress/e2e/eda/admin-user/controller-token.cy.ts b/cypress/e2e/eda/admin-user/controller-token.cy.ts index 0ab5703bbc..53fcf1e6f4 100644 --- a/cypress/e2e/eda/admin-user/controller-token.cy.ts +++ b/cypress/e2e/eda/admin-user/controller-token.cy.ts @@ -1,40 +1,37 @@ import { EdaControllerToken } from '../../../../frontend/eda/interfaces/EdaControllerToken'; -import { cyLabel } from '../../../support/cyLabel'; import { edaAPI } from '../../../support/formatApiPathForEDA'; -cyLabel(['upstream'], () => { - describe('EDA Admin User', () => { - const checkEmptyState = () => { - cy.contains('h4', 'You currently do not have any tokens from Automation Controller.'); +describe('EDA Admin User', () => { + const checkEmptyState = () => { + cy.contains('h4', 'You currently do not have any tokens from Automation Controller.'); + cy.contains( + 'div', + 'Please create a token from Automation Controller by using the button below.' + ); + cy.contains('button', 'Create controller token').should('be.enabled'); + }; + + it('checks the empty state for Controller token page and create Controller token CTA does not exist with existing token', () => { + cy.getEdaActiveUser().then((edaUser) => { + cy.intercept('GET', edaAPI`/users/me/awx-tokens/?page=1&page_size=10`).as('checkToken'); + cy.navigateTo('eda', 'users'); + cy.contains('h1', 'Users'); cy.contains( - 'div', - 'Please create a token from Automation Controller by using the button below.' + '[data-cy="app-description"]', + 'A user is someone who has access to Event Driven Automation with associated permissions and credentials.' ); - cy.contains('button', 'Create controller token').should('be.enabled'); - }; - - it('checks the empty state for Controller token page and create Controller token CTA does not exist with existing token', () => { - cy.getEdaActiveUser().then((edaUser) => { - cy.intercept('GET', edaAPI`/users/me/awx-tokens/?page=1&page_size=10`).as('checkToken'); - cy.navigateTo('eda', 'users'); - cy.contains('h1', 'Users'); - cy.contains( - '[data-cy="app-description"]', - 'A user is someone who has access to Event Driven Automation with associated permissions and credentials.' - ); - cy.contains('a', edaUser.username).click(); - cy.contains('li', 'Controller Tokens').click(); - cy.wait('@checkToken') - .its('response.body.results') - .then((results: Array) => { - if (results.length === 0) { - checkEmptyState(); - } else { - cy.get('tbody').children('tr').should('exist'); - cy.contains('button', 'Create controller token').should('not.exist'); - } - }); - }); + cy.contains('a', edaUser.username).click(); + cy.contains('li', 'Controller Tokens').click(); + cy.wait('@checkToken') + .its('response.body.results') + .then((results: Array) => { + if (results.length === 0) { + checkEmptyState(); + } else { + cy.get('tbody').children('tr').should('exist'); + cy.contains('button', 'Create controller token').should('not.exist'); + } + }); }); }); }); diff --git a/cypress/e2e/eda/main/eda-login-logout.cy.ts b/cypress/e2e/eda/main/eda-login-logout.cy.ts index aaad1d1747..081e2fa92a 100644 --- a/cypress/e2e/eda/main/eda-login-logout.cy.ts +++ b/cypress/e2e/eda/main/eda-login-logout.cy.ts @@ -1,39 +1,34 @@ //Tests a user's ability to log into and out of the EDA UI. //Note that EDA Actions do not have any CRUD functionality. import { randomString } from '../../../../framework/utils/random-string'; -import { cyLabel } from '../../../support/cyLabel'; import { edaAPI } from '../../../support/formatApiPathForEDA'; -cyLabel(['upstream'], () => { - describe('EDA Login / Logoff', () => { - it('can log into the UI and view username in the top right of the Dashboard toolbar', () => { - cy.getEdaActiveUser().then((edaUser) => { - cy.intercept('POST', edaAPI`/auth/session/logout/`).as('loggedOut'); - cy.edaLogout(); - cy.wait('@loggedOut').then((result) => { - expect(result?.response?.statusCode).to.eql(204); - }); - if (edaUser) { - cy.get('#pf-login-username-id').type(edaUser.username); - cy.get('#pf-login-password-id').type(Cypress.env('EDA_PASSWORD') as string); - cy.clickButton('Log in'); - cy.get('.pf-v5-c-dropdown__toggle').eq(1).should('contain', edaUser.username); - } +describe('EDA Login / Logoff', () => { + it('can log into the UI and view username in the top right of the Dashboard toolbar', () => { + cy.getEdaActiveUser().then((edaUser) => { + cy.intercept('POST', edaAPI`/auth/session/logout/`).as('loggedOut'); + cy.edaLogout(); + cy.wait('@loggedOut').then((result) => { + expect(result?.response?.statusCode).to.eql(204); }); + if (edaUser) { + cy.get('#pf-login-username-id').type(edaUser.username); + cy.get('#pf-login-password-id').type(Cypress.env('EDA_PASSWORD') as string); + cy.clickButton('Log in'); + cy.get('.pf-v5-c-dropdown__toggle').eq(1).should('contain', edaUser.username); + } }); + }); - it('can log out and login as a different user', () => { - const password = randomString(12); - cy.createEdaUser({ password }).then((user) => { - cy.edaLogout(); - - cy.edaLogin(user.username, password); - cy.get('.pf-v5-c-dropdown__toggle').eq(1).should('contain', user.username); - cy.edaLogout(); - - cy.edaLogin(); - cy.deleteEdaUser(user); - }); + it('can log out and login as a different user', () => { + const password = randomString(12); + cy.createEdaUser({ password }).then((user) => { + cy.edaLogout(); + cy.edaLogin(user.username, password); + cy.get('.pf-v5-c-dropdown__toggle').eq(1).should('contain', user.username); + cy.edaLogout(); + cy.edaLogin(); + cy.deleteEdaUser(user); }); }); });