test: refs #8031 e2e

This commit is contained in:
Javier Segarra 2024-09-25 10:53:38 +02:00
parent 8c7ee3024f
commit 72ddeaa90a
5 changed files with 78 additions and 8 deletions

View File

@ -78,9 +78,9 @@ async function saveDarkMode(value) {
darkMode: value, darkMode: value,
}); });
user.value.darkMode = value; user.value.darkMode = value;
notify('globals.dataSaved', 'positive'); onDataSaved();
} catch (error) { } catch (error) {
console.error(error); onDataError();
} }
} }
@ -91,9 +91,9 @@ async function saveLanguage(value) {
lang: value, lang: value,
}); });
user.value.lang = value; user.value.lang = value;
notify('globals.dataSaved', 'positive'); onDataSaved();
} catch (error) { } catch (error) {
console.error(error); onDataError();
} }
} }
@ -110,19 +110,23 @@ function localUserData() {
state.setUser(user.value); state.setUser(user.value);
} }
function saveUserData(param, value) { async function saveUserData(param, value) {
try { try {
axios.post('UserConfigs/setUserConfig', { [param]: value }); await axios.post('UserConfigs/setUserConfig', { [param]: value });
localUserData(); localUserData();
notify('globals.dataSaved', 'positive'); onDataSaved();
} catch (error) { } catch (error) {
console.error(error); onDataError();
} }
} }
const onDataSaved = () => { const onDataSaved = () => {
notify('globals.dataSaved', 'positive'); notify('globals.dataSaved', 'positive');
}; };
const onDataError = () => {
notify('errors.updateUserConfig', 'negative');
};
</script> </script>
<template> <template>

View File

@ -302,6 +302,7 @@ errors:
statusBadGateway: It seems that the server has fall down statusBadGateway: It seems that the server has fall down
statusGatewayTimeout: Could not contact the server statusGatewayTimeout: Could not contact the server
userConfig: Error fetching user config userConfig: Error fetching user config
updateUserConfig: Error updating user config
tokenConfig: Error fetching token config tokenConfig: Error fetching token config
writeRequest: The requested operation could not be completed writeRequest: The requested operation could not be completed
login: login:

View File

@ -306,6 +306,7 @@ errors:
statusBadGateway: Parece ser que el servidor ha caído statusBadGateway: Parece ser que el servidor ha caído
statusGatewayTimeout: No se ha podido contactar con el servidor statusGatewayTimeout: No se ha podido contactar con el servidor
userConfig: Error al obtener configuración de usuario 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 tokenConfig: Error al obtener configuración de token
writeRequest: No se pudo completar la operación solicitada writeRequest: No se pudo completar la operación solicitada
login: login:

View File

@ -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();
}

View File

@ -248,3 +248,9 @@ Cypress.Commands.add('validateContent', (selector, expectedValue) => {
Cypress.Commands.add('openActionsDescriptor', () => { Cypress.Commands.add('openActionsDescriptor', () => {
cy.get('.header > :nth-child(3) > .q-btn__content > .q-icon').click(); 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();
});