Skip to content

Commit

Permalink
Address e2e and component tests after moving to the latest PatternFly…
Browse files Browse the repository at this point in the history
… dropdown
  • Loading branch information
marshmalien committed Jul 11, 2024
1 parent 84a127e commit f19c4c2
Show file tree
Hide file tree
Showing 44 changed files with 265 additions and 299 deletions.
4 changes: 3 additions & 1 deletion cypress/e2e/awx/access/users.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ describe('Users Delete Actions', () => {

it('deletes a user from the users list row item', () => {
cy.navigateTo('awx', 'users');
cy.clickTableRowKebabAction(user.username, 'delete-user');
cy.clickTableRowAction('username', user.username, 'delete-user', {
inKebab: true,
});
cy.get('#confirm').click();
cy.clickButton(/^Delete user/);
cy.contains(/^Success$/);
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/awx/administration/applications.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('Applications', () => {
cy.verifyPageTitle('OAuth Applications');
cy.filterTableBySingleSelect('name', app.name);
cy.clickTableRowAction('name', app.name, 'edit-application', {
inKebab: true,
inKebab: false,
disableFilter: true,
});
cy.intercept('PATCH', awxAPI`/applications/*/`).as('editApp');
Expand Down
10 changes: 8 additions & 2 deletions cypress/e2e/awx/administration/credentialTypes.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ describe('Credential Types', () => {
});
cy.navigateTo('awx', 'credential-types');
cy.filterTableByMultiSelect('name', [editedCredentialTypeName]);
cy.clickTableRowKebabAction(`${editedCredentialTypeName}`, 'delete-credential-type', false);
cy.clickTableRowAction('name', editedCredentialTypeName, 'delete-credential-type', {
disableFilter: true,
inKebab: true,
});
cy.get('#confirm').click();
cy.intercept('DELETE', awxAPI`/credential_types/${credType1.id.toString()}/`).as(
'deleteCredType'
Expand Down Expand Up @@ -285,7 +288,10 @@ describe('Credential Types', () => {
it('can delete a credential type from the list row action', () => {
cy.navigateTo('awx', 'credential-types');
cy.filterTableByMultiSelect('name', [credType1.name]);
cy.clickTableRowKebabAction(credType1.name, 'delete-credential-type', false);
cy.clickTableRowAction('name', credType1.name, 'delete-credential-type', {
disableFilter: true,
inKebab: true,
});
cy.get('#confirm').click();
cy.clickButton(/^Delete credential type/);
cy.contains(/^Success$/);
Expand Down
14 changes: 10 additions & 4 deletions cypress/e2e/awx/administration/instanceGroups.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe(`Instance Groups`, () => {
cy.navigateTo('awx', 'instance-groups');
cy.verifyPageTitle('Instance Groups');
cy.clickButton(/^Create group$/);
cy.clickLink(`Create instance group`);
cy.clickButton(`Create instance group`);
cy.get('[data-cy="name"]').type(name);
cy.get('[data-cy="policy-instance-minimum"]').clear();
cy.get('[data-cy="policy-instance-minimum"]').type('1');
Expand Down Expand Up @@ -100,7 +100,10 @@ describe(`Instance Groups`, () => {
cy.navigateTo('awx', 'instance-groups');
cy.verifyPageTitle('Instance Groups');
cy.filterTableBySingleSelect('name', instanceGroup.name);
cy.clickTableRowKebabAction(instanceGroup.name, `edit-instance-group`, false);
cy.clickTableRowAction('name', instanceGroup.name, `edit-instance-group`, {
inKebab: false,
disableFilter: true,
});
cy.get('[data-cy="name"]').clear();
cy.get('[data-cy="name"]').type(`${instanceGroup.name}- edited`);
cy.get('[data-cy="policy-instance-minimum"]').clear();
Expand Down Expand Up @@ -237,7 +240,7 @@ describe(`Instance Groups`, () => {
cy.navigateTo('awx', 'instance-groups');
cy.verifyPageTitle('Instance Groups');
cy.clickButton(/^Create group$/);
cy.clickLink(`Create container group`);
cy.clickButton(/^Create container group$/);
cy.get('[data-cy="name"]').type(name);
cy.get('[data-cy="max-concurrent-jobs"]').clear();
cy.get('[data-cy="max-concurrent-jobs"]').type('3');
Expand Down Expand Up @@ -1008,7 +1011,10 @@ describe(`Instance Groups`, () => {
cy.clickTab(/^Jobs$/, true);
cy.filterTableBySingleSelect('name', job_template.name);
cy.intercept('DELETE', awxAPI`/jobs/*/`).as('deleted');
cy.clickTableRowKebabAction(job_template.name, 'delete-job', false);
cy.clickTableRowAction('name', job_template.name, 'delete-job', {
inKebab: true,
disableFilter: true,
});
cy.clickModalConfirmCheckbox();
cy.clickModalButton('Delete job');
cy.assertModalSuccess();
Expand Down
5 changes: 4 additions & 1 deletion cypress/e2e/awx/resources/credentials.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ describe('Credentials', () => {
it('can delete machine credential from the list row action', () => {
cy.navigateTo('awx', 'credentials');
cy.filterTableByMultiSelect('name', [credential.name]);
cy.clickTableRowKebabAction(credential.name, 'delete-credential', false);
cy.clickTableRowAction('name', credential.name, 'delete-credential', {
disableFilter: true,
inKebab: true,
});
cy.get('#confirm').click();
cy.intercept('DELETE', awxAPI`/credentials/${credential.id.toString()}/`).as('deleted');
cy.clickButton(/^Delete credential/);
Expand Down
5 changes: 4 additions & 1 deletion cypress/e2e/awx/resources/executionEnvironments.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ describe('Execution Environments', () => {
cy.clickTab(/^Back to Execution Environments$/, true);
cy.verifyPageTitle('Execution Environments');
cy.filterTableBySingleSelect('name', execEnvName);
cy.clickTableRowKebabAction(execEnvName, 'delete-execution-environment', false);
cy.clickTableRowAction('name', execEnvName, 'delete-execution-environment', {
inKebab: true,
disableFilter: true,
});
cy.clickModalConfirmCheckbox();
cy.intercept('DELETE', awxAPI`/execution_environments/*/`).as('deleteEE');
cy.clickModalButton('Delete execution environments');
Expand Down
12 changes: 9 additions & 3 deletions cypress/e2e/awx/resources/inventories.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Inventories Tests', () => {
const inventoryName = 'E2E Inventory ' + randomString(4);
cy.navigateTo('awx', 'inventories');
cy.clickButton(/^Create inventory$/);
cy.clickLink(/^Create inventory$/);
cy.get('#create-inventory').click();
//Assert that user is on the form view to create an inventory
cy.get('[data-cy="name"]').type(inventoryName);
cy.singleSelectByDataCy('organization', organization.name);
Expand Down Expand Up @@ -122,15 +122,21 @@ describe('Inventories Tests', () => {
//Refactor this test to match the updated test case and improve the assertions
cy.navigateTo('awx', 'inventories'); //Add assertion to verify the user is on the inventories list view
cy.filterTableBySingleSelect('name', inventory.name);
cy.clickTableRowKebabAction(inventory.name, 'copy-inventory', false);
cy.clickTableRowAction('name', inventory.name, 'copy-inventory', {
disableFilter: true,
inKebab: true,
});
cy.hasAlert(`${inventory.name.toString()} copied`);
//Assert the presence of the original and the copy by performing a search on the list of inventories
});

it('can delete an inventory from the inventory list row item', () => {
cy.navigateTo('awx', 'inventories');
cy.filterTableBySingleSelect('name', inventory.name);
cy.clickTableRowKebabAction(inventory.name, 'delete-inventory', false);
cy.clickTableRowAction('name', inventory.name, 'delete-inventory', {
disableFilter: true,
inKebab: true,
});
//Add assertion to show the presence of the expected inventory
cy.get('#confirm').click();
cy.clickButton(/^Delete inventory/);
Expand Down
6 changes: 2 additions & 4 deletions cypress/e2e/awx/resources/inventoriesConstructed.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ describe('Constructed Inventories CRUD Tests', () => {
const verbosityValue = generateRandom(0, 2);

cy.navigateTo('awx', 'inventories');
cy.getByDataCy('create-inventory').click();
cy.get('.pf-v5-c-dropdown__menu').within(() => {
cy.get('[data-cy="create-constructed-inventory"]').click();
});
cy.clickButton(/^Create inventory$/);
cy.clickButton(/^Create constructed inventory$/);
cy.getByDataCy('name').type(constInvName);
cy.getByDataCy('description').type(`Description of "${constInvName}" typed by Cypress`);
cy.intercept({
Expand Down
7 changes: 5 additions & 2 deletions cypress/e2e/awx/resources/inventoryGroup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ describe('Inventory Groups', () => {
cy.getByDataCy('name-column-cell').should('contain', host.name);
cy.clickTab(/^Groups$/, true);
cy.filterTableByMultiSelect('name', [group.name]);
cy.clickTableRowKebabAction(group.name, 'edit-group', false);
cy.clickTableRowAction('name', group.name, 'edit-group', {
inKebab: false,
disableFilter: true,
});
cy.verifyPageTitle('Edit group');
cy.get('[data-cy="name-form-group"]').type('-changed');
cy.get('[data-cy="Submit"]').click();
Expand All @@ -118,7 +121,7 @@ describe('Inventory Groups', () => {
cy.clickTableRowLink('name', inventory.name, { disableFilter: true });
cy.verifyPageTitle(inventory.name);
cy.clickTab(/^Groups$/, true);
cy.clickKebabAction('actions-dropdown', 'run-command');
cy.clickButton(/^Run Command$/);
cy.selectDropdownOptionByResourceName('module-name', 'shell');
cy.getByDataCy('module-args-form-group').type('argument');
cy.selectDropdownOptionByResourceName('verbosity', '1 (Verbose)');
Expand Down
15 changes: 5 additions & 10 deletions cypress/e2e/awx/resources/jobTemplates.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ describe.skip('Job Templates Tests', function () {
});
cy.get('[data-ouia-component-type="PF5/ModalContent"]').within(() => {
cy.filterTableBySingleSelect('name', executionEnvironmentName);
cy.get('[data-ouia-component-id="simple-table"] tbody').within(() => {
cy.get('[data-cy="checkbox-column-cell"] input').click();
});
cy.selectTableRowByCheckbox('name', executionEnvironmentName, { disableFilter: true });
cy.clickButton(/^Confirm/);
});
cy.clickButton(/^Next/);
Expand Down Expand Up @@ -546,9 +544,9 @@ describe.skip('Job Templates Tests', function () {
cy.intercept('POST', awxAPI`/job_templates/${jobTemplate.id.toString()}/copy/`).as(
'copyTemplate'
);
cy.getByDataCy('actions-column-cell').within(() => {
cy.getByDataCy('actions-dropdown').click();
cy.getByDataCy('copy-template').click();
cy.clickTableRowAction('name', jobTemplate.name, 'copy-template', {
inKebab: true,
disableFilter: true,
});
cy.wait('@copyTemplate')
.its('response.body.name')
Expand Down Expand Up @@ -630,10 +628,7 @@ describe.skip('Job Templates Tests', function () {
it('can delete a job template from the list line item', function () {
cy.navigateTo('awx', 'templates');
cy.filterTableBySingleSelect('name', jobTemplate.name);
cy.getByDataCy('actions-column-cell').within(() => {
cy.getByDataCy('actions-dropdown').click();
cy.getByDataCy('delete-template').click();
});
cy.clickTableRowKebabAction(jobTemplate.name, 'delete-template');
cy.clickModalConfirmCheckbox();
cy.intercept('DELETE', awxAPI`/job_templates/${jobTemplate.id.toString()}/`).as('deleteJT');
cy.clickModalButton('Delete template');
Expand Down
5 changes: 4 additions & 1 deletion cypress/e2e/awx/resources/projects/project-details.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ describe('Projects', () => {

it('can delete a schedule from the schedules list row', () => {
cy.filterTableBySingleSelect('name', schedule.name);
cy.clickTableRowKebabAction(schedule.name, 'delete-schedule', false);
cy.clickTableRowAction('name', schedule.name, 'delete-schedule', {
disableFilter: true,
inKebab: true,
});
cy.getModal().then(() => {
cy.get('#confirm').click();
cy.intercept('DELETE', awxAPI`/schedules/${schedule.id.toString()}/`).as('deleted');
Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/awx/resources/sharedTemplateSurvey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ export class ReusableTemplateSurveyTestSuite {
cy.contains(question.question_name);
cy.contains(question.default);
cy.contains('text');
cy.getByDataCy('actions-dropdown').click();
cy.contains('Delete question').click();
});
cy.clickTableRowAction('name', question.question_name, 'delete-question', {
inKebab: true,
disableFilter: true,
});
cy.clickModalConfirmCheckbox();
cy.intercept(
Expand Down
10 changes: 4 additions & 6 deletions cypress/e2e/awx/views/jobs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,18 @@ describe('Jobs', () => {
it('can render the toolbar and row actions', () => {
cy.navigateTo('awx', 'jobs');
cy.get('.pf-v5-c-toolbar__group button.toggle-kebab').click();
cy.get('.pf-v5-c-dropdown__menu').within(() => {
cy.contains(/^Delete selected jobs$/).should('exist');
cy.contains(/^Cancel selected jobs$/).should('exist');
});
cy.contains(/^Delete selected jobs$/).should('exist');
cy.contains(/^Cancel selected jobs$/).should('exist');
cy.filterTableByMultiSelect('id', [job.id ? job.id.toString() : '']);
const jobName = job.name ? job.name : '';
cy.contains('td', jobName)
.parent()
.within(() => {
// Relaunch job
cy.get('#relaunch-job').should('exist');
cy.get('.pf-v5-c-dropdown__toggle').click();
cy.contains('.pf-v5-c-dropdown__menu-item', /^Delete job$/).should('exist');
cy.getByDataCy('actions-dropdown').click();
});
cy.contains('#delete-job', /^Delete job$/).should('exist');
cy.clearAllFilters();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('EDA Decision Environment List', () => {
cy.setTableView('table');
cy.filterTableByTextFilter('name', edaDE.name, { disableFilterSelection: true });
cy.setTableView('card');
cy.clickListCardKebabAction(edaDE.id, edaDE.name, 'delete-decision-environment');
cy.clickListCardKebabAction(edaDE.id, 'delete-decision-environment');
cy.get('#confirm').click();
cy.clickButton(/^Delete decision environment/);
cy.contains(/^Success$/);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ describe('EDA rulebook activations- Create, Edit, Delete', () => {

it('can delete a single Rulebook Activation from the line item on the list view', () => {
cy.navigateTo('eda', 'rulebook-activations');
cy.edaRuleBookActivationCheckbox(edaRBA1.name).within(() => {
cy.clickPageAction('delete-rulebook-activation');
cy.clickTableRowAction('name', edaRBA1.name, 'delete-rulebook-activation', {
disableFilter: true,
inKebab: true,
});
cy.get('div[role="dialog"]').within(() => {
cy.get('.pf-v5-c-check__label').should(
Expand Down
12 changes: 8 additions & 4 deletions cypress/e2e/hub/remotes.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ describe('Remotes', () => {
cy.contains('Remotes').click();
cy.url().should('include', Remotes.url);
cy.filterTableBySingleText(remoteName);
cy.get('[data-cy="actions-column-cell"]').click();
cy.get('[data-cy="delete-remote"]').click({ force: true });
cy.clickTableRowAction('remote-name', remoteName, 'delete-remote', {
disableFilter: true,
inKebab: true,
});
cy.get('#confirm').click();
cy.clickButton(/^Delete remote/);
cy.contains(/^Success$/);
Expand Down Expand Up @@ -95,8 +97,10 @@ describe('Remotes', () => {
cy.wait('@remote').then(() => {
cy.contains('Remotes').click();
cy.filterTableBySingleText(remoteName);
cy.get('[data-cy="actions-column-cell"]').click();
cy.get('[data-cy="delete-remote"]').click({ force: true });
cy.clickTableRowAction('remote-name', remoteName, 'delete-remote', {
disableFilter: true,
inKebab: true,
});
cy.get('#confirm').click();
cy.clickButton(/^Delete remote/);
cy.contains(/^Success$/);
Expand Down
31 changes: 18 additions & 13 deletions cypress/support/awx-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,12 @@ Cypress.Commands.add('hasTooltip', (label: string | RegExp) => {
Cypress.Commands.add('clickToolbarKebabAction', (dataCy: string) => {
cy.getBy('[data-ouia-component-id="page-toolbar"]').within(() => {
cy.getByDataCy('actions-dropdown').click();
cy.getByDataCy(dataCy).click();
cy.document()
.its('body')
.find('.pf-v5-c-menu__content')
.within(() => {
cy.getByDataCy(dataCy).click();
});
});
});

Expand Down Expand Up @@ -474,18 +479,18 @@ Cypress.Commands.add(
});
}
);
Cypress.Commands.add(
'clickListCardKebabAction',
(id: number, name: string | RegExp, dataCyLabel: string | RegExp) => {
cy.get(`[data-ouia-component-id="${id}"]`).within(() => {
cy.get('[data-cy*="actions-dropdown"]')
.click()
.then(() => {
cy.get(`[data-cy=${dataCyLabel}]`).click();
});
});
}
);

Cypress.Commands.add('clickListCardKebabAction', (id: number, dataCyLabel: string) => {
cy.get(`[data-ouia-component-id="${id}"]`).within(() => {
cy.get('[data-cy*="actions-dropdown"]').click();
cy.document()
.its('body')
.find('.pf-v5-c-menu__content')
.within(() => {
cy.getByDataCy(dataCyLabel).click();
});
});
});

Cypress.Commands.add(
'clickTableRowPinnedAction',
Expand Down
11 changes: 3 additions & 8 deletions cypress/support/commands.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,15 +547,10 @@ declare global {

/**
* Finds a list card containing text and clicks action specified by label.
* @param name
* @param label
* @param filter
* @param id
* @param dataCyLabel
*/
clickListCardKebabAction(
id: number,
name: string | RegExp,
dataCyLabel: string | RegExp
): Chainable<void>;
clickListCardKebabAction(id: number, dataCyLabel: string): Chainable<void>;

/** Finds a table row containing text and clicks action specified by label. */
clickTableRowPinnedAction(
Expand Down
7 changes: 6 additions & 1 deletion cypress/support/table-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ Cypress.Commands.add(

Cypress.Commands.add('clickKebabAction', (kebabDataCy: string, actionDataCy: string) => {
cy.getByDataCy(kebabDataCy).click();
cy.getByDataCy(actionDataCy).click();
cy.document()
.its('body')
.find(`[data-cy="${actionDataCy}"]`)
.within(() => {
cy.get('button').click();
});
});

Cypress.Commands.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ describe('CredentialTypePage', () => {
credentialType.summary_fields.user_capabilities.delete = false;
});
cy.mount(<CredentialTypePage />);
cy.get('button[aria-label="Actions"]').click();
cy.contains('a.pf-v5-c-dropdown__menu-item', 'Delete credential type').should(
cy.getByDataCy('actions-dropdown').click();
cy.contains('#delete-credential-type', /^Delete credential type$/).should(
'have.attr',
'aria-disabled',
'true'
Expand Down
Loading

0 comments on commit f19c4c2

Please sign in to comment.