Skip to content

Commit

Permalink
rebase and updates with suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
tiyiprh committed Jul 18, 2024
1 parent ffdfa5b commit 347a9b4
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 71 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/awx/resources/inventoriesConstructed.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('Constructed Inventories CRUD Tests', () => {
pathname: awxAPI`/inventories/`,
query: { name__icontains: invNames[invToCreate - 1] },
}).as('filterInputInventories');
cy.multiSelectBy('[data-cy="inventories"]', invNames);
cy.multiSelectByDataCy('inventories', invNames);
cy.wait('@filterInputInventories');
cy.getByDataCy('update_cache_timeout').clear().type(String(cacheTimeoutValue));
cy.singleSelectByDataCy('verbosity', String(verbosityValue));
Expand Down
22 changes: 11 additions & 11 deletions cypress/e2e/awx/resources/inventoryGroup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Inventory Groups', () => {
cy.verifyPageTitle(inventory.name);
cy.get(`a[href*="/groups?"]`).click();
cy.clickButton(/^Create group$/);
cy.verifyPageTitle('Create new group');
cy.verifyPageTitle('Create group');
cy.get('[data-cy="name"]').type(newGroupName);
cy.get('[data-cy="description"]').type('This is a description');
cy.dataEditorTypeByDataCy('variables', 'test: true');
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('Inventory Groups', () => {
cy.clickTab(/^Groups$/, true);
cy.filterTableByMultiSelect('name', [group.name]);
cy.clickTableRowKebabAction(group.name, 'edit-group', false);
cy.verifyPageTitle('Edit group');
cy.verifyPageTitle(`Edit ${group.name}`);
cy.get('[data-cy="name-form-group"]').type('-changed');
cy.get('[data-cy="Submit"]').click();
cy.verifyPageTitle(group.name + '-changed');
Expand Down Expand Up @@ -224,7 +224,7 @@ describe('Inventory Groups', () => {
cy.verifyPageTitle(inventory.name);
cy.get(`a[href*="/groups?"]`).click();
cy.clickButton(/^Create group$/);
cy.verifyPageTitle('Create new group');
cy.verifyPageTitle('Create group');
cy.get('[data-cy="name"]').type(newGroupName);
cy.get('[data-cy="description"]').type('This is a description');
cy.dataEditorTypeByDataCy('variables', 'test: true');
Expand Down Expand Up @@ -272,7 +272,7 @@ describe('Inventory Groups', () => {
cy.verifyPageTitle(group.name);
cy.intercept('PATCH', awxAPI`/groups/*/`).as('editGroup');
cy.get('[data-cy="edit-group"]').click();
cy.verifyPageTitle('Edit group');
cy.verifyPageTitle(`Edit ${group.name}`);
cy.get('[data-cy="name-form-group"]').type('-changed');
cy.get('[data-cy="Submit"]').click();
cy.wait('@editGroup')
Expand Down Expand Up @@ -305,7 +305,7 @@ describe('Inventory Groups', () => {
cy.verifyPageTitle(group.name);
cy.clickTab(/^Related Groups$/, true);
cy.clickButton(/^New group/);
cy.verifyPageTitle('Create new group');
cy.verifyPageTitle('Create group');
cy.get('[data-cy="name-form-group"]').type(newRelatedGroup);
cy.get('[data-cy="Submit"]').click();
cy.contains(newRelatedGroup);
Expand Down Expand Up @@ -358,7 +358,7 @@ describe('Inventory Groups', () => {
disableFilter: true,
});
cy.intercept('PATCH', awxAPI`/groups/*/`).as('editGroup');
cy.verifyPageTitle('Edit group');
cy.verifyPageTitle(`Edit ${newGroup}`);
cy.get('[data-cy="name-form-group"]').type('-changed');
cy.get('[data-cy="Submit"]').click();
cy.wait('@editGroup')
Expand Down Expand Up @@ -403,7 +403,7 @@ describe('Inventory Groups', () => {
cy.verifyPageTitle(group.name);
cy.clickTab(/^Related Groups$/, true);
cy.clickButton(/^New group/);
cy.verifyPageTitle('Create new group');
cy.verifyPageTitle('Create group');
cy.get('[data-cy="name-form-group"]').type(newRelatedGroup);
cy.get('[data-cy="Submit"]').click();
cy.contains(newRelatedGroup);
Expand Down Expand Up @@ -468,7 +468,7 @@ describe('Inventory Groups', () => {
cy.clickModalButton(/^Close/);
cy.intercept('POST', awxAPI`/hosts/`).as('createHost');
cy.clickButton(/^Create host$/);
cy.verifyPageTitle('Create Host');
cy.verifyPageTitle('Create host');
cy.getByDataCy('name').type(newHostName);
cy.getByDataCy('description').type('This is the description');
cy.clickButton(/^Create host$/);
Expand All @@ -477,7 +477,7 @@ describe('Inventory Groups', () => {
.then((response) => {
expect(response?.statusCode).to.eql(201);
});
cy.verifyPageTitle('Host Details');
cy.verifyPageTitle(newHostName);
cy.clickTab(/^Back to Hosts$/, true);
cy.filterTableBySingleSelect('name', newHostName);
});
Expand All @@ -492,7 +492,7 @@ describe('Inventory Groups', () => {
disableFilter: true,
});
cy.intercept('PATCH', awxAPI`/hosts/*/`).as('editHost');
cy.verifyPageTitle('Edit host');
cy.verifyPageTitle(`Edit ${thisHost.name}`);
cy.getByDataCy('name').type('-edited');
cy.getByDataCy('description').type('This is the description');
cy.clickButton(/^Save host$/);
Expand All @@ -501,7 +501,7 @@ describe('Inventory Groups', () => {
.then((response) => {
expect(response?.statusCode).to.eql(200);
});
cy.verifyPageTitle('Host Details');
cy.verifyPageTitle(`${thisHost.name}-edited`);
cy.clickTab(/^Back to Hosts$/, true);
cy.filterTableBySingleSelect('name', thisHost.name + '-edited');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/awx/resources/inventorySource.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe.skip('Inventory Sources', () => {
goToSourceList(inventory.name);
// Create inventory source
cy.getBy('#add-source').click();
cy.verifyPageTitle('Add new source');
cy.verifyPageTitle('Create source');
cy.getBy('[data-cy="name"]').type('amazon ec2 source');
cy.selectDropdownOptionByResourceName('source_control_type', 'Amazon EC2');
cy.getBy('[data-cy="host-filter"]').type('/^test$/');
Expand Down
24 changes: 9 additions & 15 deletions cypress/support/hostsfunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,12 @@ export function createAndCheckHost(host_type: string, inventory: string) {

// create host
cy.clickButton(/^Create host$/);
cy.verifyPageTitle('Create Host');
cy.verifyPageTitle('Create host');
cy.getByDataCy('name').type(hostName);
cy.getByDataCy('description').type('This is the description');

if (host_type === 'stand_alone_host') {
cy.getByDataCy('inventory').click();
cy.contains('button', 'Browse').click();
cy.getModal().within(() => {
cy.filterTableBySingleSelect('name', inventory);
cy.get(`[data-cy="checkbox-column-cell"] input`).click();
cy.contains('button', 'Confirm').click();
});
cy.singleSelectBy('[data-cy="inventory-form-group"]', inventory);
}

// after creation - verify data is currect
Expand Down Expand Up @@ -61,19 +55,19 @@ export function createHost(host_type: string, inventoryID: number) {
return hostName;
}

function editHost(invenotryName: string, host_type: string, hostName: string, view: string) {
function editHost(inventoryName: string, host_type: string, hostName: string, view: string) {
// function that editing host data from list or details views
// this function cover both inventory host and stand alone host
if (view === 'list') {
navigateToBaseView(host_type, invenotryName);
navigateToBaseView(host_type, inventoryName);
cy.filterTableByMultiSelect('name', [hostName]);
} else {
// for details view
navigateToHost(host_type, hostName, '[data-cy="name-column-cell"] a', invenotryName);
navigateToHost(host_type, hostName, '[data-cy="name-column-cell"] a', inventoryName);
}

cy.getByDataCy('edit-host').click();
cy.verifyPageTitle('Edit host');
cy.verifyPageTitle(`Edit ${hostName}`);
cy.getByDataCy('description').clear().type('This is the description edited');
cy.getByDataCy('Submit').click();
cy.hasDetail(/^Description$/, 'This is the description edited');
Expand Down Expand Up @@ -161,7 +155,7 @@ export function checkHostGroup(host_type: string, organization: Organization) {
cy.clickLink(/^Groups$/);
//check edit group
cy.getByDataCy('edit-group').click();
cy.verifyPageTitle('Edit group');
cy.verifyPageTitle(`Edit ${group.name}`);
cy.getByDataCy('name-form-group').type('-changed');
cy.getByDataCy('Submit').click();
cy.verifyPageTitle(group.name + '-changed');
Expand Down Expand Up @@ -277,7 +271,7 @@ export function createHostAndCancelJob(
cy.navigateTo('awx', 'inventories');
cy.filterTableByMultiSelect('name', [inventory.name]);
cy.get('[data-cy="name-column-cell"]').contains(inventory.name).click();
cy.get('.pf-v5-c-tabs__item > a').contains('Job templates').click();
cy.get('.pf-v5-c-tabs__item > a').contains('Job Templates').click();
// run a template and wait for redirect to Job output
cy.get('[data-cy="launch-template"]').first().click();
cy.location('pathname').should('match', /\/output$/);
Expand Down Expand Up @@ -323,7 +317,7 @@ export function launchHostJob(
cy.navigateTo('awx', 'inventories');
cy.filterTableByMultiSelect('name', [inventory.name]);
cy.get('[data-cy="name-column-cell"]').contains(inventory.name).click();
cy.contains(`[role='tab']`, 'Job templates').click();
cy.contains(`[role='tab']`, 'Job Templates').click();

// run a template and wait for request
cy.intercept('POST', awxAPI`/job_templates/*/launch`).as('launch');
Expand Down
25 changes: 13 additions & 12 deletions frontend/awx/resources/inventories/InventoryForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ export function CreateInventory(props: { inventoryKind: '' | 'constructed' | 'sm
const getPageUrl = useGetPageUrl();
const title =
inventoryKind === ''
? t('Create Inventory')
? t('Create inventory')
: inventoryKind === 'smart'
? t('Create Smart Inventory')
: t('Create Constructed Inventory');
? t('Create smart inventory')
: t('Create constructed inventory');

const defaultValue =
inventoryKind === 'smart'
Expand Down Expand Up @@ -257,13 +257,6 @@ export function EditInventory() {
);
}

const title =
inventory.kind === ''
? t('Edit Inventory')
: inventory.kind === 'smart'
? t('Edit Smart Inventory')
: t('Edit Constructed Inventory');

const defaultValue =
inventory.kind === 'smart'
? { ...inventory, instanceGroups: originalInstanceGroups }
Expand All @@ -282,10 +275,18 @@ export function EditInventory() {
return (
<PageLayout>
<PageHeader
title={title}
title={
inventory?.name
? t('Edit {{inventoryName}}', { inventoryName: inventory?.name })
: t('Inventory')
}
breadcrumbs={[
{ label: t('Inventories'), to: getPageUrl(AwxRoute.Inventories) },
{ label: title },
{
label: inventory?.name
? t('Edit {{inventoryName}}', { inventoryName: inventory?.name })
: t('Inventory'),
},
]}
/>
<AwxPageForm<InventoryCreate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function InventoryPage() {
!isSmartInventory &&
!isConstructedInventory && { label: t('Sources'), page: AwxRoute.InventorySources },
{ label: t('Jobs'), page: AwxRoute.InventoryJobs },
{ label: t('Job templates'), page: AwxRoute.InventoryJobTemplates },
{ label: t('Job Templates'), page: AwxRoute.InventoryJobTemplates },
]}
params={params}
componentParams={{ inventory }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('CreateGroup', () => {
.its('results')
.should('be.an', 'array')
.then(() => {
cy.contains('Create new group');
cy.contains('Create group');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface GroupFormPageHeaderProps {

interface BreadCrumbLink {
label: string;
to: string;
to?: string;
}

type BreadCrumbs = Record<string, BreadCrumbLink>;
Expand Down Expand Up @@ -66,7 +66,7 @@ function GroupFormPageHeader(props: GroupFormPageHeaderProps) {
}),
},
relatedGroups: {
label: t('Related groups'),
label: t('Related Groups'),
to: getPageUrl(AwxRoute.InventoryGroupRelatedGroups, {
params: {
...breadcrumbsParams.id,
Expand All @@ -75,6 +75,8 @@ function GroupFormPageHeader(props: GroupFormPageHeaderProps) {
},
}),
},
createGroup: { label: t('Create group') },
editGroup: { label: t('Edit {{groupName}}', { groupName: props.groupName }) },
};

return (
Expand All @@ -97,12 +99,17 @@ export function CreateGroup() {
if (error) return <AwxError error={error} handleRefresh={refresh} />;
if (!inventory) return <LoadingPage breadcrumbs tabs />;

const breadcrumbs: Array<keyof BreadCrumbs> = ['inventories', 'inventory', 'groups'];
const breadcrumbs: Array<keyof BreadCrumbs> = [
'inventories',
'inventory',
'groups',
'createGroup',
];

return (
<PageLayout>
<GroupFormPageHeader
title={t('Create new group')}
title={t('Create group')}
breadcrumbs={breadcrumbs}
urlParams={params}
inventoryName={inventory?.name}
Expand All @@ -124,12 +131,12 @@ export function EditGroup() {
if (error) return <AwxError error={error} handleRefresh={refresh} />;
if (!group) return <LoadingPage breadcrumbs tabs />;

const breadcrumbs: Array<keyof BreadCrumbs> = ['inventories', 'inventory', 'groups', 'group'];
const breadcrumbs: Array<keyof BreadCrumbs> = ['inventories', 'inventory', 'groups', 'editGroup'];

return (
<PageLayout>
<GroupFormPageHeader
title={t('Edit group')}
title={t('Edit {{groupName}}', { groupName: group?.name })}
breadcrumbs={breadcrumbs}
urlParams={params}
inventoryName={group?.summary_fields.inventory.name}
Expand Down Expand Up @@ -158,12 +165,13 @@ export function CreateRelatedGroup() {
'groups',
'group',
'relatedGroups',
'createGroup',
];

return (
<PageLayout>
<GroupFormPageHeader
title={t('Create new group')}
title={t('Create group')}
breadcrumbs={breadcrumbs}
urlParams={params}
inventoryName={inventoryGroup?.summary_fields.inventory.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,21 @@ export function CreateHost() {
}),
}
: {},
{ label: t('Add') },
{ label: t('Create host') },
];
} else {
breadcrumbs = [
{
label: t('Hosts'),
to: getPageUrl(AwxRoute.Hosts),
},
{ label: t('Create') },
{ label: t('Create host') },
];
}

return (
<PageLayout>
<PageHeader breadcrumbs={breadcrumbs} title={t('Create Host')} />
<PageHeader breadcrumbs={breadcrumbs} title={t('Create host')} />
<AwxPageForm
submitText={t('Create host')}
onSubmit={onSubmit}
Expand Down Expand Up @@ -256,31 +256,24 @@ export function EditHost() {
},
}),
},
{
label: t(`${hostResponse?.name}`),
to: getPageUrl(AwxRoute.InventoryHostDetails, {
params: {
id: params.id,
inventory_type: params.inventory_type,
host_id: params.host_id,
},
}),
},
{ label: t('Edit') },
{ label: t('Edit {{hostName}}', { hostName: host?.name }) },
];
} else {
breadcrumbs = [
{
label: t('Hosts'),
to: getPageUrl(AwxRoute.Hosts),
},
{ label: t('Edit') },
{ label: t('Edit {{hostName}}', { hostName: host?.name }) },
];
}

return (
<PageLayout>
<PageHeader breadcrumbs={breadcrumbs} title={t('Edit host')} />
<PageHeader
breadcrumbs={breadcrumbs}
title={t('Edit {{hostName}}', { hostName: host?.name })}
/>
<AwxPageForm<IHostInput>
submitText={t('Save host')}
onSubmit={onSubmit}
Expand Down
Loading

0 comments on commit 347a9b4

Please sign in to comment.