diff --git a/packages/core/client/src/data-source/data-block/DataBlockRequestProvider.tsx b/packages/core/client/src/data-source/data-block/DataBlockRequestProvider.tsx index cb35bbda9..45759d922 100644 --- a/packages/core/client/src/data-source/data-block/DataBlockRequestProvider.tsx +++ b/packages/core/client/src/data-source/data-block/DataBlockRequestProvider.tsx @@ -114,7 +114,7 @@ export const BlockRequestProvider: FC = ({ children }) => { {action !== 'list' ? ( diff --git a/packages/core/client/src/modules/blocks/data-blocks/form/__e2e__/form-create/associationForm.test.ts b/packages/core/client/src/modules/blocks/data-blocks/form/__e2e__/form-create/associationForm.test.ts new file mode 100644 index 000000000..f7ce94f73 --- /dev/null +++ b/packages/core/client/src/modules/blocks/data-blocks/form/__e2e__/form-create/associationForm.test.ts @@ -0,0 +1,21 @@ +import { test, expect } from '@nocobase/test/e2e'; +import { T3529 } from './templatesOfBug'; + +test.describe('association form block', () => { + // https://nocobase.height.app/T-3529 + test('should be created instead of updated', async ({ page, mockPage, mockRecord }) => { + const nocoPage = await mockPage(T3529).waitForInit(); + await mockRecord('general'); + await nocoPage.goto(); + + await page.getByLabel('action-Action.Link-View-view-general-table-0').click(); + void page.getByLabel('action-Action-Submit-submit-').click(); + + const request = await page.waitForRequest((request) => { + return request.url().includes('m2mField0:create'); + }); + + // 应该有包含 :create 的请求 + expect(request).toBeTruthy(); + }); +}); diff --git a/packages/core/client/src/modules/blocks/data-blocks/form/__e2e__/form-create/templatesOfBug.ts b/packages/core/client/src/modules/blocks/data-blocks/form/__e2e__/form-create/templatesOfBug.ts index c19e35cf7..03cae11ff 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/form/__e2e__/form-create/templatesOfBug.ts +++ b/packages/core/client/src/modules/blocks/data-blocks/form/__e2e__/form-create/templatesOfBug.ts @@ -1,4 +1,4 @@ -import { PageConfig, generalWithM2oSingleSelect } from '@nocobase/test/e2e'; +import { PageConfig, generalWithM2oSingleSelect, generalWithMultiLevelM2mFields } from '@nocobase/test/e2e'; export const T2165 = { pageSchema: { @@ -5701,3 +5701,374 @@ export const T3469: PageConfig = { 'x-async': true, }, }; + +// https://nocobase.height.app/T-3529 +export const T3529: PageConfig = { + collections: generalWithMultiLevelM2mFields, + pageSchema: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Page', + properties: { + '5i47muli5of': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'BlockInitializers', + properties: { + l62athlwjbe: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Row', + properties: { + gv12rstt0n6: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Col', + properties: { + '44sjepqege8': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-decorator': 'TableBlockProvider', + 'x-acl-action': 'general:list', + 'x-decorator-props': { + collection: 'general', + dataSource: 'main', + resource: 'general', + action: 'list', + params: { + pageSize: 20, + }, + rowKey: 'id', + showIndex: true, + dragSort: false, + disableTemplate: false, + }, + 'x-toolbar': 'BlockSchemaToolbar', + 'x-settings': 'blockSettings:table', + 'x-component': 'CardItem', + 'x-filter-targets': [], + properties: { + actions: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-initializer': 'TableActionInitializers', + 'x-component': 'ActionBar', + 'x-component-props': { + style: { + marginBottom: 'var(--nb-spacing)', + }, + }, + 'x-uid': 'gcqzwfc98cz', + 'x-async': false, + 'x-index': 1, + }, + cndkuudjlrn: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'array', + 'x-initializer': 'TableColumnInitializers', + 'x-component': 'TableV2', + 'x-component-props': { + rowKey: 'id', + rowSelection: { + type: 'checkbox', + }, + useProps: '{{ useTableBlockProps }}', + }, + properties: { + actions: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{ t("Actions") }}', + 'x-action-column': 'actions', + 'x-decorator': 'TableV2.Column.ActionBar', + 'x-component': 'TableV2.Column', + 'x-designer': 'TableV2.ActionColumnDesigner', + 'x-initializer': 'TableActionColumnInitializers', + properties: { + '7glkmum3znh': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-decorator': 'DndContext', + 'x-component': 'Space', + 'x-component-props': { + split: '|', + }, + properties: { + '34feo0sq1b1': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{ t("View") }}', + 'x-action': 'view', + 'x-toolbar': 'ActionSchemaToolbar', + 'x-settings': 'actionSettings:view', + 'x-component': 'Action.Link', + 'x-component-props': { + openMode: 'drawer', + }, + 'x-decorator': 'ACLActionProvider', + 'x-designer-props': { + linkageAction: true, + }, + properties: { + drawer: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{ t("View record") }}', + 'x-component': 'Action.Container', + 'x-component-props': { + className: 'nb-action-popup', + }, + properties: { + tabs: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Tabs', + 'x-component-props': {}, + 'x-initializer': 'TabPaneInitializers', + properties: { + tab1: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{t("Details")}}', + 'x-component': 'Tabs.TabPane', + 'x-designer': 'Tabs.Designer', + 'x-component-props': {}, + properties: { + grid: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'RecordBlockInitializers', + properties: { + '5ubuvb82lbu': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Row', + properties: { + pe6vly71p50: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Col', + properties: { + ls6i68y4q5r: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-acl-action-props': { + skipScopeCheck: true, + }, + 'x-acl-action': 'general.m2mField0:create', + 'x-decorator': 'FormBlockProvider', + 'x-decorator-props': { + useSourceId: '{{ useSourceIdFromParentRecord }}', + useParams: '{{ useParamsFromRecord }}', + action: null, + dataSource: 'main', + resource: 'general.m2mField0', + collection: 'm2mField1', + association: 'general.m2mField0', + }, + 'x-toolbar': 'BlockSchemaToolbar', + 'x-settings': 'blockSettings:createForm', + 'x-component': 'CardItem', + 'x-component-props': {}, + properties: { + '4g1wyduvzzq': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'FormV2', + 'x-component-props': { + useProps: '{{ useFormBlockProps }}', + }, + properties: { + grid: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'FormItemInitializers', + 'x-uid': 'aigmsbzdyeb', + 'x-async': false, + 'x-index': 1, + }, + v5tx6a8ya3q: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-initializer': 'CreateFormActionInitializers', + 'x-component': 'ActionBar', + 'x-component-props': { + layout: 'one-column', + style: { + marginTop: 24, + }, + }, + properties: { + dhmchgjzu2d: { + _isJSONSchemaObject: true, + version: '2.0', + title: '{{ t("Submit") }}', + 'x-action': 'submit', + 'x-component': 'Action', + 'x-toolbar': 'ActionSchemaToolbar', + 'x-settings': 'actionSettings:createSubmit', + 'x-component-props': { + type: 'primary', + htmlType: 'submit', + useProps: '{{ useCreateActionProps }}', + }, + 'x-action-settings': { + triggerWorkflows: [], + }, + type: 'void', + 'x-uid': 'bgi90aunfbx', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '6m4zb9wz65e', + 'x-async': false, + 'x-index': 2, + }, + }, + 'x-uid': 'sbl64rh18y4', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'z76kadyn2d8', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'kb89ln0xf6j', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'zyqb93i3dfg', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'zxthz54u0wr', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '4vis0296ryj', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'p23nq2w7s15', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'zaqeevlcwap', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'r1tzkph9sg3', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '2k7344qkff4', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'jozmqdix3a6', + 'x-async': false, + 'x-index': 1, + }, + exdcwiv8fnb: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-decorator': 'TableV2.Column.Decorator', + 'x-toolbar': 'TableColumnSchemaToolbar', + 'x-settings': 'fieldSettings:TableColumn', + 'x-component': 'TableV2.Column', + properties: { + m2mField0: { + _isJSONSchemaObject: true, + version: '2.0', + 'x-collection-field': 'general.m2mField0', + 'x-component': 'CollectionField', + 'x-component-props': { + fieldNames: { + value: 'id', + label: 'id', + }, + ellipsis: true, + size: 'small', + }, + 'x-read-pretty': true, + 'x-decorator': null, + 'x-decorator-props': { + labelStyle: { + display: 'none', + }, + }, + 'x-uid': 'gzktad04dhq', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'fulrpp42vr2', + 'x-async': false, + 'x-index': 2, + }, + }, + 'x-uid': '6rucf9up8f4', + 'x-async': false, + 'x-index': 2, + }, + }, + 'x-uid': 'izfl6h66ch4', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'i8m1l6l6qg5', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'v0y71zujt89', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'vpa330z2xp5', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'l4kzvh7mdoa', + 'x-async': true, + 'x-index': 1, + }, +}; diff --git a/packages/plugins/@nocobase/plugin-collection-manager/src/client/__e2e__/fields/oneToMany/schemaSettings.test.ts b/packages/plugins/@nocobase/plugin-collection-manager/src/client/__e2e__/fields/oneToMany/schemaSettings.test.ts index b5f74d374..b162e858e 100644 --- a/packages/plugins/@nocobase/plugin-collection-manager/src/client/__e2e__/fields/oneToMany/schemaSettings.test.ts +++ b/packages/plugins/@nocobase/plugin-collection-manager/src/client/__e2e__/fields/oneToMany/schemaSettings.test.ts @@ -496,23 +496,16 @@ test.describe('form item & view form', () => { }); }); - test('field component', async ({ page, mockPage, mockRecords }) => { - await (async (mockPage, mockRecords) => { - const nocoPage = await mockPage(oneTableBlockWithAddNewAndViewAndEditAndAssociationFields).waitForInit(); - const record = (await mockRecords('general', 1))[0]; - await nocoPage.goto(); + test('field component', async ({ page, mockPage, mockRecord }) => { + const nocoPage = await mockPage(oneTableBlockWithAddNewAndViewAndEditAndAssociationFields).waitForInit(); + await mockRecord('general'); + await nocoPage.goto(); - return record; - })(mockPage, mockRecords); - await (async (page: Page) => { - await page.getByLabel('action-Action.Link-View record-view-general-table-0').click(); - })(page); - await (async (page: Page, fieldName: string) => { - await page.getByLabel(`block-item-CollectionField-general-form-general.${fieldName}-${fieldName}`).hover(); - await page - .getByLabel(`designer-schema-settings-CollectionField-FormItem.Designer-general-general.${fieldName}`) - .hover(); - })(page, 'oneToMany'); + await page.getByLabel('action-Action.Link-View record-view-general-table-0').click(); + await page.getByLabel(`block-item-CollectionField-general-form-general.oneToMany-oneToMany`).hover(); + await page + .getByLabel(`designer-schema-settings-CollectionField-FormItem.Designer-general-general.oneToMany`) + .hover(); await page.getByRole('menuitem', { name: 'Field component' }).click(); // 断言支持的选项