#8031 - Enable notify positive when user update self data #750
|
@ -78,9 +78,9 @@ async function saveDarkMode(value) {
|
|||
darkMode: value,
|
||||
});
|
||||
user.value.darkMode = value;
|
||||
notify('globals.dataSaved', 'positive');
|
||||
onDataSaved();
|
||||
} catch (error) {
|
||||
jsegarra marked this conversation as resolved
|
||||
console.error(error);
|
||||
onDataError();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,9 +91,9 @@ async function saveLanguage(value) {
|
|||
lang: value,
|
||||
});
|
||||
user.value.lang = value;
|
||||
notify('globals.dataSaved', 'positive');
|
||||
onDataSaved();
|
||||
} catch (error) {
|
||||
jsegarra marked this conversation as resolved
alexm
commented
Con un try catch para un console.log, el usuario no se dará cuenta si falla Con un try catch para un console.log, el usuario no se dará cuenta si falla
|
||||
console.error(error);
|
||||
onDataError();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,19 +110,23 @@ function localUserData() {
|
|||
state.setUser(user.value);
|
||||
}
|
||||
|
||||
function saveUserData(param, value) {
|
||||
async function saveUserData(param, value) {
|
||||
try {
|
||||
axios.post('UserConfigs/setUserConfig', { [param]: value });
|
||||
await axios.post('UserConfigs/setUserConfig', { [param]: value });
|
||||
localUserData();
|
||||
notify('globals.dataSaved', 'positive');
|
||||
onDataSaved();
|
||||
} catch (error) {
|
||||
jsegarra marked this conversation as resolved
alexm
commented
Con un try catch para un console.log, el usuario no se dará cuenta si falla Con un try catch para un console.log, el usuario no se dará cuenta si falla
|
||||
console.error(error);
|
||||
onDataError();
|
||||
}
|
||||
}
|
||||
|
||||
const onDataSaved = () => {
|
||||
jsegarra marked this conversation as resolved
alexm
commented
No se llama nunca No se llama nunca
|
||||
notify('globals.dataSaved', 'positive');
|
||||
};
|
||||
|
||||
const onDataError = () => {
|
||||
notify('errors.updateUserConfig', 'negative');
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -302,6 +302,7 @@ errors:
|
|||
statusBadGateway: It seems that the server has fall down
|
||||
statusGatewayTimeout: Could not contact the server
|
||||
userConfig: Error fetching user config
|
||||
updateUserConfig: Error updating user config
|
||||
tokenConfig: Error fetching token config
|
||||
writeRequest: The requested operation could not be completed
|
||||
login:
|
||||
|
|
|
@ -306,6 +306,7 @@ errors:
|
|||
statusBadGateway: Parece ser que el servidor ha caído
|
||||
statusGatewayTimeout: No se ha podido contactar con el servidor
|
||||
userConfig: Error al obtener configuración de usuario
|
||||
updateUserConfig: Error al actualizar la configuración de usuario
|
||||
tokenConfig: Error al obtener configuración de token
|
||||
writeRequest: No se pudo completar la operación solicitada
|
||||
login:
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/// <reference types="cypress" />
|
||||
describe('UserPanel', () => {
|
||||
beforeEach(() => {
|
||||
cy.viewport(1280, 720);
|
||||
cy.login('developer');
|
||||
cy.visit(`/#dashboard`);
|
||||
cy.waitForElement('.q-page', 6000);
|
||||
});
|
||||
|
||||
it('should notify when update user warehouse', () => {
|
||||
const userWarehouse =
|
||||
'.q-menu .q-gutter-xs > :nth-child(3) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native> .q-field__input';
|
||||
|
||||
// Abro el panel
|
||||
cy.openUserPanel();
|
||||
|
||||
// Compruebo la opcion inicial
|
||||
cy.get(userWarehouse).should('have.value', 'VNL').click();
|
||||
|
||||
// Actualizo la opción
|
||||
getOption(3);
|
||||
|
||||
//Compruebo la notificación
|
||||
cy.get('.q-notification').should('be.visible');
|
||||
cy.get(userWarehouse).should('have.value', 'VNH');
|
||||
|
||||
//Restauro el valor
|
||||
cy.get(userWarehouse).click();
|
||||
getOption(2);
|
||||
});
|
||||
it('should notify when update user company', () => {
|
||||
const userCompany =
|
||||
'.q-menu .q-gutter-xs > :nth-child(2) > .q-field--float > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native> .q-field__input';
|
||||
|
||||
// Abro el panel
|
||||
cy.openUserPanel();
|
||||
|
||||
// Compruebo la opcion inicial
|
||||
cy.get(userCompany).should('have.value', 'Warehouse One').click();
|
||||
|
||||
//Actualizo la opción
|
||||
getOption(2);
|
||||
|
||||
//Compruebo la notificación
|
||||
cy.get('.q-notification').should('be.visible');
|
||||
cy.get(userCompany).should('have.value', 'Warehouse Two');
|
||||
|
||||
//Restauro el valor
|
||||
cy.get(userCompany).click();
|
||||
getOption(1);
|
||||
});
|
||||
});
|
||||
|
||||
function getOption(index) {
|
||||
cy.waitForElement('[role="listbox"]');
|
||||
const option = `[role="listbox"] .q-item:nth-child(${index})`;
|
||||
cy.get(option).click();
|
||||
}
|
|
@ -248,3 +248,9 @@ Cypress.Commands.add('validateContent', (selector, expectedValue) => {
|
|||
Cypress.Commands.add('openActionsDescriptor', () => {
|
||||
cy.get('.header > :nth-child(3) > .q-btn__content > .q-icon').click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('openUserPanel', () => {
|
||||
cy.get(
|
||||
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
|
||||
).click();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Con un try catch para un console.log, el usuario no se dará cuenta si falla