Skip to content

Commit

Permalink
Update cypress awx org, team, and user create commands to use partial…
Browse files Browse the repository at this point in the history
… objects (#2633)

Signed-off-by: James Talton <[email protected]>
  • Loading branch information
jamestalton authored Jul 2, 2024
1 parent 5e2f4ac commit 298aac6
Show file tree
Hide file tree
Showing 23 changed files with 120 additions and 122 deletions.
20 changes: 10 additions & 10 deletions cypress/e2e/awx/access/organizations.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ describe('Organizations: Edit and Delete', function () {

beforeEach(function () {
const orgName = randomE2Ename();
cy.createAwxOrganization(orgName).then((testOrganization) => {
cy.createAwxOrganization({ name: orgName }).then((testOrganization) => {
organization = testOrganization;
cy.createAwxUser(organization).then((testUser) => {
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
cy.giveUserOrganizationAccess(organization.name, user.id, 'Read');
});
Expand Down Expand Up @@ -165,9 +165,9 @@ describe('Organizations: Users Tab', function () {

beforeEach(function () {
const orgName = randomE2Ename();
cy.createAwxOrganization(orgName).then((testOrganization) => {
cy.createAwxOrganization({ name: orgName }).then((testOrganization) => {
organization = testOrganization;
cy.createAwxUser(organization).then((testUser) => {
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
cy.giveUserOrganizationAccess(organization.name, user.id, 'Read');
});
Expand All @@ -193,9 +193,9 @@ describe('Organizations: Teams Tab', function () {

beforeEach(function () {
const orgName = randomE2Ename();
cy.createAwxOrganization(orgName).then((testOrganization) => {
cy.createAwxOrganization({ name: orgName }).then((testOrganization) => {
organization = testOrganization;
cy.createAwxUser(organization).then((testUser) => {
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
cy.giveUserOrganizationAccess(organization.name, user.id, 'Read');
});
Expand All @@ -217,9 +217,9 @@ describe('Organizations: Execution Environments Tab', function () {

beforeEach(function () {
const orgName = randomE2Ename();
cy.createAwxOrganization(orgName).then((testOrganization) => {
cy.createAwxOrganization({ name: orgName }).then((testOrganization) => {
organization = testOrganization;
cy.createAwxUser(organization).then((testUser) => {
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
cy.giveUserOrganizationAccess(organization.name, user.id, 'Read');
});
Expand All @@ -240,9 +240,9 @@ describe('Organizations: Notifications Tab', function () {

beforeEach(function () {
const orgName = randomE2Ename();
cy.createAwxOrganization(orgName).then((testOrganization) => {
cy.createAwxOrganization({ name: orgName }).then((testOrganization) => {
organization = testOrganization;
cy.createAwxUser(organization).then((testUser) => {
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
cy.giveUserOrganizationAccess(organization.name, user.id, 'Read');
});
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/awx/access/teams.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Teams: Edit and Delete', () => {
beforeEach(() => {
cy.createAwxOrganization().then((org) => {
organization = org;
cy.createAwxTeam(organization).then((createdTeam) => {
cy.createAwxTeam({ organization: organization.id }).then((createdTeam) => {
team = createdTeam;
});
});
Expand Down Expand Up @@ -152,9 +152,9 @@ describe('Teams: Add and Remove users', () => {
beforeEach(() => {
cy.createAwxOrganization().then((o) => {
organization = o;
cy.createAwxUser(organization).then((user) => {
cy.createAwxUser({ organization: organization.id }).then((user) => {
user1 = user;
cy.createAwxTeam(organization).then((createdTeam) => {
cy.createAwxTeam({ organization: organization.id }).then((createdTeam) => {
team = createdTeam;
cy.giveUserTeamAccess(team.name, user1.id, 'Read');
});
Expand Down Expand Up @@ -273,7 +273,7 @@ describe('Teams: Bulk delete', () => {
cy.createAwxOrganization().then((org) => {
organization = org;
for (let i = 0; i < 5; i++) {
cy.createAwxTeam(organization).then((createdTeam) => {
cy.createAwxTeam({ organization: organization.id }).then((createdTeam) => {
team = createdTeam;
arrayOfElementText.push(team.name);
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/awx/access/tokens.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('User Tokens Actions', () => {
beforeEach(() => {
cy.createAwxOrganization().then((org) => {
organization = org;
cy.createAwxUser(organization).then((testUser) => {
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
});
});
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/awx/access/users.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Users List Actions', () => {
beforeEach(() => {
cy.createAwxOrganization().then((org) => {
organization = org;
cy.createAwxUser(organization).then((testUser) => {
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
});
});
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('Users Delete Actions', () => {
beforeEach(() => {
cy.createAwxOrganization().then((org) => {
organization = org;
cy.createAwxUser(organization).then((testUser) => {
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
});
});
Expand Down
8 changes: 5 additions & 3 deletions cypress/e2e/awx/administration/activity-stream.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ describe('activity-stream', () => {
let activeUser: AwxUser;

before(function () {
cy.createAwxTeam(this.globalAwxOrganization as Organization).then((createdTeam) => {
team = createdTeam;
});
cy.createAwxTeam({ organization: (this.globalAwxOrganization as Organization).id }).then(
(createdTeam) => {
team = createdTeam;
}
);
cy.requestGet<AwxItemsResponse<AwxUser>>(awxAPI`/me/`)
.its('results')
.then((results) => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/awx/administration/instanceGroups.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ instanceGroupTypes.forEach((igType) => {
beforeEach(function () {
cy.createAwxOrganization().then((o) => {
organization = o;
cy.createAwxTeam(organization).then((createdTeam) => {
cy.createAwxTeam({ organization: organization.id }).then((createdTeam) => {
team = createdTeam;
cy.createAwxInstanceGroup(
igType === 'Container'
Expand Down Expand Up @@ -454,7 +454,7 @@ instanceGroupTypes.forEach((igType) => {
beforeEach(function () {
cy.createAwxOrganization().then((o) => {
organization = o;
cy.createAwxUser(organization).then((u) => {
cy.createAwxUser({ organization: organization.id }).then((u) => {
user = u;
cy.createAwxInstanceGroup(
igType === 'Container'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Notifications: List View', () => {
let organization: Organization;

before(() => {
cy.createAwxOrganization(randomE2Ename()).then((org) => {
cy.createAwxOrganization().then((org) => {
organization = org;
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { randomE2Ename } from '../../../../support/utils';
import { getDefaultMessages } from '../../../../../frontend/awx/administration/notifiers/notifierFormMessagesHelpers';
import { AwxItemsResponse } from '../../../../../frontend/awx/common/AwxItemsResponse';
import { awxAPI } from '../../../../../frontend/awx/common/api/awx-utils';
import { Notification } from '../../../../../frontend/awx/interfaces/generated-from-swagger/api';
import { randomE2Ename } from '../../../../support/utils';

export function testNotification(
type: string,
options?: { details?: boolean; skipMessages?: boolean }
) {
const notificationName = randomE2Ename();
const orgName = randomE2Ename();
cy.createAwxOrganization(orgName).then(() => {
cy.createAwxOrganization({ name: orgName }).then(() => {
cy.navigateTo('awx', 'notification-templates');
cy.get(`[data-cy="add-notifier"]`).click();
cy.verifyPageTitle('Add notifier');
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/awx/administration/notifiers/notifiersTabs.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { awxAPI } from '../../../../../frontend/awx/common/api/awx-utils';
import { randomE2Ename } from '../../../../support/utils';
import { testNotification, testDelete } from './notifiersSharedFunctions';
import { Organization } from '../../../../../frontend/awx/interfaces/Organization';
import { randomE2Ename } from '../../../../support/utils';
import { testDelete, testNotification } from './notifiersSharedFunctions';

/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */

Expand All @@ -11,7 +11,7 @@ describe('Notifications', () => {

before(() => {
cy.login();
cy.createAwxOrganization(randomE2Ename()).then((org) => {
cy.createAwxOrganization().then((org) => {
organization = org;
});
});
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('Notifications', () => {
const orgName = randomE2Ename();

before(() => {
cy.createAwxOrganization(orgName).then(() => {});
cy.createAwxOrganization({ name: orgName }).then(() => {});
});

it('can navigate to the Organizations -> Notifications list and then to the details page of the Notification', () => {
Expand Down
5 changes: 2 additions & 3 deletions cypress/e2e/awx/administration/topology-view.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Organization } from '../../../../frontend/awx/interfaces/Organization';
import { Settings } from '../../../../frontend/awx/interfaces/Settings';
import { AwxUser } from '../../../../frontend/awx/interfaces/User';
import { awxAPI } from '../../../support/formatApiPathForAwx';
import { randomE2Ename } from '../../../support/utils';

describe('Topology view', () => {
let user: AwxUser;
Expand All @@ -14,7 +13,7 @@ describe('Topology view', () => {
before(() => {
cy.login();

cy.createAwxOrganization(randomE2Ename()).then((org) => {
cy.createAwxOrganization().then((org) => {
organization = org;
});
});
Expand Down Expand Up @@ -65,7 +64,7 @@ describe('Topology view', () => {
});

it('does not show Topology View in sidebar for non admins', function () {
cy.createAwxUser(organization).then((awxUser) => {
cy.createAwxUser({ organization: organization.id }).then((awxUser) => {
user = awxUser;

cy.awxLoginTestUser(user.username, 'pw');
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/awx/administration/wfApprovalsList.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ describe.skip('Workflow Approvals Tests', () => {
).then((proj) => {
project = proj;

cy.createAwxUser(organization).then((u) => {
cy.createAwxUser({ organization: organization.id }).then((u) => {
user = u;
});
cy.createAwxUser(organization).then((u) => {
cy.createAwxUser({ organization: organization.id }).then((u) => {
userWFApprove = u;
});
cy.createAwxUser(organization).then((u) => {
cy.createAwxUser({ organization: organization.id }).then((u) => {
userWFDeny = u;
});
cy.createAwxUser(organization).then((u) => {
cy.createAwxUser({ organization: organization.id }).then((u) => {
userWFCancel = u;
});
cy.createAwxInventory({ organization: organization.id })
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/awx/resources/credentials.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Credentials', () => {
before(() => {
cy.createAwxOrganization().then((org) => {
organization = org;
cy.createAwxUser(organization).then((testUser) => {
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
});
});
Expand Down Expand Up @@ -569,7 +569,7 @@ describe('Credentials Tabbed View - Team and User Access', () => {
cy.awxLogin();
cy.createAwxOrganization().then((awxOrg) => {
awxOrganization = awxOrg;
cy.createAwxUser(awxOrganization).then((awxUser) => {
cy.createAwxUser({ organization: awxOrganization.id }).then((awxUser) => {
createdAwxUser = awxUser;
cy.createAWXCredential({
kind: 'machine',
Expand All @@ -579,7 +579,7 @@ describe('Credentials Tabbed View - Team and User Access', () => {
machineCredential = cred;
});
});
cy.createAwxTeam(awxOrganization).then((createdAwxTeam) => {
cy.createAwxTeam({ organization: awxOrganization.id }).then((createdAwxTeam) => {
awxTeam = createdAwxTeam;
});
});
Expand Down
12 changes: 5 additions & 7 deletions cypress/e2e/awx/resources/executionEnvironments.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ describe('Execution Environments: Create', () => {
}).then((cred) => {
credential = cred;
});
if (Cypress.currentTest.title.includes('access to a user')) {
cy.createAwxUser(organization).then((testUser) => {
user = testUser;
});
}
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
});
});
execEnvName = 'E2E Execution Environment Create' + randomString(4);
image = 'quay.io/ansible/awx-ee:latest';
Expand Down Expand Up @@ -422,10 +420,10 @@ describe('Execution Environments: User/Team access', () => {
before(() => {
cy.createAwxOrganization().then((org) => {
organization = org;
cy.createAwxUser(organization).then((testUser) => {
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
});
cy.createAwxTeam(organization).then((testTeam) => {
cy.createAwxTeam({ organization: organization.id }).then((testTeam) => {
team = testTeam;
});
cy.createAwxExecutionEnvironment({
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/awx/resources/inventories.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Inventories Tests', () => {
if (kind === '') {
beforeEach(() => {
const orgName = 'E2E Organization Inv tests' + randomString(4);
cy.createAwxOrganization(orgName).then((org) => {
cy.createAwxOrganization({ name: orgName }).then((org) => {
organization = org;
cy.createAwxLabel({ organization: organization.id }).then((lbl) => {
label = lbl;
Expand All @@ -34,7 +34,7 @@ describe('Inventories Tests', () => {
cy.createAwxInstanceGroup().then((ig) => {
instanceGroup = ig;
});
cy.createAwxUser(organization).then((testUser) => {
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
cy.giveUserInventoryAccess(inventory.name, user.id, 'Read');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/awx/resources/inventoriesConstructed.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Constructed Inventories CRUD Tests', () => {

before(() => {
const orgName = 'E2E Org Constructed Inventory tests ' + randomString(4);
cy.createAwxOrganization(orgName).then((org) => {
cy.createAwxOrganization({ name: orgName }).then((org) => {
organization = org;
cy.createAwxInstanceGroup().then((ig) => {
instanceGroup = ig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// cy.createAwxInventory({ organization: organization.id }).then((inv) => {
// inventory = inv;
// });
// cy.createAwxUser(organization).then((testUser) => {
// cy.createAwxUser({ organization: organization.id }).then((testUser) => {
// user = testUser;
// });
// });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { awxAPI } from '../../../../../frontend/awx/common/api/awx-utils';
import { randomString } from '../../../../../framework/utils/random-string';
import { Inventory } from '../../../../../frontend/awx/interfaces/Inventory';
import { Organization } from '../../../../../frontend/awx/interfaces/Organization';
import { Project } from '../../../../../frontend/awx/interfaces/Project';
import { AwxUser } from '../../../../../frontend/awx/interfaces/User';
import { runCommand } from './runCommandFunction';
import { randomString } from '../../../../../framework/utils/random-string';
import { launchHostJob } from '../../../../support/hostsfunctions';
import { Project } from '../../../../../frontend/awx/interfaces/Project';
import { runCommand } from './runCommandFunction';

import { awxAPI } from '../../../../support/formatApiPathForAwx';
import {
checkFactsInHost,
checkHostGroup,
createAndEditAndDeleteHost,
testHostBulkDelete,
checkFactsInHost,
createHost,
createHostAndCancelJob,
testHostBulkDelete,
} from '../../../../support/hostsfunctions';

describe('Inventory Host Tab Tests for regular inventory', () => {
Expand All @@ -31,7 +31,7 @@ describe('Inventory Host Tab Tests for regular inventory', () => {
cy.createAwxProject({ organization: organization.id }).then((proj) => {
project = proj;
});
cy.createAwxUser(organization).then((testUser) => {
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
});
});
Expand Down
Loading

0 comments on commit 298aac6

Please sign in to comment.