0
1
Fork 0

Add news view tests

This commit is contained in:
William Buezas 2024-10-22 14:49:29 -03:00
parent cb1542937a
commit 186ec60937
5 changed files with 50 additions and 4 deletions

View File

@ -240,6 +240,7 @@ defineExpose({
flat
:disabled="!showBottomActions && !updatedColumns.length"
@click="submit()"
data-testid="formDefaultSaveButton"
>
<QTooltip>{{ t('save') }}</QTooltip>
</QBtn>

View File

@ -106,6 +106,7 @@ onMounted(async () => {
v-model="data.title"
:label="t('title')"
:clearable="false"
data-testid="newsTitleInput"
/>
<div class="row justify-between q-gutter-x-md">
<VnSelect
@ -115,12 +116,14 @@ onMounted(async () => {
option-value="name"
:options="newsTags"
class="col"
data-testid="newsTagSelect"
/>
<VnInput
v-model="data.priority"
:label="t('priority')"
:clearable="false"
class="col"
data-testid="newsPriorityInput"
/>
</div>
<QEditor

View File

@ -64,6 +64,7 @@ onMounted(async () => getNews());
:to="{ name: 'adminNewsDetails' }"
rounded
no-caps
data-testid="addNewBtn"
>
<QTooltip>{{ t('addNew') }}</QTooltip>
</QBtn>
@ -74,6 +75,7 @@ onMounted(async () => getNews());
v-for="(newsItem, index) in news"
:key="index"
:to="{ name: 'adminNewsDetails', params: { id: newsItem.id } }"
data-testid="newsCard"
>
<template #prepend>
<VnImg
@ -106,6 +108,7 @@ onMounted(async () => getNews());
() => deleteNew(newsItem.id, index)
)
"
data-testid="deleteNewBtn"
>
<QTooltip>{{ t('remove') }}</QTooltip>
</QBtn>

View File

@ -0,0 +1,43 @@
describe('NewsView', () => {
before(() => {
cy.resetDB();
});
beforeEach(() => {
cy.loginFlow('developer');
cy.visit('/#/news/news');
});
it('should delete a new', () => {
cy.dataCy('newsCard').should('exist');
cy.dataCy('newsCard').should('have.length', 3);
cy.dataCy('newsCard')
.first()
.within(() => {
cy.dataCy('deleteNewBtn').click();
});
cy.dataCy('confirmDialogButton').should('exist');
cy.dataCy('confirmDialogButton').click();
cy.dataCy('positiveNotify').should('contain', 'Datos guardados');
cy.dataCy('newsCard').should('have.length', 2);
});
it('should create a new', () => {
cy.dataCy('addNewBtn').should('exist');
cy.dataCy('addNewBtn').click();
cy.dataCy('formDefaultSaveButton').should('exist');
cy.dataCy('formDefaultSaveButton').should('be.disabled');
cy.dataCy('newsTitleInput').should('exist');
cy.get('input[data-testid="newsTitleInput"]').type('Test new');
cy.dataCy('newsTagSelect').should('exist');
cy.selectOption('[data-testid="newsTagSelect"]', 'Curso');
cy.dataCy('newsPriorityInput').should('exist');
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.dataCy('newsCard').should('exist');
cy.dataCy('newsCard').should('contain', 'Test new');
cy.dataCy('newsCard').should('contain', '2');
});
});

View File

@ -1,8 +1,4 @@
describe('PendingOrders', () => {
before(() => {
// cy.resetDB();
});
beforeEach(() => {
cy.login('brucewayne');
cy.visit('/#/ecomerce/orders');