Compare commits

..

8 Commits

Author SHA1 Message Date
Jose Antonio Tubau def62c5e12 Merge branch 'dev' into 7069-testVnAccountNumber
gitea/salix-front/pipeline/pr-dev This commit is unstable Details
2025-05-12 05:13:46 +00:00
Alex Moreno 649686f128 refactor: refs #7069 remove keyup.enter and blur event emissions from VnInput component
gitea/salix-front/pipeline/pr-dev This commit looks good Details
2025-05-09 09:53:42 +02:00
Alex Moreno 43258214e1 feat: refs #7069 add keyup.enter and blur event emissions to VnInput component
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details
2025-05-09 09:46:06 +02:00
Alex Moreno c723608d6b refactor: refs #7069 simplify VnInput emits and update event handling in tests
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details
2025-05-09 09:09:57 +02:00
Alex Moreno 2a8feaa5d1 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 7069-testVnAccountNumber 2025-05-09 08:42:48 +02:00
Jose Antonio Tubau 9639c56ce0 Merge branch 'dev' into 7069-testVnAccountNumber
gitea/salix-front/pipeline/pr-dev This commit looks good Details
2025-05-05 13:58:58 +00:00
Jose Antonio Tubau d10549939b Merge branch 'dev' into 7069-testVnAccountNumber
gitea/salix-front/pipeline/pr-dev This commit is unstable Details
2025-04-30 09:29:43 +00:00
Jose Antonio Tubau b21c5752b8 test: refs #7069 add unit tests for VnAccountNumber component
gitea/salix-front/pipeline/pr-dev This commit is unstable Details
2025-04-30 10:41:49 +02:00
3 changed files with 54 additions and 10 deletions

View File

@ -0,0 +1,43 @@
import { describe, expect, it, vi, beforeEach } from 'vitest';
import { createWrapper } from 'app/test/vitest/helper';
import VnAccountNumber from 'src/components/common/VnAccountNumber.vue';
describe('VnAccountNumber', () => {
let wrapper;
let input;
let vnInput;
let spyShort;
beforeEach(() => {
wrapper = createWrapper(VnAccountNumber);
wrapper = wrapper.wrapper;
input = wrapper.find('input');
vnInput = wrapper.findComponent({ name: 'VnInput' });
spyShort = vi.spyOn(wrapper.vm, 'useAccountShortToStandard');
});
it('should filter out non-numeric characters on input event', async () => {
await input.setValue('abc123.45!@#');
const emitted = wrapper.emitted('update:modelValue');
expect(emitted.pop()[0]).toBe('123.45');
expect(spyShort).not.toHaveBeenCalled();
});
it('should apply conversion on blur when valid short value is provided', async () => {
await input.setValue('123.45');
await vnInput.trigger('blur');
const emitted = wrapper.emitted('update:modelValue');
expect(emitted.pop()[0]).toBe('1230000045');
expect(spyShort).toHaveBeenCalled();
});
it('should not change value for invalid input values', async () => {
await input.setValue('123');
await vnInput.trigger('blur');
const emitted = wrapper.emitted('update:modelValue');
expect(emitted.pop()[0]).toBe('123');
expect(spyShort).toHaveBeenCalled();
});
});

View File

@ -6,13 +6,7 @@ import { useRequired } from 'src/composables/useRequired';
const $attrs = useAttrs();
const { isRequired, requiredFieldRule } = useRequired($attrs);
const { t } = useI18n();
const emit = defineEmits([
'update:modelValue',
'update:options',
'keyup.enter',
'remove',
'blur',
]);
const emit = defineEmits(['update:modelValue', 'update:options', 'remove']);
const $props = defineProps({
modelValue: {
@ -126,6 +120,14 @@ const handleInsertMode = (e) => {
const handleUppercase = () => {
value.value = value.value?.toUpperCase() || '';
};
const listeners = computed(() =>
Object.fromEntries(
Object.entries($attrs).filter(
([key, val]) => key.startsWith('on') && typeof val === 'function',
),
),
);
</script>
<template>
@ -134,10 +136,9 @@ const handleUppercase = () => {
ref="vnInputRef"
v-model="value"
v-bind="{ ...$attrs, ...styleAttrs }"
v-on="listeners"
:type="$attrs.type"
:class="{ required: isRequired }"
@keyup.enter="emit('keyup.enter')"
@blur="emit('blur')"
@keydown="handleKeydown"
:clearable="false"
:rules="mixinRules"

View File

@ -1,4 +1,4 @@
describe.skip('RoadMap', () => {
describe('RoadMap', () => {
const getSelector = (colField) =>
`tr:last-child > [data-col-field="${colField}"] > .no-padding`;