0
1
Fork 0

PendingOrdersView and OrdersView tests

This commit is contained in:
William Buezas 2024-10-21 15:05:04 -03:00
parent ff423ae79b
commit cfff9f7aeb
7 changed files with 103 additions and 2 deletions

View File

@ -91,6 +91,7 @@ async function confirm() {
@click="confirm()"
unelevated
autofocus
data-testid="confirmDialogButton"
/>
</QCardActions>
</QCard>

View File

@ -73,6 +73,7 @@ const onConfirmPay = async () => {
@click="onPayClick()"
rounded
no-caps
data-testid="makePaymentButton"
>
<QTooltip>
{{ t('makePayment') }}
@ -124,6 +125,7 @@ const onConfirmPay = async () => {
v-model="showAmountToPayDialog"
message=" "
:promise="onConfirmPay"
data-testid="payAmountDialog"
>
<template #customHTML>
<VnInput
@ -133,6 +135,7 @@ const onConfirmPay = async () => {
type="number"
min="0"
:max="debt * -1"
data-testid="payAmountInput"
>
<template #append></template>
</VnInput>

View File

@ -116,6 +116,7 @@ onMounted(async () => {
() => removeOrder(order.id, index)
)
"
data-testid="pendingOrderCardDelete"
>
<QTooltip>{{ t('deleteOrder') }}</QTooltip>
</QBtn>
@ -124,6 +125,7 @@ onMounted(async () => {
flat
rounded
@click.stop.prevent="loadOrder(order.id)"
data-testid="addOrderToBasket"
>
<QTooltip>{{ t('loadOrderIntoCart') }}</QTooltip>
</QBtn>

View File

@ -27,6 +27,6 @@ describe('UsersView', () => {
'contain',
'New test nickname'
);
cy.clearDB();
cy.resetDB();
});
});

View File

@ -0,0 +1,36 @@
describe('PendingOrders', () => {
before(() => {
// cy.resetDB();
});
beforeEach(() => {
cy.login('brucewayne');
cy.visit('/#/ecomerce/orders');
});
const makePayment = typeAmount => {
cy.dataCy('makePaymentButton').should('exist');
cy.dataCy('makePaymentButton').click();
cy.dataCy('payAmountDialog').should('exist');
cy.get('input[data-testid="payAmountInput"]').should('exist');
cy.get('input[data-testid="payAmountInput"]').clear();
if (typeAmount || typeAmount === 0)
cy.get('input[data-testid="payAmountInput"]').type(typeAmount);
cy.dataCy('confirmDialogButton').should('exist');
cy.dataCy('confirmDialogButton').click();
};
// it('when confirm payment redirects to payment site', () => {
// makePayment('100');
// TODO: Ver como hacer para verificar redirección a sitio externo
// });
it('fails payment if pay amount is 0', () => {
cy.visit('/#/ecomerce/orders');
makePayment(0);
cy.dataCy('negativeNotify').should(
'contain',
'La cantidad debe ser un número positivo e inferior o igual al importe pendiente'
);
});
});

View File

@ -0,0 +1,59 @@
describe('PendingOrders', () => {
before(() => {
// Esto se ejecuta una vez antes de todas las pruebas
cy.resetDB();
});
beforeEach(() => {
cy.login('developer');
});
const checkEmptyList = () => {
cy.dataCy('pendingOrdersList').should('exist');
cy.dataCy('pendingOrdersList').should('contain', 'Lista vacía');
cy.dataCy('pendingOrderCard').should('not.exist');
};
const checkExistingOrder = () => {
cy.dataCy('pendingOrdersList').should('exist');
cy.dataCy('pendingOrdersList').should('not.contain', 'Lista vacía');
cy.dataCy('pendingOrderCard').should('exist');
};
it('shows empty state', () => {
// Cuando la db se reinicia el usuario developer no tiene ordenes pendientes
cy.visit('/#/ecomerce/pending');
checkEmptyList();
});
it('creates a new order', () => {
cy.createOrderReceiveFlow();
cy.visit('/#/ecomerce/pending');
checkExistingOrder();
cy.dataCy('pendingOrderCard').should('have.length', 1);
cy.resetDB();
});
it('deletes an order', () => {
cy.createOrderReceiveFlow();
cy.visit('/#/ecomerce/pending');
checkExistingOrder();
cy.dataCy('pendingOrderCard').should('have.length', 1);
cy.dataCy('pendingOrderCardDelete').click();
cy.dataCy('confirmDialogButton').should('exist');
cy.dataCy('confirmDialogButton').click();
cy.dataCy('positiveNotify').should('contain', 'Datos guardados');
checkEmptyList();
});
it('adds order to basket', () => {
cy.createOrderReceiveFlow();
cy.visit('/#/ecomerce/pending');
cy.dataCy('addOrderToBasket').should('exist');
cy.dataCy('addOrderToBasket').click();
cy.dataCy('positiveNotify').should(
'contain',
'¡Pedido cargado en la cesta!'
);
});
});

View File

@ -79,6 +79,6 @@ Cypress.Commands.add('setSessionStorage', (key, value) => {
});
});
Cypress.Commands.add('clearDB', () => {
Cypress.Commands.add('resetDB', () => {
cy.exec('npm run resetDatabase');
});