Skip to content

Commit

Permalink
rebase branch
Browse files Browse the repository at this point in the history
  • Loading branch information
tiyiprh committed Aug 21, 2024
1 parent 3821791 commit af53a21
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 44 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/awx/inventories-source/inventorySource.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('Inventory Sources', () => {
}).then((cred) => {
credential = cred;
goToSourceList(inventory.name);
cy.clickButton(/^Add source/);
cy.clickButton(/^Create source/);
cy.verifyPageTitle('Add new source');
cy.getByDataCy('name').type('project source');
cy.selectDropdownOptionByResourceName('source_control_type', 'Sourced from a Project');
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('Inventory Sources', () => {
});
cy.getByDataCy('description').clear().type('mock description');
cy.getByDataCy('overwrite').check();
cy.clickButton(/^Save$/);
cy.clickButton(/^Save source$/);
cy.getByDataCy('description').should('contain', 'mock description');
cy.getByDataCy('enabled-options').should('contain', 'Overwrite');
});
Expand Down
7 changes: 5 additions & 2 deletions cypress/e2e/awx/inventories/inventories.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ describe('Inventories Tests', () => {
cy.navigateTo('awx', 'inventories');
cy.filterTableBySingleSelect('name', inventory.name);
cy.selectTableRowByCheckbox('name', inventory.name, { disableFilter: true });
cy.clickToolbarKebabAction('delete-selected-inventories');
//Add an assertion that the expected inventory name appears where it should
cy.clickToolbarKebabAction('delete-inventories');
cy.get('#confirm').click();
cy.clickButton(/^Delete inventory/);
cy.contains(/^Success$/);
Expand All @@ -157,7 +158,9 @@ describe('Inventories Tests', () => {
cy.contains(inv2.name);
cy.contains(inv3.name);
cy.getByDataCy('select-all').click();
cy.clickToolbarKebabAction('delete-selected-inventories');

cy.clickToolbarKebabAction('delete-inventories');

cy.get('#confirm').click();
cy.clickButton(/^Delete inventories/);
cy.contains(/^Success$/);
Expand Down
20 changes: 10 additions & 10 deletions cypress/e2e/awx/inventories/inventoryGroup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('Inventory Groups', () => {
cy.get('tbody tr').should('have.length', 1);
cy.get('[data-cy="checkbox-column-cell"] input').click();
});
cy.clickToolbarKebabAction('delete-selected-groups');
cy.clickToolbarKebabAction('delete-groups');
cy.intercept('DELETE', awxAPI`/groups/*/`).as('deleted');
cy.get('[data-cy="delete-groups-dialog-radio-delete"]').click();
cy.get('[data-cy="delete-group-modal-delete-button"]').click();
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('Inventory Groups', () => {
cy.clickTableRowLink('name', inventory.name, { disableFilter: true });
cy.verifyPageTitle(inventory.name);
cy.clickTab(/^Groups$/, true);
cy.clickButton(/^Run Command$/);
cy.clickButton(/^Run command$/);

runCommand({
selections: 'all',
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('Inventory Groups', () => {
cy.get('tbody tr').should('have.length', 5);
cy.getByDataCy('select-all').click();
cy.intercept('DELETE', awxAPI`/groups/*/`).as('deleted');
cy.clickToolbarKebabAction('delete-selected-groups');
cy.clickToolbarKebabAction('delete-groups');
cy.getModal().within(() => {
cy.get('[data-cy="delete-groups-dialog-radio-delete"]').click();
cy.get('[data-cy="delete-group-modal-delete-button"]').click();
Expand Down Expand Up @@ -261,15 +261,15 @@ describe('Inventory Groups', () => {
cy.clickTableRowLink('name', group.name, { disableFilter: true });
cy.verifyPageTitle(group.name);
cy.clickTab(/^Related Groups$/, true);
cy.clickButton(/^New group/);
cy.clickButton(/^Create group/);
cy.verifyPageTitle('Create new group');
cy.get('[data-cy="name-form-group"]').type(newRelatedGroup);
cy.get('[data-cy="Submit"]').click();
cy.contains(newRelatedGroup);
cy.filterTableByMultiSelect('name', [newRelatedGroup]);
cy.selectTableRow(newRelatedGroup, false);
cy.intercept('POST', awxAPI`/groups/*/children/`).as('disassociateGroup');
cy.clickToolbarKebabAction('disassociate-selected-groups');
cy.clickToolbarKebabAction('disassociate-groups');
cy.clickModalConfirmCheckbox();
cy.clickButton(/^Disassociate groups/);
cy.wait('@disassociateGroup')
Expand Down Expand Up @@ -305,7 +305,7 @@ describe('Inventory Groups', () => {
cy.clickTableRowLink('name', group.name, { disableFilter: true });
cy.verifyPageTitle(group.name);
cy.clickTab(/^Related Groups$/, true);
cy.clickButton(/^Existing group/);
cy.clickButton(/^Add existing group/);
cy.filterTableByMultiSelect('name', [newGroup]);
cy.selectTableRow(newGroup, false);
cy.clickButton(/^Add groups/);
Expand All @@ -329,7 +329,7 @@ describe('Inventory Groups', () => {
cy.clickTab(/^Related Groups$/, true);
cy.selectTableRow(newGroup, false);
cy.intercept('POST', awxAPI`/groups/*/children/`).as('disassociateGroup');
cy.clickToolbarKebabAction('disassociate-selected-groups');
cy.clickToolbarKebabAction('disassociate-groups');
cy.clickModalConfirmCheckbox();
cy.clickButton(/^Disassociate groups/);
cy.wait('@disassociateGroup')
Expand Down Expand Up @@ -360,15 +360,15 @@ describe('Inventory Groups', () => {
cy.clickTableRowLink('name', group.name, { disableFilter: true });
cy.verifyPageTitle(group.name);
cy.clickTab(/^Related Groups$/, true);
cy.clickButton(/^New group/);
cy.clickButton(/^Create group/);
cy.verifyPageTitle('Create new group');
cy.get('[data-cy="name-form-group"]').type(newRelatedGroup);
cy.get('[data-cy="Submit"]').click();
cy.contains(newRelatedGroup);
cy.filterTableBySingleSelect('name', newRelatedGroup);
cy.selectTableRow(newRelatedGroup, false);
cy.intercept('POST', awxAPI`/groups/*/children/`).as('disassociateGroup');
cy.clickButton(/^Run Command$/);
cy.clickButton(/^Run command$/);

runCommand({
selections: newRelatedGroup,
Expand Down Expand Up @@ -466,7 +466,7 @@ describe('Inventory Groups', () => {
cy.clickTableRowLink('name', thisInventory.name, { disableFilter: true });
cy.verifyPageTitle(thisInventory.name);
cy.clickTab(/^Hosts$/, true);
cy.clickButton(/^Run Command$/);
cy.clickButton(/^Run command$/);

runCommand({
selections: 'all',
Expand Down
7 changes: 2 additions & 5 deletions frontend/awx/resources/groups/GroupHosts.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,10 @@ describe('GroupHosts', () => {
.then(() => {
if (kind === '') {
cy.get('[data-cy="checkbox-column-cell"] > label > input').click();
cy.get('[data-cy="disassociate-selected-hosts"]').click();
cy.get('[data-cy="disassociate-hosts"]').click();
cy.contains('Disassociate host from group?');
} else {
cy.get('body').should(
'not.have.descendants',
'[data-cy="disassociate-selected-hosts"]'
);
cy.get('body').should('not.have.descendants', '[data-cy="disassociate-hosts"]');
}
});
});
Expand Down
8 changes: 4 additions & 4 deletions frontend/awx/resources/groups/GroupRelatedGroups.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ inventories.forEach((inventory) => {
.then((results: InventoryGroup[]) => {
const group = results[0];
cy.selectTableRow(group.name, false);
cy.clickToolbarKebabAction('disassociate-selected-groups');
cy.clickToolbarKebabAction('disassociate-groups');
cy.contains('Permanently disassociate groups');
});
});
Expand Down Expand Up @@ -151,7 +151,7 @@ inventories.forEach((inventory) => {
.should('be.an', 'array')
.then(() => {
cy.get('[data-cy="add-group"]').click();
cy.get('#create-new-group').should('have.attr', 'aria-disabled', 'true');
cy.get('[data-cy="create-group"]').should('have.attr', 'aria-disabled', 'true');
});
});
}
Expand All @@ -178,8 +178,8 @@ inventories.forEach((inventory) => {

cy.get(`[data-cy="run-command"]`);
cy.get(`[data-cy="add-group"]`);
cy.get(`[data-cy="actions-dropdown"]`).click();
cy.get(`[data-cy="disassociate-selected-groups"]`);
cy.get(`[aria-label="Actions"]`).click();
cy.get(`[data-cy="disassociate-groups"]`);
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { GroupSelectDialog } from './useGroupSelectDialog';
import { postRequest } from '../../../../common/crud/Data';
import { ButtonVariant } from '@patternfly/react-core';
import { IAwxView } from '../../../common/useAwxView';
import { PlusCircleIcon } from '@patternfly/react-icons';

export function useRelatedGroupsEmptyStateActions(view: IAwxView<InventoryGroup>) {
const [_, setDialog] = usePageDialog();
Expand Down Expand Up @@ -63,7 +64,8 @@ export function useRelatedGroupsEmptyStateActions(view: IAwxView<InventoryGroup>
type: PageActionType.Button,
selection: PageActionSelection.None,
variant: ButtonVariant.primary,
label: t('Existing group'),
icon: PlusCircleIcon,
label: t('Add existing group'),
isPinned: true,
onClick: () =>
setDialog(
Expand All @@ -77,7 +79,8 @@ export function useRelatedGroupsEmptyStateActions(view: IAwxView<InventoryGroup>
type: PageActionType.Button,
selection: PageActionSelection.None,
variant: ButtonVariant.primary,
label: t('New group'),
icon: PlusCircleIcon,
label: t('Create group'),
isPinned: true,
onClick: () =>
pageNavigate(String(AwxRoute.InventoryGroupRelatedGroupsCreate), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function useRelatedGroupsToolbarActions(view: IAwxView<InventoryGroup>) {
{
type: PageActionType.Button,
selection: PageActionSelection.None,
label: t('Create new group'),
label: t('Create group'),
isHidden: () => isConstructed,
onClick: () =>
pageNavigate(String(AwxRoute.InventoryGroupRelatedGroupsCreate), {
Expand Down Expand Up @@ -122,7 +122,7 @@ export function useRelatedGroupsToolbarActions(view: IAwxView<InventoryGroup>) {
type: PageActionType.Button,
selection: PageActionSelection.Multiple,
icon: TrashIcon,
label: t('Disassociate selected groups'),
label: t('Disassociate groups'),
onClick: disassociateGroups,
isDanger: true,
isDisabled:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ types.forEach((type) => {
.then((results: InventoryGroup[]) => {
const group = results[0];
cy.selectTableRow(group.name, false);
cy.clickToolbarKebabAction('delete-selected-groups');
cy.clickToolbarKebabAction('delete-groups');
cy.get('[data-cy="delete-group-modal-delete-button"]').should('be.disabled');
cy.get('[data-cy="delete-groups-dialog-radio-delete"]').click();
cy.get('[data-cy="delete-group-modal-delete-button"]').should('be.enabled');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('InventorySources.cy.ts', () => {
.then((results: InventorySource[]) => {
const source = results[0];
cy.selectTableRow(source.name, false);
cy.clickToolbarKebabAction('delete-selected-sources');
cy.clickToolbarKebabAction('delete-sources');
cy.contains('Permanently delete source').should('be.visible');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function InventorySources() {
}
emptyStateIcon={canCreateSource ? undefined : CubesIcon}
emptyStateButtonIcon={<PlusCircleIcon />}
emptyStateButtonText={canCreateSource ? t('Add source') : undefined}
emptyStateButtonText={canCreateSource ? t('Create source') : undefined}
emptyStateButtonClick={
canCreateSource
? () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { AwxRoute } from '../../../main/AwxRoutes';
import { cannotDeleteResource, cannotEditResource } from '../../../../common/utils/RBAChelpers';
import { useParams } from 'react-router-dom';
import { useDeleteGroups } from '../../groups/hooks/useDeleteGroups';
import { ButtonVariant } from '@patternfly/react-core';

export function useInventoriesGroupActions() {
const { t } = useTranslation();
Expand All @@ -33,6 +34,7 @@ export function useInventoriesGroupActions() {
selection: PageActionSelection.Single,
isPinned: true,
icon: PencilAltIcon,
variant: ButtonVariant.primary,
label: t('Edit group'),
isHidden: () => params.inventory_type === 'constructed_inventory',
onClick: (group) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export function useInventoriesGroupsHostsToolbarActions(view: IAwxView<AwxHost>)
type: PageActionType.Button,
selection: PageActionSelection.Multiple,
isPinned: true,
label: t('Disassociate selected hosts'),
label: t('Disassociate hosts'),
onClick: disassociateHosts,
isDisabled:
view.selectedItems.length === 0 ? t('Select at least one item from the list') : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
PageActionType,
usePageNavigate,
} from '../../../../../framework';
import { PlusCircleIcon, TrashIcon } from '@patternfly/react-icons';
import { CogIcon, PlusCircleIcon, TrashIcon } from '@patternfly/react-icons';
import { useDeleteGroups } from '../../groups/hooks/useDeleteGroups';
import { useParams } from 'react-router-dom';
import { useOptions } from '../../../../common/crud/useOptions';
Expand Down Expand Up @@ -77,7 +77,7 @@ export function useInventoriesGroupsToolbarActions(view: IAwxView<InventoryGroup
type: PageActionType.Button,
selection: PageActionSelection.Multiple,
icon: TrashIcon,
label: t('Delete selected groups'),
label: t('Delete groups'),
onClick: deleteGroups,
isDanger: true,
isDisabled:
Expand Down Expand Up @@ -154,7 +154,7 @@ export function useRunCommandAction<T extends { name: string }>(
selection: PageActionSelection.None,
variant: ButtonVariant.secondary,
isPinned: options?.isPinned !== undefined ? options?.isPinned : true,
label: t('Run Command'),
label: t('Run command'),
onClick: () => {
onClick(params.selectedItems || []);
},
Expand All @@ -167,7 +167,8 @@ export function useRunCommandAction<T extends { name: string }>(
type: PageActionType.Button,
selection: PageActionSelection.Single,
isPinned: options?.isPinned,
label: t('Run Command'),
icon: CogIcon,
label: t('Run command'),
onClick: (item) => {
onClick([item]);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function useInventoriesSourcesToolbarActions(
variant: ButtonVariant.primary,
isPinned: true,
icon: PlusCircleIcon,
label: t('Add source'),
label: t('Create source'),
onClick: () =>
pageNavigate(String(AwxRoute.InventorySourcesAdd), {
params: { inventory_type: params.inventory_type, id: params.id },
Expand All @@ -83,7 +83,7 @@ export function useInventoriesSourcesToolbarActions(
type: PageActionType.Button,
selection: PageActionSelection.Multiple,
icon: TrashIcon,
label: t('Delete selected sources'),
label: t('Delete sources'),
onClick: deleteSources,
isDanger: true,
isDisabled: (sources: InventorySource[]) => cannotDeleteResources(sources, t),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function useInventoriesToolbarActions(view: IAwxView<Inventory>) {
type: PageActionType.Button,
selection: PageActionSelection.Multiple,
icon: TrashIcon,
label: t('Delete selected inventories'),
label: t('Delete inventories'),
onClick: deleteInventories,
isDanger: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('Inventory Host Groups List', () => {
path: path,
initialEntries: initialEntries,
});
cy.contains('button', /^Associate$/).should('have.attr', 'aria-disabled', 'false');
cy.contains('button', /^Associate group$/).should('have.attr', 'aria-disabled', 'false');
});

it(`Edit inventory group row action is enabled if the user has permission to edit inventory group (${type})`, () => {
Expand All @@ -148,7 +148,7 @@ describe('Inventory Host Groups List', () => {
path: path,
initialEntries: initialEntries,
});
cy.contains('button', /^Associate$/).should('have.attr', 'aria-disabled', 'true');
cy.contains('button', /^Associate group$/).should('have.attr', 'aria-disabled', 'true');
});

it(`Edit inventory group row action is disabled if the user does not have permission to edit inventory group (${type})`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function useHostsGroupsToolbarActions(
variant: ButtonVariant.primary,
isPinned: true,
icon: PlusCircleIcon,
label: t('Associate'),
label: t('Associate group'),
onClick: () =>
openInventoryHostsGroupsAddModal({
onAdd: associateGroups,
Expand All @@ -74,7 +74,7 @@ export function useHostsGroupsToolbarActions(
arr.push({
type: PageActionType.Button,
selection: PageActionSelection.Multiple,
label: t('Disassociate'),
label: t('Disassociate groups'),
isDisabled:
view.selectedItems.length === 0 ? t('Select at least one item from the list') : undefined,
onClick: disassociateGroups,
Expand Down
4 changes: 2 additions & 2 deletions frontend/awx/resources/sources/InventorySourceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function CreateInventorySource() {
]}
/>
<AwxPageForm
submitText={t('Save')}
submitText={t('Create source')}
onSubmit={onSubmit}
onCancel={() => navigate(-1)}
defaultValue={{
Expand Down Expand Up @@ -210,7 +210,7 @@ export function EditInventorySource() {
]}
/>
<AwxPageForm
submitText={t('Save')}
submitText={t('Save source')}
onSubmit={onSubmit}
onCancel={() => navigate(-1)}
defaultValue={defaultValue}
Expand Down

0 comments on commit af53a21

Please sign in to comment.