@usequeek/theme-kit 0.1.15 → 0.1.16

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usequeek/theme-kit",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "The framework a Queek storefront theme is built against.",
@@ -0,0 +1,48 @@
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
+ import { fetchOrders } from '../api/orders';
3
+
4
+ /**
5
+ * `GET store/orders` answers the ONE storefront list envelope (pagination
6
+ * Slice 4b, founder 28/9/26): `has_more` + `next_cursor` top-level, no
7
+ * `links`, no paginator `meta`. The kit reads the page it asked for.
8
+ */
9
+ describe('fetchOrders walk state', () => {
10
+ afterEach(() => vi.unstubAllGlobals());
11
+
12
+ it('asks /client/store/orders by page and returns the top-level walk state', async () => {
13
+ const fetchMock = vi.fn(async () => ({
14
+ ok: true,
15
+ json: async () => ({
16
+ status: 'success',
17
+ message: 'Orders retrieved',
18
+ data: [{ id: 'o1', order_no: 'Q-1' }],
19
+ meta: { currency: { code: 'NGN' } },
20
+ has_more: true,
21
+ next_cursor: 'eyJ2IjoxfQ',
22
+ }),
23
+ }));
24
+ vi.stubGlobal('fetch', fetchMock);
25
+
26
+ const page = await fetchOrders('kili-foods', 2, 'ongoing');
27
+
28
+ const url = String((fetchMock.mock.calls[0] as unknown[])[0]);
29
+ expect(url).toContain('/client/store/orders');
30
+ expect(url).toContain('page=2');
31
+ expect(url).toContain('status=ongoing');
32
+ expect(page.has_more).toBe(true);
33
+ expect(page.next_cursor).toBe('eyJ2IjoxfQ');
34
+ expect(page).not.toHaveProperty('links');
35
+ expect(page.data).toHaveLength(1);
36
+ });
37
+
38
+ it('never sends status=all (the unfiltered list)', async () => {
39
+ const fetchMock = vi.fn(async () => ({ ok: true, json: async () => ({ data: [], has_more: false, next_cursor: null }) }));
40
+ vi.stubGlobal('fetch', fetchMock);
41
+
42
+ const page = await fetchOrders('kili-foods', 1, 'all');
43
+
44
+ expect(String((fetchMock.mock.calls[0] as unknown[])[0])).not.toContain('status=');
45
+ expect(page.has_more).toBe(false);
46
+ expect(page.next_cursor).toBeNull();
47
+ });
48
+ });
package/types/order.ts CHANGED
@@ -85,16 +85,18 @@ export interface OrderDetail {
85
85
  table?: { id: string; name: string; section?: string | null } | null;
86
86
  }
87
87
 
88
- export interface OrderPageMeta {
89
- current_page: number;
90
- last_page: number;
91
- per_page: number;
92
- total: number;
93
- }
94
-
88
+ /**
89
+ * `GET store/orders` — the ONE storefront list envelope: the walk state rides
90
+ * top-level. A page-mode reader (`?page=N`) labels the page it asked for and
91
+ * loads the next while `has_more` is true; a cursor reader passes
92
+ * `next_cursor` back as `starting_after`. No totals, page counts or page URLs
93
+ * are sent; `meta` is context only (e.g. `currency`).
94
+ */
95
95
  export interface OrderListResponse {
96
96
  data: OrderListItem[];
97
- meta: OrderPageMeta;
97
+ has_more: boolean;
98
+ next_cursor: string | null;
99
+ meta?: Record<string, unknown>;
98
100
  }
99
101
 
100
102
  export interface CheckoutPayload {