cy.get('#count').type('1');
} else if (serviceType === 'ingress') {
this.selectOption('backend_service', 'rgw.rgw.foo');
- cy.get('#service_id').type('rgw.rgw.foo');
+ cy.get('#service_id').should('have.value', 'rgw.rgw.foo');
cy.get('#virtual_ip').type('192.168.20.1/24');
cy.get('#frontend_port').type('8081');
cy.get('#monitor_port').type('8082');
<select id="backend_service"
name="backend_service"
class="form-control custom-select"
- formControlName="backend_service">
+ formControlName="backend_service"
+ (change)="prePopulateId()">
<option *ngIf="services === null"
[ngValue]="null"
i18n>Loading...</option>
describe('should test service ingress', () => {
beforeEach(() => {
formHelper.setValue('service_type', 'ingress');
- formHelper.setValue('service_id', 'rgw.foo');
formHelper.setValue('backend_service', 'rgw.foo');
formHelper.setValue('virtual_ip', '192.168.20.1/24');
formHelper.setValue('ssl', false);
});
});
+ it('should pre-populate the service id', () => {
+ component.prePopulateId();
+ const prePopulatedID = component.serviceForm.getValue('service_id');
+ expect(prePopulatedID).toBe('rgw.foo');
+ });
+
it('should submit valid frontend and monitor port', () => {
// min value
formHelper.setValue('frontend_port', 1);
reader.readAsText(file, 'utf8');
}
+ prePopulateId() {
+ const control: AbstractControl = this.serviceForm.get('service_id');
+ const backendService = this.serviceForm.getValue('backend_service');
+ // Set Id as read-only
+ control.reset({ value: backendService, disabled: true });
+ }
+
onSubmit() {
const self = this;
const values: object = this.serviceForm.value;
break;
case 'ingress':
serviceSpec['backend_service'] = values['backend_service'];
+ serviceSpec['service_id'] = values['backend_service'];
if (_.isString(values['virtual_ip']) && !_.isEmpty(values['virtual_ip'])) {
serviceSpec['virtual_ip'] = values['virtual_ip'].trim();
}