From 26ebc17e5eaed6e4ce45d5f4ae81da803e0c2b99 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 --- cypress/e2e/awx/administration/instances.cy.ts | 16 +++++++++++++--- cypress/support/awx-commands.ts | 10 ++++++++++ cypress/support/commands.d.ts | 2 ++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/awx/administration/instances.cy.ts b/cypress/e2e/awx/administration/instances.cy.ts index 8a3b09e039..be211a1da9 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 @@ -147,6 +153,10 @@ tag(['upstream'], () => { cy.verifyPageTitle('Instances'); }); + afterEach(() => { + cy.removeAwxInstance(instance.id.toString()); + }); + it('can remove an instance from details page', () => { cy.intercept('PATCH', awxAPI`/instances/*`).as('removedInstance'); cy.filterTableBySingleSelect('hostname', instance.hostname); 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(