@shopbite-de/storefront 1.7.6 → 1.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
2
|
+
import type { NavigationMenuItem } from "@nuxt/ui";
|
|
3
|
+
|
|
4
|
+
const route = useRoute();
|
|
5
|
+
|
|
6
|
+
const { data: navigationData } = useAsyncData("navigation", () =>
|
|
7
|
+
queryCollection("navigation").first(),
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const navi = computed<NavigationMenuItem[]>(() => {
|
|
11
|
+
if (!navigationData.value?.main) return [];
|
|
12
|
+
|
|
13
|
+
return navigationData.value.main.map((item) => ({
|
|
14
|
+
label: item.label,
|
|
15
|
+
icon: item.icon,
|
|
16
|
+
to: item.to,
|
|
17
|
+
target: item.target,
|
|
18
|
+
active:
|
|
19
|
+
item.to === "/"
|
|
20
|
+
? route.path.length === 1
|
|
21
|
+
: route.path.startsWith(item.to),
|
|
22
|
+
}));
|
|
23
|
+
});
|
|
3
24
|
</script>
|
|
4
25
|
|
|
5
26
|
<template>
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
2
|
+
import type { NavigationMenuItem } from "@nuxt/ui";
|
|
3
|
+
|
|
4
|
+
const route = useRoute();
|
|
5
|
+
|
|
6
|
+
const { data: navigationData } = await useAsyncData("navigation", () =>
|
|
7
|
+
queryCollection("navigation").first(),
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const navi = computed<NavigationMenuItem[]>(() => {
|
|
11
|
+
if (!navigationData.value?.main) return [];
|
|
12
|
+
|
|
13
|
+
return navigationData.value.main.map((item) => ({
|
|
14
|
+
label: item.label,
|
|
15
|
+
icon: item.icon,
|
|
16
|
+
to: item.to,
|
|
17
|
+
target: item.target,
|
|
18
|
+
active:
|
|
19
|
+
item.to === "/"
|
|
20
|
+
? route.path.length === 1
|
|
21
|
+
: route.path.startsWith(item.to),
|
|
22
|
+
}));
|
|
23
|
+
});
|
|
24
|
+
|
|
3
25
|
const loginSlide = ref(false);
|
|
4
26
|
</script>
|
|
5
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopbite-de/storefront",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.8",
|
|
4
4
|
"main": "nuxt.config.ts",
|
|
5
5
|
"description": "Shopware storefront for food delivery shops",
|
|
6
6
|
"keywords": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@heroicons/vue": "^2.2.0",
|
|
19
19
|
"@iconify-json/lucide": "^1.2.73",
|
|
20
20
|
"@iconify-json/simple-icons": "^1.2.59",
|
|
21
|
-
"@nuxt/content": "^3.
|
|
21
|
+
"@nuxt/content": "^3.11.0",
|
|
22
22
|
"@nuxt/image": "^2.0.0",
|
|
23
23
|
"@nuxt/scripts": "0.13.2",
|
|
24
24
|
"@nuxt/ui": "^4.1.0",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { NavigationMenuItem } from "@nuxt/ui";
|
|
2
|
-
|
|
3
|
-
export const useHeaderNavigation = async () => {
|
|
4
|
-
const route = useRoute();
|
|
5
|
-
|
|
6
|
-
const { data: navigationData } = await useAsyncData("navigation", () =>
|
|
7
|
-
queryCollection("navigation").first(),
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
const navi = computed<NavigationMenuItem[]>(() => {
|
|
11
|
-
if (!navigationData.value?.main) return [];
|
|
12
|
-
|
|
13
|
-
return navigationData.value.main.map((item) => ({
|
|
14
|
-
label: item.label,
|
|
15
|
-
icon: item.icon,
|
|
16
|
-
to: item.to,
|
|
17
|
-
target: item.target,
|
|
18
|
-
active:
|
|
19
|
-
item.to === "/"
|
|
20
|
-
? route.path.length === 1
|
|
21
|
-
: route.path.startsWith(item.to),
|
|
22
|
-
}));
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
navigationData,
|
|
27
|
-
navi,
|
|
28
|
-
};
|
|
29
|
-
};
|
package/test/nuxt/Header.test.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from "vitest";
|
|
2
|
-
import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
3
|
-
import Header from "~/components/Header.vue";
|
|
4
|
-
import { ref } from "vue";
|
|
5
|
-
|
|
6
|
-
mockNuxtImport("useHeaderNavigation", () => () => ({
|
|
7
|
-
navi: ref([{ label: "Home", to: "/" }]),
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
mockNuxtImport("useUser", () => () => ({
|
|
11
|
-
isLoggedIn: ref(false),
|
|
12
|
-
isGuestSession: ref(false),
|
|
13
|
-
user: ref(null),
|
|
14
|
-
logout: vi.fn(),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
mockNuxtImport("useShopBiteConfig", () => () => ({
|
|
18
|
-
isCheckoutEnabled: ref(true),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
mockNuxtImport("useCart", () => () => ({
|
|
22
|
-
count: ref(0),
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
mockNuxtImport("useToast", () => () => ({
|
|
26
|
-
add: vi.fn(),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
mockNuxtImport("useRuntimeConfig", () => () => ({
|
|
30
|
-
app: { baseURL: "/" },
|
|
31
|
-
public: { site: { name: "ShopBite" } },
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
// Mock Nuxt Content queryCollection
|
|
35
|
-
mockNuxtImport("queryCollection", () => (collection: string) => ({
|
|
36
|
-
first: () =>
|
|
37
|
-
Promise.resolve({
|
|
38
|
-
account: {
|
|
39
|
-
loggedIn: [],
|
|
40
|
-
loggedOut: [],
|
|
41
|
-
},
|
|
42
|
-
}),
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
describe("Header", () => {
|
|
46
|
-
it("renders structure correctly", async () => {
|
|
47
|
-
const component = await mountSuspended(Header);
|
|
48
|
-
|
|
49
|
-
const srOnlySiteName = component.find(".sr-only");
|
|
50
|
-
expect(srOnlySiteName.exists()).toBe(true);
|
|
51
|
-
expect(srOnlySiteName.text()).toBe("ShopBite");
|
|
52
|
-
expect(component.html()).toContain("i-lucide:phone");
|
|
53
|
-
expect(component.html()).toContain("i-lucide:shopping-cart");
|
|
54
|
-
|
|
55
|
-
const navMenu = component.findComponent({ name: "UNavigationMenu" });
|
|
56
|
-
expect(navMenu.exists()).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("renders login slideover", async () => {
|
|
60
|
-
const component = await mountSuspended(Header);
|
|
61
|
-
|
|
62
|
-
// USlideover might not be directly in HTML if it uses teleport and is closed
|
|
63
|
-
const slideover = component.findComponent({ name: "USlideover" });
|
|
64
|
-
expect(slideover.exists()).toBe(true);
|
|
65
|
-
expect(slideover.props("title")).toBe("Konto");
|
|
66
|
-
});
|
|
67
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
3
|
-
import HeaderBody from "~/components/Header/Body.vue";
|
|
4
|
-
import { ref } from "vue";
|
|
5
|
-
|
|
6
|
-
const mockNavi = [
|
|
7
|
-
{ label: "Home", to: "/", icon: "i-lucide-home" },
|
|
8
|
-
{ label: "Products", to: "/products", icon: "i-lucide-package" },
|
|
9
|
-
];
|
|
10
|
-
|
|
11
|
-
mockNuxtImport("useHeaderNavigation", () => () => ({
|
|
12
|
-
navi: ref(mockNavi),
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
describe("HeaderBody", () => {
|
|
16
|
-
it("renders navigation menu with correct items", async () => {
|
|
17
|
-
const component = await mountSuspended(HeaderBody);
|
|
18
|
-
const navMenu = component.findComponent({ name: "UNavigationMenu" });
|
|
19
|
-
|
|
20
|
-
expect(navMenu.exists()).toBe(true);
|
|
21
|
-
expect(navMenu.props("items")).toEqual(mockNavi);
|
|
22
|
-
expect(navMenu.props("orientation")).toBe("vertical");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("renders SalesChannelSwitch", async () => {
|
|
26
|
-
const component = await mountSuspended(HeaderBody);
|
|
27
|
-
const switchComponent = component.findComponent({
|
|
28
|
-
name: "SalesChannelSwitch",
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
expect(switchComponent.exists()).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
});
|