@shopbite-de/storefront 1.5.1 → 1.5.3

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.
@@ -84,8 +84,9 @@ const cartQuickViewOpen = ref(false);
84
84
  <template #title>
85
85
  <NuxtLink to="/" class="-m-1.5 p-1.5">
86
86
  <span class="sr-only">{{ siteName }}</span>
87
- <NuxtImg
88
- src="/light/Logo.svg"
87
+ <UColorModeImage
88
+ light="/light/Logo.png"
89
+ dark="/dark/Logo.png"
89
90
  class="h-12 w-auto"
90
91
  />
91
92
  </NuxtLink>
@@ -22,7 +22,7 @@ export function useBusinessHours() {
22
22
  const getServiceIntervals = (date: Date): Array<ServiceInterval> => {
23
23
  if (!data.value) return [];
24
24
 
25
- const dayOfWeek = date.getDay();
25
+ const dayOfWeek = date.getDay() === 0 ? 7 : date.getDay();
26
26
  const dayBusinessHours = data.value.filter(
27
27
  (bh) => bh.dayOfWeek === dayOfWeek,
28
28
  );
@@ -38,6 +38,7 @@ export function useBusinessHours() {
38
38
  end: setTime(date, endH, endM),
39
39
  };
40
40
  })
41
+ .sort((a, b) => a.start.getTime() - b.start.getTime())
41
42
  .filter((interval): interval is ServiceInterval => interval !== null);
42
43
  };
43
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopbite-de/storefront",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "main": "nuxt.config.ts",
5
5
  "description": "Shopware storefront for food delivery shops",
6
6
  "keywords": [
Binary file
Binary file
@@ -18,6 +18,7 @@ mockNuxtImport("useAsyncData", () => {
18
18
  const mockBusinessHoursData = [
19
19
  { dayOfWeek: 1, openingTime: "11:30", closingTime: "14:30" },
20
20
  { dayOfWeek: 1, openingTime: "17:30", closingTime: "23:00" },
21
+ { dayOfWeek: 7, openingTime: "17:30", closingTime: "23:00" },
21
22
  ];
22
23
 
23
24
  mockNuxtImport("useShopwareContext", () => () => ({
@@ -55,4 +56,51 @@ describe("useBusinessHours", () => {
55
56
  isClosedHoliday.mockReturnValue(true);
56
57
  expect(isStoreOpen(openTime, isClosedHoliday)).toBe(false);
57
58
  });
59
+
60
+ it("should handle Sunday (day 7) correctly", async () => {
61
+ const { isStoreOpen, refresh } = useBusinessHours();
62
+ await refresh();
63
+
64
+ const isClosedHoliday = vi.fn().mockReturnValue(false);
65
+
66
+ // 2026-01-04 is a Sunday
67
+ const sundayOpenTime = new Date("2026-01-04T18:00:00");
68
+ expect(isStoreOpen(sundayOpenTime, isClosedHoliday)).toBe(true);
69
+
70
+ const sundayClosedTime = new Date("2026-01-04T12:00:00");
71
+ expect(isStoreOpen(sundayClosedTime, isClosedHoliday)).toBe(false);
72
+ });
73
+
74
+ it("should return correct next opening time", async () => {
75
+ const { getNextOpeningTime, refresh } = useBusinessHours();
76
+ await refresh();
77
+
78
+ const isClosedHoliday = vi.fn().mockReturnValue(false);
79
+
80
+ // Sunday at 12:00 -> should open at 17:30 today
81
+ const sundayNoon = ref(new Date("2026-01-04T12:00:00"));
82
+ expect(getNextOpeningTime(sundayNoon, isClosedHoliday)).toBe("17:30 Uhr");
83
+
84
+ // Sunday at 23:30 -> should open tomorrow (Monday) at 11:30
85
+ const sundayNight = ref(new Date("2026-01-04T23:30:00"));
86
+ expect(getNextOpeningTime(sundayNight, isClosedHoliday)).toBe(
87
+ "morgen um 11:30 Uhr",
88
+ );
89
+ });
90
+
91
+ it("should sort intervals correctly", async () => {
92
+ const { getServiceIntervals, refresh } = useBusinessHours();
93
+ await refresh();
94
+
95
+ // Monday
96
+ const monday = new Date("2023-10-23T10:00:00");
97
+ const intervals = getServiceIntervals(monday);
98
+
99
+ expect(intervals).toHaveLength(2);
100
+ expect(intervals[0].start.getHours()).toBe(11);
101
+ expect(intervals[1].start.getHours()).toBe(17);
102
+ expect(intervals[0].start.getTime()).toBeLessThan(
103
+ intervals[1].start.getTime(),
104
+ );
105
+ });
58
106
  });