0
1
Fork 0

Some changes and more tests

This commit is contained in:
William Buezas 2024-10-24 10:02:15 -03:00
parent 186ec60937
commit 0bec75b2d3
14 changed files with 134 additions and 26 deletions

View File

@ -13,7 +13,9 @@ module.exports = defineConfig({
video: false,
screenshotOnRunFailure: false,
setupNodeEvents(on, config) {
// implement node event listeners here
on('after:spec', (spec, results) => {
console.log('Finished running', spec.relative);
});
}
}
});

View File

@ -153,6 +153,7 @@ onMounted(async () => getImageCollections());
option-label="desc"
option-value="name"
:options="imageCollections"
data-testid="photoCollectionSelect"
/>
<QUploader
ref="fileUploaderRef"
@ -164,13 +165,19 @@ onMounted(async () => getImageCollections());
bordered
hide-upload-btn
@added="onFilesAdded"
data-testid="photoUploader"
>
<template #list="scope">
<QList v-if="addedFiles.length" separator>
<QList
v-if="addedFiles.length"
separator
data-testid="photoUploaderList"
>
<QItem
v-for="(file, index) in scope.files"
:key="file.__key"
class="flex full-width row items-center justify-center"
data-testid="photoUploaderItem"
>
<img
:src="file.__img.src"
@ -204,6 +211,7 @@ onMounted(async () => getImageCollections());
].icon
"
size="sm"
data-testid="photoUploaderItemsStatusIcon"
>
<QTooltip>
{{
@ -229,6 +237,7 @@ onMounted(async () => getImageCollections());
round
icon="delete"
@click="removeFile(file, index)"
data-testid="photoUploaderItemsDeleteBtn"
>
<QTooltip>{{ t('remove') }}</QTooltip>
</QBtn>
@ -248,6 +257,7 @@ onMounted(async () => getImageCollections());
no-caps
flat
@click="clearFiles()"
data-testid="photoUploaderClearBtn"
/>
<QBtn
:label="t('uploadFiles')"
@ -256,6 +266,7 @@ onMounted(async () => getImageCollections());
flat
:disable="!isSubmitable"
@click="onSubmit(data)"
data-testid="photoUploadSubmitBtn"
/>
</template>
</VnForm>

View File

@ -40,7 +40,11 @@ export default route(function (/* { store, ssrContext } */) {
Router.beforeEach((to, from, next) => {
const userStore = useUserStore();
if (!userStore.storage.getItem('token') && to.name !== 'login') {
if (
!userStore.storage.getItem('token') &&
to.name !== 'login' &&
!userStore.isGuest
) {
return next({ name: 'login' });
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -17,5 +17,6 @@ describe('User flow: Login, create a new order, add item to basket and go to con
cy.dataCy('basketToConfirmBtn').should('exist');
cy.dataCy('basketToConfirmBtn').click();
cy.url().should('contain', '/#/ecomerce/confirm');
cy.resetDB();
});
});

View File

@ -4,7 +4,7 @@ describe('NewsView', () => {
});
beforeEach(() => {
cy.loginFlow('developer');
cy.login('developer');
cy.visit('/#/news/news');
});

View File

@ -0,0 +1,83 @@
describe('Photo Uploader Component', () => {
beforeEach(() => {
cy.login('developer');
cy.visit('/#/admin/photos');
});
const uploadFile = fileName => {
cy.get('.q-uploader__input').selectFile(fileName);
};
it('should display the photo collection select', () => {
// Verificar que el select de colección esté presente
cy.dataCy('photoCollectionSelect').should('exist');
});
it('should allow selecting a photo collection', () => {
// Simular la selección de una colección de fotos
cy.selectOption('[data-testid="photoCollectionSelect"]', 'Enlace');
cy.getValue('[data-testid="photoCollectionSelect"]').should(
'equal',
'Enlace'
);
});
it('submit button should be disabled if no files are selected', () => {
cy.dataCy('photoUploadSubmitBtn').should('be.disabled');
});
it('should allow adding files', () => {
cy.dataCy('photoUploaderItem').should('not.exist');
uploadFile('src/test/cypress/fixtures/lowres.jpg');
cy.dataCy('photoUploaderItem').should('exist');
cy.dataCy('photoUploaderItem').should('have.length', 1);
});
it('should remove a file when delete button is clicked', () => {
uploadFile('src/test/cypress/fixtures/lowres.jpg');
cy.dataCy('photoUploaderItem').should('exist');
cy.dataCy('photoUploaderItemsDeleteBtn').click();
cy.dataCy('photoUploaderItem').should('not.exist');
});
it('should enable the upload button when files are pending', () => {
uploadFile('src/test/cypress/fixtures/lowres.jpg');
cy.dataCy('photoUploadSubmitBtn').should('not.be.disabled');
});
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'
);
});
it('should show the correct status icon', () => {
uploadFile('src/test/cypress/fixtures/lowres.jpg');
cy.dataCy('photoUploaderItemsStatusIcon').should('have.text', 'add');
cy.dataCy('photoUploadSubmitBtn').click();
cy.dataCy('photoUploaderItemsStatusIcon').should(
'have.text',
'cloud_done'
);
});
it('should clear all files when clear button is clicked', () => {
uploadFile('src/test/cypress/fixtures/lowres.jpg');
cy.dataCy('photoUploaderItem').should('exist');
cy.dataCy('photoUploaderClearBtn').click();
cy.dataCy('photoUploaderItem').should('not.exist');
});
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',
'Ocurrieron errores al subir alguna de las imágenes'
);
});
});

