support displaying error banners on configmap creation page

This commit is contained in:
Mo Mesgin 2024-05-14 16:00:28 -07:00
parent ed3f8f5992
commit 2e2694e4ec
3 changed files with 29 additions and 3 deletions

View File

@ -25,6 +25,10 @@ export default class ConfigMapPo extends CreateEditViewPo {
return LabeledInputPo.byLabel(this.self(), 'Description');
}
errorBanner() {
return cy.get('#cru-errors');
}
saveCreateForm(): AsyncButtonPo {
return new AsyncButtonPo('[data-testid="form-save"]', this.self());
}

View File

@ -59,4 +59,20 @@ skipGeometric=true`;
// Assert the current value yaml dumps will append a newline at the end
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');
});
});

View File

@ -61,11 +61,17 @@ export default {
},
methods: {
async saveConfigMap() {
async saveConfigMap(saveCb) {
this.errors = [];
const yaml = await this.$refs.cru.createResourceYaml(this.yamlModifiers);
await this.value.saveYaml(yaml);
this.done();
try {
await this.value.saveYaml(yaml);
this.done();
} catch (err) {
this.errors.push(err);
saveCb(false);
}
},
updateValue(val, type) {