test: association name block e2e test (#4021)

* fix: initializer use useAassociationName

* test: association table block e2e test
This commit is contained in:
katherinehhh 2024-04-12 00:24:06 +08:00 committed by GitHub
parent e1533ec800
commit d4b4391aba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 882 additions and 1 deletions

View File

@ -1,5 +1,5 @@
import { deleteRecords, expect, test } from '@nocobase/test/e2e'; import { deleteRecords, expect, test } from '@nocobase/test/e2e';
import { T3529, T3953 } from './templatesOfBug'; import { T3529, T3953, T3979 } from './templatesOfBug';
test.describe('association form block', () => { test.describe('association form block', () => {
// https://nocobase.height.app/T-3529 // https://nocobase.height.app/T-3529
@ -34,4 +34,26 @@ test.describe('association form block', () => {
// 3. 将创建的 roles record 删除,防止影响其他测试 // 3. 将创建的 roles record 删除,防止影响其他测试
await deleteRecords('roles', { name: { $ne: ['root', 'admin', 'member'] } }); await deleteRecords('roles', { name: { $ne: ['root', 'admin', 'member'] } });
}); });
// https://nocobase.height.app/T-3979/description
test('association table block add new ', async ({ page, mockPage, mockRecord }) => {
await mockPage(T3979).goto();
await mockRecord('general');
await expect(await page.getByLabel('block-item-CardItem-general-')).toBeVisible();
// 1. 打开关系字段弹窗
await page.getByLabel('block-item-CardItem-general-').locator('a').click();
await page.getByLabel('block-item-CardItem-roles-').click();
// 2. 提交后Table 会显示新增的数据
await page.getByLabel('action-Action-Add new-create-roles-table-').click();
// 3. 区块数据表为关系字段的区块
await page
.getByTestId('drawer-Action.Container-roles-Add record')
.getByLabel('schema-initializer-Grid-popup')
.click();
await page.getByRole('menuitem', { name: 'form Form' }).click();
await expect(await page.getByLabel('block-item-CardItem-roles-form')).toBeVisible();
});
}); });

View File

