test: refactor e2e
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Alex Moreno 2024-11-04 13:41:37 +01:00
parent 08204aa5f0
commit e050a077d4
4 changed files with 28 additions and 14 deletions

View File

@ -170,6 +170,7 @@ function addDefaultData(data) {
@update:model-value="onFileChange(dms.files)" @update:model-value="onFileChange(dms.files)"
class="required" class="required"
:display-value="dms.file" :display-value="dms.file"
data-cy="VnDms_inputFile"
> >
<template #append> <template #append>
<QIcon <QIcon

View File

@ -103,6 +103,7 @@ function cancel() {
@click="confirm()" @click="confirm()"
unelevated unelevated
autofocus autofocus
data-cy="VnConfirm_confirm"
/> />
</QCardActions> </QCardActions>
</QCard> </QCard>

View File

@ -179,7 +179,11 @@ function deleteFile(dmsFk) {
class="full-width" class="full-width"
:disable="true" :disable="true"
/> />
<div v-if="data.dmsFk" class="row no-wrap q-pa-xs q-gutter-x-xs"> <div
v-if="data.dmsFk"
class="row no-wrap q-pa-xs q-gutter-x-xs"
data-cy="dms-buttons"
>
<QBtn <QBtn
:class="{ :class="{
'no-pointer-events': editDownloadDisabled, 'no-pointer-events': editDownloadDisabled,
@ -232,6 +236,7 @@ function deleteFile(dmsFk) {
delete documentDialogRef.dms; delete documentDialogRef.dms;
} }
" "
data-cy="dms-create"
> >
<QTooltip>{{ t('Create document') }}</QTooltip> <QTooltip>{{ t('Create document') }}</QTooltip>
</QBtn> </QBtn>

View File

@ -2,9 +2,8 @@
describe('InvoiceInBasicData', () => { describe('InvoiceInBasicData', () => {
const formInputs = '.q-form > .q-card input'; const formInputs = '.q-form > .q-card input';
const firstFormSelect = '.q-card > .vn-row:nth-child(1) > .q-select'; const firstFormSelect = '.q-card > .vn-row:nth-child(1) > .q-select';
const documentBtns = '.q-form .q-field button'; const documentBtns = '[data-cy="dms-buttons"] button';
const dialogInputs = '.q-dialog input'; const dialogInputs = '.q-dialog input';
const dialogActionBtns = '.q-card__actions button';
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
@ -21,27 +20,35 @@ describe('InvoiceInBasicData', () => {
cy.get(formInputs).eq(1).invoke('val').should('eq', '4739'); cy.get(formInputs).eq(1).invoke('val').should('eq', '4739');
}); });
it('should edit the dms data', () => { it('should edit, remove and create the dms data', () => {
const firtsInput = 'Ticket:65'; const firtsInput = 'Ticket:65';
const secondInput = "I don't know what posting here!"; const secondInput = "I don't know what posting here!";
//edit
cy.get(documentBtns).eq(1).click(); cy.get(documentBtns).eq(1).click();
cy.get(dialogInputs).eq(0).type(`{selectall}${firtsInput}`); cy.get(dialogInputs).eq(0).type(`{selectall}${firtsInput}`);
cy.get('textarea').type(`{selectall}${secondInput}`); cy.get('textarea').type(`{selectall}${secondInput}`);
cy.get(dialogActionBtns).eq(1).click(); cy.get('[data-cy="FormModelPopup_save"]').click();
cy.get(documentBtns).eq(1).click(); cy.get(documentBtns).eq(1).click();
cy.get(dialogInputs).eq(0).invoke('val').should('eq', firtsInput); cy.get(dialogInputs).eq(0).invoke('val').should('eq', firtsInput);
cy.get('textarea').invoke('val').should('eq', secondInput); cy.get('textarea').invoke('val').should('eq', secondInput);
}); cy.get('[data-cy="FormModelPopup_save"]').click();
cy.checkNotification('Data saved');
it('should throw an error creating a new dms if a file is not attached', () => { //remove
cy.get(formInputs).eq(7).type('{selectall}{backspace}'); cy.get(documentBtns).eq(2).click();
cy.get(documentBtns).eq(0).click(); cy.get('[data-cy="VnConfirm_confirm"]').click();
cy.get(dialogActionBtns).eq(1).click(); cy.checkNotification('Data saved');
cy.get('.q-notification__message').should(
'have.text', //create
"The files can't be empty" cy.get('[data-cy="dms-create"]').eq(0).click();
cy.get('[data-cy="VnDms_inputFile"').selectFile(
'test/cypress/fixtures/image.jpg',
{
force: true,
}
); );
cy.get('[data-cy="FormModelPopup_save"]').click();
cy.checkNotification('Data saved');
}); });
}); });