@nocobase/app 3.0.0-alpha.1 → 3.0.0-alpha.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.
@@ -75,47 +75,31 @@ function runBrowserChecker(options: RunBrowserCheckerOptions) {
75
75
  }
76
76
 
77
77
  describe('v2 browser checker', () => {
78
- it('redirects the modern client root to Settings only in modern-only mode', () => {
79
- expect(
80
- runBrowserChecker({
81
- appClientEntryMode: 'modern-only',
82
- pathname: '/v/',
83
- }).replacements,
84
- ).toEqual(['https://example.test/settings']);
85
-
86
- expect(
87
- runBrowserChecker({
88
- appClientEntryMode: 'modern-default',
89
- pathname: '/v/',
90
- }).replacements,
91
- ).toEqual([]);
92
-
93
- expect(
94
- runBrowserChecker({
95
- pathname: '/v/',
96
- }).replacements,
97
- ).toEqual([]);
98
- });
99
-
100
- it('redirects scoped modern client roots to scoped Settings only in modern-only mode', () => {
101
- expect(
102
- runBrowserChecker({
103
- appClientEntryMode: 'modern-only',
104
- pathname: '/v/apps/demo',
105
- search: '?from=admin',
106
- hash: '#portal',
107
- }).replacements,
108
- ).toEqual(['https://example.test/settings/apps/demo?from=admin#portal']);
78
+ it.each([undefined, 'modern-default', 'modern-only'] as const)(
79
+ 'redirects the modern client root to Settings for entry mode %s',
80
+ (appClientEntryMode) => {
81
+ expect(
82
+ runBrowserChecker({
83
+ appClientEntryMode,
84
+ pathname: '/v/',
85
+ }).replacements,
86
+ ).toEqual(['https://example.test/settings']);
87
+ },
88
+ );
109
89
 
110
- expect(
111
- runBrowserChecker({
112
- appClientEntryMode: 'modern-default',
113
- pathname: '/v/apps/demo',
114
- search: '?from=admin',
115
- hash: '#portal',
116
- }).replacements,
117
- ).toEqual([]);
118
- });
90
+ it.each([undefined, 'modern-default', 'modern-only'] as const)(
91
+ 'redirects scoped modern client roots to scoped Settings for entry mode %s',
92
+ (appClientEntryMode) => {
93
+ expect(
94
+ runBrowserChecker({
95
+ appClientEntryMode,
96
+ pathname: '/v/apps/demo',
97
+ search: '?from=admin',
98
+ hash: '#portal',
99
+ }).replacements,
100
+ ).toEqual(['https://example.test/settings/apps/demo?from=admin#portal']);
101
+ },
102
+ );
119
103
 
120
104
  it('keeps Settings scoped trailing slash normalization independent from entry mode', () => {
121
105
  expect(
@@ -81,11 +81,7 @@ function resolveScopedSettingsRootPath(publicPath, pathname) {
81
81
  const basename = normalizePublicPath(window['__nocobase_public_path__'] || '/');
82
82
  const currentPath = ensureLeadingSlash(String(window.location.pathname || '/').trim() || '/').replace(/\/{2,}/g, '/');
83
83
  const basenameWithoutTrailingSlash = basename === '/' ? '/' : basename.replace(/\/+$/, '');
84
- const appClientEntryMode = window['__nocobase_app_client_entry_mode__'];
85
- const settingsRootPath =
86
- appClientEntryMode === 'modern-only'
87
- ? resolveSettingsRootPath(basename, window['__nocobase_modern_client_prefix__'], currentPath)
88
- : null;
84
+ const settingsRootPath = resolveSettingsRootPath(basename, window['__nocobase_modern_client_prefix__'], currentPath);
89
85
  const scopedSettingsRootPath = isSettingsBrowserCheckerScript(document.currentScript)
90
86
  ? resolveScopedSettingsRootPath(basename, currentPath)
91
87
  : null;