Skip to content

Commit

Permalink
Update instance tests
Browse files Browse the repository at this point in the history
Update instance tests
  • Loading branch information
nixocio committed Jul 16, 2024
1 parent bf7badb commit 26ebc17
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cypress/e2e/awx/administration/instances.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions cypress/support/awx-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -1735,3 +1736,12 @@ Cypress.Commands.add('toggleAndAssert', (types: string[]) => {
});
});
});

Cypress.Commands.add('skipIfNotK8S', () => {
cy.requestGet<Settings>(awxAPI`/settings/system/`).then((data) => {
if (!data?.IS_K8S) {
cy.log('TEST SKIPPED | IS_K8S: False');
return;
}
});
});
2 changes: 2 additions & 0 deletions cypress/support/commands.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,8 @@ declare global {
*/
toggleAndAssert(types: string[]): Chainable<void>;

skipIfNotK8S(): Chainable<boolean>;

selectPromptOnLaunch(resourceName: string): Chainable<void>;

createNotificationTemplate(
Expand Down

0 comments on commit 26ebc17

Please sign in to comment.