Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,28 @@ ManageIQ implements the following cypress extensions:
* `cy.validateFormFields(fieldConfigs)` - validates form input fields based on provided configurations. `fieldConfigs` is an array of field configuration objects with properties: `id` (required) - the ID of the form field, `fieldType` (optional, default: 'input') - the type of field ('input', 'select', 'textarea'), `inputFieldType` (optional, default: 'text') - the type of input field ('text', 'password', 'number'), `shouldBeDisabled` (optional, default: false) - whether the field should be disabled, `expectedValue` (optional) - the expected value of the field. e.g. `cy.validateFormFields([{ id: 'name', shouldBeDisabled: true }, { id: 'role', fieldType: 'select', expectedValue: 'admin' }]);` or using constants: `cy.validateFormFields([{ [FIELD_CONFIG_KEYS.ID]: 'email', [FIELD_CONFIG_KEYS.INPUT_FIELD_TYPE]: 'email' }, { [FIELD_CONFIG_KEYS.ID]: 'name', [FIELD_CONFIG_KEYS.SHOULD_BE_DISABLED]: true }]);`
* `cy.validateFormFooterButtons(buttonConfigs)` - validates form buttons based on provided configurations. `buttonConfigs` is an array of button configuration objects with properties: `buttonText` (required) - the text of the button, `buttonType` (optional, default: 'button') - the type of button (e.g., 'submit', 'reset'), `shouldBeDisabled` (optional, default: false) - whether the button should be disabled. e.g. `cy.validateFormFooterButtons([{ buttonText: 'Cancel' }, { buttonText: 'Submit', buttonType: 'submit', shouldBeDisabled: true }]);` or using constants: `cy.validateFormFooterButtons([{ [BUTTON_CONFIG_KEYS.TEXT]: 'Cancel' }]);`

##### provider_helper_commands

* `cy.fillCommonFormFields(providerConfig, nameValue)` - fills common form fields that are present in all provider forms. `providerConfig` is the provider configuration object. `nameValue` is the name to use for the provider.
* `cy.fillFormFields(fields, values)` - fills form fields based on field definitions and values. `fields` is an array of field definition objects. `values` is an object containing field values.
* `cy.fillProviderForm(providerConfig, nameValue, hostValue)` - fills a provider form based on provider configuration. `providerConfig` is the provider configuration object. `nameValue` is the name to use for the provider. `hostValue` is the hostname to use for the provider.
* `cy.validateCommonFormFields(providerType, isEdit)` - validates common form fields that are present in all provider forms. `providerType` is the type of provider to be validated. `isEdit` is whether the form is in edit mode.
* `cy.validateFormFields(fields, isEdit)` - validates form fields based on field definitions. `fields` is an array of field definition objects. `isEdit` is whether the form is in edit mode.
* `cy.validateFormButtons(providerType, isEdit)` - validates form buttons (validate, add/save, reset, cancel). `providerType` is the type of provider to be validated. `isEdit` is whether the form is in edit mode.
* `cy.validateProviderForm(providerConfig, isEdit)` - validates a provider form based on provider configuration. `providerConfig` is the provider configuration object. `isEdit` is whether the form is in edit mode.
* `cy.updateProviderFieldsForEdit(providerConfig)` - updates provider fields for edit validation tests based on provider type. `providerConfig` is the provider configuration object.
* `cy.selectCreatedProvider(providerName)` - selects a created provider from the data table. `providerName` is the name of the provider to select.
* `cy.addProviderAndOpenEditForm(providerConfig, nameValue, hostValue)` - adds a provider and opens the edit form. `providerConfig` is the provider configuration object. `nameValue` is the name to use for the provider. `hostValue` is the hostname to use for the provider.
* `cy.interceptAddAzureStackProviderApi()` - intercepts the API call when adding an Azure Stack provider and forces a successful response.
* `cy.addAzureStackProviderAndOpenEditForm(providerConfig, nameValue, hostValue)` - special handling for Azure Stack provider which requires additional API interception. `providerConfig` is the provider configuration object. `nameValue` is the name to use for the provider. `hostValue` is the hostname to use for the provider.
* `cy.assertValidationFailureMessage()` - asserts validation failure message.
* `cy.assertValidationSuccessMessage()` - asserts validation success message.
* `cy.assertNameAlreadyExistsError()` - asserts name already exists error.
* `cy.validate({ stubErrorResponse, errorMessage })` - performs validation with optional error response stubbing. `stubErrorResponse` is whether to stub an error response. `errorMessage` is the error message to show.
* `cy.selectProviderAndDeleteWithOptionalFlashMessage({ createdProviderName, assertDeleteFlashMessage })` - deletes a provider with optional flash message check. `createdProviderName` is the name of the provider to delete. `assertDeleteFlashMessage` is whether to assert the delete flash message.
* `cy.cleanUp({ createdProviderName })` - cleans up a provider by deleting it. `createdProviderName` is the name of the provider to clean up.
* `generateProviderTests(providerConfig)` - generates all test suites for a provider. `providerConfig` is the provider configuration object.

