From 347a9b4506f06fe2f17f9938b0e40d7a10418635 Mon Sep 17 00:00:00 2001 From: Tina Yip Date: Thu, 18 Jul 2024 18:40:33 -0400 Subject: [PATCH] rebase and updates with suggestions --- .../resources/inventoriesConstructed.cy.ts | 2 +- .../e2e/awx/resources/inventoryGroup.cy.ts | 22 ++++++++-------- .../e2e/awx/resources/inventorySource.cy.ts | 2 +- cypress/support/hostsfunctions.ts | 24 +++++++----------- .../resources/inventories/InventoryForm.tsx | 25 ++++++++++--------- .../InventoryPage/InventoryPage.tsx | 2 +- .../inventoryGroup/InventoryGroupForm.cy.tsx | 2 +- .../inventoryGroup/InventoryGroupForm.tsx | 22 ++++++++++------ .../inventoryHostsPage/InventoryHostForm.tsx | 25 +++++++------------ .../inventoryHostsPage/InventoryHostPage.tsx | 2 +- .../sources/InventorySourceForm.cy.tsx | 2 +- .../resources/sources/InventorySourceForm.tsx | 8 +++--- 12 files changed, 67 insertions(+), 71 deletions(-) diff --git a/cypress/e2e/awx/resources/inventoriesConstructed.cy.ts b/cypress/e2e/awx/resources/inventoriesConstructed.cy.ts index af91a96ef4..83da410c01 100644 --- a/cypress/e2e/awx/resources/inventoriesConstructed.cy.ts +++ b/cypress/e2e/awx/resources/inventoriesConstructed.cy.ts @@ -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)); diff --git a/cypress/e2e/awx/resources/inventoryGroup.cy.ts b/cypress/e2e/awx/resources/inventoryGroup.cy.ts index 2c35498e49..10f6386355 100644 --- a/cypress/e2e/awx/resources/inventoryGroup.cy.ts +++ b/cypress/e2e/awx/resources/inventoryGroup.cy.ts @@ -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'); @@ -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'); @@ -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'); @@ -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') @@ -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); @@ -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') @@ -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); @@ -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$/); @@ -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); }); @@ -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$/); @@ -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'); }); diff --git a/cypress/e2e/awx/resources/inventorySource.cy.ts b/cypress/e2e/awx/resources/inventorySource.cy.ts index b96d88b0df..e71b6404c2 100644 --- a/cypress/e2e/awx/resources/inventorySource.cy.ts +++ b/cypress/e2e/awx/resources/inventorySource.cy.ts @@ -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$/'); diff --git a/cypress/support/hostsfunctions.ts b/cypress/support/hostsfunctions.ts index 282fc1098d..56656e0338 100644 --- a/cypress/support/hostsfunctions.ts +++ b/cypress/support/hostsfunctions.ts @@ -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 @@ -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'); @@ -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'); @@ -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$/); @@ -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'); diff --git a/frontend/awx/resources/inventories/InventoryForm.tsx b/frontend/awx/resources/inventories/InventoryForm.tsx index bdef3a795a..e01fe54fcd 100644 --- a/frontend/awx/resources/inventories/InventoryForm.tsx +++ b/frontend/awx/resources/inventories/InventoryForm.tsx @@ -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' @@ -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 } @@ -282,10 +275,18 @@ export function EditInventory() { return ( diff --git a/frontend/awx/resources/inventories/InventoryPage/InventoryPage.tsx b/frontend/awx/resources/inventories/InventoryPage/InventoryPage.tsx index 98abae390b..8b2552c2d9 100644 --- a/frontend/awx/resources/inventories/InventoryPage/InventoryPage.tsx +++ b/frontend/awx/resources/inventories/InventoryPage/InventoryPage.tsx @@ -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 }} diff --git a/frontend/awx/resources/inventories/inventoryGroup/InventoryGroupForm.cy.tsx b/frontend/awx/resources/inventories/inventoryGroup/InventoryGroupForm.cy.tsx index 98712a9bc8..cb9812aae1 100644 --- a/frontend/awx/resources/inventories/inventoryGroup/InventoryGroupForm.cy.tsx +++ b/frontend/awx/resources/inventories/inventoryGroup/InventoryGroupForm.cy.tsx @@ -21,7 +21,7 @@ describe('CreateGroup', () => { .its('results') .should('be.an', 'array') .then(() => { - cy.contains('Create new group'); + cy.contains('Create group'); }); }); diff --git a/frontend/awx/resources/inventories/inventoryGroup/InventoryGroupForm.tsx b/frontend/awx/resources/inventories/inventoryGroup/InventoryGroupForm.tsx index 948ef655e8..bbc6afbc43 100644 --- a/frontend/awx/resources/inventories/inventoryGroup/InventoryGroupForm.tsx +++ b/frontend/awx/resources/inventories/inventoryGroup/InventoryGroupForm.tsx @@ -26,7 +26,7 @@ interface GroupFormPageHeaderProps { interface BreadCrumbLink { label: string; - to: string; + to?: string; } type BreadCrumbs = Record; @@ -66,7 +66,7 @@ function GroupFormPageHeader(props: GroupFormPageHeaderProps) { }), }, relatedGroups: { - label: t('Related groups'), + label: t('Related Groups'), to: getPageUrl(AwxRoute.InventoryGroupRelatedGroups, { params: { ...breadcrumbsParams.id, @@ -75,6 +75,8 @@ function GroupFormPageHeader(props: GroupFormPageHeaderProps) { }, }), }, + createGroup: { label: t('Create group') }, + editGroup: { label: t('Edit {{groupName}}', { groupName: props.groupName }) }, }; return ( @@ -97,12 +99,17 @@ export function CreateGroup() { if (error) return ; if (!inventory) return ; - const breadcrumbs: Array = ['inventories', 'inventory', 'groups']; + const breadcrumbs: Array = [ + 'inventories', + 'inventory', + 'groups', + 'createGroup', + ]; return ( ; if (!group) return ; - const breadcrumbs: Array = ['inventories', 'inventory', 'groups', 'group']; + const breadcrumbs: Array = ['inventories', 'inventory', 'groups', 'editGroup']; return ( - + - + submitText={t('Save host')} onSubmit={onSubmit} diff --git a/frontend/awx/resources/inventories/inventoryHostsPage/InventoryHostPage.tsx b/frontend/awx/resources/inventories/inventoryHostsPage/InventoryHostPage.tsx index d9947292b0..dbdd1e7ac7 100644 --- a/frontend/awx/resources/inventories/inventoryHostsPage/InventoryHostPage.tsx +++ b/frontend/awx/resources/inventories/inventoryHostsPage/InventoryHostPage.tsx @@ -52,7 +52,7 @@ export function InventoryHostPage() { return ( { it('renders create new source page', () => { cy.mount(); - cy.contains('Add new source'); + cy.contains('Create source'); }); it('disables save button when name is empty', () => { diff --git a/frontend/awx/resources/sources/InventorySourceForm.tsx b/frontend/awx/resources/sources/InventorySourceForm.tsx index 487ea991e8..203bfa628b 100644 --- a/frontend/awx/resources/sources/InventorySourceForm.tsx +++ b/frontend/awx/resources/sources/InventorySourceForm.tsx @@ -79,7 +79,7 @@ export function CreateInventorySource() { return (