Skip to content

Commit d6c6f62

Browse files
committed
fix e2e, fix button to nuxtlink
1 parent 14dcac4 commit d6c6f62

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

app/components/ui/AppButton.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script setup lang="ts">
2+
import { NuxtLink } from '#components'
3+
24
interface Props {
35
variant?: 'primary' | 'glass' | 'text'
46
to?: string
@@ -18,7 +20,7 @@ withDefaults(defineProps<Props>(), {
1820

1921
<template>
2022
<component
21-
:is="to ? 'NuxtLink' : 'button'"
23+
:is="to ? NuxtLink : 'button'"
2224
:to="to"
2325
:type="!to ? type : undefined"
2426
:disabled="disabled || loading"

app/pages/products/index.vue

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ interface Product {
1313
rating: number
1414
}
1515
16+
interface Category {
17+
slug: string
18+
name: string
19+
url: string
20+
}
21+
1622
const products = ref<Product[]>([])
17-
const categories = ref<string[]>([])
23+
const categories = ref<Category[]>([])
1824
const selectedCategory = ref('')
1925
const searchQuery = ref('')
2026
const limit = 12
@@ -29,15 +35,15 @@ if (initialData.value) {
2935
skip.value = 12
3036
}
3137
32-
const { data: categoryData } = await useFetch<string[]>('https://dummyjson.com/products/categories')
38+
const { data: categoryData } = await useFetch<Category[]>('https://dummyjson.com/products/categories')
3339
if (categoryData.value) {
3440
categories.value = categoryData.value
3541
}
3642
3743
const fetchMore = async () => {
3844
if (loading.value || !hasMore.value) return
3945
loading.value = true
40-
46+
4147
let url = `https://dummyjson.com/products?limit=${limit}&skip=${skip.value}`
4248
if (selectedCategory.value) {
4349
url = `https://dummyjson.com/products/category/${selectedCategory.value}?limit=${limit}&skip=${skip.value}`
@@ -62,7 +68,7 @@ const handleFilter = async () => {
6268
}
6369
6470
// Intersection Observer for infinite scroll
65-
const observerTarget = ref(null)
71+
const observerTarget = ref<HTMLElement | null>(null)
6672
onMounted(() => {
6773
const observer = new IntersectionObserver((entries) => {
6874
if (entries[0].isIntersecting) {
@@ -104,9 +110,12 @@ useSeoMeta({
104110
class="input-field bg-surface-container-lowest border-none rounded-lg px-4 py-2 text-white/70 focus:ring-2 focus:ring-secondary/50 h-full min-h-[42px] appearance-none cursor-pointer"
105111
>
106112
<option value="">Все категории</option>
107-
<option v-for="cat in categories" :key="cat" :value="cat">
108-
{{ cat }}
109-
<!-- {{ cat.charAt(0).toUpperCase() + cat.slice(1) }} -->
113+
<option
114+
v-for="cat in categories"
115+
:key="cat.slug"
116+
:value="cat.slug"
117+
>
118+
{{ cat.name }}
110119
</option>
111120
</select>
112121
</div>
@@ -130,7 +139,7 @@ useSeoMeta({
130139
${{ product.price }}
131140
</div>
132141
</div>
133-
142+
134143
<div class="flex-grow flex flex-col gap-2">
135144
<div class="text-xs text-white/40 uppercase tracking-widest">{{ product.category }}</div>
136145
<h3 class="text-lg font-heading font-bold line-clamp-1 group-hover:text-primary transition-colors">

cypress/e2e/navigation.cy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
describe('Main Navigation and User Scenarios', () => {
22
beforeEach(() => {
3+
cy.viewport(1280, 800)
34
cy.visit('/')
45
})
56

0 commit comments

Comments
 (0)