|
| 1 | +import { NewClusterPage } from '../../../views/pages/NewClusterPage'; |
| 2 | +import { ClusterDetailsForm } from '../../../views/forms/ClusterDetails/ClusterDetailsForm'; |
| 3 | +import { clusterDetailsPage } from '../../../views/clusterDetails'; |
| 4 | + |
| 5 | +describe('Create a new cluster and show correct validations for every field', () => { |
| 6 | + const setTestStartSignal = (activeSignal: string) => { |
| 7 | + cy.setTestEnvironment({ |
| 8 | + activeSignal, |
| 9 | + activeScenario: 'AI_CREATE_MULTINODE', |
| 10 | + }); |
| 11 | + }; |
| 12 | + before(() => setTestStartSignal('')); |
| 13 | + |
| 14 | + beforeEach(() => { |
| 15 | + setTestStartSignal(''); |
| 16 | + NewClusterPage.visit(); |
| 17 | + ClusterDetailsForm.init(); |
| 18 | + }); |
| 19 | + |
| 20 | + it('Base Name (Invalid)', () => { |
| 21 | + const invalidDnsDomain = 'iamnotavaliddnsdomain-iamnotavaliddnsdomain-iamnotavaliddnsdomain'; |
| 22 | + clusterDetailsPage.inputClusterName(); |
| 23 | + clusterDetailsPage.inputBaseDnsDomain(invalidDnsDomain); |
| 24 | + clusterDetailsPage.clickClusterDetailsBody(); |
| 25 | + clusterDetailsPage.validateInputDnsDomainFieldHelper( |
| 26 | + `Every single host component in the base domain name cannot contain more than 63 characters and must not contain spaces.`, |
| 27 | + ); |
| 28 | + }); |
| 29 | + |
| 30 | + it('Base Name (Field Not Empty)', () => { |
| 31 | + const emptyDns = ' '; |
| 32 | + clusterDetailsPage.inputBaseDnsDomain(emptyDns); |
| 33 | + clusterDetailsPage.clickClusterDetailsBody(); |
| 34 | + clusterDetailsPage.validateInputDnsDomainFieldHelper( |
| 35 | + `Every single host component in the base domain name cannot contain more than 63 characters and must not contain spaces.`, |
| 36 | + ); |
| 37 | + }); |
| 38 | + |
| 39 | + it('Pull secret (Field not empty)', () => { |
| 40 | + const emptyPullSecret = '{}'; |
| 41 | + let pullSecretError = 'Required.'; |
| 42 | + clusterDetailsPage.inputPullSecret(emptyPullSecret); |
| 43 | + clusterDetailsPage.clearPullSecret(); |
| 44 | + clusterDetailsPage.validateInputPullSecretFieldHelper(pullSecretError); |
| 45 | + }); |
| 46 | + |
| 47 | + it('Pull Secret (Malformed)', () => { |
| 48 | + const malformedJsonPullSecret = '{{}}'; |
| 49 | + let pullSecretError = |
| 50 | + "Invalid pull secret format. You must use your Red Hat account's pull secret"; |
| 51 | + clusterDetailsPage.inputPullSecret(malformedJsonPullSecret); |
| 52 | + clusterDetailsPage.clickClusterDetailsBody(); |
| 53 | + clusterDetailsPage.validateInputPullSecretFieldHelper(pullSecretError); |
| 54 | + }); |
| 55 | + |
| 56 | + it('Pull secret (Invalid entry)', () => { |
| 57 | + const invalidPullSecret = '{"invalid": "pull-secret"}'; |
| 58 | + // Need to set valid name and DNS |
| 59 | + clusterDetailsPage.inputClusterName(); |
| 60 | + clusterDetailsPage.inputBaseDnsDomain(); |
| 61 | + clusterDetailsPage.inputPullSecret(invalidPullSecret); |
| 62 | + |
| 63 | + const errorSuffix = Cypress.env('OCM_USER') |
| 64 | + ? 'Learn more about pull secrets and view examples' |
| 65 | + : "A Red Hat account's pull secret can be found in"; |
| 66 | + clusterDetailsPage.clickClusterDetailsBody(); |
| 67 | + clusterDetailsPage.validateInputPullSecretFieldHelper( |
| 68 | + `Invalid pull secret format. You must use your Red Hat account's pull secret`, |
| 69 | + ); |
| 70 | + }); |
| 71 | +}); |
0 commit comments