@nocobase/client-v2 2.2.0-beta.9 → 3.0.0-alpha.1
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/es/APIClient.d.ts +1 -3
- package/es/BaseApplication.d.ts +1 -0
- package/es/acl/ACLProvider.d.ts +10 -0
- package/es/authRedirect.d.ts +5 -0
- package/es/collection-field-interface/CollectionFieldInterface.d.ts +1 -0
- package/es/collection-field-interface/CollectionFieldInterfaceManager.d.ts +1 -0
- package/es/components/AttachmentUpload.d.ts +51 -0
- package/es/components/category-tabs/SortableCategoryTabs.d.ts +55 -0
- package/es/components/category-tabs/index.d.ts +9 -0
- package/es/components/form/ScanInput/useCodeScanner.d.ts +3 -2
- package/es/components/form/TypedVariableInput.d.ts +31 -5
- package/es/components/form/filter/CollectionFilter.d.ts +2 -0
- package/es/components/form/filter/CollectionFilterItem.d.ts +11 -1
- package/es/components/form/filter/CollectionFilterPanel.d.ts +2 -0
- package/es/components/form/filter/index.d.ts +2 -0
- package/es/components/form/filter/useFilterActionProps.d.ts +2 -0
- package/es/components/index.d.ts +2 -0
- package/es/flow/actions/index.d.ts +1 -1
- package/es/flow/actions/linkageRules.d.ts +3 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +1 -0
- package/es/flow/admin-shell/admin-layout/NocoBaseLogo.d.ts +10 -0
- package/es/flow/components/FieldAssignExactDatePicker.d.ts +1 -0
- package/es/flow/components/FieldAssignValueInput.d.ts +9 -0
- package/es/flow/components/FlowRoute.d.ts +2 -2
- package/es/flow/components/RunJSValueEditor.d.ts +1 -0
- package/es/flow/components/filter/FilterGroup.d.ts +1 -0
- package/es/flow/components/filter/VariableFilterItem.d.ts +6 -1
- package/es/flow/index.d.ts +1 -0
- package/es/flow/internal/registerDeviceTypeContext.d.ts +10 -0
- package/es/flow/models/base/ActionModelCore.d.ts +4 -2
- package/es/flow/models/base/BlockGridModel.d.ts +3 -0
- package/es/flow/models/base/PageModel/PageModel.d.ts +12 -0
- package/es/flow/models/base/PageModel/PageModelTabBar.d.ts +22 -0
- package/es/flow/models/base/PageModel/PageTabModel.d.ts +12 -0
- package/es/flow/models/blocks/form/QuickEditFormModel.d.ts +17 -2
- package/es/flow/models/blocks/table/TableColumnModel.d.ts +1 -0
- package/es/flow/models/fields/DateTimeFieldModel/dateLimit.d.ts +15 -7
- package/es/flow-compat/fieldValidationConstants.d.ts +1 -1
- package/es/flow-compat/routeTypes.d.ts +1 -0
- package/es/index.d.ts +8 -1
- package/es/index.mjs +190 -141
- package/es/nocobase-buildin-plugin/currentUserAuthStatus.d.ts +11 -0
- package/es/nocobase-buildin-plugin/index.d.ts +9 -0
- package/es/settings-app/SettingsApplication.d.ts +18 -0
- package/es/settings-app/SettingsBrand.d.ts +16 -0
- package/es/settings-app/SettingsBuildInPlugin.d.ts +9 -0
- package/es/settings-app/SettingsDocumentRedirect.d.ts +10 -0
- package/es/settings-app/SettingsGroupNav.d.ts +17 -0
- package/es/settings-app/SettingsPluginSettingsManager.d.ts +14 -0
- package/es/settings-app/SettingsRouterManager.d.ts +15 -0
- package/es/settings-app/SettingsSearch.d.ts +17 -0
- package/es/settings-app/SettingsShell.d.ts +10 -0
- package/es/settings-app/isSettingsApp.d.ts +18 -0
- package/es/settings-app/runtimePaths.d.ts +18 -0
- package/es/settings-app/settingsDocumentPath.d.ts +14 -0
- package/es/settings-app/settingsTheme.d.ts +87 -0
- package/es/settings-app/useSettingsThemeConfig.d.ts +22 -0
- package/es/settings-center/AdminSettingsLayout.d.ts +2 -2
- package/es/settings-center/groups.d.ts +66 -0
- package/es/settings-center/useSettingsGroups.d.ts +36 -0
- package/es/settings-center/useSettingsSearch.d.ts +35 -0
- package/es/settings-center/utils.d.ts +24 -0
- package/es/theme/index.d.ts +1 -0
- package/es/theme/itemActive.d.ts +24 -0
- package/es/theme/type.d.ts +9 -0
- package/es/utils/getRouteRuntimeVersion.d.ts +23 -0
- package/es/utils/index.d.ts +1 -0
- package/lib/index.js +195 -146
- package/lib/locale/languageCodes.js +3 -1
- package/package.json +9 -7
- package/src/APIClient.ts +1 -10
- package/src/Application.tsx +4 -0
- package/src/BaseApplication.tsx +11 -6
- package/src/__tests__/app.test.tsx +73 -0
- package/src/__tests__/authRedirect.test.ts +137 -0
- package/src/__tests__/browserChecker.test.ts +185 -6
- package/src/__tests__/getRouteRuntimeVersion.test.ts +68 -0
- package/src/__tests__/mockSettingsApplication.ts +29 -0
- package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +79 -10
- package/src/__tests__/plugin-manager.test.tsx +7 -6
- package/src/__tests__/settings-application.test.ts +164 -0
- package/src/__tests__/settings-auth-routes.test.ts +71 -0
- package/src/__tests__/settings-center.test.tsx +38 -37
- package/src/__tests__/settings-layout-root.test.tsx +260 -0
- package/src/__tests__/settings-runtime-paths.test.ts +99 -0
- package/src/__tests__/settings-shell.test.tsx +200 -0
- package/src/acl/ACLProvider.tsx +21 -0
- package/src/authRedirect.ts +72 -3
- package/src/collection-field-interface/CollectionFieldInterface.ts +1 -0
- package/src/collection-field-interface/CollectionFieldInterfaceManager.ts +1 -0
- package/src/collection-manager/field-validation.ts +1 -1
- package/src/components/AttachmentUpload.tsx +275 -0
- package/src/components/README.md +7 -1
- package/src/components/README.zh-CN.md +6 -1
- package/src/components/category-tabs/SortableCategoryTabs.tsx +210 -0
- package/src/components/category-tabs/index.ts +10 -0
- package/src/components/form/JsonTextArea.tsx +4 -0
- package/src/components/form/ScanInput/CodeScanner.tsx +79 -35
- package/src/components/form/ScanInput/__tests__/CodeScanner.test.tsx +101 -0
- package/src/components/form/ScanInput/__tests__/useCodeScanner.test.tsx +284 -11
- package/src/components/form/ScanInput/useCodeScanner.ts +332 -24
- package/src/components/form/TypedVariableInput.tsx +452 -101
- package/src/components/form/__tests__/TypedVariableInput.test.tsx +364 -12
- package/src/components/form/filter/CollectionFilter.tsx +4 -0
- package/src/components/form/filter/CollectionFilterItem.tsx +32 -7
- package/src/components/form/filter/CollectionFilterPanel.tsx +4 -0
- package/src/components/form/filter/__tests__/CollectionFilterItem.test.tsx +38 -0
- package/src/components/form/filter/__tests__/useFilterActionProps.test.tsx +95 -0
- package/src/components/form/filter/index.ts +2 -0
- package/src/components/form/filter/useFilterActionProps.ts +37 -6
- package/src/components/index.ts +2 -0
- package/src/flow/FlowPage.tsx +9 -1
- package/src/flow/__tests__/FlowPage.test.tsx +50 -3
- package/src/flow/__tests__/FlowRoute.test.tsx +128 -10
- package/src/flow/__tests__/PluginFlowEngine.test.ts +58 -0
- package/src/flow/actions/__tests__/actionLinkageRules.forkProps.test.ts +314 -0
- package/src/flow/actions/__tests__/dataScopeFormValueClear.test.ts +102 -0
- package/src/flow/actions/__tests__/linkageRules.tab.test.ts +171 -0
- package/src/flow/actions/__tests__/linkageRulesRefresh.test.ts +7 -3
- package/src/flow/actions/index.ts +2 -0
- package/src/flow/actions/linkageRules.tsx +111 -16
- package/src/flow/actions/linkageRulesRefresh.tsx +2 -6
- package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +1 -57
- package/src/flow/admin-shell/admin-layout/NocoBaseLogo.tsx +77 -0
- package/src/flow/admin-shell/admin-layout/TopbarActionsBar.tsx +37 -14
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutComponent.test.tsx +253 -6
- package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +77 -13
- package/src/flow/common/Markdown/style.ts +4 -0
- package/src/flow/components/BlockItemCard.tsx +2 -2
- package/src/flow/components/FieldAssignExactDatePicker.tsx +25 -11
- package/src/flow/components/FieldAssignValueInput.tsx +91 -20
- package/src/flow/components/FlowRoute.tsx +78 -32
- package/src/flow/components/RunJSValueEditor.tsx +9 -1
- package/src/flow/components/__tests__/FieldAssignValueInput.context.test.tsx +216 -0
- package/src/flow/components/filter/FilterGroup.tsx +33 -5
- package/src/flow/components/filter/VariableFilterItem.tsx +158 -10
- package/src/flow/components/filter/__tests__/FilterGroup.test.tsx +45 -0
- package/src/flow/components/filter/__tests__/VariableFilterItem.leftMetaTree.test.tsx +9 -0
- package/src/flow/components/filter/__tests__/VariableFilterItem.test.tsx +70 -1
- package/src/flow/index.ts +3 -0
- package/src/flow/internal/registerDeviceTypeContext.ts +39 -0
- package/src/flow/models/base/ActionModelCore.tsx +11 -2
- package/src/flow/models/base/BlockGridModel.tsx +26 -0
- package/src/flow/models/base/CollectionBlockModel.tsx +6 -2
- package/src/flow/models/base/PageModel/PageModel.tsx +387 -53
- package/src/flow/models/base/PageModel/PageModelTabBar.tsx +114 -0
- package/src/flow/models/base/PageModel/PageTabModel.tsx +249 -18
- package/src/flow/models/base/PageModel/__tests__/PageModel.test.ts +790 -10
- package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.module-isolation.test.tsx +130 -0
- package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.test.tsx +118 -0
- package/src/flow/models/base/PageModel/__tests__/PageTabModel.test.ts +1075 -7
- package/src/flow/models/base/__tests__/ActionModelCore.render.test.tsx +49 -0
- package/src/flow/models/base/__tests__/BlockGridModel.selectSceneActivation.test.ts +124 -0
- package/src/flow/models/base/__tests__/CollectionBlockModel.addAppends.test.ts +41 -0
- package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +28 -3
- package/src/flow/models/blocks/filter-form/FilterFormItemModel.tsx +27 -12
- package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.defineChildren.test.ts +36 -0
- package/src/flow/models/blocks/filter-form/__tests__/defaultValues.wiring.test.ts +66 -4
- package/src/flow/models/blocks/form/QuickEditFormModel.tsx +189 -36
- package/src/flow/models/blocks/form/__tests__/QuickEditFormModel.quickEdit.test.ts +350 -2
- package/src/flow/models/blocks/js-block/JSBlock.tsx +1 -1
- package/src/flow/models/blocks/table/TableActionsColumnModel.tsx +2 -1
- package/src/flow/models/blocks/table/TableBlockModel.tsx +4 -2
- package/src/flow/models/blocks/table/TableColumnModel.tsx +30 -1
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.quickEditRefresh.test.ts +12 -0
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +33 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +2 -1
- package/src/flow/models/fields/DateTimeFieldModel/__tests__/DateTimeNoTzFieldModel.dateLimit.test.tsx +149 -0
- package/src/flow/models/fields/DateTimeFieldModel/dateLimit.ts +149 -113
- package/src/flow/models/fields/JsonFieldModel.tsx +31 -8
- package/src/flow/models/fields/VariableFieldFormModel.tsx +3 -3
- package/src/flow/models/fields/__tests__/JsonFieldModel.test.ts +82 -0
- package/src/flow/models/fields/__tests__/VariableFieldFormModel.test.tsx +51 -0
- package/src/flow/models/fields/mobile-components/MobileLazySelect.tsx +20 -10
- package/src/flow/models/fields/mobile-components/MobileSelect.tsx +24 -12
- package/src/flow/models/topbar/TopbarActionModel.tsx +52 -180
- package/src/flow/utils/dataScopeFormValueClear.ts +4 -3
- package/src/flow-compat/fieldValidationConstants.ts +1 -1
- package/src/flow-compat/routeTypes.ts +1 -0
- package/src/index.ts +14 -1
- package/src/locale/languageCodes.ts +3 -1
- package/src/nocobase-buildin-plugin/currentUserAuthStatus.ts +58 -0
- package/src/nocobase-buildin-plugin/index.tsx +110 -70
- package/src/settings-app/SettingsApplication.ts +31 -0
- package/src/settings-app/SettingsBrand.tsx +108 -0
- package/src/settings-app/SettingsBuildInPlugin.ts +10 -0
- package/src/settings-app/SettingsDocumentRedirect.tsx +26 -0
- package/src/settings-app/SettingsGroupNav.tsx +124 -0
- package/src/settings-app/SettingsPluginSettingsManager.ts +38 -0
- package/src/settings-app/SettingsRouterManager.ts +92 -0
- package/src/settings-app/SettingsSearch.tsx +238 -0
- package/src/settings-app/SettingsShell.tsx +167 -0
- package/src/settings-app/isSettingsApp.ts +21 -0
- package/src/settings-app/runtimePaths.ts +104 -0
- package/src/settings-app/settingsDocumentPath.ts +66 -0
- package/src/settings-app/settingsTheme.ts +301 -0
- package/src/settings-app/useSettingsThemeConfig.ts +100 -0
- package/src/settings-center/AdminSettingsLayout.tsx +122 -141
- package/src/settings-center/SystemSettingsPage.tsx +4 -170
- package/src/settings-center/groups.ts +108 -0
- package/src/settings-center/useSettingsGroups.ts +105 -0
- package/src/settings-center/useSettingsSearch.ts +173 -0
- package/src/settings-center/utils.tsx +50 -1
- package/src/theme/index.tsx +1 -0
- package/src/theme/itemActive.ts +31 -0
- package/src/theme/type.ts +10 -0
- package/src/utils/getRouteRuntimeVersion.ts +185 -0
- package/src/utils/index.tsx +1 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { FlowEngine, FlowEngineProvider, type Collection } from '@nocobase/flow-engine';
|
|
11
|
+
import { renderHook } from '@testing-library/react';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
14
|
+
import { useFilterActionProps } from '../useFilterActionProps';
|
|
15
|
+
|
|
16
|
+
vi.mock('../../../flow/components/filter/useFilterOptions', () => ({
|
|
17
|
+
useFilterOptions: () => [],
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
vi.mock('../CollectionFilterItem', () => ({
|
|
21
|
+
createCollectionFilterItem: () => undefined,
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
function makeCollection(): Collection {
|
|
25
|
+
return {
|
|
26
|
+
getFields: () => [{ name: 'title' }, { name: 'type' }],
|
|
27
|
+
} as unknown as Collection;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function makeWrapper() {
|
|
31
|
+
const engine = new FlowEngine();
|
|
32
|
+
const Wrapper: React.FC = ({ children }) => <FlowEngineProvider engine={engine}>{children}</FlowEngineProvider>;
|
|
33
|
+
return Wrapper;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
describe('useFilterActionProps', () => {
|
|
37
|
+
it('seeds the editable group from defaultValue when initialValue is missing', () => {
|
|
38
|
+
const { result } = renderHook(
|
|
39
|
+
() =>
|
|
40
|
+
useFilterActionProps({
|
|
41
|
+
collection: makeCollection(),
|
|
42
|
+
defaultValue: { $and: [{ title: { $includes: '' } }, { type: { $eq: undefined } }] },
|
|
43
|
+
onApply: () => undefined,
|
|
44
|
+
}),
|
|
45
|
+
{ wrapper: makeWrapper() },
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
expect(result.current.value).toMatchObject({
|
|
49
|
+
logic: '$and',
|
|
50
|
+
items: [
|
|
51
|
+
{ path: 'title', operator: '$includes', value: '' },
|
|
52
|
+
{ path: 'type', operator: '$eq', value: undefined },
|
|
53
|
+
],
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('reset restores defaultValue and emits its compiled filter', () => {
|
|
58
|
+
const onApply = vi.fn();
|
|
59
|
+
const { result } = renderHook(
|
|
60
|
+
() =>
|
|
61
|
+
useFilterActionProps({
|
|
62
|
+
collection: makeCollection(),
|
|
63
|
+
defaultValue: { $and: [{ title: { $includes: '' } }, { type: { $eq: undefined } }] },
|
|
64
|
+
initialValue: { $and: [{ title: { $includes: 'abc' } }] },
|
|
65
|
+
onApply,
|
|
66
|
+
}),
|
|
67
|
+
{ wrapper: makeWrapper() },
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
result.current.onReset();
|
|
71
|
+
|
|
72
|
+
expect(result.current.value).toMatchObject({
|
|
73
|
+
logic: '$and',
|
|
74
|
+
items: [
|
|
75
|
+
{ path: 'title', operator: '$includes', value: '' },
|
|
76
|
+
{ path: 'type', operator: '$eq', value: undefined },
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
expect(onApply).toHaveBeenCalledWith(undefined, 'reset');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('counts only effective compiled conditions, so empty default rows do not highlight the button', () => {
|
|
83
|
+
const { result } = renderHook(
|
|
84
|
+
() =>
|
|
85
|
+
useFilterActionProps({
|
|
86
|
+
collection: makeCollection(),
|
|
87
|
+
defaultValue: { $and: [{ title: { $includes: '' } }, { type: { $eq: undefined } }] },
|
|
88
|
+
onApply: () => undefined,
|
|
89
|
+
}),
|
|
90
|
+
{ wrapper: makeWrapper() },
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
expect(result.current.conditionCount).toBe(0);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -11,5 +11,7 @@
|
|
|
11
11
|
export { CollectionFilter } from './CollectionFilter';
|
|
12
12
|
export type { CollectionFilterProps } from './CollectionFilter';
|
|
13
13
|
export { CollectionFilterPanel } from './CollectionFilterPanel';
|
|
14
|
+
export { CollectionFilterItem } from './CollectionFilterItem';
|
|
15
|
+
export type { CollectionFilterItemValue } from './CollectionFilterItem';
|
|
14
16
|
export type { CollectionFilterPanelProps, CollectionFilterPanelRef } from './CollectionFilterPanel';
|
|
15
17
|
export type { CompiledFilter } from './useFilterActionProps';
|
|
@@ -43,6 +43,14 @@ const isCondition = (item: FilterGroupItem): item is CollectionFilterItemValue =
|
|
|
43
43
|
typeof (item as CollectionFilterItemValue).path === 'string' &&
|
|
44
44
|
Object.prototype.hasOwnProperty.call(item, 'operator');
|
|
45
45
|
|
|
46
|
+
const cloneFilterGroupItem = (item: FilterGroupItem): FilterGroupItem =>
|
|
47
|
+
isGroup(item) ? { logic: item.logic, items: item.items.map((child) => cloneFilterGroupItem(child)) } : { ...item };
|
|
48
|
+
|
|
49
|
+
const cloneFilterGroup = (group: FilterGroupValue): FilterGroupValue => ({
|
|
50
|
+
logic: group.logic,
|
|
51
|
+
items: group.items.map((item) => cloneFilterGroupItem(item)),
|
|
52
|
+
});
|
|
53
|
+
|
|
46
54
|
/**
|
|
47
55
|
* `true` when the rhs of a condition is "no real value yet" — covers `undefined` / `null` / empty string / empty array / empty plain object. Mirrors v1's `removeNullCondition` `isEmpty` predicate so half-filled rows ("Locked time → is → (no date picked yet)") get dropped on Submit instead of being sent to the server as `{lockedTs:{}}` and triggering a 500.
|
|
48
56
|
*/
|
|
@@ -164,6 +172,8 @@ export interface UseFilterActionPropsArgs extends UseFilterOptionsArgs {
|
|
|
164
172
|
collection: Collection | undefined;
|
|
165
173
|
/** Previously compiled filter param used to seed the editable filter group. */
|
|
166
174
|
initialValue?: CompiledFilter;
|
|
175
|
+
/** Default compiled filter used both for initial empty state and Reset. */
|
|
176
|
+
defaultValue?: CompiledFilter;
|
|
167
177
|
/**
|
|
168
178
|
* Called when the user submits or resets the filter popover. Receives the compiled filter param (`undefined` when cleared) and which footer button triggered the call. Typical implementation: `(filter, action) => { listRequest.run(filter); if (action === 'submit') closePopover(); }`.
|
|
169
179
|
*/
|
|
@@ -216,12 +226,23 @@ export interface UseFilterActionPropsResult {
|
|
|
216
226
|
* ```
|
|
217
227
|
*/
|
|
218
228
|
export function useFilterActionProps(args: UseFilterActionPropsArgs): UseFilterActionPropsResult {
|
|
219
|
-
const {
|
|
229
|
+
const {
|
|
230
|
+
collection,
|
|
231
|
+
initialValue,
|
|
232
|
+
defaultValue,
|
|
233
|
+
onApply,
|
|
234
|
+
filterableFieldNames,
|
|
235
|
+
nonfilterableFieldNames,
|
|
236
|
+
noIgnore,
|
|
237
|
+
t,
|
|
238
|
+
} = args;
|
|
239
|
+
const seedValue = initialValue ?? defaultValue;
|
|
240
|
+
const defaultGroup = decompileFilterGroup(defaultValue) || createEmptyGroup();
|
|
220
241
|
|
|
221
242
|
// Held in a ref so the group object identity is stable for the lifetime of the host component — `<FilterContent>` mutates this object directly (push/splice on `items`, swap `logic`), and a fresh observable on every render would reset that internal state.
|
|
222
243
|
const valueRef = useRef<FilterGroupValue>();
|
|
223
244
|
if (!valueRef.current) {
|
|
224
|
-
valueRef.current = observable(decompileFilterGroup(
|
|
245
|
+
valueRef.current = observable(decompileFilterGroup(seedValue) || createEmptyGroup()) as FilterGroupValue;
|
|
225
246
|
}
|
|
226
247
|
const value = valueRef.current;
|
|
227
248
|
|
|
@@ -240,9 +261,10 @@ export function useFilterActionProps(args: UseFilterActionPropsArgs): UseFilterA
|
|
|
240
261
|
});
|
|
241
262
|
|
|
242
263
|
const onReset = useMemoizedFn(() => {
|
|
243
|
-
|
|
244
|
-
value.
|
|
245
|
-
|
|
264
|
+
const next = cloneFilterGroup(defaultGroup);
|
|
265
|
+
value.logic = next.logic;
|
|
266
|
+
value.items = next.items;
|
|
267
|
+
onApply(compileFilterGroup(value), 'reset');
|
|
246
268
|
});
|
|
247
269
|
|
|
248
270
|
const translate = useMemoizedFn((key: string) => (t ? t(key) : key));
|
|
@@ -261,7 +283,16 @@ export function useFilterActionProps(args: UseFilterActionPropsArgs): UseFilterA
|
|
|
261
283
|
);
|
|
262
284
|
|
|
263
285
|
// Re-read on each render so `observer`-wrapped hosts re-render when the reactive `items` array length changes. No useMemo needed — the `value` object's identity is stable (held in a ref), but its observable `items.length` is what we actually care about, and the eslint exhaustive-deps rule rightly complains about depending on a mutable property of a stable ref.
|
|
264
|
-
const conditionCount =
|
|
286
|
+
const conditionCount = (() => {
|
|
287
|
+
const compiled = compileFilterGroup(value);
|
|
288
|
+
if (compiled?.$and && Array.isArray(compiled.$and)) {
|
|
289
|
+
return compiled.$and.length;
|
|
290
|
+
}
|
|
291
|
+
if (compiled?.$or && Array.isArray(compiled.$or)) {
|
|
292
|
+
return compiled.$or.length;
|
|
293
|
+
}
|
|
294
|
+
return 0;
|
|
295
|
+
})();
|
|
265
296
|
|
|
266
297
|
return { value, options, FilterItem, ctx, onSubmit, onReset, conditionCount };
|
|
267
298
|
}
|
package/src/components/index.ts
CHANGED
package/src/flow/FlowPage.tsx
CHANGED
|
@@ -60,7 +60,9 @@ type FlowPageProps = {
|
|
|
60
60
|
type FlowPageViewContext = FlowEngineContext & {
|
|
61
61
|
view?: {
|
|
62
62
|
inputArgs?: {
|
|
63
|
+
filterByTk?: unknown;
|
|
63
64
|
isMobileLayout?: unknown;
|
|
65
|
+
sourceId?: unknown;
|
|
64
66
|
};
|
|
65
67
|
};
|
|
66
68
|
};
|
|
@@ -102,6 +104,10 @@ export const FlowPage = React.memo((props: FlowPageProps & Record<string, unknow
|
|
|
102
104
|
subType: 'object',
|
|
103
105
|
use: pageModelClass,
|
|
104
106
|
};
|
|
107
|
+
const isRuntimeRecordScopedPage =
|
|
108
|
+
!flowEngine.context.flowSettingsEnabled &&
|
|
109
|
+
(typeof ctx?.view?.inputArgs?.filterByTk !== 'undefined' ||
|
|
110
|
+
typeof ctx?.view?.inputArgs?.sourceId !== 'undefined');
|
|
105
111
|
if (shouldInjectDefaultChildTab) {
|
|
106
112
|
const tabTitle = defaultTabTitle || flowEngine.translate?.('Details');
|
|
107
113
|
options['subModels'] = {
|
|
@@ -128,7 +134,9 @@ export const FlowPage = React.memo((props: FlowPageProps & Record<string, unknow
|
|
|
128
134
|
},
|
|
129
135
|
};
|
|
130
136
|
}
|
|
131
|
-
const data =
|
|
137
|
+
const data =
|
|
138
|
+
(isRuntimeRecordScopedPage && (await flowEngine.loadModel({ ...options, refresh: true }))) ||
|
|
139
|
+
(await flowEngine.loadOrCreateModel(options, { skipSave: !flowEngine.context.flowSettingsEnabled }));
|
|
132
140
|
if (data?.uid && onModelLoaded) {
|
|
133
141
|
data.context.addDelegate(ctx);
|
|
134
142
|
bindViewLayoutState(data, ctx);
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { render, waitFor } from '@testing-library/react';
|
|
11
11
|
import React from 'react';
|
|
12
|
-
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
12
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
13
13
|
import { FlowPage } from '../FlowPage';
|
|
14
14
|
|
|
15
15
|
type TestContextProperty = {
|
|
@@ -71,10 +71,15 @@ const createPageModel = (): TestPageModel => {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
const mocks = vi.hoisted(() => ({
|
|
74
|
+
flowSettingsEnabled: false,
|
|
75
|
+
loadModel: vi.fn(),
|
|
76
|
+
loadOrCreateModel: vi.fn(),
|
|
74
77
|
rendererMobileStates: [] as boolean[],
|
|
75
78
|
rendererProps: undefined as RendererProps | undefined,
|
|
76
79
|
model: undefined as TestPageModel | undefined,
|
|
80
|
+
viewFilterByTk: undefined as unknown,
|
|
77
81
|
viewInputMobileLayout: true as boolean | undefined,
|
|
82
|
+
viewSourceId: undefined as unknown,
|
|
78
83
|
contextMobileLayout: undefined as boolean | undefined,
|
|
79
84
|
}));
|
|
80
85
|
|
|
@@ -94,15 +99,20 @@ vi.mock('@nocobase/flow-engine', async () => {
|
|
|
94
99
|
}),
|
|
95
100
|
useFlowEngine: vi.fn(() => ({
|
|
96
101
|
getModelClassAsync: vi.fn(async () => TestPageModelClass),
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
loadModel: mocks.loadModel,
|
|
103
|
+
loadOrCreateModel: mocks.loadOrCreateModel,
|
|
104
|
+
context: {
|
|
105
|
+
flowSettingsEnabled: mocks.flowSettingsEnabled,
|
|
106
|
+
},
|
|
99
107
|
translate: vi.fn((value: string) => value),
|
|
100
108
|
})),
|
|
101
109
|
useFlowModelById: vi.fn(() => mocks.model),
|
|
102
110
|
useFlowViewContext: vi.fn(() => ({
|
|
103
111
|
view: {
|
|
104
112
|
inputArgs: {
|
|
113
|
+
...(typeof mocks.viewFilterByTk !== 'undefined' ? { filterByTk: mocks.viewFilterByTk } : {}),
|
|
105
114
|
...(typeof mocks.viewInputMobileLayout === 'boolean' ? { isMobileLayout: mocks.viewInputMobileLayout } : {}),
|
|
115
|
+
...(typeof mocks.viewSourceId !== 'undefined' ? { sourceId: mocks.viewSourceId } : {}),
|
|
106
116
|
},
|
|
107
117
|
},
|
|
108
118
|
...(typeof mocks.contextMobileLayout === 'boolean' ? { isMobileLayout: mocks.contextMobileLayout } : {}),
|
|
@@ -154,11 +164,21 @@ vi.mock('ahooks', async () => {
|
|
|
154
164
|
});
|
|
155
165
|
|
|
156
166
|
describe('FlowPage', () => {
|
|
167
|
+
beforeEach(() => {
|
|
168
|
+
mocks.loadModel.mockImplementation(async () => null);
|
|
169
|
+
mocks.loadOrCreateModel.mockImplementation(async () => mocks.model);
|
|
170
|
+
});
|
|
171
|
+
|
|
157
172
|
afterEach(() => {
|
|
173
|
+
mocks.flowSettingsEnabled = false;
|
|
174
|
+
mocks.loadModel.mockReset();
|
|
175
|
+
mocks.loadOrCreateModel.mockReset();
|
|
158
176
|
mocks.rendererMobileStates = [];
|
|
159
177
|
mocks.rendererProps = undefined;
|
|
160
178
|
mocks.model = undefined;
|
|
179
|
+
mocks.viewFilterByTk = undefined;
|
|
161
180
|
mocks.viewInputMobileLayout = true;
|
|
181
|
+
mocks.viewSourceId = undefined;
|
|
162
182
|
mocks.contextMobileLayout = undefined;
|
|
163
183
|
});
|
|
164
184
|
|
|
@@ -203,4 +223,31 @@ describe('FlowPage', () => {
|
|
|
203
223
|
expect(mocks.rendererMobileStates[0]).toBe(expected);
|
|
204
224
|
},
|
|
205
225
|
);
|
|
226
|
+
|
|
227
|
+
it('reloads runtime page models for record scoped views', async () => {
|
|
228
|
+
mocks.model = createPageModel();
|
|
229
|
+
mocks.viewFilterByTk = 1;
|
|
230
|
+
mocks.loadModel.mockImplementation(async () => mocks.model);
|
|
231
|
+
|
|
232
|
+
render(<FlowPage onModelLoaded={vi.fn()} />);
|
|
233
|
+
|
|
234
|
+
await waitFor(() => {
|
|
235
|
+
expect(mocks.loadModel).toHaveBeenCalled();
|
|
236
|
+
});
|
|
237
|
+
expect(mocks.loadModel.mock.calls[0]?.[0]).toMatchObject({ refresh: true });
|
|
238
|
+
expect(mocks.loadOrCreateModel).not.toHaveBeenCalled();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('keeps configured page model cache behavior in flow settings mode', async () => {
|
|
242
|
+
mocks.flowSettingsEnabled = true;
|
|
243
|
+
mocks.model = createPageModel();
|
|
244
|
+
mocks.viewFilterByTk = 1;
|
|
245
|
+
|
|
246
|
+
render(<FlowPage onModelLoaded={vi.fn()} />);
|
|
247
|
+
|
|
248
|
+
await waitFor(() => {
|
|
249
|
+
expect(mocks.loadOrCreateModel).toHaveBeenCalled();
|
|
250
|
+
});
|
|
251
|
+
expect(mocks.loadModel).not.toHaveBeenCalled();
|
|
252
|
+
});
|
|
206
253
|
});
|
|
@@ -116,6 +116,7 @@ describe('FlowRoute', () => {
|
|
|
116
116
|
}),
|
|
117
117
|
);
|
|
118
118
|
});
|
|
119
|
+
expect(engine.context.deviceType).toBe('computer');
|
|
119
120
|
|
|
120
121
|
rerender(
|
|
121
122
|
<FlowEngineProvider engine={engine}>
|
|
@@ -581,14 +582,14 @@ describe('FlowRoute', () => {
|
|
|
581
582
|
expect(getRouteBySchemaUid).toHaveBeenCalledTimes(1);
|
|
582
583
|
});
|
|
583
584
|
|
|
584
|
-
it('should
|
|
585
|
+
it('should explain how to open a legacy page outside the v2 runtime', async () => {
|
|
585
586
|
const originalLocation = window.location;
|
|
586
587
|
const replace = vi.fn();
|
|
587
588
|
Object.defineProperty(window, 'location', {
|
|
588
589
|
configurable: true,
|
|
589
590
|
value: {
|
|
590
591
|
...originalLocation,
|
|
591
|
-
pathname: '/v2/admin/test-page/tab/tab-1',
|
|
592
|
+
pathname: '/nocobase/v2/apps/jhb20/admin/test-page/tab/tab-1',
|
|
592
593
|
search: '?from=direct',
|
|
593
594
|
hash: '#dialog',
|
|
594
595
|
replace,
|
|
@@ -607,9 +608,9 @@ describe('FlowRoute', () => {
|
|
|
607
608
|
});
|
|
608
609
|
engine.context.defineProperty('app', {
|
|
609
610
|
value: {
|
|
610
|
-
getPublicPath: () => '/v2/',
|
|
611
|
+
getPublicPath: () => '/nocobase/v2/',
|
|
611
612
|
router: {
|
|
612
|
-
getBasename: () => '/v2',
|
|
613
|
+
getBasename: () => '/nocobase/v2',
|
|
613
614
|
},
|
|
614
615
|
},
|
|
615
616
|
});
|
|
@@ -625,15 +626,25 @@ describe('FlowRoute', () => {
|
|
|
625
626
|
|
|
626
627
|
render(
|
|
627
628
|
<FlowEngineProvider engine={engine}>
|
|
628
|
-
<MemoryRouter initialEntries={['/
|
|
629
|
+
<MemoryRouter initialEntries={['/nocobase/v2/apps/jhb20/admin/test-page/tab/tab-1?from=direct#dialog']}>
|
|
629
630
|
<Routes>
|
|
630
|
-
<Route path="/
|
|
631
|
+
<Route path="/nocobase/v2/apps/jhb20/admin/:name/*" element={<FlowRoute />} />
|
|
631
632
|
</Routes>
|
|
632
633
|
</MemoryRouter>
|
|
633
634
|
</FlowEngineProvider>,
|
|
634
635
|
);
|
|
635
636
|
|
|
636
|
-
expect(await screen.findByText('
|
|
637
|
+
expect(await screen.findByText('This page is not supported in the /v2/ branch')).toBeInTheDocument();
|
|
638
|
+
expect(
|
|
639
|
+
screen.getByText(
|
|
640
|
+
'The /v2/ branch only supports new pages. This page is a legacy page. Please open it from the original entry.',
|
|
641
|
+
),
|
|
642
|
+
).toBeInTheDocument();
|
|
643
|
+
expect(screen.queryByText('404')).not.toBeInTheDocument();
|
|
644
|
+
expect(screen.getByRole('link', { name: 'Open from the original entry' })).toHaveAttribute(
|
|
645
|
+
'href',
|
|
646
|
+
'/nocobase/apps/jhb20/admin/test-page/tab/tab-1?from=direct#dialog',
|
|
647
|
+
);
|
|
637
648
|
expect(replace).not.toHaveBeenCalled();
|
|
638
649
|
expect(adminLayoutModel.registerRoutePage).not.toHaveBeenCalled();
|
|
639
650
|
expect(adminLayoutModel.updateRoutePage).not.toHaveBeenCalled();
|
|
@@ -706,6 +717,113 @@ describe('FlowRoute', () => {
|
|
|
706
717
|
}
|
|
707
718
|
});
|
|
708
719
|
|
|
720
|
+
it('should render 404 for missing FlowModel in notFound mode without routeRepository', async () => {
|
|
721
|
+
const engine = new FlowEngine();
|
|
722
|
+
engine.context.defineProperty('app', {
|
|
723
|
+
value: {
|
|
724
|
+
getPublicPath: () => '/v2/',
|
|
725
|
+
router: {
|
|
726
|
+
getBasename: () => '/v2',
|
|
727
|
+
},
|
|
728
|
+
},
|
|
729
|
+
});
|
|
730
|
+
|
|
731
|
+
const adminLayoutModel: MockAdminLayoutModel = Object.assign(
|
|
732
|
+
engine.createModel({ uid: 'admin-layout-model', use: 'FlowModel' }),
|
|
733
|
+
{
|
|
734
|
+
registerRoutePage: vi.fn(),
|
|
735
|
+
updateRoutePage: vi.fn(),
|
|
736
|
+
unregisterRoutePage: vi.fn(),
|
|
737
|
+
},
|
|
738
|
+
);
|
|
739
|
+
|
|
740
|
+
render(
|
|
741
|
+
<FlowEngineProvider engine={engine}>
|
|
742
|
+
<MemoryRouter initialEntries={['/embed/missing-page']}>
|
|
743
|
+
<Routes>
|
|
744
|
+
<Route path="/embed/:name" element={<FlowRoute legacyPageBehavior="notFound" />} />
|
|
745
|
+
</Routes>
|
|
746
|
+
</MemoryRouter>
|
|
747
|
+
</FlowEngineProvider>,
|
|
748
|
+
);
|
|
749
|
+
|
|
750
|
+
expect(await screen.findByText('404')).toBeInTheDocument();
|
|
751
|
+
expect(adminLayoutModel.registerRoutePage).not.toHaveBeenCalled();
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
it('should bridge by default when routeRepository does not exist', async () => {
|
|
755
|
+
const engine = new FlowEngine();
|
|
756
|
+
engine.context.defineProperty('app', {
|
|
757
|
+
value: {
|
|
758
|
+
getPublicPath: () => '/v2/',
|
|
759
|
+
router: {
|
|
760
|
+
getBasename: () => '/v2',
|
|
761
|
+
},
|
|
762
|
+
},
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
const adminLayoutModel: MockAdminLayoutModel = Object.assign(
|
|
766
|
+
engine.createModel({ uid: 'admin-layout-model', use: 'FlowModel' }),
|
|
767
|
+
{
|
|
768
|
+
registerRoutePage: vi.fn(),
|
|
769
|
+
updateRoutePage: vi.fn(),
|
|
770
|
+
unregisterRoutePage: vi.fn(),
|
|
771
|
+
},
|
|
772
|
+
);
|
|
773
|
+
|
|
774
|
+
render(
|
|
775
|
+
<FlowEngineProvider engine={engine}>
|
|
776
|
+
<MemoryRouter initialEntries={['/flow/missing-page']}>
|
|
777
|
+
<Routes>
|
|
778
|
+
<Route path="/flow/:name" element={<FlowRoute />} />
|
|
779
|
+
</Routes>
|
|
780
|
+
</MemoryRouter>
|
|
781
|
+
</FlowEngineProvider>,
|
|
782
|
+
);
|
|
783
|
+
|
|
784
|
+
await waitFor(() => {
|
|
785
|
+
expect(adminLayoutModel.registerRoutePage).toHaveBeenCalledWith('missing-page', expect.any(Object));
|
|
786
|
+
});
|
|
787
|
+
expect(screen.queryByText('404')).not.toBeInTheDocument();
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
it('should bridge existing FlowModel in notFound mode without routeRepository', async () => {
|
|
791
|
+
const engine = new FlowEngine();
|
|
792
|
+
engine.createModel({ uid: 'test-page', use: 'FlowModel' });
|
|
793
|
+
engine.context.defineProperty('app', {
|
|
794
|
+
value: {
|
|
795
|
+
getPublicPath: () => '/v2/',
|
|
796
|
+
router: {
|
|
797
|
+
getBasename: () => '/v2',
|
|
798
|
+
},
|
|
799
|
+
},
|
|
800
|
+
});
|
|
801
|
+
|
|
802
|
+
const adminLayoutModel: MockAdminLayoutModel = Object.assign(
|
|
803
|
+
engine.createModel({ uid: 'admin-layout-model', use: 'FlowModel' }),
|
|
804
|
+
{
|
|
805
|
+
registerRoutePage: vi.fn(),
|
|
806
|
+
updateRoutePage: vi.fn(),
|
|
807
|
+
unregisterRoutePage: vi.fn(),
|
|
808
|
+
},
|
|
809
|
+
);
|
|
810
|
+
|
|
811
|
+
render(
|
|
812
|
+
<FlowEngineProvider engine={engine}>
|
|
813
|
+
<MemoryRouter initialEntries={['/embed/test-page']}>
|
|
814
|
+
<Routes>
|
|
815
|
+
<Route path="/embed/:name" element={<FlowRoute legacyPageBehavior="notFound" />} />
|
|
816
|
+
</Routes>
|
|
817
|
+
</MemoryRouter>
|
|
818
|
+
</FlowEngineProvider>,
|
|
819
|
+
);
|
|
820
|
+
|
|
821
|
+
await waitFor(() => {
|
|
822
|
+
expect(adminLayoutModel.registerRoutePage).toHaveBeenCalledWith('test-page', expect.any(Object));
|
|
823
|
+
});
|
|
824
|
+
expect(screen.queryByText('404')).not.toBeInTheDocument();
|
|
825
|
+
});
|
|
826
|
+
|
|
709
827
|
it('should bridge existing FlowModel when behavior is notFound and routeRepository has no route', async () => {
|
|
710
828
|
const engine = new FlowEngine();
|
|
711
829
|
engine.setModelRepository({
|
|
@@ -1666,7 +1784,7 @@ describe('FlowRoute', () => {
|
|
|
1666
1784
|
expect(engine.getModel('public-form-1')).toBeUndefined();
|
|
1667
1785
|
});
|
|
1668
1786
|
|
|
1669
|
-
it('should
|
|
1787
|
+
it('should skip accessible route loading when layout authCheck is false', async () => {
|
|
1670
1788
|
const engine = new FlowEngine();
|
|
1671
1789
|
const ensureAccessibleLoaded = vi.fn().mockRejectedValue(new Error('cannot load accessible routes'));
|
|
1672
1790
|
const getRouteBySchemaUid = vi.fn();
|
|
@@ -1735,7 +1853,7 @@ describe('FlowRoute', () => {
|
|
|
1735
1853
|
await waitFor(() => {
|
|
1736
1854
|
expect(layoutModel.registerRoutePage).toHaveBeenCalledWith('public-form-1', expect.any(Object));
|
|
1737
1855
|
});
|
|
1738
|
-
expect(ensureAccessibleLoaded).
|
|
1856
|
+
expect(ensureAccessibleLoaded).not.toHaveBeenCalled();
|
|
1739
1857
|
expect(getRouteBySchemaUid).not.toHaveBeenCalled();
|
|
1740
1858
|
});
|
|
1741
1859
|
|
|
@@ -1801,7 +1919,7 @@ describe('FlowRoute', () => {
|
|
|
1801
1919
|
}
|
|
1802
1920
|
});
|
|
1803
1921
|
|
|
1804
|
-
it('should render
|
|
1922
|
+
it('should render 404 when route and FlowModel do not exist', async () => {
|
|
1805
1923
|
const originalLocation = window.location;
|
|
1806
1924
|
const replace = vi.fn();
|
|
1807
1925
|
Object.defineProperty(window, 'location', {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { createMockClient, PluginFlowEngine } from '@nocobase/client-v2';
|
|
11
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
12
|
+
|
|
13
|
+
const { detectedDeviceType } = vi.hoisted(() => ({
|
|
14
|
+
detectedDeviceType: { value: 'mobile' },
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
vi.mock('react-device-detect', () => ({
|
|
18
|
+
get deviceType() {
|
|
19
|
+
return detectedDeviceType.value;
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
describe('PluginFlowEngine', () => {
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
detectedDeviceType.value = 'mobile';
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should register the current device type before shared flow components', async () => {
|
|
29
|
+
const app = createMockClient({
|
|
30
|
+
router: {
|
|
31
|
+
type: 'memory',
|
|
32
|
+
initialEntries: ['/'],
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const plugin = new PluginFlowEngine({}, app);
|
|
36
|
+
const addComponents = app.addComponents.bind(app);
|
|
37
|
+
const deviceTypesBeforeComponentRegistration: string[] = [];
|
|
38
|
+
vi.spyOn(app, 'addComponents').mockImplementation((components) => {
|
|
39
|
+
deviceTypesBeforeComponentRegistration.push(app.flowEngine.context.deviceType);
|
|
40
|
+
return addComponents(components);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
await plugin.load();
|
|
44
|
+
|
|
45
|
+
expect(app.flowEngine.context.deviceType).toBe('mobile');
|
|
46
|
+
expect(deviceTypesBeforeComponentRegistration).toEqual(['mobile']);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should normalize the browser device type to computer', async () => {
|
|
50
|
+
detectedDeviceType.value = 'browser';
|
|
51
|
+
const app = createMockClient();
|
|
52
|
+
const plugin = new PluginFlowEngine({}, app);
|
|
53
|
+
|
|
54
|
+
await plugin.load();
|
|
55
|
+
|
|
56
|
+
expect(app.flowEngine.context.deviceType).toBe('computer');
|
|
57
|
+
});
|
|
58
|
+
});
|