WIP: #7283 item_missing_e2e #1029

Draft
jsegarra wants to merge 190 commits from 7283_item_missing_e2e into dev
12 changed files with 143 additions and 6 deletions
Showing only changes of commit d8c1bd5b16 - Show all commits

View File

@ -394,6 +394,7 @@ watch(formUrl, async () => {
@click="onSubmit" @click="onSubmit"
:disable="!hasChanges" :disable="!hasChanges"
:title="t('globals.save')" :title="t('globals.save')"
data-testid="crudModelDefaultSaveBtn"
/> />
<slot name="moreAfterActions" /> <slot name="moreAfterActions" />
</QBtnGroup> </QBtnGroup>

View File

@ -86,7 +86,7 @@ async function send() {
</script> </script>
<template> <template>
<QDialog ref="dialogRef"> <QDialog ref="dialogRef" data-testid="vnSmsDialog">
<QCard class="q-pa-sm"> <QCard class="q-pa-sm">
<QCardSection class="row items-center q-pb-none"> <QCardSection class="row items-center q-pb-none">
<span class="text-h6 text-grey"> <span class="text-h6 text-grey">
@ -161,6 +161,7 @@ async function send() {
:loading="isLoading" :loading="isLoading"
color="primary" color="primary"
unelevated unelevated
data-testid="sendSmsBtn"
/> />
</QCardActions> </QCardActions>
</QCard> </QCard>

View File

@ -104,6 +104,7 @@ function cancel() {
unelevated unelevated
autofocus autofocus
data-cy="VnConfirm_confirm" data-cy="VnConfirm_confirm"
data-testid="vnConfirmConfirmBtn"
/> />
</QCardActions> </QCardActions>
</QCard> </QCard>

View File

@ -130,6 +130,7 @@ function ticketFilter(ticket) {
<QBadge <QBadge
text-color="black" text-color="black"
:color="entity.ticketState.state.classColor" :color="entity.ticketState.state.classColor"
data-testid="ticketDescriptorStateBadge"
> >
{{ entity.ticketState.state.name }} {{ entity.ticketState.state.name }}
</QBadge> </QBadge>

View File

@ -75,6 +75,7 @@ const cancel = () => {
dense dense
style="width: 50%" style="width: 50%"
@click="save()" @click="save()"
data-testid="saveManaBtn"
> >
{{ t('globals.save') }} {{ t('globals.save') }}
</QBtn> </QBtn>

View File

@ -86,12 +86,14 @@ async function handleSave() {
option-value="id" option-value="id"
v-model="row.observationTypeFk" v-model="row.observationTypeFk"
:disable="!!row.id" :disable="!!row.id"
data-testid="ticketNotesObservationType"
/> />
<VnInput <VnInput
:label="t('ticketNotes.description')" :label="t('ticketNotes.description')"
v-model="row.description" v-model="row.description"
class="col" class="col"
@keyup.enter="handleSave" @keyup.enter="handleSave"
data-testid="ticketNotesDescription"
/> />
<QIcon <QIcon
name="delete" name="delete"
@ -99,6 +101,7 @@ async function handleSave() {
class="cursor-pointer" class="cursor-pointer"
color="primary" color="primary"
@click="handleDelete(row)" @click="handleDelete(row)"
data-testid="ticketNotesRemoveNoteBtn"
> >
<QTooltip> <QTooltip>
{{ t('ticketNotes.removeNote') }} {{ t('ticketNotes.removeNote') }}
@ -113,6 +116,7 @@ async function handleSave() {
class="fill-icon-on-hover q-ml-md" class="fill-icon-on-hover q-ml-md"
color="primary" color="primary"
@click="ticketNotesCrudRef.insert()" @click="ticketNotesCrudRef.insert()"
data-testid="ticketNotesAddNoteBtn"
> >
<QTooltip> <QTooltip>
{{ t('ticketNotes.addNote') }} {{ t('ticketNotes.addNote') }}

View File

@ -577,6 +577,7 @@ watch(
color="primary" color="primary"
:disable="!isTicketEditable || ticketState === 'OK'" :disable="!isTicketEditable || ticketState === 'OK'"
@click="changeTicketState('OK')" @click="changeTicketState('OK')"
data-testid="ticketSaleOkStateBtn"
> >
<QTooltip>{{ t(`Change ticket state to 'Ok'`) }}</QTooltip> <QTooltip>{{ t(`Change ticket state to 'Ok'`) }}</QTooltip>
</QBtn> </QBtn>
@ -585,6 +586,7 @@ watch(
color="primary" color="primary"
:label="t('ticketSale.state')" :label="t('ticketSale.state')"
:disable="!isTicketEditable" :disable="!isTicketEditable"
data-testid="ticketSaleStateDropdown"
> >
<VnSelect <VnSelect
:options="editableStatesOptions" :options="editableStatesOptions"
@ -594,6 +596,7 @@ watch(
hide-dropdown-icon hide-dropdown-icon
focus-on-mount focus-on-mount
@update:model-value="changeTicketState" @update:model-value="changeTicketState"
data-testid="ticketSaleStateSelect"
/> />
</QBtnDropdown> </QBtnDropdown>
<TicketSaleMoreActions <TicketSaleMoreActions
@ -833,7 +836,7 @@ watch(
<QBtn flat class="link" dense @click="onOpenEditDiscountPopover(row)"> <QBtn flat class="link" dense @click="onOpenEditDiscountPopover(row)">
{{ toPercentage(row.discount / 100) }} {{ toPercentage(row.discount / 100) }}
</QBtn> </QBtn>
<TicketEditManaProxy <!-- <TicketEditManaProxy
:mana="mana" :mana="mana"
:new-price="getNewPrice" :new-price="getNewPrice"
:uses-mana="usesMana" :uses-mana="usesMana"
@ -848,7 +851,7 @@ watch(
<div v-if="usesMana" class="column q-gutter-y-sm q-mt-sm"> <div v-if="usesMana" class="column q-gutter-y-sm q-mt-sm">
<VnUsesMana :mana-code="manaCode" /> <VnUsesMana :mana-code="manaCode" />
</div> </div>
</TicketEditManaProxy> </TicketEditManaProxy> -->
</template> </template>
<span v-else>{{ toPercentage(row.discount / 100) }}</span> <span v-else>{{ toPercentage(row.discount / 100) }}</span>
</template> </template>
@ -858,7 +861,14 @@ watch(
</VnTable> </VnTable>
<QPageSticky :offset="[20, 20]" style="z-index: 2"> <QPageSticky :offset="[20, 20]" style="z-index: 2">
<QBtn @click="newOrderFromTicket()" color="primary" fab icon="add" shortcut="+" /> <QBtn
@click="newOrderFromTicket()"
color="primary"
fab
icon="add"
shortcut="+"
data-testid="ticketSaleAddToBasketBtn"
/>
<QTooltip class="text-no-wrap"> <QTooltip class="text-no-wrap">
{{ t('Add item to basket') }} {{ t('Add item to basket') }}
</QTooltip> </QTooltip>

View File

@ -179,6 +179,7 @@ const createRefund = async (withWarehouse) => {
color="primary" color="primary"
:label="t('ticketSale.more')" :label="t('ticketSale.more')"
:disable="disable" :disable="disable"
data-testid="ticketSaleMoreActionsDropdown"
> >
<template #label> <template #label>
<QTooltip>{{ t('Select lines to see the options') }}</QTooltip> <QTooltip>{{ t('Select lines to see the options') }}</QTooltip>
@ -190,6 +191,7 @@ const createRefund = async (withWarehouse) => {
v-close-popup v-close-popup
v-ripple v-ripple
@click="showSmsDialog('productNotAvailable')" @click="showSmsDialog('productNotAvailable')"
data-testid="sendShortageSMSItem"
> >
<QItemSection> <QItemSection>
<QItemLabel>{{ t('Send shortage SMS') }}</QItemLabel> <QItemLabel>{{ t('Send shortage SMS') }}</QItemLabel>
@ -201,12 +203,18 @@ const createRefund = async (withWarehouse) => {
v-close-popup v-close-popup
v-ripple v-ripple
@click="calculateSalePrice()" @click="calculateSalePrice()"
data-testid="recalculatePriceItem"
> >
<QItemSection> <QItemSection>
<QItemLabel>{{ t('Recalculate price') }}</QItemLabel> <QItemLabel>{{ t('Recalculate price') }}</QItemLabel>
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem clickable v-ripple @click="emit('getMana')"> <QItem
clickable
v-ripple
@click="emit('getMana')"
data-testid="updateDiscountItem"
>
<QItemSection> <QItemSection>
<QItemLabel>{{ t('Update discount') }}</QItemLabel> <QItemLabel>{{ t('Update discount') }}</QItemLabel>
</QItemSection> </QItemSection>
@ -215,6 +223,7 @@ const createRefund = async (withWarehouse) => {
v-model.number="newDiscount" v-model.number="newDiscount"
:label="t('ticketSale.discount')" :label="t('ticketSale.discount')"
type="number" type="number"
data-testid="ticketSaleDiscountInput"
/> />
</TicketEditManaProxy> </TicketEditManaProxy>
</QItem> </QItem>
@ -224,6 +233,7 @@ const createRefund = async (withWarehouse) => {
v-close-popup v-close-popup
v-ripple v-ripple
@click="createClaim()" @click="createClaim()"
data-testid="createClaimItem"
> >
<QItemSection> <QItemSection>
<QItemLabel>{{ t('Add claim') }}</QItemLabel> <QItemLabel>{{ t('Add claim') }}</QItemLabel>

View File

@ -1,5 +1,5 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('Ticket descriptor', () => { describe('TicketList', () => {
const firstRow = 'tbody > :nth-child(1)'; const firstRow = 'tbody > :nth-child(1)';
beforeEach(() => { beforeEach(() => {

View File

@ -0,0 +1,25 @@
/// <reference types="cypress" />
describe('TicketRequest', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/observation');
});
it('Creates and deletes a note', () => {
cy.dataCy('ticketNotesAddNoteBtn').should('exist');
cy.dataCy('ticketNotesAddNoteBtn').click();
cy.dataCy('ticketNotesObservationType').should('exist');
cy.selectOption('[data-testid="ticketNotesObservationType"]:last', 'Weight');
cy.dataCy('ticketNotesDescription').should('exist');
cy.get('[data-testid="ticketNotesDescription"]:last').type(
'This is a note description'
);
cy.dataCy('crudModelDefaultSaveBtn').click();
cy.checkNotification('Data saved');
cy.dataCy('ticketNotesRemoveNoteBtn').should('exist');
cy.dataCy('ticketNotesRemoveNoteBtn').click();
cy.dataCy('vnConfirmConfirmBtn').click();
cy.checkNotification('Data saved');
});
});

View File

@ -0,0 +1,22 @@
/// <reference types="cypress" />
describe('TicketRequest', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/request');
});
it('Creates a new request', () => {
cy.dataCy('vnTableCreateBtn').should('exist');
cy.dataCy('vnTableCreateBtn').click();
const data = {
Description: { val: 'Purchase description' },
Atender: { val: 'buyerNick', type: 'select' },
Quantity: { val: 2 },
Price: { val: 123 },
};
cy.fillInForm(data);
cy.get('.q-mt-lg > .q-btn--standard').click();
cy.checkNotification('Data created');
});
});

View File

@ -0,0 +1,61 @@
/// <reference types="cypress" />
describe('TicketSale', () => {
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
cy.visit('/#/ticket/31/sale');
});
const firstRow = 'tbody > :nth-child(1)';
const selectFirstRow = () => {
cy.waitForElement(firstRow);
cy.get(firstRow).find('.q-checkbox__inner').click();
};
it('it should add item to basket', () => {
cy.window().then((win) => {
cy.stub(win, 'open').as('windowOpen');
});
cy.dataCy('ticketSaleAddToBasketBtn').should('exist');
cy.dataCy('ticketSaleAddToBasketBtn').click();
cy.get('@windowOpen').should('be.calledWithMatch', /\/order\/\d+\/catalog/);
});
it('should send SMS', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-testid="sendShortageSMSItem"]');
cy.dataCy('sendShortageSMSItem').should('exist');
cy.dataCy('sendShortageSMSItem').click();
cy.dataCy('vnSmsDialog').should('exist');
cy.dataCy('sendSmsBtn').click();
cy.checkNotification('SMS sent');
});
it('should recalculate price when "Recalculate price" is clicked', () => {
cy.intercept('POST', '**/recalculatePrice').as('recalculatePrice');
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-testid="recalculatePriceItem"]');
cy.dataCy('recalculatePriceItem').should('exist');
cy.dataCy('recalculatePriceItem').click();
cy.wait('@recalculatePrice').its('response.statusCode').should('eq', 200);
cy.checkNotification('Data saved');
});
it('should update discount when "Update discount" is clicked', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.waitForElement('[data-testid="updateDiscountItem"]');
cy.dataCy('updateDiscountItem').should('exist');
cy.dataCy('updateDiscountItem').click();
cy.waitForElement('[data-testid="ticketSaleDiscountInput"]');
cy.dataCy('ticketSaleDiscountInput').find('input').focus();
cy.dataCy('ticketSaleDiscountInput').find('input').type('10');
cy.dataCy('saveManaBtn').click();
cy.waitForElement('.q-notification__message');
cy.checkNotification('Data saved');
});
});