8627-devToTest #1421

Merged
alexm merged 768 commits from 8627-devToTest into test 2025-02-18 12:37:37 +00:00
5 changed files with 74 additions and 18 deletions
Showing only changes of commit 5c5a6069ce - Show all commits

View File

@ -0,0 +1,61 @@
import { vi, describe, expect, it, beforeEach, beforeAll, afterEach } from 'vitest';
import { createWrapper } from 'app/test/vitest/helper';
import UserPanel from 'src/components/UserPanel.vue';
import axios from 'axios';
import { useState } from 'src/composables/useState';
describe('UserPanel', () => {
let wrapper;
let vm;
let state;
beforeEach(() => {
wrapper = createWrapper(UserPanel, {});
state = useState();
state.setUser({
id: 115,
name: 'itmanagement',
nickname: 'itManagementNick',
lang: 'en',
darkMode: false,
companyFk: 442,
warehouseFk: 1,
});
wrapper = wrapper.wrapper;
vm = wrapper.vm;
});
afterEach(() => {
vi.clearAllMocks();
});
it('should fetch warehouses data on mounted', async () => {
const fetchData = wrapper.findComponent({ name: 'FetchData' });
expect(fetchData.props('url')).toBe('Warehouses');
expect(fetchData.props('autoLoad')).toBe(true);
});
it('should toggle dark mode correctly and update preferences', async () => {
await vm.saveDarkMode(true);
expect(axios.patch).toHaveBeenCalledWith('/UserConfigs/115', { darkMode: true });
expect(vm.user.darkMode).toBe(true);
vm.updatePreferences();
expect(vm.darkMode).toBe(true);
});
it('should change user language and update preferences', async () => {
const userLanguage = 'es';
await vm.saveLanguage(userLanguage);
expect(axios.patch).toHaveBeenCalledWith('/VnUsers/115', { lang: userLanguage });
expect(vm.user.lang).toBe(userLanguage);
vm.updatePreferences();
expect(vm.locale).toBe(userLanguage);
});
it('should update user data', async () => {
const key = 'name';
const value = 'itboss';
await vm.saveUserData(key, value);
expect(axios.post).toHaveBeenCalledWith('UserConfigs/setUserConfig', { [key]: value });
});
});

View File

@ -134,6 +134,7 @@ function downloadCSV(rows) {
@click=" @click="
openReport(`Entries/${entityId}/labelSupplier`) openReport(`Entries/${entityId}/labelSupplier`)
" "
data-cy="printLabelsBtn"
/> />
</template> </template>
<template #body="props"> <template #body="props">

View File

@ -177,7 +177,7 @@ const cols = computed(() => [
:required="true" :required="true"
/> />
<VnInput <VnInput
:label="t('invoicein.list.supplierRef')" :label="t('invoiceIn.list.supplierRef')"
v-model="data.supplierRef" v-model="data.supplierRef"
/> />
<VnSelect <VnSelect
@ -190,7 +190,7 @@ const cols = computed(() => [
:required="true" :required="true"
/> />
<VnInputDate <VnInputDate
:label="t('invoicein.summary.issued')" :label="t('invoiceIn.summary.issued')"
v-model="data.issued" v-model="data.issued"
/> />
</template> </template>

View File

@ -8,12 +8,12 @@ describe('EntryMy when is supplier', () => {
}, },
}); });
}); });
// https://redmine.verdnatura.es/issues/8418
it.skip('should open buyLabel when is supplier', () => { it('should open buyLabel when is supplier', () => {
cy.get( cy.get(
'[to="/null/3"] > .q-card > .column > .q-btn > .q-btn__content > .q-icon' '[to="/null/3"] > .q-card > .column > .q-btn > .q-btn__content > .q-icon'
).click(); ).click();
cy.get('.q-card__actions > .q-btn').click(); cy.dataCy('printLabelsBtn').click();
cy.window().its('open').should('be.called'); cy.window().its('open').should('be.called');
}); });
}); });

View File

@ -12,28 +12,22 @@ describe('Item tag', () => {
cy.get('.q-page-sticky > div').click(); cy.get('.q-page-sticky > div').click();
cy.dataCy('Tag_select').eq(7).type('Tallos'); cy.dataCy('Tag_select').eq(7).type('Tallos');
cy.get('.q-menu .q-item').contains('Tallos').click(); cy.get('.q-menu .q-item').contains('Tallos').click();
cy.get( cy.get(':nth-child(8) > [label="Value"]').type('1');
':nth-child(8) > [label="Value"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="Value_input"]'
).type('1');
+cy.dataCy('crudModelDefaultSaveBtn').click(); +cy.dataCy('crudModelDefaultSaveBtn').click();
cy.checkNotification("The tag or priority can't be repeated for an item"); cy.checkNotification("The tag or priority can't be repeated for an item");
}); });
// https://redmine.verdnatura.es/issues/8422
it.skip('should add a new tag', () => { it('should add a new tag', () => {
cy.get('.q-page').should('be.visible'); cy.get('.q-page').should('be.visible');
cy.get('.q-page-sticky > div').click(); cy.get('.q-page-sticky > div').click();
cy.get('.q-page-sticky > div').click(); cy.get('.q-page-sticky > div').click();
cy.dataCy('Tag_select').eq(7).click(); cy.dataCy('Tag_select').eq(7).click();
cy.get('.q-menu .q-item').contains('Ancho de la base').click(); cy.get('.q-menu .q-item').contains('Ancho de la base').type('{enter}');
cy.get( cy.get(':nth-child(8) > [label="Value"]').type('50');
':nth-child(8) > [label="Value"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="Value_input"]'
).type('50');
cy.dataCy('crudModelDefaultSaveBtn').click(); cy.dataCy('crudModelDefaultSaveBtn').click();
cy.checkNotification('Data saved'); cy.checkNotification('Data saved');
cy.get( cy.dataCy('itemTags').children(':nth-child(8)').find('.justify-center > .q-icon').click();
'[data-cy="itemTags"] > :nth-child(7) > .justify-center > .q-icon'
).click();
cy.dataCy('VnConfirm_confirm').click(); cy.dataCy('VnConfirm_confirm').click();
cy.checkNotification('Data saved'); cy.checkNotification('Data saved');
}); });
}); });