Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Machine reg YAML edition with Cypress #286

Merged
merged 2 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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