View File

@ -4,10 +4,6 @@ describe('UsersView', () => {
cy.visit('/#/admin/users');
});
afterEach(() => {
cy.logout();
});
it('should show empty state when entering the view', () => {
cy.dataCy('usersViewList').should('contain', 'Sin datos');
});

View File

@ -1,16 +1,17 @@
describe('CatalogView', () => {
beforeEach(() => {
// 1- Loguear usuario
cy.login('employee');
// 2- Crear una orden
cy.createOrderReceiveFlow();
});
it('Adds item to basket', () => cy.addItemToBasketFlow());
it('Goes to basket', () => {
cy.dataCy('catalogGoToBasketButton').should('exist');
cy.dataCy('catalogGoToBasketButton').click();
cy.url().should('contain', '/#/ecomerce/basket');
});
// beforeEach(() => {
// // 1- Loguear usuario
// cy.login('developer');
// // 2- Crear una orden
// cy.resetDB();
// cy.createOrderReceiveFlow();
// });
// it('Adds item to basket', () => {
// cy.addItemToBasketFlow();
// });
// it('Goes to basket', () => {
// cy.dataCy('catalogGoToBasketButton').should('exist');
// cy.dataCy('catalogGoToBasketButton').click();
// cy.url().should('contain', '/#/ecomerce/basket');
// });
});

View File

@ -1,4 +1,8 @@
describe('CheckoutStepper', () => {
before(() => {
cy.resetDB();
});
beforeEach(() => {
cy.login('employee');
});

View File

@ -1,5 +1,11 @@
describe('Changes user nickname', () => {
beforeEach(() => {
cy.login('brucewayne');
cy.visit('/#/account/conf');
});
it('success', () => {
cy.changeUserNickname('Bruce Wayne', 'New test nickname');
cy.resetDB();
});
});

View File

@ -8,15 +8,15 @@ Cypress.Commands.add('login', user => {
password: 'nightmare'
}
}).then(response => {
window.localStorage.setItem('token', response.body.token);
window.sessionStorage.setItem('token', response.body.token);
cy.request({
method: 'GET',
url: '/api/VnUsers/ShareToken',
headers: {
Authorization: window.localStorage.getItem('token')
Authorization: window.sessionStorage.getItem('token')
}
}).then(({ body }) => {
window.localStorage.setItem(
window.sessionStorage.setItem(
'tokenMultimedia',
body.multimediaToken.id
);

View File

@ -16,7 +16,7 @@ describe('PendingOrders', () => {
cy.dataCy('confirmDialogButton').click();
};
// it('when confirm payment redirects to payment site', () => {
// it('confirm payment redirects to payment site', () => {
// makePayment('100');
// TODO: Ver como hacer para verificar redirección a sitio externo
// });