Skip to content

Commit

Permalink
Test Machine reg YAML edition with Cypress (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
juadk authored Aug 25, 2022
1 parent 1262f44 commit 5666798
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
11 changes: 8 additions & 3 deletions cypress/integration/unit_tests/machine_registration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ describe('Machine registration testing', () => {
cy.checkMachRegAnnotation({machRegName: 'edit-config-test', annotationName: 'myAnnotation1', annotationValue: 'myAnnotationValue1'});
});

it.skip('Edit a machine registration with edit YAML button', () => {
//cy.createMachReg({machRegName: 'edit-yaml-test'});
// TBD
it('Edit a machine registration with edit YAML button', () => {
cy.createMachReg({machRegName: 'edit-yaml-test'});
cy.editMachReg({machRegName: 'edit-yaml-test', addLabel: true, addAnnotation: true, withYAML: true });
cy.clickButton('Save');

// Check that we can see our label and annotation in the YAML
cy.checkMachRegLabel({machRegName: 'edit-yaml-test', labelName: 'myLabel1', labelValue: 'myLabelValue1'});
cy.checkMachRegAnnotation({machRegName: 'edit-yaml-test', annotationName: 'myAnnotation1', annotationValue: 'myAnnotationValue1'});
});

it('Clone a machine registration', () => {
Expand Down
22 changes: 12 additions & 10 deletions cypress/support/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Cypress.Commands.add('addMachRegLabel', ({labelName, labelValue}) => {
cy.contains('.row', 'Labels').within(() => {
cy.get('.kv-item.key').type(labelName);
cy.get('.kv-item.value').type(labelValue);
})
});
});

// Add Annotation to machine registration
Expand All @@ -161,7 +161,7 @@ Cypress.Commands.add('addMachRegAnnotation', ({annotationName, annotationValue})
cy.contains('.row', 'Annotations').within(() => {
cy.get('.kv-item.key').type(annotationName);
cy.get('.kv-item.value').type(annotationValue);
})
});
});

// Check machine registration label in YAML
Expand All @@ -185,18 +185,20 @@ Cypress.Commands.add('checkMachRegAnnotation', ({machRegName, annotationName, an
});

// Edit a machine registration
Cypress.Commands.add('editMachReg', ({machRegName, addLabel=false, addAnnotation=false}) => {
Cypress.Commands.add('editMachReg', ({machRegName, addLabel=false, addAnnotation=false, withYAML=false}) => {
cy.contains(machRegName).click();

// Select the 3dots button and edit configuration
cy.get('div.actions > .role-multi-action').click()
cy.contains('li', 'Edit Config').click();

// Add Label
if (addLabel) {cy.addMachRegLabel({labelName: 'myLabel1', labelValue: 'myLabelValue1'})};

// Add Annotation
if (addAnnotation) {cy.addMachRegAnnotation({annotationName: 'myAnnotation1', annotationValue: 'myAnnotationValue1'})};
if (withYAML) {
cy.contains('li', 'Edit YAML').click();
cy.contains('metadata').click(0,0).type('{end}{enter} labels:{enter} myLabel1: myLabelValue1');
cy.contains('metadata').click(0,0).type('{end}{enter} annotations:{enter} myAnnotation1: myAnnotationValue1');
} else {
cy.contains('li', 'Edit Config').click();
if (addLabel) {cy.addMachRegLabel({labelName: 'myLabel1', labelValue: 'myLabelValue1', withYAML: withYAML})};
if (addAnnotation) {cy.addMachRegAnnotation({annotationName: 'myAnnotation1', annotationValue: 'myAnnotationValue1', withYAML: withYAML})};
}
});

// Delete a machine registration
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ declare global {
checkMachRegLabel(machRegName: string, labelName: string, labelValue: string):Chainable<Element>;
checkMachRegAnnotation(machRegName: string, annotationName: string, annotationValue: string):Chainable<Element>;
addMachRegAnnotation(annotationName: string, annotationValue: string):Chainable<Element>;
editMachReg(machRegName: string, addLabel?: boolean, addAnnotation?: boolean): Chainable<Element>;
editMachReg(machRegName: string, addLabel?: boolean, addAnnotation?: boolean, withYAML?: boolean): Chainable<Element>;
}
}}

Expand Down

0 comments on commit 5666798

Please sign in to comment.