mirror of https://github.com/rancher/dashboard.git
support displaying error banners on configmap creation page
This commit is contained in:
parent
ed3f8f5992
commit
2e2694e4ec
|
|
@ -25,6 +25,10 @@ export default class ConfigMapPo extends CreateEditViewPo {
|
||||||
return LabeledInputPo.byLabel(this.self(), 'Description');
|
return LabeledInputPo.byLabel(this.self(), 'Description');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errorBanner() {
|
||||||
|
return cy.get('#cru-errors');
|
||||||
|
}
|
||||||
|
|
||||||
saveCreateForm(): AsyncButtonPo {
|
saveCreateForm(): AsyncButtonPo {
|
||||||
return new AsyncButtonPo('[data-testid="form-save"]', this.self());
|
return new AsyncButtonPo('[data-testid="form-save"]', this.self());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,4 +59,20 @@ skipGeometric=true`;
|
||||||
// Assert the current value yaml dumps will append a newline at the end
|
// Assert the current value yaml dumps will append a newline at the end
|
||||||
configMapPo.valueInput().value().should('eq', `${ expectedValue }\n`);
|
configMapPo.valueInput().value().should('eq', `${ expectedValue }\n`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should show an error banner if the api call sends back an error', () => {
|
||||||
|
// Navigate to Service Discovery => ConfigMaps
|
||||||
|
ConfigMapPagePo.navTo();
|
||||||
|
// Click on Create
|
||||||
|
configMapPage.clickCreate();
|
||||||
|
// Enter ConfigMap name
|
||||||
|
const configMapPo = new ConfigMapPo();
|
||||||
|
|
||||||
|
// Enter an invalid name so the api call fails
|
||||||
|
configMapPo.nameInput().set('$^$^"£%');
|
||||||
|
// Click on Create
|
||||||
|
configMapPo.saveCreateForm().click();
|
||||||
|
// Error banner should be displayed
|
||||||
|
configMapPo.errorBanner().should('exist').and('be.visible');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -61,11 +61,17 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async saveConfigMap() {
|
async saveConfigMap(saveCb) {
|
||||||
|
this.errors = [];
|
||||||
const yaml = await this.$refs.cru.createResourceYaml(this.yamlModifiers);
|
const yaml = await this.$refs.cru.createResourceYaml(this.yamlModifiers);
|
||||||
|
|
||||||
await this.value.saveYaml(yaml);
|
try {
|
||||||
this.done();
|
await this.value.saveYaml(yaml);
|
||||||
|
this.done();
|
||||||
|
} catch (err) {
|
||||||
|
this.errors.push(err);
|
||||||
|
saveCb(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateValue(val, type) {
|
updateValue(val, type) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue