@selfhelp/shared 1.19.0 → 1.21.0

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.
@@ -0,0 +1,63 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ import type { INavigationMenu, INavigationMenuItem, TNavigationMenuKey } from './navigationPayload';
6
+
7
+ function flattenItems(items: INavigationMenuItem[]): INavigationMenuItem[] {
8
+ const out: INavigationMenuItem[] = [];
9
+ for (const item of items) {
10
+ out.push(item);
11
+ if (item.children?.length) {
12
+ out.push(...flattenItems(item.children));
13
+ }
14
+ }
15
+ return out;
16
+ }
17
+
18
+ export function collectPageIdsFromMenuItems(items: INavigationMenuItem[]): Set<number> {
19
+ const ids = new Set<number>();
20
+ for (const item of flattenItems(items)) {
21
+ if (item.page?.id != null) {
22
+ ids.add(item.page.id);
23
+ }
24
+ }
25
+ return ids;
26
+ }
27
+
28
+ export function isPageInMenuTree(items: INavigationMenuItem[], pageId: number): boolean {
29
+ return collectPageIdsFromMenuItems(items).has(pageId);
30
+ }
31
+
32
+ export function isPageInResolvedMenus(
33
+ menus: Partial<Record<TNavigationMenuKey, INavigationMenu>>,
34
+ menuKeys: TNavigationMenuKey[],
35
+ pageId: number,
36
+ ): boolean {
37
+ for (const key of menuKeys) {
38
+ const menu = menus[key];
39
+ if (menu && isPageInMenuTree(menu.items, pageId)) {
40
+ return true;
41
+ }
42
+ }
43
+ return false;
44
+ }
45
+
46
+ export function isOnAnyMobileMenu(
47
+ menus: Partial<Record<TNavigationMenuKey, INavigationMenu>>,
48
+ pageId: number,
49
+ ): boolean {
50
+ return isPageInResolvedMenus(menus, ['mobile_drawer', 'mobile_bottom_tabs'], pageId);
51
+ }
52
+
53
+ export function findMenuItemByPageId(
54
+ items: INavigationMenuItem[],
55
+ pageId: number,
56
+ ): INavigationMenuItem | null {
57
+ for (const item of flattenItems(items)) {
58
+ if (item.page?.id === pageId) {
59
+ return item;
60
+ }
61
+ }
62
+ return null;
63
+ }
@@ -0,0 +1,68 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ import type { INavigationMenuItem, INavigationPayload } from './navigationPayload';
6
+ import { flattenMenuItems } from './menuVisibility';
7
+ import { getNavigationItemHref, getNavigationItemLabel } from './navLinks';
8
+
9
+ export interface IMenuSearchHit {
10
+ page_id: number;
11
+ keyword: string;
12
+ url: string | null;
13
+ title: string;
14
+ }
15
+
16
+ function haystacksForItem(item: INavigationMenuItem): string[] {
17
+ const page = item.page;
18
+ const label = getNavigationItemLabel(item);
19
+ const values = [label];
20
+ if (page) {
21
+ values.push(page.title ?? '', page.keyword ?? '', page.url ?? '');
22
+ }
23
+ return values.map((value) => value.trim().toLowerCase()).filter((value) => value !== '');
24
+ }
25
+
26
+ /**
27
+ * Client-side search over resolved menu trees (`menu_pages` search mode).
28
+ */
29
+ export function searchMenuPagesInPayload(
30
+ payload: INavigationPayload,
31
+ query: string,
32
+ limit = 8,
33
+ ): IMenuSearchHit[] {
34
+ const needle = query.trim().toLowerCase();
35
+ if (needle === '') {
36
+ return [];
37
+ }
38
+
39
+ const hits: IMenuSearchHit[] = [];
40
+ const seen = new Set<number>();
41
+
42
+ for (const menu of Object.values(payload.menus)) {
43
+ if (!menu?.items?.length) {
44
+ continue;
45
+ }
46
+ for (const item of flattenMenuItems(menu.items)) {
47
+ if (!item.page || seen.has(item.page.id)) {
48
+ continue;
49
+ }
50
+ const matched = haystacksForItem(item).some((haystack) => haystack.includes(needle));
51
+ if (!matched) {
52
+ continue;
53
+ }
54
+ seen.add(item.page.id);
55
+ hits.push({
56
+ page_id: item.page.id,
57
+ keyword: item.page.keyword,
58
+ url: getNavigationItemHref(item),
59
+ title: getNavigationItemLabel(item),
60
+ });
61
+ if (hits.length >= limit) {
62
+ return hits;
63
+ }
64
+ }
65
+ }
66
+
67
+ return hits;
68
+ }
@@ -3,36 +3,35 @@ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
3
  SPDX-License-Identifier: MPL-2.0
