refactor(VnAccountNumber): refs #8718 update input handling and improve test descriptions
gitea/salix-front/pipeline/pr-master This commit looks good
Details
gitea/salix-front/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
5ac8e8a9e6
commit
d4a18e5846
|
@ -29,7 +29,6 @@ async function handleUpdateModel(val) {
|
||||||
<VnInput
|
<VnInput
|
||||||
v-model="model"
|
v-model="model"
|
||||||
ref="inputRef"
|
ref="inputRef"
|
||||||
v-bind="$attrs"
|
|
||||||
:insertable
|
:insertable
|
||||||
@update:model-value="handleUpdateModel"
|
@update:model-value="handleUpdateModel"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -143,7 +143,7 @@ const handleUppercase = () => {
|
||||||
:rules="mixinRules"
|
:rules="mixinRules"
|
||||||
:lazy-rules="true"
|
:lazy-rules="true"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_input'"
|
:data-cy="$attrs['data-cy'] ?? $attrs.label + '_input'"
|
||||||
>
|
>
|
||||||
<template #prepend v-if="$slots.prepend">
|
<template #prepend v-if="$slots.prepend">
|
||||||
<slot name="prepend" />
|
<slot name="prepend" />
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
describe('VnInput Component', () => {
|
describe('VnAccountNumber', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.login('developer');
|
cy.login('developer');
|
||||||
cy.viewport(1920, 1080);
|
cy.viewport(1920, 1080);
|
||||||
|
@ -6,34 +6,46 @@ describe('VnInput Component', () => {
|
||||||
cy.domContentLoad();
|
cy.domContentLoad();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('VnInput handleInsertMode()', () => {
|
||||||
it('should replace character at cursor position in insert mode', () => {
|
it('should replace character at cursor position in insert mode', () => {
|
||||||
// Simula escribir en el input
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').type(
|
||||||
cy.dataCy('supplierFiscalDataAccount').clear();
|
'{selectall}4100000001',
|
||||||
cy.dataCy('supplierFiscalDataAccount').type('4100000001');
|
);
|
||||||
// Coloca el cursor en la posición 0
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').type('{movetostart}');
|
||||||
cy.dataCy('supplierFiscalDataAccount').type('{movetostart}');
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').type('999');
|
||||||
// Escribe un número y verifica que se reemplace correctamente
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').should(
|
||||||
cy.dataCy('supplierFiscalDataAccount').type('999');
|
'have.value',
|
||||||
cy.dataCy('supplierFiscalDataAccount')
|
'9990000001',
|
||||||
.should('have.value', '9990000001');
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should replace character at cursor position in insert mode', () => {
|
it('should replace character at cursor position in insert mode', () => {
|
||||||
// Simula escribir en el input
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').clear();
|
||||||
cy.dataCy('supplierFiscalDataAccount').clear();
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').type('4100000001');
|
||||||
cy.dataCy('supplierFiscalDataAccount').type('4100000001');
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').type('{movetostart}');
|
||||||
// Coloca el cursor en la posición 0
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').type('999');
|
||||||
cy.dataCy('supplierFiscalDataAccount').type('{movetostart}');
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').should(
|
||||||
// Escribe un número y verifica que se reemplace correctamente en la posicion incial
|
'have.value',
|
||||||
cy.dataCy('supplierFiscalDataAccount').type('999');
|
'9990000001',
|
||||||
cy.dataCy('supplierFiscalDataAccount')
|
);
|
||||||
.should('have.value', '9990000001');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should respect maxlength prop', () => {
|
it('should respect maxlength prop', () => {
|
||||||
cy.dataCy('supplierFiscalDataAccount').clear();
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').clear();
|
||||||
cy.dataCy('supplierFiscalDataAccount').type('123456789012345');
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').type('123456789012345');
|
||||||
cy.dataCy('supplierFiscalDataAccount')
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').should(
|
||||||
.should('have.value', '1234567890'); // asumiendo que maxlength es 10
|
'have.value',
|
||||||
|
'1234567890',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should convert short account number to standard format', () => {
|
||||||
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').clear();
|
||||||
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').type('123.');
|
||||||
|
cy.get('input[data-cy="supplierFiscalDataAccount"]').should(
|
||||||
|
'have.value',
|
||||||
|
'1230000000',
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue