From e532b8f0068920857ddcda9e05a973f1b1f0050f Mon Sep 17 00:00:00 2001 From: Zeke Zhang <958414905@qq.com> Date: Thu, 7 Nov 2024 20:44:54 +0800 Subject: [PATCH] test: add e2e test --- .../table/__e2e__/linkageRules.test.ts | 23 + .../table/__e2e__/templatesOfBug.ts | 587 ++++++++++++++++++ 2 files changed, 610 insertions(+) create mode 100644 packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/linkageRules.test.ts diff --git a/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/linkageRules.test.ts b/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/linkageRules.test.ts new file mode 100644 index 0000000000..9a7f8f938c --- /dev/null +++ b/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/linkageRules.test.ts @@ -0,0 +1,23 @@ +/** + * This file is part of the NocoBase (R) project. + * Copyright (c) 2020-2024 NocoBase Co., Ltd. + * Authors: NocoBase Team. + * + * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. + * For more information, please refer to: https://www.nocobase.com/agreement. + */ + +import { expect, test } from '@nocobase/test/e2e'; +import { subTableLinkageRules } from './templatesOfBug'; + +test('linkage rules', async ({ page, mockPage }) => { + // Linkage rules have been set in the sub-table, the rule is: disable the singleLineText field + await mockPage(subTableLinkageRules).goto(); + + // Open the data selector popup, in the form within the dialog, the singleLineText field should not be disabled + await page.getByText('Add new').click(); + await page.getByTestId('select-data-picker').click(); + await expect( + page.getByTestId('drawer-AssociationField.Selector-t_3pmvgy00kxz-Select record').getByRole('textbox'), + ).not.toBeDisabled(); +}); diff --git a/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/templatesOfBug.ts b/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/templatesOfBug.ts index 72ba397b28..ee3301ce0c 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/templatesOfBug.ts +++ b/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/templatesOfBug.ts @@ -7926,3 +7926,590 @@ export const differentURL_DifferentPopupContent = { 'x-index': 1, }, }; +export const subTableLinkageRules = { + collections: [ + { + name: 'collection1', + fields: [ + { + name: 'manyToMany', + interface: 'm2m', + target: 'collection2', + targetKey: 'id', + }, + ], + }, + { + name: 'collection2', + fields: [ + { + name: 'manyToMany', + type: 'belongsToMany', + interface: 'm2m', + target: 'collection3s', + targetKey: 'id', + }, + { + name: 'singleLineText', + interface: 'input', + }, + ], + }, + { + name: 'collection3', + fields: [ + { + name: 'singleLineText', + interface: 'input', + }, + ], + }, + ], + pageSchema: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Page', + 'x-app-version': '1.4.0-alpha.2', + properties: { + w8odriar0fx: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'page:addBlock', + 'x-app-version': '1.4.0-alpha.2', + properties: { + mwlgbbtshin: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Row', + 'x-app-version': '1.4.0-alpha.2', + properties: { + '8ynn4206h34': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Col', + 'x-app-version': '1.4.0-alpha.2', + properties: { + mu5jt0kcboy: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-acl-action-props': { + skipScopeCheck: true, + }, + 'x-acl-action': 'collection1:create', + 'x-decorator': 'FormBlockProvider', + 'x-use-decorator-props': 'useCreateFormBlockDecoratorProps', + 'x-decorator-props': { + dataSource: 'main', + collection: 'collection1', + }, + 'x-toolbar': 'BlockSchemaToolbar', + 'x-settings': 'blockSettings:createForm', + 'x-component': 'CardItem', + 'x-app-version': '1.4.0-alpha.2', + properties: { + h1hq3tt652b: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'FormV2', + 'x-use-component-props': 'useCreateFormBlockProps', + 'x-app-version': '1.4.0-alpha.2', + properties: { + grid: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'form:configureFields', + 'x-app-version': '1.4.0-alpha.2', + properties: { + '5da1gzl23cu': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Row', + 'x-app-version': '1.4.0-alpha.2', + properties: { + k52w3z0wu6h: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Col', + 'x-app-version': '1.4.0-alpha.2', + properties: { + manyToMany: { + 'x-uid': 'x5zyuok7av9', + _isJSONSchemaObject: true, + version: '2.0', + type: 'string', + 'x-toolbar': 'FormItemSchemaToolbar', + 'x-settings': 'fieldSettings:FormItem', + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'collection1.manyToMany', + 'x-component-props': { + fieldNames: { + value: 'id', + label: 'id', + }, + mode: 'SubTable', + }, + 'x-app-version': '1.4.0-alpha.2', + default: null, + 'x-linkage-rules': [ + { + condition: { + $and: [], + }, + actions: [ + { + targetFields: ['singleLineText'], + operator: 'disabled', + }, + ], + }, + ], + properties: { + vrkv4jzit4h: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'AssociationField.Nester', + 'x-index': 1, + 'x-app-version': '1.4.0-alpha.2', + properties: { + grid: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'form:configureFields', + 'x-app-version': '1.4.0-alpha.2', + properties: { + uubjjosxdz1: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Row', + 'x-app-version': '1.4.0-alpha.2', + properties: { + d9uw2h6rscl: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Col', + 'x-app-version': '1.4.0-alpha.2', + properties: { + singleLineText: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'string', + 'x-toolbar': 'FormItemSchemaToolbar', + 'x-settings': 'fieldSettings:FormItem', + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 't_an1l9v3mhet.singleLineText', + 'x-component-props': {}, + 'x-app-version': '1.4.0-alpha.2', + 'x-uid': 'uglafqok6sg', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '1fnw74k2ecc', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'kp98heavift', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'xqdnxqrfesy', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'zkx9pr5bc7w', + 'x-async': false, + }, + zx5euqoh0vc: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'AssociationField.SubTable', + 'x-initializer': 'table:configureColumns', + 'x-initializer-props': { + action: false, + }, + 'x-index': 2, + 'x-app-version': '1.4.0-alpha.2', + properties: { + gu5lapoqe0i: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-decorator': 'TableV2.Column.Decorator', + 'x-toolbar': 'TableColumnSchemaToolbar', + 'x-settings': 'fieldSettings:TableColumn', + 'x-component': 'TableV2.Column', + 'x-app-version': '1.4.0-alpha.2', + properties: { + manyToMany: { + 'x-uid': 'bfd2sj8bntg', + _isJSONSchemaObject: true, + version: '2.0', + 'x-collection-field': 't_an1l9v3mhet.manyToMany', + 'x-component': 'CollectionField', + 'x-component-props': { + fieldNames: { + value: 'id', + label: 'id', + }, + ellipsis: true, + size: 'small', + mode: 'Picker', + }, + 'x-decorator': 'FormItem', + 'x-decorator-props': { + labelStyle: { + display: 'none', + }, + }, + 'x-use-decorator-props': 'useSubTableFormItemProps', + 'x-app-version': '1.4.0-alpha.2', + properties: { + '3eahe76nrn7': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'AssociationField.Selector', + title: '{{ t("Select record") }}', + 'x-component-props': { + className: 'nb-record-picker-selector', + }, + 'x-index': 1, + 'x-app-version': '1.4.0-alpha.2', + properties: { + grid: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'popup:tableSelector:addBlock', + 'x-app-version': '1.4.0-alpha.2', + properties: { + '938a5xr15zs': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Row', + 'x-app-version': '1.4.0-alpha.2', + properties: { + '1y9nuo4wo1f': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Col', + 'x-app-version': '1.4.0-alpha.2', + properties: { + '6d2frspdmy5': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-decorator': 'FilterFormBlockProvider', + 'x-use-decorator-props': + 'useFilterFormBlockDecoratorProps', + 'x-decorator-props': { + dataSource: 'main', + collection: 't_3pmvgy00kxz', + }, + 'x-toolbar': 'BlockSchemaToolbar', + 'x-settings': 'blockSettings:filterForm', + 'x-component': 'CardItem', + 'x-filter-targets': [], + 'x-app-version': '1.4.0-alpha.2', + properties: { + fsv1sfwiaya: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'FormV2', + 'x-use-component-props': + 'useFilterFormBlockProps', + 'x-app-version': '1.4.0-alpha.2', + properties: { + grid: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': + 'filterForm:configureFields', + 'x-app-version': '1.4.0-alpha.2', + properties: { + '2o2rsiujxg7': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Row', + 'x-app-version': '1.4.0-alpha.2', + properties: { + wcdp5wwyh98: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Col', + 'x-app-version': + '1.4.0-alpha.2', + properties: { + singleLineText: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'string', + required: false, + 'x-toolbar': + 'FormItemSchemaToolbar', + 'x-settings': + 'fieldSettings:FilterFormItem', + 'x-component': + 'CollectionField', + 'x-decorator': 'FormItem', + 'x-use-decorator-props': + 'useFormItemProps', + 'x-collection-field': + 't_3pmvgy00kxz.singleLineText', + 'x-component-props': { + utc: false, + underFilter: true, + }, + 'x-app-version': + '1.4.0-alpha.2', + 'x-uid': 'my1fiypdia8', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'i0kifm6yedk', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'dcahjqsy91u', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '1cj8rvsn1sr', + 'x-async': false, + 'x-index': 1, + }, + tp4c2u6ydko: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-initializer': + 'filterForm:configureActions', + 'x-component': 'ActionBar', + 'x-component-props': { + layout: 'one-column', + style: { + float: 'right', + }, + }, + 'x-app-version': '1.4.0-alpha.2', + 'x-uid': 'rnd15e1cq82', + 'x-async': false, + 'x-index': 2, + }, + }, + 'x-uid': 'svx1l2w427y', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'e3q3y5ihdk0', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'i97utj0o96s', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'h6fnh2v9am5', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '2v98025xs3p', + 'x-async': false, + 'x-index': 1, + }, + footer: { + _isJSONSchemaObject: true, + version: '2.0', + 'x-component': 'Action.Container.Footer', + 'x-component-props': {}, + 'x-app-version': '1.4.0-alpha.2', + properties: { + actions: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'ActionBar', + 'x-component-props': {}, + 'x-app-version': '1.4.0-alpha.2', + properties: { + submit: { + _isJSONSchemaObject: true, + version: '2.0', + title: '{{ t("Submit") }}', + 'x-action': 'submit', + 'x-component': 'Action', + 'x-use-component-props': 'usePickActionProps', + 'x-toolbar': 'ActionSchemaToolbar', + 'x-settings': 'actionSettings:submit', + 'x-component-props': { + type: 'primary', + htmlType: 'submit', + }, + 'x-app-version': '1.4.0-alpha.2', + 'x-uid': 'jpb7kfmr6ei', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'f8wpc0wjhg2', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '0ajhhov7m2q', + 'x-async': false, + 'x-index': 2, + }, + }, + 'x-uid': 'ens17ye6b4z', + 'x-async': false, + }, + }, + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '3e7l2qq36at', + 'x-async': false, + 'x-index': 3, + }, + '0atm7ny49t0': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-decorator': 'TableV2.Column.Decorator', + 'x-toolbar': 'TableColumnSchemaToolbar', + 'x-settings': 'fieldSettings:TableColumn', + 'x-component': 'TableV2.Column', + 'x-app-version': '1.4.0-alpha.2', + properties: { + singleLineText: { + _isJSONSchemaObject: true, + version: '2.0', + 'x-collection-field': 't_an1l9v3mhet.singleLineText', + 'x-component': 'CollectionField', + 'x-component-props': { + ellipsis: true, + }, + 'x-decorator': 'FormItem', + 'x-decorator-props': { + labelStyle: { + display: 'none', + }, + }, + 'x-use-decorator-props': 'useSubTableFormItemProps', + 'x-app-version': '1.4.0-alpha.2', + 'x-uid': 'xw218vaxarw', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '3t7yljdj30g', + 'x-async': false, + 'x-index': 4, + }, + }, + 'x-uid': '9t2plx8wlu9', + 'x-async': false, + }, + }, + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'uivnczul8ds', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'y71816ls7oh', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '5jw0wd4ffq3', + 'x-async': false, + 'x-index': 1, + }, + '9xcv5mbr774': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-initializer': 'createForm:configureActions', + 'x-component': 'ActionBar', + 'x-component-props': { + layout: 'one-column', + }, + 'x-app-version': '1.4.0-alpha.2', + 'x-uid': '07iwd1qvy8n', + 'x-async': false, + 'x-index': 2, + }, + }, + 'x-uid': '9vza1p2nrpw', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '83evmrf9yyq', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'lx4mv9bfieq', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '0eoj7kpp7u7', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'w7uye840qc3', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'z9zmqq3syx9', + 'x-async': true, + 'x-index': 1, + }, +};