#### Assertions

* `cy.expect_explorer_title(title)` - check that the title on an explorer screen matches the provided title. `title`: String for the title.
Expand Down
57 changes: 57 additions & 0 deletions cypress/e2e/ui/Compute/Clouds/Providers/cloud_provider.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* eslint-disable no-undef */
import { generateProviderTests } from '../../../../../support/commands/provider_helper_commands';
import { getProviderConfig, PROVIDER_TYPES } from './provider-factory';

describe('Automate Cloud Provider form operations: Compute > Clouds > Providers > Configuration > Add a New Cloud Provider', () => {
beforeEach(() => {
cy.login();
cy.menu('Compute', 'Clouds', 'Providers');
cy.toolbar('Configuration', 'Add a New Cloud Provider');
});

// Generate tests for VMware vCloud provider
const vmwareVcloudConfig = getProviderConfig(PROVIDER_TYPES.VMWARE_VCLOUD);
generateProviderTests(vmwareVcloudConfig);

// Generate tests for Amazon EC2 provider
const amazonEC2Config = getProviderConfig(PROVIDER_TYPES.AMAZON_EC2);
generateProviderTests(amazonEC2Config);

// Generate tests for Azure provider
const azureConfig = getProviderConfig(PROVIDER_TYPES.AZURE);
generateProviderTests(azureConfig);

// Generate tests for Azure Stack provider (requires special handling)
const azureStackConfig = getProviderConfig(PROVIDER_TYPES.AZURE_STACK);
generateProviderTests(azureStackConfig);

// Generate tests for Google Compute Engine provider
const googleComputeConfig = getProviderConfig(PROVIDER_TYPES.GOOGLE_COMPUTE);
generateProviderTests(googleComputeConfig);

// Generate tests for IBM Cloud VPC provider
const ibmCloudVpcConfig = getProviderConfig(PROVIDER_TYPES.IBM_CLOUD_VPC);
generateProviderTests(ibmCloudVpcConfig);

// Generate tests for IBM Power Systems Virtual Servers provider
const ibmPowerSystemsConfig = getProviderConfig(
PROVIDER_TYPES.IBM_POWER_SYSTEMS
);
generateProviderTests(ibmPowerSystemsConfig);

// Generate tests for IBM PowerVC provider
const ibmPowerVcConfig = getProviderConfig(PROVIDER_TYPES.IBM_POWERVC);
generateProviderTests(ibmPowerVcConfig);

// Generate tests for IBM Cloud Infrastructure Center provider
const ibmCicConfig = getProviderConfig(PROVIDER_TYPES.IBM_CIC);
generateProviderTests(ibmCicConfig);

// Generate tests for Oracle Cloud provider
const oracleCloudConfig = getProviderConfig(PROVIDER_TYPES.ORACLE_CLOUD);
generateProviderTests(oracleCloudConfig);

// Generate tests for OpenStack provider
const openstackConfig = getProviderConfig(PROVIDER_TYPES.OPENSTACK);
generateProviderTests(openstackConfig);
});
Loading
Loading