4
4
  */
5
5
  /**
6
- * The single "is this page on the menu?" predicate, shared by web + mobile menu
7
- * renderers AND by the automatic virtual-navigation decision. A page is on the
8
- * menu when the author placed it there (`navPosition != null`) and it is not a
9
- * headless content-only fragment.
10
- *
11
- * Footer-only pages (`footerPosition != null && navPosition == null`), headless
12
- * pages, and ACL-pruned pages (never in the tree to begin with) are NOT menu
13
- * pages, so they never appear in a navigation block.
6
+ * Menu visibility helpers for the menu-builder model.
14
7
  */
15
8
 
16
- import type { IPageItem } from '../types/pages';
9
+ import type { INavigationMenuItem, INavigationPayload, TNavigationMenuKey } from './navigationPayload';
10
+ import { isPageInResolvedMenus } from './menuMembership';
17
11
 
18
- export function isMenuVisible(page: Pick<IPageItem, 'is_headless' | 'navPosition'>): boolean {
19
- if (page.is_headless) return false;
20
- return page.navPosition !== null && page.navPosition !== undefined;
12
+ const WEB_MENU_KEYS: TNavigationMenuKey[] = ['web_header', 'web_footer'];
13
+ const MOBILE_MENU_KEYS: TNavigationMenuKey[] = ['mobile_drawer', 'mobile_bottom_tabs'];
14
+ const ALL_MENU_KEYS: TNavigationMenuKey[] = [...WEB_MENU_KEYS, ...MOBILE_MENU_KEYS];
15
+
16
+ export function isPageOnAnyMenu(payload: INavigationPayload, pageId: number): boolean {
17
+ return isPageInResolvedMenus(payload.menus, ALL_MENU_KEYS, pageId);
21
18
  }
22
19
 
23
- /** Children of `page` that should appear in a navigation block, in nav order. */
24
- export function getMenuVisibleChildren(page: IPageItem): IPageItem[] {
25
- const children = page.children ?? [];
26
- return children
27
- .filter(isMenuVisible)
28
- .sort((a, b) => (a.navPosition ?? 0) - (b.navPosition ?? 0));
20
+ export function isPageOnWebMenu(payload: INavigationPayload, pageId: number): boolean {
21
+ return isPageInResolvedMenus(payload.menus, WEB_MENU_KEYS, pageId);
29
22
  }
30
23
 
31
- /**
32
- * A "navigation page" is a page whose children act as its menu. The hybrid
33
- * auto-render rule additionally requires the page to have no visible body
34
- * sections (decided by the caller, which has the resolved page content).
35
- */
36
- export function isNavigationPage(page: IPageItem): boolean {
37
- return getMenuVisibleChildren(page).length > 0;
24
+ export function isPageOnMobileMenu(payload: INavigationPayload, pageId: number): boolean {
25
+ return isPageInResolvedMenus(payload.menus, MOBILE_MENU_KEYS, pageId);
26
+ }
27
+
28
+ export function flattenMenuItems(items: INavigationMenuItem[]): INavigationMenuItem[] {
29
+ const out: INavigationMenuItem[] = [];
30
+ for (const item of items) {
31
+ out.push(item);
32
+ if (item.children?.length) {
33
+ out.push(...flattenMenuItems(item.children));
34
+ }
35
+ }
36
+ return out;
38
37
  }
@@ -0,0 +1,20 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ /**
6
+ * Map a CMS page canonical URL + keyword to an Expo Router path.
7
+ *
8
+ * Wave 1 uses keyword-based routes (`[keyword].tsx`), not file `[...slug]`
9
+ * segments. Nested public URLs (`/parent/child`) still navigate by keyword.
10
+ */
11
+ export function pageUrlToMobileRoute(url: string | null | undefined, keyword: string): string {
12
+ const normalizedKeyword = keyword.trim().toLowerCase();
13
+ if (normalizedKeyword === 'profile') {
14
+ return '/profile';
15
+ }
16
+ if (normalizedKeyword === 'home' || url === '/' || url === '' || url == null) {
17
+ return '/index';
18
+ }
19
+ return `/${normalizedKeyword}`;
20
+ }
@@ -0,0 +1,38 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ import type { INavigationMenuItem } from './navigationPayload';
6
+
7
+ export function getNavigationItemLabel(item: INavigationMenuItem): string {
8
+ return item.label || item.page?.title || item.page?.keyword || '';
9
+ }
10
+
11
+ export function getNavigationItemHref(item: INavigationMenuItem): string {
12
+ if (item.item_type === 'external_url' && item.external_url) {
13
+ return item.external_url;
14
+ }
15
+ const page = item.page;
16
+ if (!page) {
17
+ return '#';
18
+ }
19
+ if (page.url) {
20
+ return page.url;
21
+ }
22
+ return page.keyword === 'home' ? '/' : `/${page.keyword}`;
23
+ }
24
+
25
+ export function flattenNavigationMenuItems(items: INavigationMenuItem[]): INavigationMenuItem[] {
26
+ const out: INavigationMenuItem[] = [];
27
+ for (const item of items) {
28
+ out.push(item);
29
+ if (item.children?.length) {
30
+ out.push(...flattenNavigationMenuItems(item.children));
31
+ }
32
+ }
33
+ return out;
34
+ }
35
+
36
+ export function getNavigationItemKeyword(item: INavigationMenuItem): string | null {
37
+ return item.page?.keyword ?? null;
38
+ }
@@ -0,0 +1,84 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ import type { TWebHeaderPreset } from './headerPreset';
6
+
7
+ export type TNavigationMenuKey =
8
+ | 'web_header'
9
+ | 'web_footer'
10
+ | 'mobile_drawer'
11
+ | 'mobile_bottom_tabs';
12
+
13
+ export type TNavigationMenuItemType = 'page' | 'external_url' | 'group';
14
+
15
+ export type TNavigationChildSource = 'manual' | 'page_children' | 'manual_plus_suggestions';
16
+
17
+ export type TNavigationSearchMode = 'off' | 'menu_pages' | 'searchable_pages' | 'content_index';
18
+
19
+ export type TNavigationStartMode = 'fixed_page' | 'last_visited_then_fixed_page';
20
+
21
+ export type TNavigationMobileStartSource = 'same_as_web' | 'custom_mobile_pages';
22
+
23
+ export interface INavigationResolvedPageRef {
24
+ id: number;
25
+ keyword: string;
26
+ url: string | null;
27
+ title: string | null;
28
+ icon?: string | null;
29
+ mobile_icon?: string | null;
30
+ has_content?: boolean;
31
+ section_count?: number;
32
+ }
33
+
34
+ export interface INavigationMenuItem {
35
+ id: number | string;
36
+ item_type: TNavigationMenuItemType;
37
+ label: string;
38
+ description?: string | null;
39
+ aria_label?: string | null;
40
+ icon?: string | null;
41
+ position: number;
42
+ external_url?: string | null;
43
+ page?: INavigationResolvedPageRef | null;
44
+ is_virtual?: boolean;
45
+ is_active?: boolean;
46
+ child_source?: TNavigationChildSource;
47
+ children?: INavigationMenuItem[];
48
+ }
49
+
50
+ export interface INavigationMenu {
51
+ key: TNavigationMenuKey;
52
+ platform: 'web' | 'mobile';
53
+ surface: 'header' | 'footer' | 'drawer' | 'bottom_tabs';
54
+ preset?: TWebHeaderPreset | string | null;
55
+ max_depth?: number | null;
56
+ item_limit?: number | null;
57
+ items: INavigationMenuItem[];
58
+ }
59
+
60
+ export interface INavigationStartupConfig {
61
+ web_guest_start_page: INavigationResolvedPageRef | null;
62
+ web_user_start_page: INavigationResolvedPageRef | null;
63
+ web_user_start_mode: TNavigationStartMode;
64
+ web_user_last_visited_page?: INavigationResolvedPageRef | null;
65
+ mobile_guest_start_page: INavigationResolvedPageRef | null;
66
+ mobile_user_start_page: INavigationResolvedPageRef | null;
67
+ mobile_user_start_mode: TNavigationStartMode;
68
+ mobile_user_last_visited_page?: INavigationResolvedPageRef | null;
69
+ mobile_start_page_source: TNavigationMobileStartSource;
70
+ }
71
+
72
+ export interface INavigationSearchConfig {
73
+ mode: TNavigationSearchMode;
74
+ min_chars: number;
75
+ result_limit: number;
76
+ default_visibility: string;
77
+ field_policy: string;
78
+ }
79
+
80
+ export interface INavigationPayload {
81
+ menus: Record<TNavigationMenuKey, INavigationMenu>;
82
+ startup: INavigationStartupConfig;
83
+ search: INavigationSearchConfig;
84
+ }
@@ -0,0 +1,87 @@
1
+ /*
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ */
5
+ import type { INavigationResolvedPageRef, INavigationStartupConfig } from './navigationPayload';
6
+ import { pageUrlToMobileRoute } from './mobileRoute';
7
+
8
+ function pickStartPage(
9
+ startup: INavigationStartupConfig,
10
+ isLoggedIn: boolean,
11
+ platform: 'web' | 'mobile',
12
+ ): INavigationResolvedPageRef | null {
13
+ const useMobileCustom = startup.mobile_start_page_source === 'custom_mobile_pages';
14
+
15
+ if (isLoggedIn) {
16
+ const lastVisited = platform === 'mobile'
17
+ ? startup.mobile_user_last_visited_page
18
+ : startup.web_user_last_visited_page;
19
+ const startMode = platform === 'mobile'
20
+ ? startup.mobile_user_start_mode
21
+ : startup.web_user_start_mode;
22
+
23
+ if (startMode === 'last_visited_then_fixed_page' && lastVisited) {
24
+ return lastVisited;
25
+ }
26
+
27
+ if (platform === 'mobile' && useMobileCustom) {
28
+ return startup.mobile_user_start_page;
29
+ }
30
+ if (platform === 'mobile') {
31
+ return startup.mobile_user_start_page ?? startup.web_user_start_page;
32
+ }
33
+
34
+ return startup.web_user_start_page;
35
+ }
36
+
37
+ if (platform === 'mobile' && useMobileCustom) {
38
+ return startup.mobile_guest_start_page;
39
+ }
40
+ if (platform === 'mobile') {
41
+ return startup.mobile_guest_start_page ?? startup.web_guest_start_page;
42
+ }
43
+
44
+ return startup.web_guest_start_page;
45
+ }
46
+
47
+ /** Resolve the mobile Expo Router path for cold start / index redirect. */
48
+ export function resolveMobileStartupRoute(
49
+ startup: INavigationStartupConfig,
50
+ isLoggedIn: boolean,
51
+ ): string {
52
+ const page = pickStartPage(startup, isLoggedIn, 'mobile');
53
+ if (!page) {
54
+ return '/index';
55
+ }
56
+
57
+ return pageUrlToMobileRoute(page.url, page.keyword);
58
+ }
59
+
60
+ /** Keyword for the CMS page rendered on `/index` when startup maps to home. */
61
+ export function resolveMobileStartupKeyword(
62
+ startup: INavigationStartupConfig,
63
+ isLoggedIn: boolean,
64
+ ): string {
65
+ const page = pickStartPage(startup, isLoggedIn, 'mobile');
66
+
67
+ return page?.keyword ?? 'home';
68
+ }
69
+
70
+ /** Resolve a public web path for guest/user startup (leading slash). */
71
+ export function resolveWebStartupPath(
72
+ startup: INavigationStartupConfig,
73
+ isLoggedIn: boolean,
74
+ ): string | null {
75
+ const page = pickStartPage(startup, isLoggedIn, 'web');
76
+ if (!page) {
77
+ return null;
78
+ }
79
+ if (page.url && page.url !== '') {
80
+ return page.url.startsWith('/') ? page.url : `/${page.url}`;
81
+ }
82
+ if (page.keyword === 'home') {
83
+ return '/';
84
+ }
85
+
86
+ return `/${page.keyword}`;
87
+ }
@@ -23,8 +23,6 @@ describe('IPageContent route metadata (resolve responses)', () => {
23
23
  url: '/reset',
24
24
  parent_page_id: null,
25
25
  is_headless: true,
26
- nav_position: null,
27
- footer_position: null,
28
26
  route_params: { user_id: '42', token: 'abc.def~1' },
29
27
  matched_url_pattern: '/reset/{user_id}/{token}',
30
28
  canonical_url: '/reset',
@@ -44,8 +42,6 @@ describe('IPageContent route metadata (resolve responses)', () => {
44
42
  url: '/',
45
43
  parent_page_id: null,
46
44
  is_headless: false,
47
- nav_position: 1,
48
- footer_position: null,
49
45
  sections: [],
50
46
  };
51
47
 
@@ -67,8 +63,6 @@ describe('IPageContent route metadata (resolve responses)', () => {
67
63
  url: '/team/7',
68
64
  parent_page_id: null,
69
65
  is_headless: false,
70
- nav_position: null,
71
- footer_position: null,
72
66
  route_params: { record_id: '7' },
73
67
  sections: [],
74
68
  },
@@ -4,7 +4,6 @@ SPDX-License-Identifier: MPL-2.0
4
4
  */
5
5
  import type { IContentField } from './styles/base';
6
6
  import type { TStyleName } from './styles/unknown';
7
- import type { TWebNavRender, TMobileNavRender } from '../navigation/navRender';
8
7
 
9
8
  /**
10
9
  * Comprehensive page type system, single source of truth for both apps.
@@ -39,8 +38,6 @@ export interface IBasePageInfo {
39
38
  url: string | null;
40
39
  parent_page_id: number | null;
41
40
  is_headless: boolean;
42
- navPosition: number | null;
43
- footerPosition: number | null;
44
41
  is_system?: boolean;
45
42
  }
46
43
 
@@ -67,10 +64,6 @@ export interface IPageItem extends IBasePageInfo {
67
64
  icon?: string | null;
68
65
  /** Mobile menu icon (curated lucide name, e.g. `Home`). Page property field `mobile_icon`. */
69
66
  mobile_icon?: string | null;
70
- /** How this page renders its children as navigation on web. Page property field `web_nav_render`. */
71
- web_nav_render?: TWebNavRender | null;
72
- /** How this page renders its children as navigation on mobile. Page property field `mobile_nav_render`. */
73
- mobile_nav_render?: TMobileNavRender | null;
74
67
  children?: IPageItem[];
75
68
  }
76
69
 
@@ -80,18 +73,34 @@ export interface IPageContent {
80
73
  url: string | null;
81
74
  parent_page_id: number | null;
82
75
  is_headless: boolean;
83
- nav_position: number | null;
84
- footer_position: number | null;
76
+ /**
77
+ * When true, the web frontend renders this page's content inside a modal
78
+ * overlay (the page title becomes the modal header, with a close button)
79
+ * instead of a full page. Used to open CMS-in-CMS create/edit/detail pages
80
+ * from a list. Web-only — the mobile app renders the page as a normal
81
+ * screen. Mirrors the `open_in_modal` page property field.
82
+ */
83
+ open_in_modal?: boolean;
84
+ /**
85
+ * Optional modal width applied when `open_in_modal` is true (web only). A CSS
86
+ * length (e.g. `'80%'`, `'640px'`) or `'auto'` (fit content, capped at 90% of
87
+ * the viewport). `null`/absent means the frontend default (80%). Mirrors the
88
+ * `modal_width` page property field.
89
+ */
90
+ modal_width?: string | null;
91
+ /**
92
+ * Optional modal height applied when `open_in_modal` is true (web only). A CSS
93
+ * length (e.g. `'80%'`, `'600px'`) or `'auto'` (fit content, capped at 90% of
94
+ * the viewport). `null`/absent means the frontend default (80%). Mirrors the
95
+ * `modal_height` page property field.
96
+ */
97
+ modal_height?: string | null;
85
98
  title?: string | null;
86
99
  description?: string | null;
87
100
  /** Web menu icon (Tabler component name). Mirrors the `icon` page property field. */
88
101
  icon?: string | null;
89
102
  /** Mobile menu icon (curated lucide name). Mirrors the `mobile_icon` page property field. */
90
103
  mobile_icon?: string | null;
91
- /** Web child-navigation render type. Mirrors the `web_nav_render` page property field. */
92
- web_nav_render?: TWebNavRender | null;
93
- /** Mobile child-navigation render type. Mirrors the `mobile_nav_render` page property field. */
94
- mobile_nav_render?: TMobileNavRender | null;
95
104
  /**
96
105
  * Snake_case route params extracted from the matched public URL pattern
97
106
  * (e.g. `{ user_id: '42', token: 'abc' }` or `{ record_id: '7' }`). Present
@@ -42,6 +42,16 @@ export interface IFormStyle extends IStyleWithSpacing {
42
42
  confirm_submit?: IContentField<string>;
43
43
  /** Message shown in the confirmation dialog before submit. */
44
44
  confirm_message?: IContentField<string>;
45
+ /**
46
+ * When '1', a successful submit closes the surrounding web modal (only has
47
+ * an effect when the form's page is opened with `open_in_modal`). Web-only.
48
+ */
49
+ close_modal_on_save?: IContentField<string>;
50
+ /**
51
+ * Optional URL to navigate to after a successful submit (the parent list is
52
+ * refreshed). Empty = stay / close the modal. Web-only.
53
+ */
54
+ redirect_on_save?: IContentField<string>;
45
55
  // RF-21: button knobs are portable to the mobile custom form (not a 1:1
46
56
  // component map). Promoted web_* -> shared_* so both renderers read them.
47
57
  buttons_size?: IContentField<string>;
@@ -488,6 +498,18 @@ export interface IShowUserInputStyle extends IBaseStyle {
488
498
  csv_export?: IContentField<string>;
489
499
  delete_entry?: IContentField<string>;
490
500
  fields_map?: IContentField<string>;
501
+ /**
502
+ * Optional URL of a create form. When set, the web table shows an "Add new"
503
+ * button above it (e.g. opens the create form modal). Web-only.
504
+ */
505
+ add_url?: IContentField<string>;
506
+ /**
507
+ * Optional URL template for opening a row's detail (e.g.
508
+ * `/cms/team/{record_id}`). When set, each row gets an open/view action
509
+ * (eye icon) with the single-brace `{record_id}` placeholder substituted by
510
+ * the renderer at click time. Web-only.
511
+ */
512
+ edit_url?: IContentField<string>;
491
513
  delete_modal_title?: IContentField<string>;
492
514
  delete_modal_body?: IContentField<string>;
493
515
  spacing?: IContentField<string>;
@@ -11,8 +11,6 @@ describe('transformPageData', () => {
11
11
  id_pages: 7,
12
12
  keyword: 'qa-home',
13
13
  url: '/qa-home',
14
- nav_position: 3,
15
- footer_position: null,
16
14
  is_headless: 1,
17
15
  is_system: 0,
18
16
  });
@@ -20,17 +18,10 @@ describe('transformPageData', () => {
20
18
  expect(result.id).toBe(7);
21
19
  expect(result.id_pages).toBe(7);
22
20
  expect(result.keyword).toBe('qa-home');
23
- expect(result.navPosition).toBe(3);
24
- expect(result.footerPosition).toBeNull();
25
21
  expect(result.is_headless).toBe(true);
26
22
  expect(result.is_system).toBe(false);
27
23
  });
28
24
 
29
- it('prefers an explicit camelCase navPosition over the snake_case key', () => {
30
- const result = transformPageData({ id: 1, keyword: 'k', navPosition: 9, nav_position: 1 });
31
- expect(result.navPosition).toBe(9);
32
- });
33
-
34
25
  it('coerces boolean-like is_headless values (number/string/boolean)', () => {
35
26
  expect(transformPageData({ id: 1, keyword: 'k', is_headless: '1' }).is_headless).toBe(true);
36
27
  expect(transformPageData({ id: 1, keyword: 'k', is_headless: true }).is_headless).toBe(true);
@@ -41,34 +32,27 @@ describe('transformPageData', () => {
41
32
  const result = transformPageData({
42
33
  id: 1,
43
34
  keyword: 'parent',
44
- children: [{ id_pages: 2, keyword: 'child', nav_position: 5 }],
35
+ children: [{ id_pages: 2, keyword: 'child' }],
45
36
  });
46
37
  expect(result.children).toHaveLength(1);
47
38
  expect(result.children[0].id).toBe(2);
48
- expect(result.children[0].navPosition).toBe(5);
49
39
  });
50
40
 
51
- it('passes through the navigation icon + render fields', () => {
41
+ it('passes through icon fields', () => {
52
42
  const result = transformPageData({
53
43
  id: 1,
54
44
  keyword: 'team',
55
45
  icon: 'IconUsers',
56
46
  mobile_icon: 'Users',
57
- web_nav_render: 'hero-cards',
58
- mobile_nav_render: 'bottom-tabs',
59
47
  });
60
48
  expect(result.icon).toBe('IconUsers');
61
49
  expect(result.mobile_icon).toBe('Users');
62
- expect(result.web_nav_render).toBe('hero-cards');
63
- expect(result.mobile_nav_render).toBe('bottom-tabs');
64
50
  });
65
51
 
66
- it('defaults the navigation fields to null when absent', () => {
52
+ it('defaults icon fields to null when absent', () => {
67
53
  const result = transformPageData({ id: 1, keyword: 'plain' });
68
54
  expect(result.icon).toBeNull();
69
55
  expect(result.mobile_icon).toBeNull();
70
- expect(result.web_nav_render).toBeNull();
71
- expect(result.mobile_nav_render).toBeNull();
72
56
  });
73
57
 
74
58
  it('defaults missing id/keyword safely', () => {