Create check notify commands
gitea/hedera-web/pipeline/pr-4922-vueMigration This commit looks good Details

This commit is contained in:
William Buezas 2024-10-24 14:30:25 -03:00
parent e4bc14ef3b
commit a142ceb151
10 changed files with 22 additions and 33 deletions

View File

@ -17,7 +17,7 @@ describe('NewsView', () => {
cy.dataCy('deleteNewBtn').click();
});
cy.setConfirmDialog();
cy.dataCy('positiveNotify').should('contain', 'Datos guardados');
cy.checkNotify('positive', 'Datos guardados');
cy.dataCy('newsCard').should('have.length', 2);
});
@ -34,7 +34,7 @@ describe('NewsView', () => {
cy.get('input[data-testid="newsPriorityInput"]').type('2');
cy.dataCy('formDefaultSaveButton').should('not.be.disabled');
cy.dataCy('formDefaultSaveButton').click();
cy.dataCy('positiveNotify').should('contain', 'Datos guardados');
cy.checkNotify('positive', 'Datos guardados');
cy.dataCy('newsCard').should('exist');
cy.dataCy('newsCard').should('contain', 'Test new');
cy.dataCy('newsCard').should('contain', '2');

View File

@ -49,10 +49,7 @@ describe('Photo Uploader Component', () => {
it('should upload files when submit button is clicked', () => {
uploadFile('src/test/cypress/fixtures/lowres.jpg');
cy.dataCy('photoUploadSubmitBtn').click();
cy.dataCy('positiveNotify').should(
'contain',
'Imágenes subidas correctamente'
);
cy.checkNotify('positive', 'Imágenes subidas correctamente');
});
it('should show the correct status icon', () => {
@ -75,8 +72,8 @@ describe('Photo Uploader Component', () => {
it('should display error notification if an upload fails', () => {
uploadFile('src/test/cypress/fixtures/low-res.jpg');
cy.dataCy('photoUploadSubmitBtn').click();
cy.dataCy('negativeNotify').should(
'contain',
cy.checkNotify(
'negative',
'Ocurrieron errores al subir alguna de las imágenes'
);
});

View File

@ -18,5 +18,5 @@ Cypress.Commands.add('addItemToBasketFlow', () => {
cy.get('[data-testid="addItemQuantityButton"]:first').click();
cy.dataCy('catalogAddToBasketButton').should('exist');
cy.dataCy('catalogAddToBasketButton').click();
cy.dataCy('positiveNotify').should('contain', 'Añadido');
cy.checkNotify('positive', 'Añadido');
});

View File

@ -40,10 +40,7 @@ Cypress.Commands.add('createOrderReceiveFlow', () => {
cy.dataCy('pendingOrdersNewOrder').should('exist');
cy.dataCy('pendingOrdersNewOrder').click();
cy.createOrderReceive();
cy.dataCy('positiveNotify').should(
'contain',
'¡Pedido cargado en la cesta!'
);
cy.checkNotify('positive', '¡Pedido cargado en la cesta!');
});
Cypress.Commands.add('createOrderPickup', () => {
@ -84,8 +81,5 @@ Cypress.Commands.add('createOrderPickupFlow', (changeLanguage = false) => {
cy.dataCy('pendingOrdersNewOrder').should('exist');
cy.dataCy('pendingOrdersNewOrder').click();
cy.createOrderPickup();
cy.dataCy('positiveNotify').should(
'contain',
'¡Pedido cargado en la cesta!'
);
cy.checkNotify('positive', '¡Pedido cargado en la cesta!');
});

View File

@ -14,14 +14,11 @@ describe('CheckoutStepper', () => {
it('Modifies an order', () => {
cy.createOrderReceiveFlow();
cy.dataCy('orderModifyButton').click();
cy.dataCy('warningNotify').should(
'include.text',
cy.checkNotify(
'warning',
'Recuerda que si vuelves a configurar el pedido los precios o cantidades de tus artículos podrían cambiar'
);
cy.createOrderPickup(false);
cy.dataCy('positiveNotify').should(
'include.text',
'Pedido actualizado'
);
cy.checkNotify('positive', 'Pedido actualizado');
});
});

View File

@ -8,5 +8,5 @@ Cypress.Commands.add('changeUserNickname', (oldNickname, newNickname) => {
cy.get(nicknameInput).clear();
cy.get(nicknameInput).type(newNickname);
cy.get(nicknameInput).blur();
cy.dataCy('positiveNotify').should('contain', 'Datos guardados');
cy.checkNotify('positive', 'Datos guardados');
});

View File

@ -25,14 +25,14 @@ describe('Login Tests', () => {
cy.dataCy('loginUserInput').type('incorrectUser');
cy.dataCy('loginPasswordInput').type('nightmare');
cy.get('button[type="submit"]').click();
cy.dataCy('negativeNotify').should('contain', 'login failed');
cy.checkNotify('negative', 'login failed');
});
it('should fail to log in using wrong password', () => {
cy.dataCy('loginUserInput').type('incorrectUser');
cy.dataCy('loginPasswordInput').type('nightmare');
cy.get('button[type="submit"]').click();
cy.dataCy('negativeNotify').should('contain', 'login failed');
cy.checkNotify('negative', 'login failed');
});
it('should log in', () => {

View File

@ -23,8 +23,8 @@ describe('PendingOrders', () => {
it('fails payment if pay amount is 0', () => {
cy.visit('/#/ecomerce/orders');
makePayment(0);
cy.dataCy('negativeNotify').should(
'contain',
cy.checkNotify(
'negative',
'La cantidad debe ser un número positivo e inferior o igual al importe pendiente'
);
});

View File

@ -41,7 +41,7 @@ describe('PendingOrders', () => {
cy.dataCy('pendingOrderCard').should('have.length', 1);
cy.dataCy('pendingOrderCardDelete').click();
cy.setConfirmDialog();
cy.dataCy('positiveNotify').should('contain', 'Datos guardados');
cy.checkNotify('positive', 'Datos guardados');
checkEmptyList();
});
@ -50,9 +50,6 @@ describe('PendingOrders', () => {
cy.visit('/#/ecomerce/pending');
cy.dataCy('addOrderToBasket').should('exist');
cy.dataCy('addOrderToBasket').click();
cy.dataCy('positiveNotify').should(
'contain',
'¡Pedido cargado en la cesta!'
);
cy.checkNotify('positive', '¡Pedido cargado en la cesta!');
});
});

View File

@ -87,3 +87,7 @@ Cypress.Commands.add('setConfirmDialog', () => {
cy.dataCy('confirmDialogButton').should('exist');
cy.dataCy('confirmDialogButton').click();
});
Cypress.Commands.add('checkNotify', (status, content) => {
cy.dataCy(`${status}Notify`).should('contain', content);
});