create-mercato-app 0.6.1-develop.3256.1.fe3dec2464 → 0.6.1-develop.3276.1.1fcd145078

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": "create-mercato-app",
3
- "version": "0.6.1-develop.3256.1.fe3dec2464",
3
+ "version": "0.6.1-develop.3276.1.1fcd145078",
4
4
  "type": "module",
5
5
  "description": "Create a new Open Mercato application",
6
6
  "main": "./dist/index.js",
@@ -35,7 +35,8 @@ APP_URL=http://localhost:3000
35
35
 
36
36
  # Enable self-service onboarding (default: false)
37
37
  SELF_SERVICE_ONBOARDING_ENABLED=false
38
- DEMO_MODE=true
38
+ # Enable Open Mercato demo widgets (default: false)
39
+ DEMO_MODE=false
39
40
 
40
41
  # Enable enterprise-only optional modules (default: false)
41
42
  # Developer preview is free for local/dev usage.
@@ -9,6 +9,11 @@ const backendRoutes = [
9
9
  ]
10
10
 
11
11
  const mockRegisterBackendRouteManifests = jest.fn()
12
+ const mockParseBooleanWithDefault = jest.fn(() => false)
13
+ const mockCookies = jest.fn()
14
+ const mockHeaders = jest.fn()
15
+ const mockResolveTranslations = jest.fn()
16
+ const mockGetAuthFromCookies = jest.fn()
12
17
 
13
18
  jest.mock('@/.mercato/generated/backend-routes.generated', () => ({
14
19
  backendRoutes,
@@ -20,12 +25,12 @@ jest.mock('@open-mercato/shared/modules/registry', () => ({
20
25
  }))
21
26
 
22
27
  jest.mock('next/headers', () => ({
23
- cookies: jest.fn(),
24
- headers: jest.fn(),
28
+ cookies: (...args: unknown[]) => mockCookies(...args),
29
+ headers: (...args: unknown[]) => mockHeaders(...args),
25
30
  }))
26
31
 
27
32
  jest.mock('@open-mercato/shared/lib/auth/server', () => ({
28
- getAuthFromCookies: jest.fn(),
33
+ getAuthFromCookies: (...args: unknown[]) => mockGetAuthFromCookies(...args),
29
34
  }))
30
35
 
31
36
  jest.mock('@open-mercato/ui/backend/AppShell', () => ({
@@ -33,7 +38,7 @@ jest.mock('@open-mercato/ui/backend/AppShell', () => ({
33
38
  }))
34
39
 
35
40
  jest.mock('@open-mercato/shared/lib/i18n/server', () => ({
36
- resolveTranslations: jest.fn(),
41
+ resolveTranslations: (...args: unknown[]) => mockResolveTranslations(...args),
37
42
  }))
38
43
 
39
44
  jest.mock('@open-mercato/shared/lib/i18n/context', () => ({
@@ -49,7 +54,7 @@ jest.mock('@open-mercato/shared/lib/version', () => ({
49
54
  }))
50
55
 
51
56
  jest.mock('@open-mercato/shared/lib/boolean', () => ({
52
- parseBooleanWithDefault: jest.fn(() => true),
57
+ parseBooleanWithDefault: (...args: unknown[]) => mockParseBooleanWithDefault(...args),
53
58
  }))
54
59
 
55
60
  jest.mock('@open-mercato/ui/backend/injection/PageInjectionBoundary', () => ({
@@ -73,6 +78,11 @@ describe('Backend layout route registry', () => {
73
78
  beforeEach(() => {
74
79
  jest.resetModules()
75
80
  mockRegisterBackendRouteManifests.mockClear()
81
+ mockParseBooleanWithDefault.mockClear()
82
+ mockCookies.mockReset()
83
+ mockHeaders.mockReset()
84
+ mockResolveTranslations.mockReset()
85
+ mockGetAuthFromCookies.mockReset()
76
86
  })
77
87
 
78
88
  it('registers backend route manifests at module load', async () => {
@@ -82,4 +92,35 @@ describe('Backend layout route registry', () => {
82
92
 
83
93
  expect(mockRegisterBackendRouteManifests).toHaveBeenCalledWith(backendRoutes)
84
94
  })
95
+
96
+ it('defaults the demo mode flag to false when DEMO_MODE is unset', async () => {
97
+ const originalDemoMode = process.env.DEMO_MODE
98
+ delete process.env.DEMO_MODE
99
+ mockGetAuthFromCookies.mockResolvedValue(null)
100
+ mockCookies.mockResolvedValue({ get: () => undefined })
101
+ mockHeaders.mockResolvedValue({ get: () => null })
102
+ mockResolveTranslations.mockResolvedValue({
103
+ translate: (_key: string, fallback: string) => fallback,
104
+ locale: 'en',
105
+ dict: {},
106
+ })
107
+
108
+ try {
109
+ await jest.isolateModulesAsync(async () => {
110
+ const { default: BackendLayout } = await import('../layout')
111
+ await BackendLayout({
112
+ children: React.createElement('div'),
113
+ params: Promise.resolve({}),
114
+ })
115
+ })
116
+
117
+ expect(mockParseBooleanWithDefault).toHaveBeenCalledWith(undefined, false)
118
+ } finally {
119
+ if (originalDemoMode === undefined) {
120
+ delete process.env.DEMO_MODE
121
+ } else {
122
+ process.env.DEMO_MODE = originalDemoMode
123
+ }
124
+ }
125
+ })
85
126
  })
@@ -80,7 +80,7 @@ export default async function BackendLayout({
80
80
 
81
81
  const collapsedCookie = cookieStore.get('om_sidebar_collapsed')?.value
82
82
  const initialCollapsed = collapsedCookie === '1'
83
- const demoModeEnabled = parseBooleanWithDefault(process.env.DEMO_MODE, true)
83
+ const demoModeEnabled = parseBooleanWithDefault(process.env.DEMO_MODE, false)
84
84
  const deployEnv = process.env.DEPLOY_ENV
85
85
  const baseProductName = translate('appShell.productName', 'Open Mercato')
86
86
  const productName = deployEnv && deployEnv !== 'local'
@@ -97,4 +97,18 @@ describe('RootLayout', () => {
97
97
  expect(appProviders?.props.demoModeEnabled).toBe(false)
98
98
  expect(appProviders?.props.noticeBarsEnabled).toBe(true)
99
99
  })
100
+
101
+ it('defaults demo mode off when DEMO_MODE is unset', async () => {
102
+ delete process.env.DEMO_MODE
103
+ delete process.env.OM_INTEGRATION_TEST
104
+
105
+ const { default: RootLayout } = await import('../layout')
106
+ const { AppProviders } = await import('@/components/AppProviders')
107
+ const tree = await RootLayout({ children: 'child' })
108
+ const appProviders = findElementByType(tree, AppProviders)
109
+
110
+ expect(appProviders).not.toBeNull()
111
+ expect(appProviders?.props.demoModeEnabled).toBe(false)
112
+ expect(appProviders?.props.noticeBarsEnabled).toBe(true)
113
+ })
100
114
  })
@@ -22,7 +22,7 @@ export default async function RootLayout({
22
22
  }>) {
23
23
  const locale = await detectLocale()
24
24
  const dict = await loadDictionary(locale)
25
- const demoModeEnabled = process.env.DEMO_MODE !== 'false'
25
+ const demoModeEnabled = process.env.DEMO_MODE === 'true'
26
26
  const noticeBarsEnabled = process.env.OM_INTEGRATION_TEST !== 'true'
27
27
  return (
28
28
  <html lang={locale} suppressHydrationWarning>