Skip to content

Commit

Permalink
Remove global org and global project from tests
Browse files Browse the repository at this point in the history
Remove global org and global project from tests
  • Loading branch information
nixocio committed Aug 8, 2024
1 parent 8e3de5e commit 7e87ec8
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 49 deletions.
1 change: 0 additions & 1 deletion cypress/CYPRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ End-to-End tests for our project are located in the `cypress/e2e` directory. The

- Each test should be independent and capable of running on its own without relying on the state created by previous tests.
- Ideally, tests should not rely on a previously created resource, and whenever possible, the test should create the resources it needs.
- There are several tests using `Global Organization` and `Global Project` that are created as part of the `login` process. This should be avoided whenever possible, as it was identified as a possible source of flakiness in the tests.
- Create the resources in the test itself or in a `before` block, and clean them up in an `after` block.
- If certain resources were created during deployment, those should not be deleted as part of the test runs.
- Avoid tests that require execution in a specific order.
Expand Down
2 changes: 0 additions & 2 deletions cypress/support/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Cypress.Commands.add('login', () => {
switch (devBaseUrlPort) {
case '4101':
cy.awxLogin();
cy.createGlobalOrganization();
cy.createGlobalProject();
break;
case '4102':
cy.hubLogin();
Expand Down
44 changes: 0 additions & 44 deletions cypress/support/awx-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1355,50 +1355,6 @@ Cypress.Commands.add('cancelJob', (job: Job) => {
cy.requestPost<Job>(`${job.url}cancel/`, {});
});

const GLOBAL_PROJECT_NAME = 'Global Project';
const GLOBAL_PROJECT_DESCRIPTION = 'Global Read Only Project for E2E tests';
const GLOBAL_PROJECT_SCM_URL = 'https://github.com/ansible/ansible-ui';
const GLOBAL_ORG_NAME = 'Global Platform Level Organization';
const GLOBAL_ORG_DESCRIPTION = 'DO NOT DELETE: Global Organization';

/** Create a global organization if it doesn't exist. */
Cypress.Commands.add('createGlobalOrganization', function () {
cy.requestGet<AwxItemsResponse<Organization>>(awxAPI`/organizations?name=${GLOBAL_ORG_NAME}`)
.its('results')
.then((orgResults: Organization[]) => {
if (orgResults.length === 0) {
cy.requestPost<AwxItemsResponse<Organization>, Partial<Organization>>(
awxAPI`/organizations/`,
{ name: GLOBAL_ORG_NAME, description: GLOBAL_ORG_DESCRIPTION }
);
cy.wait(100).then(() => cy.createGlobalOrganization());
} else {
cy.wrap(orgResults[0]).as('globalAwxOrganization');
}
});
});

/** Create a global project if it doesn't exist. */
Cypress.Commands.add('createGlobalProject', function () {
const globalAwxOrganization = this.globalAwxOrganization as Organization;
cy.requestGet<AwxItemsResponse<Project>>(awxAPI`/projects?name=${GLOBAL_PROJECT_NAME}`)
.its('results')
.then((projectResults: Project[]) => {
if (projectResults.length === 0) {
cy.requestPost<AwxItemsResponse<Project>, Partial<Project>>(awxAPI`/projects/`, {
name: GLOBAL_PROJECT_NAME,
description: GLOBAL_PROJECT_DESCRIPTION,
organization: globalAwxOrganization.id,
scm_type: 'git',
scm_url: GLOBAL_PROJECT_SCM_URL,
});
cy.wait(100).then(() => cy.createGlobalProject());
} else {
cy.wrap(projectResults[0]).as('globalProject');
}
});
});

Cypress.Commands.add(
'createCustomAWXApplicationFromUI',
(
Expand Down
2 changes: 0 additions & 2 deletions cypress/support/commands.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,6 @@ declare global {
): Chainable<InstanceGroup>;
createAwxInstance(hostname: string, listener_port?: number): Chainable<Instance>;
createAwxLabel(label: Partial<Omit<Label, 'id'>>): Chainable<Label>;
createGlobalOrganization(): Chainable<void>;
createGlobalProject(): Chainable<void>;

deleteAwxOrganization(
organization: Organization,
Expand Down

0 comments on commit 7e87ec8

Please sign in to comment.