Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Aug 17, 2024
1 parent 9762422 commit 67f12be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/views/ProductDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</p>
<OpenFoodFactsAddMenu :productCode="productId" />
</v-alert>
<v-alert v-else-if="!categoryFound" data-name="category-not-found-alert" type="error" variant="outlined" icon="mdi-alert">
<v-alert v-else-if="categoryNotFound" data-name="category-not-found-alert" type="error" variant="outlined" icon="mdi-alert">
<i>{{ $t('ProductDetail.CategoryNotFound') }}</i>
</v-alert>
</v-col>
Expand Down Expand Up @@ -109,10 +109,13 @@ export default {
return !this.productIsCategory && this.product && !this.product.source
},
categoryFound() {
return this.productIsCategory && this.category && !this.category.status
return this.category && !this.category.status
},
categoryNotFound() {
return this.productIsCategory && !this.categoryFound
},
productOrCategoryNotFound() {
return !this.loading && (this.productNotFound || !this.categoryFound)
return !this.loading && (this.productNotFound || this.categoryNotFound)
},
getPricesParams() {
let defaultParams = { [this.productIsCategory ? 'category_tag' : 'product_code']: this.productId, order_by: `${this.currentOrder}`, page: this.productPricePage }
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('Basic tests', () => {
cy.get('#price-count').contains('1')
cy.get('[data-name="product-missing-chip"]').should('have.length', 0)
cy.get('[data-name="product-not-found-alert"]').should('have.length', 0)
cy.get('[data-name="category-not-found-alert"]').should('have.length', 0)
cy.get('[data-name="price-card"]').should('have.length', 1)
cy.contains('Load more').should('not.exist')
})
Expand All @@ -62,6 +63,7 @@ describe('Basic tests', () => {
cy.get('#price-count').contains('0')
cy.get('[data-name="product-missing-chip"]').should('have.length', 1)
cy.get('[data-name="product-not-found-alert"]').should('have.length', 1)
cy.get('[data-name="category-not-found-alert"]').should('have.length', 0)
cy.get('[data-name="price-card"]').should('have.length', 0)
cy.contains('Load more').should('not.exist')
})
Expand All @@ -72,6 +74,7 @@ describe('Basic tests', () => {
cy.get('.v-card-title').contains('Pitted apricot')
cy.get('#price-count').contains('2')
cy.get('[data-name="product-missing-chip"]').should('have.length', 0)
cy.get('[data-name="product-not-found-alert"]').should('have.length', 0)
cy.get('[data-name="category-not-found-alert"]').should('have.length', 0)
cy.get('[data-name="price-card"]').should('have.length', 2)
cy.contains('Load more').should('not.exist')
Expand All @@ -83,6 +86,7 @@ describe('Basic tests', () => {
cy.get('.v-card-title').contains('en:aaaaaaaaaaaa')
cy.get('#price-count').contains('0')
// cy.get('[data-name="product-missing-chip"]').should('have.length', 1)
cy.get('[data-name="product-not-found-alert"]').should('have.length', 0)
cy.get('[data-name="category-not-found-alert"]').should('have.length', 1)
cy.get('[data-name="price-card"]').should('have.length', 0)
cy.contains('Load more').should('not.exist')
Expand Down

0 comments on commit 67f12be

Please sign in to comment.