From 00622c9cbd34ddcb69f7923ae1631c67bfe7c214 Mon Sep 17 00:00:00 2001 From: nixocio Date: Mon, 15 Jul 2024 14:04:46 -0400 Subject: [PATCH] Update instance tests Update instance tests and instance groups. Also, add command `skipIfNotK8S` to skip certain tests based on deployment type. --- .../awx/administration/instanceGroups.cy.ts | 251 ----------------- .../e2e/awx/administration/instances.cy.ts | 12 +- .../administration/instnaceGroupsK8S.cy.ts | 254 ++++++++++++++++++ cypress/support/awx-commands.ts | 10 + cypress/support/commands.d.ts | 2 + 5 files changed, 275 insertions(+), 254 deletions(-) create mode 100644 cypress/e2e/awx/administration/instnaceGroupsK8S.cy.ts diff --git a/cypress/e2e/awx/administration/instanceGroups.cy.ts b/cypress/e2e/awx/administration/instanceGroups.cy.ts index 5d8debe058..ae57369781 100644 --- a/cypress/e2e/awx/administration/instanceGroups.cy.ts +++ b/cypress/e2e/awx/administration/instanceGroups.cy.ts @@ -1,5 +1,4 @@ import { randomString } from '../../../../framework/utils/random-string'; -import { Instance } from '../../../../frontend/awx/interfaces/Instance'; import { InstanceGroup } from '../../../../frontend/awx/interfaces/InstanceGroup'; import { Inventory } from '../../../../frontend/awx/interfaces/Inventory'; import { Job } from '../../../../frontend/awx/interfaces/Job'; @@ -10,7 +9,6 @@ import { Team } from '../../../../frontend/awx/interfaces/Team'; import { AwxUser } from '../../../../frontend/awx/interfaces/User'; import { awxAPI } from '../../../support/formatApiPathForAwx'; import { randomE2Ename } from '../../../support/utils'; -import { tag } from '../../../support/tag'; describe(`Instance Groups`, () => { let project: Project; @@ -1022,252 +1020,3 @@ describe(`Instance Groups`, () => { }); }); }); - -tag(['upstream'], () => { - //An instance can only be created in an Openshift or Kubernetes build - describe('Instance Groups: Instances Tab', () => { - let instance: Instance; - let instanceGroup: InstanceGroup; - let instanceGroupDisassociate: InstanceGroup; - let instanceToAssociate: Instance; - - beforeEach(() => { - cy.createAwxInstance('E2EInstanceIGTest' + randomString(5), 9999).then((ins: Instance) => { - instance = ins; - cy.createAwxInstanceGroup({ - name: 'E2E Instance Group Instance tab test' + randomString(4), - percent_capacity_remaining: 100, - policy_instance_minimum: 0, - policy_instance_list: !Cypress.currentTest.title.includes('associate an instance') - ? [instance.hostname] - : [], - }).then((ig: InstanceGroup) => { - instanceGroup = ig; - }); - }); - }); - - afterEach(() => { - cy.removeAwxInstance(instance?.id.toString()); - cy.deleteAwxInstanceGroup(instanceGroup, { failOnStatusCode: false }); - }); - - it('can visit the instances tab of an instance group and associate an instance to that instance group, then disable the instance', () => { - cy.navigateTo('awx', 'instance-groups'); - cy.verifyPageTitle('Instance Groups'); - cy.filterTableBySingleSelect('name', instanceGroup.name); - cy.get('[data-cy="name-column-cell"]').click(); - cy.url().then((currentUrl) => { - expect(currentUrl.includes('details')).to.be.true; - expect(currentUrl.includes('infrastructure/instance-groups')).to.be.true; - }); - - cy.clickTab(/^Instances$/, true); - cy.getByDataCy('empty-state-title').contains('There are currently no instances added'); - cy.get('[data-cy="Please associate an instance by using the button below."]').should( - 'be.visible' - ); - cy.getByDataCy('associate-instance').click(); - cy.get('[data-ouia-component-type="PF5/ModalContent"]').within(() => { - cy.get('header').contains('Select instances'); - cy.get('button').contains('Confirm').should('have.attr', 'aria-disabled', 'true'); - cy.filterTableBySingleSelect('hostname', instance.hostname); - cy.intercept('POST', awxAPI`/instance_groups/${instanceGroup.id.toString()}/instances/`).as( - 'associateInstance' - ); - cy.getByDataCy('checkbox-column-cell').find('input').click(); - cy.get('button').contains('Confirm').click(); - }); - cy.assertModalSuccess(); - cy.wait('@associateInstance') - .its('response') - .then((response) => { - expect(response?.statusCode).to.eql(204); - }); - cy.clickModalButton('Close'); - cy.intercept('PATCH', awxAPI`/instances/*/`).as('disableInstance'); - cy.getByDataCy('toggle-switch').should('be.visible').click(); - cy.wait('@disableInstance') - .then((response) => { - expect(response?.response?.statusCode).to.eql(200); - }) - .its('response.body.enabled') - .then((enabled: string) => { - expect(enabled).to.be.false; - }); - }); - - it('can visit the instances tab of an instance group and bulk disassociate instances from that instance group', () => { - const arrayOfElementText: string[] = []; - const arrayOfInstance = []; - for (let i = 0; i < 5; i++) { - cy.createAwxInstance('E2EInstanceToDisassociateFromIG' + randomString(5), 9999).then( - (ins: Instance) => { - instanceToAssociate = ins; - arrayOfElementText.push(instanceToAssociate.hostname); - arrayOfInstance.push(instanceToAssociate); - } - ); - } - cy.createAwxInstanceGroup({ - name: 'E2E Instance Group Disassociate' + randomString(4), - percent_capacity_remaining: 100, - policy_instance_minimum: 0, - policy_instance_list: arrayOfElementText, - }).then((ig: InstanceGroup) => { - instanceGroupDisassociate = ig; - cy.navigateTo('awx', 'instance-groups'); - cy.verifyPageTitle('Instance Groups'); - cy.filterTableBySingleSelect('name', instanceGroupDisassociate?.name); - cy.get('[data-cy="name-column-cell"]').click(); - cy.url().then((currentUrl) => { - expect(currentUrl.includes('details')).to.be.true; - expect(currentUrl.includes('infrastructure/instance-groups')).to.be.true; - }); - cy.clickTab(/^Instances$/, true); - cy.get('[data-ouia-component-id="simple-table"]').within(() => { - cy.get('tbody tr').should('have.length', 5); - }); - cy.get('button').contains('Disassociate').should('have.attr', 'aria-disabled', 'true'); - cy.getByDataCy('select-all').click(); - cy.get('button') - .contains('Disassociate') - .should('have.attr', 'aria-disabled', 'false') - .click(); - cy.intercept( - 'POST', - awxAPI`/instance_groups/${instanceGroupDisassociate.id.toString()}/instances/` - ).as('disassociateInstance'); - cy.get('[data-ouia-component-type="PF5/ModalContent"]').within(() => { - cy.get('header').contains('Disassociate instance from instance group'); - cy.get('button') - .contains('Disassociate instances') - .should('have.attr', 'aria-disabled', 'true'); - cy.get('input[id="confirm"]').click(); - cy.get('button') - .contains('Disassociate instances') - .should('have.attr', 'aria-disabled', 'false') - .click(); - }); - cy.assertModalSuccess(); - cy.wait('@disassociateInstance') - .its('response') - .then((response) => { - expect(response?.statusCode).to.eql(204); - }); - cy.clickModalButton('Close'); - cy.getByDataCy('empty-state-title').contains('There are currently no instances added'); - cy.get('[data-cy="Please associate an instance by using the button below."]').should( - 'be.visible' - ); - cy.deleteAwxInstanceGroup(instanceGroupDisassociate, { failOnStatusCode: false }); - arrayOfInstance.map(({ id }) => cy.removeAwxInstance(id?.toString())); - }); - }); - - it('can visit the instances tab of an instance group and run a health check from toolbar against an instance', () => { - cy.navigateTo('awx', 'instance-groups'); - cy.verifyPageTitle('Instance Groups'); - cy.filterTableBySingleSelect('name', instanceGroup.name); - cy.get('[data-cy="name-column-cell"]').click(); - cy.url().then((currentUrl) => { - expect(currentUrl.includes('details')).to.be.true; - expect(currentUrl.includes('infrastructure/instance-groups')).to.be.true; - }); - cy.clickTab(/^Instances$/, true); - cy.get('button').contains('Run health check').should('have.attr', 'aria-disabled', 'true'); - cy.filterTableBySingleSelect('hostname', instance.hostname); - cy.get('[data-ouia-component-id="simple-table"]').within(() => { - cy.get('tbody tr').should('have.length', 1); - cy.get('[data-cy="checkbox-column-cell"] input').click(); - }); - cy.getBy('[data-ouia-component-id="page-toolbar"]').within(() => { - cy.getByDataCy('run-health-check').click(); - }); - cy.intercept('POST', awxAPI`/instances/*/health_check/`).as('runHealthCheck'); - cy.get('[data-ouia-component-type="PF5/ModalContent"]').within(() => { - cy.get('header').contains('Run health checks on these instances'); - cy.get('button').contains('Run health check').should('have.attr', 'aria-disabled', 'true'); - cy.getByDataCy('name-column-cell').should('have.text', instance.hostname); - cy.get('input[id="confirm"]').click(); - cy.get('button').contains('Run health check').click(); - }); - cy.assertModalSuccess(); - cy.clickModalButton('Close'); - cy.wait('@runHealthCheck') - .then((response) => { - expect(response.response?.statusCode).to.eql(200); - }) - .its('response.body.msg') - .then((response) => { - expect(response).contains(`Health check is running for ${instance.hostname}.`); - }); - }); - - it('can visit the instances tab of an instance group and run a health check from row against an instance', () => { - cy.navigateTo('awx', 'instance-groups'); - cy.verifyPageTitle('Instance Groups'); - cy.filterTableBySingleSelect('name', instanceGroup.name); - cy.get('[data-cy="name-column-cell"]').click(); - cy.url().then((currentUrl) => { - expect(currentUrl.includes('details')).to.be.true; - expect(currentUrl.includes('infrastructure/instance-groups')).to.be.true; - }); - cy.clickTab(/^Instances$/, true); - cy.get('[data-ouia-component-id="simple-table"]').within(() => { - cy.get('tbody tr').should('have.length', 1); - }); - cy.filterTableBySingleSelect('hostname', instance.hostname); - cy.intercept('POST', awxAPI`/instances/*/health_check/`).as('runHealthCheck'); - cy.clickTableRowPinnedAction(instance.hostname, 'run-health-check', false); - cy.wait('@runHealthCheck') - .then((response) => { - expect(response.response?.statusCode).to.eql(200); - }) - .its('response.body.msg') - .then((response) => { - expect(response).contains(`Health check is running for ${instance.hostname}.`); - }); - }); - - it('can visit the details page of an instance nested inside an instance group and run health check on it', () => { - cy.navigateTo('awx', 'instance-groups'); - cy.verifyPageTitle('Instance Groups'); - cy.filterTableBySingleSelect('name', instanceGroup.name); - cy.get('[data-cy="name-column-cell"]').click(); - cy.url().then((currentUrl) => { - expect(currentUrl.includes('details')).to.be.true; - expect(currentUrl.includes('infrastructure/instance-groups')).to.be.true; - }); - cy.clickTab(/^Instances$/, true); - cy.get('[data-ouia-component-id="simple-table"]').within(() => { - cy.get('tbody tr').should('have.length', 1); - }); - cy.filterTableBySingleSelect('hostname', instance.hostname); - cy.get('[data-cy="name-column-cell"]').click(); - cy.url().then((currentUrl) => { - expect(currentUrl.includes('details')).to.be.true; - expect(currentUrl.includes('infrastructure/instance-groups')).to.be.true; - }); - cy.verifyPageTitle(instance.hostname); - cy.contains('nav[aria-label="Breadcrumb"]', 'Instance groups').should('exist'); - cy.contains('nav[aria-label="Breadcrumb"]', instanceGroup.name).should('exist'); - cy.contains('nav[aria-label="Breadcrumb"]', 'Instances').should('exist'); - cy.contains('nav[aria-label="Breadcrumb"]', instance.hostname).should('exist'); - cy.contains('nav[aria-label="Breadcrumb"]', 'Details').should('exist'); - cy.intercept('POST', awxAPI`/instances/${instance.id.toString()}/health_check/`).as( - 'runHealthCheck' - ); - cy.getByDataCy('run-health-check').click(); - cy.wait('@runHealthCheck') - .then((response) => { - expect(response.response?.statusCode).to.eql(200); - }) - .its('response.body.msg') - .then((response) => { - expect(response).contains(`Health check is running for ${instance.hostname}.`); - }); - cy.get('button').contains('Run health check').should('have.attr', 'aria-disabled', 'true'); - }); - }); -}); diff --git a/cypress/e2e/awx/administration/instances.cy.ts b/cypress/e2e/awx/administration/instances.cy.ts index 8a3b09e039..7b5b9524d7 100644 --- a/cypress/e2e/awx/administration/instances.cy.ts +++ b/cypress/e2e/awx/administration/instances.cy.ts @@ -2,10 +2,12 @@ import * as path from 'path'; import { randomString } from '../../../../framework/utils/random-string'; import { Instance } from '../../../../frontend/awx/interfaces/Instance'; import { awxAPI } from '../../../support/formatApiPathForAwx'; -import { tag } from '../../../support/tag'; -tag(['upstream'], () => { - //An instance can only be created in an Openshift or Kubernetes build +describe('Instances: All Tests', () => { + before(() => { + cy.skipIfNotK8S(); + }); + describe('Instances: Add/Edit', () => { let instance: Instance; @@ -17,6 +19,10 @@ tag(['upstream'], () => { cy.verifyPageTitle('Instances'); }); + afterEach(() => { + cy.removeAwxInstance(instance.id.toString()); + }); + it('can add a new instance and navigate to the details page', () => { const instanceHostname = 'E2EInstanceTestAddEdit' + randomString(5); // Navigate to the create instance page diff --git a/cypress/e2e/awx/administration/instnaceGroupsK8S.cy.ts b/cypress/e2e/awx/administration/instnaceGroupsK8S.cy.ts new file mode 100644 index 0000000000..a11a14be0f --- /dev/null +++ b/cypress/e2e/awx/administration/instnaceGroupsK8S.cy.ts @@ -0,0 +1,254 @@ +import { randomString } from '../../../../framework/utils/random-string'; +import { Instance } from '../../../../frontend/awx/interfaces/Instance'; +import { InstanceGroup } from '../../../../frontend/awx/interfaces/InstanceGroup'; +import { awxAPI } from '../../../support/formatApiPathForAwx'; + +describe('Instance Groups: Instances Tab', () => { + let instance: Instance; + let instanceGroup: InstanceGroup; + let instanceGroupDisassociate: InstanceGroup; + let instanceToAssociate: Instance; + + before(() => { + cy.skipIfNotK8S(); + }); + + beforeEach(() => { + cy.createAwxInstance('E2EInstanceIGTest' + randomString(5), 9999).then((ins: Instance) => { + instance = ins; + cy.createAwxInstanceGroup({ + name: 'E2E Instance Group Instance tab test' + randomString(4), + percent_capacity_remaining: 100, + policy_instance_minimum: 0, + policy_instance_list: !Cypress.currentTest.title.includes('associate an instance') + ? [instance.hostname] + : [], + }).then((ig: InstanceGroup) => { + instanceGroup = ig; + }); + }); + }); + + afterEach(() => { + cy.removeAwxInstance(instance?.id.toString()); + cy.deleteAwxInstanceGroup(instanceGroup, { failOnStatusCode: false }); + }); + + it('can visit the instances tab of an instance group and associate an instance to that instance group, then disable the instance', () => { + cy.navigateTo('awx', 'instance-groups'); + cy.verifyPageTitle('Instance Groups'); + cy.filterTableBySingleSelect('name', instanceGroup.name); + cy.get('[data-cy="name-column-cell"]').click(); + cy.url().then((currentUrl) => { + expect(currentUrl.includes('details')).to.be.true; + expect(currentUrl.includes('infrastructure/instance-groups')).to.be.true; + }); + + cy.clickTab(/^Instances$/, true); + cy.getByDataCy('empty-state-title').contains('There are currently no instances added'); + cy.get('[data-cy="Please associate an instance by using the button below."]').should( + 'be.visible' + ); + cy.getByDataCy('associate-instance').click(); + cy.get('[data-ouia-component-type="PF5/ModalContent"]').within(() => { + cy.get('header').contains('Select instances'); + cy.get('button').contains('Confirm').should('have.attr', 'aria-disabled', 'true'); + cy.filterTableBySingleSelect('hostname', instance.hostname); + cy.intercept('POST', awxAPI`/instance_groups/${instanceGroup.id.toString()}/instances/`).as( + 'associateInstance' + ); + cy.getByDataCy('checkbox-column-cell').find('input').click(); + cy.get('button').contains('Confirm').click(); + }); + cy.assertModalSuccess(); + cy.wait('@associateInstance') + .its('response') + .then((response) => { + expect(response?.statusCode).to.eql(204); + }); + cy.clickModalButton('Close'); + cy.intercept('PATCH', awxAPI`/instances/*/`).as('disableInstance'); + cy.getByDataCy('toggle-switch').should('be.visible').click(); + cy.wait('@disableInstance') + .then((response) => { + expect(response?.response?.statusCode).to.eql(200); + }) + .its('response.body.enabled') + .then((enabled: string) => { + expect(enabled).to.be.false; + }); + }); + + it('can visit the instances tab of an instance group and bulk disassociate instances from that instance group', () => { + const arrayOfElementText: string[] = []; + const arrayOfInstance = []; + for (let i = 0; i < 5; i++) { + cy.createAwxInstance('E2EInstanceToDisassociateFromIG' + randomString(5), 9999).then( + (ins: Instance) => { + instanceToAssociate = ins; + arrayOfElementText.push(instanceToAssociate.hostname); + arrayOfInstance.push(instanceToAssociate); + } + ); + } + cy.createAwxInstanceGroup({ + name: 'E2E Instance Group Disassociate' + randomString(4), + percent_capacity_remaining: 100, + policy_instance_minimum: 0, + policy_instance_list: arrayOfElementText, + }).then((ig: InstanceGroup) => { + instanceGroupDisassociate = ig; + cy.navigateTo('awx', 'instance-groups'); + cy.verifyPageTitle('Instance Groups'); + cy.filterTableBySingleSelect('name', instanceGroupDisassociate?.name); + cy.get('[data-cy="name-column-cell"]').click(); + cy.url().then((currentUrl) => { + expect(currentUrl.includes('details')).to.be.true; + expect(currentUrl.includes('infrastructure/instance-groups')).to.be.true; + }); + cy.clickTab(/^Instances$/, true); + cy.get('[data-ouia-component-id="simple-table"]').within(() => { + cy.get('tbody tr').should('have.length', 5); + }); + cy.get('button').contains('Disassociate').should('have.attr', 'aria-disabled', 'true'); + cy.getByDataCy('select-all').click(); + cy.get('button') + .contains('Disassociate') + .should('have.attr', 'aria-disabled', 'false') + .click(); + cy.intercept( + 'POST', + awxAPI`/instance_groups/${instanceGroupDisassociate.id.toString()}/instances/` + ).as('disassociateInstance'); + cy.get('[data-ouia-component-type="PF5/ModalContent"]').within(() => { + cy.get('header').contains('Disassociate instance from instance group'); + cy.get('button') + .contains('Disassociate instances') + .should('have.attr', 'aria-disabled', 'true'); + cy.get('input[id="confirm"]').click(); + cy.get('button') + .contains('Disassociate instances') + .should('have.attr', 'aria-disabled', 'false') + .click(); + }); + cy.assertModalSuccess(); + cy.wait('@disassociateInstance') + .its('response') + .then((response) => { + expect(response?.statusCode).to.eql(204); + }); + cy.clickModalButton('Close'); + cy.getByDataCy('empty-state-title').contains('There are currently no instances added'); + cy.get('[data-cy="Please associate an instance by using the button below."]').should( + 'be.visible' + ); + cy.deleteAwxInstanceGroup(instanceGroupDisassociate, { failOnStatusCode: false }); + arrayOfInstance.map(({ id }) => cy.removeAwxInstance(id?.toString())); + }); + }); + + it('can visit the instances tab of an instance group and run a health check from toolbar against an instance', () => { + cy.navigateTo('awx', 'instance-groups'); + cy.verifyPageTitle('Instance Groups'); + cy.filterTableBySingleSelect('name', instanceGroup.name); + cy.get('[data-cy="name-column-cell"]').click(); + cy.url().then((currentUrl) => { + expect(currentUrl.includes('details')).to.be.true; + expect(currentUrl.includes('infrastructure/instance-groups')).to.be.true; + }); + cy.clickTab(/^Instances$/, true); + cy.get('button').contains('Run health check').should('have.attr', 'aria-disabled', 'true'); + cy.filterTableBySingleSelect('hostname', instance.hostname); + cy.get('[data-ouia-component-id="simple-table"]').within(() => { + cy.get('tbody tr').should('have.length', 1); + cy.get('[data-cy="checkbox-column-cell"] input').click(); + }); + cy.getBy('[data-ouia-component-id="page-toolbar"]').within(() => { + cy.getByDataCy('run-health-check').click(); + }); + cy.intercept('POST', awxAPI`/instances/*/health_check/`).as('runHealthCheck'); + cy.get('[data-ouia-component-type="PF5/ModalContent"]').within(() => { + cy.get('header').contains('Run health checks on these instances'); + cy.get('button').contains('Run health check').should('have.attr', 'aria-disabled', 'true'); + cy.getByDataCy('name-column-cell').should('have.text', instance.hostname); + cy.get('input[id="confirm"]').click(); + cy.get('button').contains('Run health check').click(); + }); + cy.assertModalSuccess(); + cy.clickModalButton('Close'); + cy.wait('@runHealthCheck') + .then((response) => { + expect(response.response?.statusCode).to.eql(200); + }) + .its('response.body.msg') + .then((response) => { + expect(response).contains(`Health check is running for ${instance.hostname}.`); + }); + }); + + it('can visit the instances tab of an instance group and run a health check from row against an instance', () => { + cy.navigateTo('awx', 'instance-groups'); + cy.verifyPageTitle('Instance Groups'); + cy.filterTableBySingleSelect('name', instanceGroup.name); + cy.get('[data-cy="name-column-cell"]').click(); + cy.url().then((currentUrl) => { + expect(currentUrl.includes('details')).to.be.true; + expect(currentUrl.includes('infrastructure/instance-groups')).to.be.true; + }); + cy.clickTab(/^Instances$/, true); + cy.get('[data-ouia-component-id="simple-table"]').within(() => { + cy.get('tbody tr').should('have.length', 1); + }); + cy.filterTableBySingleSelect('hostname', instance.hostname); + cy.intercept('POST', awxAPI`/instances/*/health_check/`).as('runHealthCheck'); + cy.clickTableRowPinnedAction(instance.hostname, 'run-health-check', false); + cy.wait('@runHealthCheck') + .then((response) => { + expect(response.response?.statusCode).to.eql(200); + }) + .its('response.body.msg') + .then((response) => { + expect(response).contains(`Health check is running for ${instance.hostname}.`); + }); + }); + + it('can visit the details page of an instance nested inside an instance group and run health check on it', () => { + cy.navigateTo('awx', 'instance-groups'); + cy.verifyPageTitle('Instance Groups'); + cy.filterTableBySingleSelect('name', instanceGroup.name); + cy.get('[data-cy="name-column-cell"]').click(); + cy.url().then((currentUrl) => { + expect(currentUrl.includes('details')).to.be.true; + expect(currentUrl.includes('infrastructure/instance-groups')).to.be.true; + }); + cy.clickTab(/^Instances$/, true); + cy.get('[data-ouia-component-id="simple-table"]').within(() => { + cy.get('tbody tr').should('have.length', 1); + }); + cy.filterTableBySingleSelect('hostname', instance.hostname); + cy.get('[data-cy="name-column-cell"]').click(); + cy.url().then((currentUrl) => { + expect(currentUrl.includes('details')).to.be.true; + expect(currentUrl.includes('infrastructure/instance-groups')).to.be.true; + }); + cy.verifyPageTitle(instance.hostname); + cy.contains('nav[aria-label="Breadcrumb"]', 'Instance groups').should('exist'); + cy.contains('nav[aria-label="Breadcrumb"]', instanceGroup.name).should('exist'); + cy.contains('nav[aria-label="Breadcrumb"]', 'Instances').should('exist'); + cy.contains('nav[aria-label="Breadcrumb"]', instance.hostname).should('exist'); + cy.contains('nav[aria-label="Breadcrumb"]', 'Details').should('exist'); + cy.intercept('POST', awxAPI`/instances/${instance.id.toString()}/health_check/`).as( + 'runHealthCheck' + ); + cy.getByDataCy('run-health-check').click(); + cy.wait('@runHealthCheck') + .then((response) => { + expect(response.response?.statusCode).to.eql(200); + }) + .its('response.body.msg') + .then((response) => { + expect(response).contains(`Health check is running for ${instance.hostname}.`); + }); + cy.get('button').contains('Run health check').should('have.attr', 'aria-disabled', 'true'); + }); +}); diff --git a/cypress/support/awx-commands.ts b/cypress/support/awx-commands.ts index aa17c43d83..1c73d516e7 100644 --- a/cypress/support/awx-commands.ts +++ b/cypress/support/awx-commands.ts @@ -31,6 +31,7 @@ import { WorkflowJobNode, WorkflowNode } from '../../frontend/awx/interfaces/Wor import { awxAPI } from './formatApiPathForAwx'; import { AwxRbacRole } from '../../frontend/awx/interfaces/AwxRbacRole'; import { ContentTypeEnum } from '../../frontend/awx/interfaces/ContentType'; +import { Settings } from '../../frontend/awx/interfaces/Settings'; // AWX related custom command implementation @@ -1735,3 +1736,12 @@ Cypress.Commands.add('toggleAndAssert', (types: string[]) => { }); }); }); + +Cypress.Commands.add('skipIfNotK8S', () => { + cy.requestGet(awxAPI`/settings/system/`).then((data) => { + if (!data?.IS_K8S) { + cy.log('TEST SKIPPED | IS_K8S: False'); + return; + } + }); +}); diff --git a/cypress/support/commands.d.ts b/cypress/support/commands.d.ts index 11edaa8bb2..c56e501a15 100644 --- a/cypress/support/commands.d.ts +++ b/cypress/support/commands.d.ts @@ -1200,6 +1200,8 @@ declare global { */ toggleAndAssert(types: string[]): Chainable; + skipIfNotK8S(): Chainable; + selectPromptOnLaunch(resourceName: string): Chainable; createNotificationTemplate(