@ -7613,3 +7613,862 @@ export const T3953 = {
'x-index': 1, 'x-index': 1,
}, },
}; };
export const T3979: PageConfig = {
collections: [
{
name: 'general',
fields: [
{
key: 'rpxo494ufro',
name: 'id',
type: 'bigInt',
interface: 'integer',
description: null,
collectionName: 'general',
parentKey: null,
reverseKey: null,
autoIncrement: true,
primaryKey: true,
allowNull: false,
uiSchema: {
type: 'number',
title: '{{t("ID")}}',
'x-component': 'InputNumber',
'x-read-pretty': true,
},
},
{
key: 'zwr5gak2xne',
name: 'f_ay6rnz23q81',
type: 'bigInt',
interface: 'integer',
description: null,
collectionName: 'general',
parentKey: null,
reverseKey: null,
isForeignKey: true,
uiSchema: {
type: 'number',
title: 'f_ay6rnz23q81',
'x-component': 'InputNumber',
'x-read-pretty': true,
},
},
{
key: '42vzuonn27s',
name: 'createdAt',
type: 'date',
interface: 'createdAt',
description: null,
collectionName: 'general',
parentKey: null,
reverseKey: null,
field: 'createdAt',
uiSchema: {
type: 'datetime',
title: '{{t("Created at")}}',
'x-component': 'DatePicker',
'x-component-props': {},
'x-read-pretty': true,
},
},
{
key: 'q3p9rbgvtix',
name: 'createdBy',
type: 'belongsTo',
interface: 'createdBy',
description: null,
collectionName: 'general',
parentKey: null,
reverseKey: null,
target: 'users',
foreignKey: 'createdById',
uiSchema: {
type: 'object',
title: '{{t("Created by")}}',
'x-component': 'AssociationField',
'x-component-props': {
fieldNames: {
value: 'id',
label: 'nickname',
},
},
'x-read-pretty': true,
},
targetKey: 'id',
},
{
key: '6l3j9ffbavm',
name: 'updatedAt',
type: 'date',
interface: 'updatedAt',
description: null,
collectionName: 'general',
parentKey: null,
reverseKey: null,
field: 'updatedAt',
uiSchema: {
type: 'string',
title: '{{t("Last updated at")}}',
'x-component': 'DatePicker',
'x-component-props': {},
'x-read-pretty': true,
},
},
{
key: 'vlitghmo9e4',
name: 'updatedBy',
type: 'belongsTo',
interface: 'updatedBy',
description: null,
collectionName: 'general',
parentKey: null,
reverseKey: null,
target: 'users',
foreignKey: 'updatedById',
uiSchema: {
type: 'object',
title: '{{t("Last updated by")}}',
'x-component': 'AssociationField',
'x-component-props': {
fieldNames: {
value: 'id',
label: 'nickname',
},
},
'x-read-pretty': true,
},
targetKey: 'id',
},
{
key: 'ga1xaptx2m5',
name: 'f_4jozl4andtv',
type: 'belongsTo',
interface: 'm2o',
description: null,
collectionName: 'general',
parentKey: null,
reverseKey: null,
foreignKey: 'f_ay6rnz23q81',
onDelete: 'SET NULL',
uiSchema: {
'x-component': 'AssociationField',
'x-component-props': {
multiple: false,
},
title: 'user',
},
target: 'users',
targetKey: 'id',
},
],
},
],
pageSchema: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Page',
'x-app-version': '0.21.0-alpha.6',
properties: {
'0osui04l650': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid',
'x-initializer': 'page:addBlock',
'x-app-version': '0.21.0-alpha.6',
properties: {
'3vwwts1qhfi': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '0.21.0-alpha.6',
properties: {
gnpakgl904x: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Col',
'x-app-version': '0.21.0-alpha.6',
properties: {
e1y9qp0um5a: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-decorator': 'TableBlockProvider',
'x-acl-action': 'general:list',
'x-use-decorator-props': 'useTableBlockDecoratorProps',
'x-decorator-props': {
collection: 'general',
dataSource: 'main',
action: 'list',
params: {
pageSize: 20,
},
rowKey: 'id',
showIndex: true,
dragSort: false,
},
'x-toolbar': 'BlockSchemaToolbar',
'x-settings': 'blockSettings:table',
'x-component': 'CardItem',
'x-filter-targets': [],
'x-app-version': '0.21.0-alpha.6',
properties: {
actions: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-initializer': 'table:configureActions',
'x-component': 'ActionBar',
'x-component-props': {
style: {
marginBottom: 'var(--nb-spacing)',
},
},
'x-app-version': '0.21.0-alpha.6',
properties: {
c5ctl0tju3g: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-action': 'create',
'x-acl-action': 'create',
title: "{{t('Add new')}}",
'x-toolbar': 'ActionSchemaToolbar',
'x-settings': 'actionSettings:addNew',
'x-component': 'Action',
'x-decorator': 'ACLActionProvider',
'x-component-props': {
openMode: 'drawer',
type: 'primary',
component: 'CreateRecordAction',
icon: 'PlusOutlined',
},
'x-align': 'right',
'x-acl-action-props': {
skipScopeCheck: true,
},
'x-app-version': '0.21.0-alpha.6',
properties: {
drawer: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
title: '{{ t("Add record") }}',
'x-component': 'Action.Container',
'x-component-props': {
className: 'nb-action-popup',
},
'x-app-version': '0.21.0-alpha.6',
properties: {
tabs: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'popup:addTab',
'x-initializer-props': {
gridInitializer: 'popup:addNew:addBlock',
},
'x-app-version': '0.21.0-alpha.6',
properties: {
tab1: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
title: '{{t("Add new")}}',
'x-component': 'Tabs.TabPane',
'x-designer': 'Tabs.Designer',
'x-component-props': {},
'x-app-version': '0.21.0-alpha.6',
properties: {
grid: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid',
'x-initializer': 'popup:addNew:addBlock',
'x-app-version': '0.21.0-alpha.6',
properties: {
i087pxwwooh: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '0.21.0-alpha.6',
properties: {
sg0dc5npnc4: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Col',
'x-app-version': '0.21.0-alpha.6',
properties: {
d3yrtf44e5o: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-acl-action-props': {
skipScopeCheck: true,
},
'x-acl-action': 'general:create',
'x-decorator': 'FormBlockProvider',
'x-use-decorator-props': 'useCreateFormBlockDecoratorProps',
'x-decorator-props': {
dataSource: 'main',
collection: 'general',
},
'x-toolbar': 'BlockSchemaToolbar',
'x-settings': 'blockSettings:createForm',
'x-component': 'CardItem',
'x-app-version': '0.21.0-alpha.6',
properties: {
zo3ueve2fe4: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'FormV2',
'x-use-component-props': 'useCreateFormBlockProps',
'x-app-version': '0.21.0-alpha.6',
properties: {
grid: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid',
'x-initializer': 'form:configureFields',
'x-app-version': '0.21.0-alpha.6',
properties: {
'4kz58m4p1ge': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '0.21.0-alpha.6',
properties: {
sm4cp07nna2: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Col',
'x-app-version': '0.21.0-alpha.6',
properties: {
f_4jozl4andtv: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'string',
'x-toolbar': 'FormItemSchemaToolbar',
'x-settings': 'fieldSettings:FormItem',
'x-component': 'CollectionField',
'x-decorator': 'FormItem',
'x-collection-field':
'general.f_4jozl4andtv',
'x-component-props': {
fieldNames: {
value: 'id',
label: 'id',
},
},
'x-app-version': '0.21.0-alpha.6',
'x-uid': 'dwiggk4w4io',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'vthdr7ci1sm',
'x-async': false,
'x-index': 1,
},
},
'x-uid': '6q68zb0uals',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'n7637yzqcbq',
'x-async': false,
'x-index': 1,
},
'80zytylsm1f': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-initializer': 'createForm:configureActions',
'x-component': 'ActionBar',
'x-component-props': {
layout: 'one-column',
style: {
marginTop: 24,
},
},
'x-app-version': '0.21.0-alpha.6',
properties: {
'3gwww31ss2v': {
_isJSONSchemaObject: true,
version: '2.0',
title: '{{ t("Submit") }}',
'x-action': 'submit',
'x-component': 'Action',
'x-use-component-props': 'useCreateActionProps',
'x-toolbar': 'ActionSchemaToolbar',
'x-settings': 'actionSettings:createSubmit',
'x-component-props': {
type: 'primary',
htmlType: 'submit',
},
'x-action-settings': {
triggerWorkflows: [],
},
type: 'void',
'x-app-version': '0.21.0-alpha.6',
'x-uid': '3nd6tzxwals',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'ax9xnhiuh2f',
'x-async': false,
'x-index': 2,
},
},
'x-uid': 'lcl7dnngk2e',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'v8w6pvj2wyj',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'det88qfvr6i',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'c5wt7syr5tk',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'q28facon923',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'kxgpkg0qirl',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'm0c622mltj2',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'cf2ad1u233x',
'x-async': false,
'x-index': 1,
},
},
'x-uid': '63qns05ztgz',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'e3tr6vsw64p',
'x-async': false,
'x-index': 1,
},
tzemisxecwn: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'array',
'x-initializer': 'table:configureColumns',
'x-component': 'TableV2',
'x-use-component-props': 'useTableBlockProps',
'x-component-props': {
rowKey: 'id',
rowSelection: {
type: 'checkbox',
},
},
'x-app-version': '0.21.0-alpha.6',
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': 'table:configureItemActions',
'x-app-version': '0.21.0-alpha.6',
properties: {
ytsbuk3byb7: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-decorator': 'DndContext',
'x-component': 'Space',
'x-component-props': {
split: '|',
},
'x-app-version': '0.21.0-alpha.6',
'x-uid': 'nli0xiyvodh',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'dwh5nu7rdo6',
'x-async': false,
'x-index': 1,
},
'1z5ghlb5d8s': {
_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': '0.21.0-alpha.6',
properties: {
f_4jozl4andtv: {
_isJSONSchemaObject: true,
version: '2.0',
'x-collection-field': 'general.f_4jozl4andtv',
'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-app-version': '0.21.0-alpha.6',
properties: {
hdqa75xvpgi: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
title: '{{ t("View record") }}',
'x-component': 'AssociationField.Viewer',
'x-component-props': {
className: 'nb-action-popup',
},
'x-index': 1,
'x-app-version': '0.21.0-alpha.6',
properties: {
tabs: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'popup:addTab',
'x-app-version': '0.21.0-alpha.6',
properties: {
tab1: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
title: '{{t("Details")}}',
'x-component': 'Tabs.TabPane',
'x-designer': 'Tabs.Designer',
'x-component-props': {},
'x-app-version': '0.21.0-alpha.6',
properties: {
grid: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid',
'x-initializer': 'popup:common:addBlock',
'x-app-version': '0.21.0-alpha.6',
properties: {
nzyxfgv72na: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '0.21.0-alpha.6',
properties: {
uwrfz3kzoao: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Col',
'x-app-version': '0.21.0-alpha.6',
properties: {
'7s7dpheeku7': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-decorator': 'TableBlockProvider',
'x-acl-action': 'undefined:list',
'x-use-decorator-props': 'useTableBlockDecoratorProps',
'x-decorator-props': {
association: 'users.roles',
dataSource: 'main',
action: 'list',
params: {
pageSize: 20,
},
rowKey: 'name',
showIndex: true,
dragSort: false,
},
'x-toolbar': 'BlockSchemaToolbar',
'x-settings': 'blockSettings:table',
'x-component': 'CardItem',
'x-filter-targets': [],
'x-app-version': '0.21.0-alpha.6',
properties: {
actions: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-initializer': 'table:configureActions',
'x-component': 'ActionBar',
'x-component-props': {
style: {
marginBottom: 'var(--nb-spacing)',
},
},
'x-app-version': '0.21.0-alpha.6',
properties: {
'0gh9ejdo0l4': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-action': 'create',
'x-acl-action': 'create',
title: "{{t('Add new')}}",
'x-toolbar': 'ActionSchemaToolbar',
'x-settings': 'actionSettings:addNew',
'x-component': 'Action',
'x-decorator': 'ACLActionProvider',
'x-component-props': {
openMode: 'drawer',
type: 'primary',
component: 'CreateRecordAction',
icon: 'PlusOutlined',
},
'x-align': 'right',
'x-acl-action-props': {
skipScopeCheck: true,
},
'x-app-version': '0.21.0-alpha.6',
properties: {
drawer: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
title: '{{ t("Add record") }}',
'x-component': 'Action.Container',
'x-component-props': {
className: 'nb-action-popup',
},
'x-app-version': '0.21.0-alpha.6',
properties: {
tabs: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'popup:addTab',
'x-initializer-props': {
gridInitializer: 'popup:addNew:addBlock',
},
'x-app-version': '0.21.0-alpha.6',
properties: {
tab1: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
title: '{{t("Add new")}}',
'x-component': 'Tabs.TabPane',
'x-designer': 'Tabs.Designer',
'x-component-props': {},
'x-app-version': '0.21.0-alpha.6',
properties: {
grid: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid',
'x-initializer':
'popup:addNew:addBlock',
'x-app-version': '0.21.0-alpha.6',
'x-uid': 'mgks7usp454',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'd1jgitzca3j',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'pjdiacug4c2',
'x-async': false,
'x-index': 1,
},
},
'x-uid': '3v73tpwq65y',
'x-async': false,
'x-index': 1,
},
},
'x-uid': '84uiovnwe0k',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'd1cuw6cyi18',
'x-async': false,
'x-index': 1,
},
'4gspy2pqurh': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'array',
'x-initializer': 'table:configureColumns',
'x-component': 'TableV2',
'x-use-component-props': 'useTableBlockProps',
'x-component-props': {
rowKey: 'id',
rowSelection: {
type: 'checkbox',
},
},
'x-app-version': '0.21.0-alpha.6',
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': 'table:configureItemActions',
'x-app-version': '0.21.0-alpha.6',
properties: {
qs986rjoczh: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-decorator': 'DndContext',
'x-component': 'Space',
'x-component-props': {
split: '|',
},
'x-app-version': '0.21.0-alpha.6',
'x-uid': '7cqescd8bmh',
'x-async': false,
'x-index': 1,
},
},
'x-uid': '1mt5dw050o8',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'cit3pdz0kba',
'x-async': false,
'x-index': 2,
},
},
'x-uid': 'idb290wr61g',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'wtqcusee4fd',
'x-async': false,
'x-index': 1,
},
},
'x-uid': '2qqec1x4j3w',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'oanidkvi9fs',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'qxwgw2ckxz4',
'x-async': false,
'x-index': 1,
},
},
'x-uid': '8zue3a5kk0f',
'x-async': false,
'x-index': 1,
},
},
'x-uid': '9vg0jwas3m3',
'x-async': false,
},
},
'x-uid': 'y193btra52j',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'e11uargvejv',
'x-async': false,
'x-index': 2,
},
},
'x-uid': 'iogsquqt02v',
'x-async': false,
'x-index': 2,
},
},
'x-uid': '29nrge6glvj',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'h8vnhofv1yr',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'zpyiipi79b2',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'ent3zuqrhyh',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'gsl3rfifzh5',
'x-async': true,
'x-index': 1,
},
};