mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 22:49:26 +08:00
chore: add e2e (#4184)
* test: schemaInitializer of map * test: settings of map block * refactor: extract common options * chore: test filter blocks in page * chore: test filter block in popup * chore: add e2e for inherit fields * chore: attachement field * chore: file block * chore: should use beforEach instead of beforAll * chore: make e2e pass * chore: only run map e2e * Revert "chore: only run map e2e" This reverts commit fbdae1a5733e38d0d29f8084019ca44b671d1032.
This commit is contained in:
parent
6eac27d539
commit
def7530d14
@ -1,8 +1,8 @@
|
||||
import { Field } from '@formily/core';
|
||||
import { useField, useFieldSchema } from '@formily/react';
|
||||
import { useCollectionField } from '../data-source/collection-field/CollectionFieldProvider';
|
||||
import { useIsFileField } from '../schema-component/antd/form-item/FormItem.Settings';
|
||||
import { useColumnSchema } from '../schema-component/antd/table-v2/Table.Column.Decorator';
|
||||
import { useCollectionField } from '../data-source/collection-field/CollectionFieldProvider';
|
||||
|
||||
export function useFieldComponentName(): string {
|
||||
const { fieldSchema: tableColumnSchema, collectionField: tableColumnField } = useColumnSchema();
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { uid } from '@formily/shared';
|
||||
import { createBlockInPage, expect, oneEmptyForm, test } from '@nocobase/test/e2e';
|
||||
import { oneEmptyTableWithUsers } from '../../../details-multi/__e2e__/templatesOfBug';
|
||||
import { T3106, T3469 } from './templatesOfBug';
|
||||
import { T3106, T3469, oneFormWithInheritFields } from './templatesOfBug';
|
||||
|
||||
test.describe('where creation form block can be added', () => {
|
||||
test('page', async ({ page, mockPage }) => {
|
||||
@ -77,7 +77,21 @@ test.describe('configure fields', () => {
|
||||
await expect(page.getByLabel('block-item-Markdown.Void-general-form')).toBeVisible();
|
||||
});
|
||||
|
||||
test.pgOnly('display inherit fields', async ({ page, mockPage }) => {});
|
||||
test.pgOnly('display inherit fields', async ({ page, mockPage }) => {
|
||||
await mockPage(oneFormWithInheritFields).goto();
|
||||
|
||||
// 在表单中选择继承的字段
|
||||
await page.getByLabel('schema-initializer-Grid-form:').hover();
|
||||
await page.getByRole('menuitem', { name: 'parentField1' }).click();
|
||||
await page.getByRole('menuitem', { name: 'parentField2' }).click();
|
||||
await page.mouse.move(300, 0);
|
||||
await expect(
|
||||
page.getByLabel('block-item-CollectionField-child-form-child.parentField1-parentField1').getByRole('textbox'),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByLabel('block-item-CollectionField-child-form-child.parentField2-parentField2').getByRole('textbox'),
|
||||
).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('configure actions', () => {
|
||||
|
@ -9173,3 +9173,146 @@ export const oneFormAndOneTableWithUsers: PageConfig = {
|
||||
'x-async': true,
|
||||
},
|
||||
};
|
||||
export const oneFormWithInheritFields = {
|
||||
collections: [
|
||||
{
|
||||
name: 'parent',
|
||||
fields: [
|
||||
{
|
||||
name: 'parentField1',
|
||||
interface: 'input',
|
||||
},
|
||||
{
|
||||
name: 'parentField2',
|
||||
interface: 'input',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'child',
|
||||
fields: [
|
||||
{
|
||||
name: 'childField1',
|
||||
interface: 'input',
|
||||
},
|
||||
{
|
||||
name: 'childField2',
|
||||
interface: 'input',
|
||||
},
|
||||
],
|
||||
inherits: ['parent'],
|
||||
},
|
||||
],
|
||||
pageSchema: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Page',
|
||||
properties: {
|
||||
'79kw0s9hd2t': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'page:addBlock',
|
||||
properties: {
|
||||
'736hw3rfbbo': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
thsaywe90f0: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
e1wo8fptwxq: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-acl-action-props': {
|
||||
skipScopeCheck: true,
|
||||
},
|
||||
'x-acl-action': 'child:create',
|
||||
'x-decorator': 'FormBlockProvider',
|
||||
'x-use-decorator-props': 'useCreateFormBlockDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
dataSource: 'main',
|
||||
collection: 'child',
|
||||
},
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:createForm',
|
||||
'x-component': 'CardItem',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
'8f3ol7eyevs': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'FormV2',
|
||||
'x-use-component-props': 'useCreateFormBlockProps',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
grid: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'form:configureFields',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': 'hpydlgpgdyp',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
lmexf0nzjgb: {
|
||||
_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.15',
|
||||
'x-uid': 'i818vw5tv0g',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'xkj4q44w6ym',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 't6ajhkkuys0',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'm6wz53dmfdu',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '8x6245ii9nu',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'xtmna5prya7',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'cossd0o2fyh',
|
||||
'x-async': true,
|
||||
'x-index': 1,
|
||||
},
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { createBlockInPage, expect, oneEmptyGridCardBlock, test } from '@nocobase/test/e2e';
|
||||
import { oneEmptyTableWithUsers } from '../../details-multi/__e2e__/templatesOfBug';
|
||||
import { oneGridCardWithInheritFields } from './templatesOfBug';
|
||||
|
||||
test.describe('where grid card block can be added', () => {
|
||||
test('page', async ({ page, mockPage }) => {
|
||||
@ -187,5 +188,26 @@ test.describe('configure fields', () => {
|
||||
|
||||
await expect(page.getByLabel('block-item-Markdown.Void-general-grid-card').first()).toBeVisible();
|
||||
});
|
||||
test.pgOnly('display inherit fields', async () => {});
|
||||
|
||||
test.pgOnly('display inherit fields', async ({ page, mockPage, mockRecord }) => {
|
||||
const nocoPage = await mockPage(oneGridCardWithInheritFields).waitForInit();
|
||||
const record = await mockRecord('child');
|
||||
await nocoPage.goto();
|
||||
|
||||
// 选择继承的字段
|
||||
await page.getByLabel('schema-initializer-Grid-details:configureFields-child').hover();
|
||||
await page.getByRole('menuitem', { name: 'parentField1' }).click();
|
||||
await page.getByRole('menuitem', { name: 'parentField2' }).click();
|
||||
await page.mouse.move(300, 0);
|
||||
await expect(
|
||||
page
|
||||
.getByLabel('block-item-CollectionField-child-grid-card-child.parentField1-parentField1')
|
||||
.getByText(record.parentField1),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page
|
||||
.getByLabel('block-item-CollectionField-child-grid-card-child.parentField2-parentField2')
|
||||
.getByText(record.parentField2),
|
||||
).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
@ -149,3 +149,180 @@ export const T3813: PageConfig = {
|
||||
'x-async': true,
|
||||
},
|
||||
};
|
||||
export const oneGridCardWithInheritFields = {
|
||||
collections: [
|
||||
{
|
||||
name: 'parent',
|
||||
fields: [
|
||||
{
|
||||
name: 'parentField1',
|
||||
interface: 'input',
|
||||
},
|
||||
{
|
||||
name: 'parentField2',
|
||||
interface: 'input',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'child',
|
||||
fields: [
|
||||
{
|
||||
name: 'childField1',
|
||||
interface: 'input',
|
||||
},
|
||||
{
|
||||
name: 'childField2',
|
||||
interface: 'input',
|
||||
},
|
||||
],
|
||||
inherits: ['parent'],
|
||||
},
|
||||
],
|
||||
pageSchema: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Page',
|
||||
properties: {
|
||||
'6dd4jp5aty3': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'page:addBlock',
|
||||
properties: {
|
||||
'6j297qld7k5': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
'5ntnn78ittz': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
d5hfemedgra: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-acl-action': 'child:view',
|
||||
'x-decorator': 'GridCard.Decorator',
|
||||
'x-use-decorator-props': 'useGridCardBlockDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
collection: 'child',
|
||||
dataSource: 'main',
|
||||
readPretty: true,
|
||||
action: 'list',
|
||||
params: {
|
||||
pageSize: 12,
|
||||
},
|
||||
runWhenParamsChanged: true,
|
||||
rowKey: 'id',
|
||||
},
|
||||
'x-component': 'BlockItem',
|
||||
'x-use-component-props': 'useGridCardBlockItemProps',
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:gridCard',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
actionBar: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-initializer': 'gridCard:configureActions',
|
||||
'x-component': 'ActionBar',
|
||||
'x-component-props': {
|
||||
style: {
|
||||
marginBottom: 'var(--nb-spacing)',
|
||||
},
|
||||
},
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': 'wwi5qc647uo',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
list: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'array',
|
||||
'x-component': 'GridCard',
|
||||
'x-use-component-props': 'useGridCardBlockProps',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
item: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'object',
|
||||
'x-component': 'GridCard.Item',
|
||||
'x-read-pretty': true,
|
||||
'x-use-component-props': 'useGridCardItemProps',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
grid: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'details:configureFields',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': 'l3t86n7gvzx',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
actionBar: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-align': 'left',
|
||||
'x-initializer': 'gridCard:configureItemActions',
|
||||
'x-component': 'ActionBar',
|
||||
'x-use-component-props': 'useGridCardActionBarProps',
|
||||
'x-component-props': {
|
||||
layout: 'one-column',
|
||||
},
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': '82xmd28rt6w',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'byt0acukow5',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '93fip5eoty5',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'd7g6lotr67g',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'j0d554opvl6',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'y89y6kpb09t',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'z2h5z9118ck',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'nf4ji8havvf',
|
||||
'x-async': true,
|
||||
'x-index': 1,
|
||||
},
|
||||
};
|
||||
|
@ -47,129 +47,78 @@ const AssociatedFields = () => {
|
||||
return <SchemaInitializerChildren>{schema}</SchemaInitializerChildren>;
|
||||
};
|
||||
|
||||
const commonOptions = {
|
||||
insertPosition: 'beforeEnd',
|
||||
icon: 'SettingOutlined',
|
||||
title: '{{t("Configure columns")}}',
|
||||
wrap: (s, { isInSubTable }) => {
|
||||
if (s['x-action-column']) {
|
||||
return s;
|
||||
}
|
||||
return {
|
||||
type: 'void',
|
||||
'x-decorator': 'TableV2.Column.Decorator',
|
||||
// 'x-designer': 'TableV2.Column.Designer',
|
||||
'x-toolbar': 'TableColumnSchemaToolbar',
|
||||
'x-settings': 'fieldSettings:TableColumn',
|
||||
'x-component': 'TableV2.Column',
|
||||
properties: {
|
||||
[s.name]: {
|
||||
...s,
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
items: [
|
||||
{
|
||||
name: 'displayFields',
|
||||
type: 'itemGroup',
|
||||
title: '{{t("Display fields")}}',
|
||||
// children: DisplayFields,
|
||||
useChildren: useTableColumnInitializerFields,
|
||||
},
|
||||
{
|
||||
name: 'parentCollectionFields',
|
||||
Component: ParentCollectionFields,
|
||||
},
|
||||
{
|
||||
name: 'associationFields',
|
||||
Component: AssociatedFields,
|
||||
},
|
||||
{
|
||||
name: 'divider',
|
||||
type: 'divider',
|
||||
useVisible() {
|
||||
const fieldSchema = useFieldSchema();
|
||||
return fieldSchema['x-component'] !== 'AssociationField.SubTable';
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'item',
|
||||
name: 'add',
|
||||
title: '{{t("Action column")}}',
|
||||
Component: 'TableActionColumnInitializer',
|
||||
useVisible() {
|
||||
const fieldSchema = useFieldSchema();
|
||||
return fieldSchema['x-component'] !== 'AssociationField.SubTable';
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* use `tableColumnInitializers` instead
|
||||
*/
|
||||
export const tableColumnInitializers_deprecated = new CompatibleSchemaInitializer({
|
||||
name: 'TableColumnInitializers',
|
||||
insertPosition: 'beforeEnd',
|
||||
icon: 'SettingOutlined',
|
||||
title: '{{t("Configure columns")}}',
|
||||
wrap: (s, { isInSubTable }) => {
|
||||
if (s['x-action-column']) {
|
||||
return s;
|
||||
}
|
||||
return {
|
||||
type: 'void',
|
||||
'x-decorator': 'TableV2.Column.Decorator',
|
||||
// 'x-designer': 'TableV2.Column.Designer',
|
||||
'x-toolbar': 'TableColumnSchemaToolbar',
|
||||
'x-settings': 'fieldSettings:TableColumn',
|
||||
'x-component': 'TableV2.Column',
|
||||
properties: {
|
||||
[s.name]: {
|
||||
...s,
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
items: [
|
||||
{
|
||||
name: 'displayFields',
|
||||
type: 'itemGroup',
|
||||
title: '{{t("Display fields")}}',
|
||||
// children: DisplayFields,
|
||||
useChildren: useTableColumnInitializerFields,
|
||||
},
|
||||
{
|
||||
name: 'parentCollectionFields',
|
||||
Component: ParentCollectionFields,
|
||||
},
|
||||
{
|
||||
name: 'associationFields',
|
||||
Component: AssociatedFields,
|
||||
},
|
||||
{
|
||||
name: 'divider',
|
||||
type: 'divider',
|
||||
useVisible() {
|
||||
const fieldSchema = useFieldSchema();
|
||||
return fieldSchema['x-component'] !== 'AssociationField.SubTable';
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'item',
|
||||
name: 'add',
|
||||
title: '{{t("Action column")}}',
|
||||
Component: 'TableActionColumnInitializer',
|
||||
useVisible() {
|
||||
const fieldSchema = useFieldSchema();
|
||||
return fieldSchema['x-component'] !== 'AssociationField.SubTable';
|
||||
},
|
||||
},
|
||||
],
|
||||
...commonOptions,
|
||||
});
|
||||
|
||||
export const tableColumnInitializers = new CompatibleSchemaInitializer(
|
||||
{
|
||||
name: 'table:configureColumns',
|
||||
insertPosition: 'beforeEnd',
|
||||
icon: 'SettingOutlined',
|
||||
title: '{{t("Configure columns")}}',
|
||||
wrap: (s, { isInSubTable }) => {
|
||||
if (s['x-action-column']) {
|
||||
return s;
|
||||
}
|
||||
return {
|
||||
type: 'void',
|
||||
'x-decorator': 'TableV2.Column.Decorator',
|
||||
// 'x-designer': 'TableV2.Column.Designer',
|
||||
'x-toolbar': 'TableColumnSchemaToolbar',
|
||||
'x-settings': 'fieldSettings:TableColumn',
|
||||
'x-component': 'TableV2.Column',
|
||||
properties: {
|
||||
[s.name]: {
|
||||
...s,
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
items: [
|
||||
{
|
||||
name: 'displayFields',
|
||||
type: 'itemGroup',
|
||||
title: '{{t("Display fields")}}',
|
||||
// children: DisplayFields,
|
||||
useChildren: useTableColumnInitializerFields,
|
||||
},
|
||||
{
|
||||
name: 'parentCollectionFields',
|
||||
Component: ParentCollectionFields,
|
||||
},
|
||||
{
|
||||
name: 'associationFields',
|
||||
Component: AssociatedFields,
|
||||
},
|
||||
{
|
||||
name: 'divider',
|
||||
type: 'divider',
|
||||
useVisible() {
|
||||
const fieldSchema = useFieldSchema();
|
||||
return fieldSchema['x-component'] !== 'AssociationField.SubTable';
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'item',
|
||||
name: 'add',
|
||||
title: '{{t("Action column")}}',
|
||||
Component: 'TableActionColumnInitializer',
|
||||
useVisible() {
|
||||
const fieldSchema = useFieldSchema();
|
||||
return fieldSchema['x-component'] !== 'AssociationField.SubTable';
|
||||
},
|
||||
},
|
||||
],
|
||||
...commonOptions,
|
||||
},
|
||||
tableColumnInitializers_deprecated,
|
||||
);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createBlockInPage, expect, oneEmptyTable, test } from '@nocobase/test/e2e';
|
||||
import { T3686, T4005 } from './templatesOfBug';
|
||||
import { T3686, T4005, oneTableWithInheritFields } from './templatesOfBug';
|
||||
|
||||
test.describe('where table block can be added', () => {
|
||||
test('page', async ({ page, mockPage }) => {
|
||||
@ -246,7 +246,19 @@ test.describe('configure columns', () => {
|
||||
await expect(page.getByRole('button', { name: 'Nickname', exact: true })).not.toBeVisible();
|
||||
});
|
||||
|
||||
test.pgOnly('display inherit fields', async ({ page, mockPage }) => {});
|
||||
test.pgOnly('display inherit fields', async ({ page, mockPage, mockRecord }) => {
|
||||
const nocoPage = await mockPage(oneTableWithInheritFields).waitForInit();
|
||||
const record = await mockRecord('child');
|
||||
await nocoPage.goto();
|
||||
|
||||
// 选择继承字段
|
||||
await page.getByLabel('schema-initializer-TableV2-').hover();
|
||||
await page.getByRole('menuitem', { name: 'parentField1' }).click();
|
||||
await page.getByRole('menuitem', { name: 'parentField2' }).click();
|
||||
await page.mouse.move(300, 0);
|
||||
await expect(page.getByLabel('block-item-CardItem-child-').getByText(record.parentField1)).toBeVisible();
|
||||
await expect(page.getByLabel('block-item-CardItem-child-').getByText(record.parentField2)).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('configure actions column', () => {
|
||||
|
@ -2688,3 +2688,177 @@ export const oneTableWithUpdateRecord = {
|
||||
'x-async': true,
|
||||
},
|
||||
};
|
||||
export const oneTableWithInheritFields = {
|
||||
collections: [
|
||||
{
|
||||
name: 'parent',
|
||||
fields: [
|
||||
{
|
||||
name: 'parentField1',
|
||||
interface: 'input',
|
||||
},
|
||||
{
|
||||
name: 'parentField2',
|
||||
interface: 'input',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'child',
|
||||
fields: [
|
||||
{
|
||||
name: 'childField1',
|
||||
interface: 'input',
|
||||
},
|
||||
{
|
||||
name: 'childField2',
|
||||
interface: 'input',
|
||||
},
|
||||
],
|
||||
inherits: ['parent'],
|
||||
},
|
||||
],
|
||||
pageSchema: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Page',
|
||||
properties: {
|
||||
'2c65dc2ect7': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'page:addBlock',
|
||||
properties: {
|
||||
u6fd3y5jsw4: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
'0cftszpeysq': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
zkqmsvk69kb: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'TableBlockProvider',
|
||||
'x-acl-action': 'child:list',
|
||||
'x-use-decorator-props': 'useTableBlockDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
collection: 'child',
|
||||
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.15',
|
||||
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.15',
|
||||
'x-uid': 'iwm93jhfwrx',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
pglwezl7vl4: {
|
||||
_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.15',
|
||||
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.15',
|
||||
properties: {
|
||||
'91704g8ido3': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'DndContext',
|
||||
'x-component': 'Space',
|
||||
'x-component-props': {
|
||||
split: '|',
|
||||
},
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': 'qg83y0l4rvz',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '3v1d4gomwrc',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'r3si3q9zpil',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'upsr773evx4',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'sf3i4eqykta',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 've6jepsuju1',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '89f529bg5kn',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'hfgygvnm6sc',
|
||||
'x-async': true,
|
||||
'x-index': 1,
|
||||
},
|
||||
};
|
||||
|
@ -0,0 +1,197 @@
|
||||
import { expect, test } from '@nocobase/test/e2e';
|
||||
import { detailsTableListGridCardInPopup, tableDetailsListGridCardWithUsers } from './templates';
|
||||
|
||||
test.describe('where filter block can be added', () => {
|
||||
test('page', async ({ page, mockPage, mockRecords }) => {
|
||||
const nocoPage = await mockPage(tableDetailsListGridCardWithUsers).waitForInit();
|
||||
const newUserRecords = await mockRecords('users', 3);
|
||||
await nocoPage.goto();
|
||||
|
||||
// 1. 页面中创建一个 filter form,一个 filter collapse
|
||||
await page.getByLabel('schema-initializer-Grid-page:').hover();
|
||||
await page.getByRole('menuitem', { name: 'form Form right' }).nth(1).hover();
|
||||
await page.getByRole('menuitem', { name: 'Users' }).click();
|
||||
await page.getByLabel('schema-initializer-Grid-page:').hover();
|
||||
await page.getByRole('menuitem', { name: 'table Collapse right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Users' }).click();
|
||||
|
||||
// 2. 区块中能正常创建字段和按钮,且能正常显示字段值
|
||||
await page.getByLabel('schema-initializer-Grid-filterForm:configureFields-users').hover();
|
||||
await page.getByRole('menuitem', { name: 'Nickname' }).click();
|
||||
await page.getByLabel('schema-initializer-ActionBar-filterForm:configureActions-users').hover();
|
||||
await page.getByRole('menuitem', { name: 'Filter' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Reset' }).click();
|
||||
await page.getByLabel('schema-initializer-AssociationFilter-filterCollapse:configureFields-users').hover();
|
||||
await page.getByRole('menuitem', { name: 'Roles' }).click();
|
||||
|
||||
// 3. 与 Table、Details、List、GridCard 等区块建立连接
|
||||
const connectByForm = async (name: string) => {
|
||||
await page.getByLabel('block-item-CardItem-users-filter-form').hover();
|
||||
await page.getByLabel('designer-schema-settings-CardItem-blockSettings:filterForm-users').hover();
|
||||
await page.getByRole('menuitem', { name: 'Connect data blocks right' }).hover();
|
||||
await page.getByRole('menuitem', { name }).click();
|
||||
};
|
||||
const connectByCollapse = async (name: string) => {
|
||||
await page.getByLabel('block-item-CardItem-users-filter-collapse').hover();
|
||||
await page.getByLabel('designer-schema-settings-CardItem-blockSettings:filterCollapse-users').hover();
|
||||
await page.getByRole('menuitem', { name: 'Connect data blocks right' }).hover();
|
||||
await page.getByRole('menuitem', { name }).click();
|
||||
};
|
||||
await connectByForm('Users #79xm');
|
||||
await connectByForm('Users #4whf');
|
||||
await connectByForm('Users #qztm');
|
||||
await connectByForm('Users #2nig');
|
||||
await connectByCollapse('Users #79xm');
|
||||
await connectByCollapse('Users #4whf');
|
||||
await connectByCollapse('Users #qztm');
|
||||
await connectByCollapse('Users #2nig');
|
||||
|
||||
// 4. 筛选区块能正常筛选数据
|
||||
await page
|
||||
.getByLabel('block-item-CollectionField-users-filter-form-users.nickname-Nickname')
|
||||
.getByRole('textbox')
|
||||
.fill(newUserRecords[0].nickname);
|
||||
|
||||
// filter
|
||||
await page.getByLabel('action-Action-Filter-submit-').click({ position: { x: 10, y: 10 } });
|
||||
await page.waitForLoadState('networkidle');
|
||||
for (const record of newUserRecords) {
|
||||
await expect(page.getByLabel('block-item-CardItem-users-table').getByText(record.nickname)).toBeVisible({
|
||||
visible: record === newUserRecords[0],
|
||||
});
|
||||
await expect(page.getByLabel('block-item-CardItem-users-details').getByText(record.nickname)).toBeVisible({
|
||||
visible: record === newUserRecords[0],
|
||||
});
|
||||
await expect(page.getByLabel('block-item-CardItem-users-list').getByText(record.nickname)).toBeVisible({
|
||||
visible: record === newUserRecords[0],
|
||||
});
|
||||
await expect(page.getByLabel('block-item-BlockItem-users-grid').getByText(record.nickname)).toBeVisible({
|
||||
visible: record === newUserRecords[0],
|
||||
});
|
||||
}
|
||||
|
||||
// reset
|
||||
await page.getByLabel('action-Action-Reset-users-').click({ position: { x: 10, y: 10 } });
|
||||
await page.waitForLoadState('networkidle');
|
||||
for (const record of newUserRecords) {
|
||||
await expect(page.getByLabel('block-item-CardItem-users-table').getByText(record.nickname)).toBeVisible();
|
||||
await expect(page.getByLabel('block-item-CardItem-users-list').getByText(record.nickname)).toBeVisible();
|
||||
await expect(page.getByLabel('block-item-BlockItem-users-grid').getByText(record.nickname)).toBeVisible();
|
||||
}
|
||||
});
|
||||
|
||||
test('popup', async ({ page, mockPage, mockRecords }) => {
|
||||
const nocoPage = await mockPage(detailsTableListGridCardInPopup).waitForInit();
|
||||
const usersRecords = await mockRecords('users', 3);
|
||||
await nocoPage.goto();
|
||||
|
||||
// 1. 测试用表单筛选关系区块
|
||||
await page.getByLabel('action-Action.Link-View record-view-users-table-1').click();
|
||||
await page.getByLabel('schema-initializer-Grid-popup').hover();
|
||||
await page.getByRole('menuitem', { name: 'form Form right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Roles' }).click();
|
||||
await page.getByLabel('schema-initializer-Grid-filterForm:configureFields-roles').hover();
|
||||
await page.getByRole('menuitem', { name: 'Role UID' }).click();
|
||||
await page.getByLabel('schema-initializer-ActionBar-filterForm:configureActions-roles').hover();
|
||||
await page.getByRole('menuitem', { name: 'Filter' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Reset' }).click();
|
||||
|
||||
const conenctToAssociationBlock = async (name: string) => {
|
||||
await page.getByLabel('block-item-CardItem-roles-filter-form').hover();
|
||||
await page.getByLabel('designer-schema-settings-CardItem-blockSettings:filterForm-roles').hover();
|
||||
await page.getByRole('menuitem', { name: 'Connect data blocks right' }).hover();
|
||||
await page.getByRole('menuitem', { name }).click();
|
||||
};
|
||||
await conenctToAssociationBlock('Roles #as4s');
|
||||
await conenctToAssociationBlock('Roles #vp3q');
|
||||
await conenctToAssociationBlock('Roles #ug18');
|
||||
await conenctToAssociationBlock('Roles #q6hq');
|
||||
|
||||
await page
|
||||
.getByLabel('block-item-CardItem-roles-filter-form')
|
||||
.getByRole('textbox')
|
||||
.fill(usersRecords[0].roles[0].name);
|
||||
await page.getByLabel('action-Action-Filter-submit-').click({ position: { x: 10, y: 10 } });
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
for (const record of usersRecords[0].roles) {
|
||||
await expect(page.getByLabel('block-item-CardItem-roles-details').getByText(record.name)).toBeVisible({
|
||||
visible: record.name === usersRecords[0].roles[0].name,
|
||||
});
|
||||
await expect(page.getByLabel('block-item-CardItem-roles-table').getByText(record.name)).toBeVisible({
|
||||
visible: record.name === usersRecords[0].roles[0].name,
|
||||
});
|
||||
await expect(page.getByLabel('block-item-CardItem-roles-list').getByText(record.name)).toBeVisible({
|
||||
visible: record.name === usersRecords[0].roles[0].name,
|
||||
});
|
||||
await expect(page.getByLabel('block-item-BlockItem-roles-').getByText(record.name)).toBeVisible({
|
||||
visible: record.name === usersRecords[0].roles[0].name,
|
||||
});
|
||||
}
|
||||
|
||||
await page.getByLabel('action-Action-Reset-roles-').click({ position: { x: 10, y: 10 } });
|
||||
await page.waitForLoadState('networkidle');
|
||||
for (const record of usersRecords[0].roles) {
|
||||
await expect(page.getByLabel('block-item-CardItem-roles-table').getByText(record.name)).toBeVisible();
|
||||
await expect(page.getByLabel('block-item-CardItem-roles-list').getByText(record.name)).toBeVisible();
|
||||
await expect(page.getByLabel('block-item-BlockItem-roles-').getByText(record.name)).toBeVisible();
|
||||
}
|
||||
|
||||
// 2. 测试用表单筛选其它区块
|
||||
await page.getByLabel('schema-initializer-Grid-popup').hover();
|
||||
await page.getByRole('menuitem', { name: 'form Form right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Users' }).click();
|
||||
await page.getByLabel('schema-initializer-Grid-filterForm:configureFields-users').hover();
|
||||
await page.getByRole('menuitem', { name: 'Nickname' }).click();
|
||||
await page.getByLabel('schema-initializer-ActionBar-filterForm:configureActions-users').hover();
|
||||
await page.getByRole('menuitem', { name: 'Filter' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Reset' }).click();
|
||||
|
||||
const conenctToOtherBlock = async (name: string) => {
|
||||
await page.getByLabel('block-item-CardItem-users-filter-form').hover();
|
||||
await page.getByLabel('designer-schema-settings-CardItem-blockSettings:filterForm-users').hover();
|
||||
await page.getByRole('menuitem', { name: 'Connect data blocks right' }).hover();
|
||||
await page.getByRole('menuitem', { name }).click();
|
||||
};
|
||||
await conenctToOtherBlock('Users #iwq7');
|
||||
await conenctToOtherBlock('Users #1xi2');
|
||||
await conenctToOtherBlock('Users #11h7');
|
||||
await conenctToOtherBlock('Users #o1nq');
|
||||
|
||||
await page.getByLabel('block-item-CardItem-users-filter-form').getByRole('textbox').fill(usersRecords[0].nickname);
|
||||
await page.getByLabel('action-Action-Filter-submit-users-filter-form-').click({ position: { x: 10, y: 10 } });
|
||||
await page.waitForLoadState('networkidle');
|
||||
for (const record of usersRecords) {
|
||||
await expect(page.getByLabel('block-item-CardItem-users-details').getByText(record.nickname)).toBeVisible({
|
||||
visible: record === usersRecords[0],
|
||||
});
|
||||
await expect(
|
||||
page
|
||||
.getByTestId('drawer-Action.Container-users-View record')
|
||||
.getByLabel('block-item-CardItem-users-table')
|
||||
.getByText(record.nickname),
|
||||
).toBeVisible({
|
||||
visible: record === usersRecords[0],
|
||||
});
|
||||
await expect(page.getByLabel('block-item-CardItem-users-list').getByText(record.nickname)).toBeVisible({
|
||||
visible: record === usersRecords[0],
|
||||
});
|
||||
await expect(page.getByLabel('block-item-BlockItem-users-grid').getByText(record.nickname)).toBeVisible({
|
||||
visible: record === usersRecords[0],
|
||||
});
|
||||
}
|
||||
|
||||
await page.getByLabel('action-Action-Reset-users-').click({ position: { x: 10, y: 10 } });
|
||||
await page.waitForLoadState('networkidle');
|
||||
for (const record of usersRecords) {
|
||||
await expect(
|
||||
page
|
||||
.getByTestId('drawer-Action.Container-users-View record')
|
||||
.getByLabel('block-item-CardItem-users-table')
|
||||
.getByText(record.nickname),
|
||||
).toBeVisible();
|
||||
await expect(page.getByLabel('block-item-CardItem-users-list').getByText(record.nickname)).toBeVisible();
|
||||
await expect(page.getByLabel('block-item-BlockItem-users-grid').getByText(record.nickname)).toBeVisible();
|
||||
}
|
||||
});
|
||||
});
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
||||
import { createBlockInPage, expect, oneEmptyFilterFormBlock, test } from '@nocobase/test/e2e';
|
||||
import { oneFilterFormWithInherit } from './templatesOfBug';
|
||||
|
||||
test.describe('where filter form block can be added', () => {
|
||||
test('page', async ({ page, mockPage }) => {
|
||||
@ -65,7 +66,25 @@ test.describe('configure fields', () => {
|
||||
await expect(page.getByLabel('block-item-Markdown.Void-general-filter-form')).toBeVisible();
|
||||
});
|
||||
|
||||
test.pgOnly('display inherit fields', async ({ page, mockPage }) => {});
|
||||
test.pgOnly('display inherit fields', async ({ page, mockPage }) => {
|
||||
await mockPage(oneFilterFormWithInherit).goto();
|
||||
|
||||
// 选择继承的字段
|
||||
await page.getByLabel('schema-initializer-Grid-filterForm:configureFields-child').hover();
|
||||
await page.getByRole('menuitem', { name: 'parentField1' }).click();
|
||||
await page.getByRole('menuitem', { name: 'parentField2' }).click();
|
||||
await page.mouse.move(300, 0);
|
||||
await expect(
|
||||
page
|
||||
.getByLabel('block-item-CollectionField-child-filter-form-child.parentField1-parentField1')
|
||||
.getByRole('textbox'),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page
|
||||
.getByLabel('block-item-CollectionField-child-filter-form-child.parentField2-parentField2')
|
||||
.getByRole('textbox'),
|
||||
).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('configure actions', () => {
|
||||
|
@ -0,0 +1,141 @@
|
||||
export const oneFilterFormWithInherit = {
|
||||
collections: [
|
||||
{
|
||||
name: 'parent',
|
||||
fields: [
|
||||
{
|
||||
name: 'parentField1',
|
||||
interface: 'input',
|
||||
},
|
||||
{
|
||||
name: 'parentField2',
|
||||
interface: 'input',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'child',
|
||||
fields: [
|
||||
{
|
||||
name: 'childField1',
|
||||
interface: 'input',
|
||||
},
|
||||
{
|
||||
name: 'childField2',
|
||||
interface: 'input',
|
||||
},
|
||||
],
|
||||
inherits: ['parent'],
|
||||
},
|
||||
],
|
||||
pageSchema: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Page',
|
||||
properties: {
|
||||
kq51phui0q9: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'page:addBlock',
|
||||
properties: {
|
||||
pp7ov10hhjj: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
nz5peics4uj: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
ibeh994er9g: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'FilterFormBlockProvider',
|
||||
'x-use-decorator-props': 'useFilterFormBlockDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
dataSource: 'main',
|
||||
collection: 'child',
|
||||
},
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:filterForm',
|
||||
'x-component': 'CardItem',
|
||||
'x-filter-targets': [],
|
||||
'x-filter-operators': {},
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
al2miukt2y0: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'FormV2',
|
||||
'x-use-component-props': 'useFilterFormBlockProps',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
grid: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'filterForm:configureFields',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': 'fs8883bxalw',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
ni40rr6efvb: {
|
||||
_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': '0.21.0-alpha.15',
|
||||
'x-uid': 'jhtfu538zve',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'krv6g3fyqwu',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'zne83pn4hvx',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '7s8os6m891x',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'chovlhzi0ee',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '9xzpdna59re',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'oxtr4rkwpwy',
|
||||
'x-async': true,
|
||||
'x-index': 1,
|
||||
},
|
||||
};
|
@ -0,0 +1,50 @@
|
||||
import { Field } from '@formily/core';
|
||||
import { useField, useFieldSchema } from '@formily/react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings';
|
||||
import { useColumnSchema } from '../../../../schema-component/antd/table/Table.Column.Decorator';
|
||||
import { useDesignable } from '../../../../schema-component/hooks/useDesignable';
|
||||
|
||||
export const previewComponentFieldSettings = new SchemaSettings({
|
||||
name: 'fieldSettings:component:Preview',
|
||||
items: [
|
||||
{
|
||||
name: 'size',
|
||||
type: 'select',
|
||||
useVisible() {
|
||||
const { fieldSchema: tableColumnSchema } = useColumnSchema();
|
||||
const isInTable = tableColumnSchema?.parent?.['x-component'] === 'TableV2.Column';
|
||||
return !isInTable;
|
||||
},
|
||||
useComponentProps() {
|
||||
const { t } = useTranslation();
|
||||
const field = useField<Field>();
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { dn } = useDesignable();
|
||||
return {
|
||||
title: t('Size'),
|
||||
options: [
|
||||
{ label: t('Large'), value: 'large' },
|
||||
{ label: t('Default'), value: 'default' },
|
||||
{ label: t('Small'), value: 'small' },
|
||||
],
|
||||
value: field?.componentProps?.size || 'default',
|
||||
onChange(size) {
|
||||
const schema = {
|
||||
['x-uid']: fieldSchema['x-uid'],
|
||||
};
|
||||
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
|
||||
fieldSchema['x-component-props']['size'] = size;
|
||||
schema['x-component-props'] = fieldSchema['x-component-props'];
|
||||
field.componentProps = field.componentProps || {};
|
||||
field.componentProps.size = size;
|
||||
dn.emit('patch', {
|
||||
schema,
|
||||
});
|
||||
dn.refresh();
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
@ -2,7 +2,7 @@ import { Field } from '@formily/core';
|
||||
import { useField, useFieldSchema } from '@formily/react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings';
|
||||
import { useDesignable } from '../../../../schema-component';
|
||||
import { useColumnSchema, useDesignable } from '../../../../schema-component';
|
||||
import { useIsFieldReadPretty } from '../../../../schema-component/antd/form-item/FormItem.Settings';
|
||||
|
||||
export const uploadAttachmentComponentFieldSettings = new SchemaSettings({
|
||||
@ -12,8 +12,10 @@ export const uploadAttachmentComponentFieldSettings = new SchemaSettings({
|
||||
name: 'size',
|
||||
type: 'select',
|
||||
useVisible() {
|
||||
const { fieldSchema: tableColumnSchema } = useColumnSchema();
|
||||
const isInTable = tableColumnSchema?.parent?.['x-component'] === 'TableV2.Column';
|
||||
const readPretty = useIsFieldReadPretty();
|
||||
return readPretty;
|
||||
return readPretty && !isInTable;
|
||||
},
|
||||
useComponentProps() {
|
||||
const { t } = useTranslation();
|
||||
|
@ -12,6 +12,7 @@ import {
|
||||
useCollectionManager_deprecated,
|
||||
useCollection_deprecated,
|
||||
} from '../../../collection-manager';
|
||||
import { useCollectionManager } from '../../../data-source';
|
||||
import { useFlag } from '../../../flag-provider';
|
||||
import { useRecord } from '../../../record-provider';
|
||||
import { useColumnSchema } from '../../../schema-component/antd/table-v2/Table.Column.Decorator';
|
||||
@ -979,9 +980,9 @@ export function useIsAssociationField() {
|
||||
}
|
||||
|
||||
export function useIsFileField() {
|
||||
const { getCollection } = useCollectionManager_deprecated();
|
||||
const cm = useCollectionManager();
|
||||
const collectionField = useFormItemCollectionField();
|
||||
const targetCollection = getCollection(collectionField?.target);
|
||||
const targetCollection = cm.getCollection(collectionField?.target);
|
||||
const isFileField = isFileCollection(targetCollection as any);
|
||||
return isFileField;
|
||||
}
|
||||
|
@ -261,201 +261,86 @@ function useRecordBlocks() {
|
||||
return res;
|
||||
}
|
||||
|
||||
const commonOptions = {
|
||||
wrap: gridRowColWrap,
|
||||
title: '{{t("Add block")}}',
|
||||
icon: 'PlusOutlined',
|
||||
items: [
|
||||
{
|
||||
type: 'itemGroup',
|
||||
name: 'dataBlocks',
|
||||
title: '{{t("Data blocks")}}',
|
||||
useChildren: useRecordBlocks,
|
||||
},
|
||||
{
|
||||
name: 'filterBlocks',
|
||||
title: '{{t("Filter blocks")}}',
|
||||
type: 'itemGroup',
|
||||
useVisible() {
|
||||
const collection = useCollection();
|
||||
return useMemo(
|
||||
() =>
|
||||
collection.fields.some(
|
||||
(field) => canMakeAssociationBlock(field) && ['hasMany', 'belongsToMany'].includes(field.type),
|
||||
),
|
||||
[collection.fields],
|
||||
);
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'filterForm',
|
||||
title: '{{t("Form")}}',
|
||||
Component: 'FilterFormBlockInitializer',
|
||||
useComponentProps() {
|
||||
return {
|
||||
filterCollections({ collection }) {
|
||||
return true;
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'filterCollapse',
|
||||
title: '{{t("Collapse")}}',
|
||||
Component: 'FilterCollapseBlockInitializer',
|
||||
useComponentProps() {
|
||||
return {
|
||||
filterCollections({ collection }) {
|
||||
return true;
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'itemGroup',
|
||||
name: 'otherBlocks',
|
||||
title: '{{t("Other blocks")}}',
|
||||
children: [
|
||||
{
|
||||
name: 'markdown',
|
||||
title: '{{t("Markdown")}}',
|
||||
Component: 'MarkdownBlockInitializer',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* use `recordBlockInitializers` instead
|
||||
*/
|
||||
export const recordBlockInitializers_deprecated = new CompatibleSchemaInitializer({
|
||||
name: 'RecordBlockInitializers',
|
||||
wrap: gridRowColWrap,
|
||||
title: '{{t("Add block")}}',
|
||||
icon: 'PlusOutlined',
|
||||
items: [
|
||||
{
|
||||
type: 'itemGroup',
|
||||
name: 'dataBlocks',
|
||||
title: '{{t("Data blocks")}}',
|
||||
useChildren: useRecordBlocks,
|
||||
},
|
||||
{
|
||||
name: 'filterBlocks',
|
||||
title: '{{t("Filter blocks")}}',
|
||||
type: 'itemGroup',
|
||||
useVisible() {
|
||||
const collection = useCollection();
|
||||
return useMemo(
|
||||
() =>
|
||||
collection.fields.some(
|
||||
(field) => canMakeAssociationBlock(field) && ['hasMany', 'belongsToMany'].includes(field.type),
|
||||
),
|
||||
[collection.fields],
|
||||
);
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'filterForm',
|
||||
title: '{{t("Form")}}',
|
||||
Component: 'FilterFormBlockInitializer',
|
||||
useComponentProps() {
|
||||
const collection = useCollection_deprecated();
|
||||
const toManyField = useMemo(
|
||||
() => collection.fields.filter((field) => ['hasMany', 'belongsToMany'].includes(field.type)),
|
||||
[collection.fields],
|
||||
);
|
||||
|
||||
return {
|
||||
filterCollections({ collection }) {
|
||||
if (collection) {
|
||||
return toManyField.some((field) => field.target === collection.name);
|
||||
}
|
||||
},
|
||||
onlyCurrentDataSource: true,
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'filterCollapse',
|
||||
title: '{{t("Collapse")}}',
|
||||
Component: 'FilterCollapseBlockInitializer',
|
||||
useComponentProps() {
|
||||
const collection = useCollection();
|
||||
const toManyField = useMemo(
|
||||
() => collection.fields.filter((field) => ['hasMany', 'belongsToMany'].includes(field.type)),
|
||||
[collection.fields],
|
||||
);
|
||||
|
||||
return {
|
||||
filterCollections({ collection }) {
|
||||
if (collection) {
|
||||
return toManyField.some((field) => field.target === collection.name);
|
||||
}
|
||||
},
|
||||
onlyCurrentDataSource: true,
|
||||
};
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
// {
|
||||
// type: 'itemGroup',
|
||||
// name: 'relationshipBlocks',
|
||||
// title: '{{t("Relationship blocks")}}',
|
||||
// useChildren: useRelationFields,
|
||||
// useVisible() {
|
||||
// const res = useRelationFields();
|
||||
// return res.length > 0;
|
||||
// },
|
||||
// },
|
||||
{
|
||||
type: 'itemGroup',
|
||||
name: 'otherBlocks',
|
||||
title: '{{t("Other blocks")}}',
|
||||
children: [
|
||||
{
|
||||
name: 'markdown',
|
||||
title: '{{t("Markdown")}}',
|
||||
Component: 'MarkdownBlockInitializer',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
...commonOptions,
|
||||
});
|
||||
|
||||
export const recordBlockInitializers = new CompatibleSchemaInitializer(
|
||||
{
|
||||
name: 'popup:common:addBlock',
|
||||
wrap: gridRowColWrap,
|
||||
title: '{{t("Add block")}}',
|
||||
icon: 'PlusOutlined',
|
||||
items: [
|
||||
{
|
||||
type: 'itemGroup',
|
||||
name: 'dataBlocks',
|
||||
title: '{{t("Data blocks")}}',
|
||||
useChildren: useRecordBlocks,
|
||||
},
|
||||
{
|
||||
name: 'filterBlocks',
|
||||
title: '{{t("Filter blocks")}}',
|
||||
type: 'itemGroup',
|
||||
useVisible() {
|
||||
const collection = useCollection();
|
||||
return useMemo(
|
||||
() =>
|
||||
collection.fields.some(
|
||||
(field) => canMakeAssociationBlock(field) && ['hasMany', 'belongsToMany'].includes(field.type),
|
||||
),
|
||||
[collection.fields],
|
||||
);
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'filterForm',
|
||||
title: '{{t("Form")}}',
|
||||
Component: 'FilterFormBlockInitializer',
|
||||
useComponentProps() {
|
||||
const collection = useCollection_deprecated();
|
||||
const toManyField = useMemo(
|
||||
() => collection.fields.filter((field) => ['hasMany', 'belongsToMany'].includes(field.type)),
|
||||
[collection.fields],
|
||||
);
|
||||
|
||||
return {
|
||||
filterCollections({ collection }) {
|
||||
if (collection) {
|
||||
return toManyField.some((field) => field.target === collection.name);
|
||||
}
|
||||
},
|
||||
onlyCurrentDataSource: true,
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'filterCollapse',
|
||||
title: '{{t("Collapse")}}',
|
||||
Component: 'FilterCollapseBlockInitializer',
|
||||
useComponentProps() {
|
||||
const collection = useCollection();
|
||||
const toManyField = useMemo(
|
||||
() => collection.fields.filter((field) => ['hasMany', 'belongsToMany'].includes(field.type)),
|
||||
[collection.fields],
|
||||
);
|
||||
|
||||
return {
|
||||
filterCollections({ collection }) {
|
||||
if (collection) {
|
||||
return toManyField.some((field) => field.target === collection.name);
|
||||
}
|
||||
},
|
||||
onlyCurrentDataSource: true,
|
||||
};
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
// {
|
||||
// type: 'itemGroup',
|
||||
// name: 'relationshipBlocks',
|
||||
// title: '{{t("Relationship blocks")}}',
|
||||
// useChildren: useRelationFields,
|
||||
// useVisible() {
|
||||
// const res = useRelationFields();
|
||||
// return res.length > 0;
|
||||
// },
|
||||
// },
|
||||
{
|
||||
type: 'itemGroup',
|
||||
name: 'otherBlocks',
|
||||
title: '{{t("Other blocks")}}',
|
||||
children: [
|
||||
{
|
||||
name: 'markdown',
|
||||
title: '{{t("Markdown")}}',
|
||||
Component: 'MarkdownBlockInitializer',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
...commonOptions,
|
||||
},
|
||||
recordBlockInitializers_deprecated,
|
||||
);
|
||||
|
@ -110,6 +110,8 @@ export const useTableColumnInitializerFields = () => {
|
||||
.map((field) => {
|
||||
const interfaceConfig = getInterface(field.interface);
|
||||
const isFileCollection = field?.target && getCollection(field?.target)?.template === 'file';
|
||||
const isPreviewComponent = field?.uiSchema?.['x-component'] === 'Preview';
|
||||
|
||||
const schema = {
|
||||
name: field.name,
|
||||
'x-collection-field': `${name}.${field.name}`,
|
||||
@ -121,6 +123,8 @@ export const useTableColumnInitializerFields = () => {
|
||||
value: 'id',
|
||||
},
|
||||
}
|
||||
: isPreviewComponent
|
||||
? { size: 'small' }
|
||||
: {},
|
||||
'x-read-pretty': isReadPretty || field.uiSchema?.['x-read-pretty'],
|
||||
'x-decorator': isSubTable
|
||||
|
@ -39,6 +39,7 @@ import { markdownBlockSettings } from '../modules/blocks/other-blocks/markdown/m
|
||||
import { cascadeSelectComponentFieldSettings } from '../modules/fields/component/CascadeSelect/cascadeSelectComponentFieldSettings';
|
||||
import { datePickerComponentFieldSettings } from '../modules/fields/component/DatePicker/datePickerComponentFieldSettings';
|
||||
import { fileManagerComponentFieldSettings } from '../modules/fields/component/FileManager/fileManagerComponentFieldSettings';
|
||||
import { previewComponentFieldSettings } from '../modules/fields/component/FileManager/previewComponentFieldSettings';
|
||||
import { uploadAttachmentComponentFieldSettings } from '../modules/fields/component/FileManager/uploadAttachmentComponentFieldSettings';
|
||||
import { inputNumberComponentFieldSettings } from '../modules/fields/component/InputNumber/inputNumberComponentFieldSettings';
|
||||
import { subformComponentFieldSettings } from '../modules/fields/component/Nester/subformComponentFieldSettings';
|
||||
@ -105,5 +106,6 @@ export class SchemaSettingsPlugin extends Plugin {
|
||||
this.schemaSettingsManager.add(tagComponentFieldSettings);
|
||||
this.schemaSettingsManager.add(cascadeSelectComponentFieldSettings);
|
||||
this.schemaSettingsManager.add(uploadAttachmentComponentFieldSettings);
|
||||
this.schemaSettingsManager.add(previewComponentFieldSettings);
|
||||
}
|
||||
}
|
||||
|
@ -216,12 +216,12 @@ interface ExtendUtils {
|
||||
/**
|
||||
* @param collectionName 数据表名称
|
||||
* @param data 自定义的数据,缺失时会生成随机数据
|
||||
* @param maxDepth - 生成的数据的最大深度,默认为 4,当不想生成太多数据时可以设置一个较低的值
|
||||
* @param maxDepth - 生成的数据的最大深度,默认为 1,当想生成多层级数据时可以设置一个较高的值
|
||||
*/
|
||||
<T = any>(collectionName: string, data?: any, maxDepth?: number): Promise<T>;
|
||||
/**
|
||||
* @param collectionName 数据表名称
|
||||
* @param maxDepth - 生成的数据的最大深度,默认为 4,当不想生成太多数据时可以设置一个较低的值
|
||||
* @param maxDepth - 生成的数据的最大深度,默认为 1,当想生成多层级数据时可以设置一个较高的值
|
||||
*/
|
||||
<T = any>(collectionName: string, maxDepth?: number): Promise<T>;
|
||||
};
|
||||
@ -232,13 +232,13 @@ interface ExtendUtils {
|
||||
/**
|
||||
* @param collectionName - 数据表名称
|
||||
* @param count - 生成的数据条数
|
||||
* @param maxDepth - 生成的数据的最大深度,默认为 4,当不想生成太多数据时可以设置一个较低的值
|
||||
* @param maxDepth - 生成的数据的最大深度,默认为 1,当想生成多层级数据时可以设置一个较高的值
|
||||
*/
|
||||
<T = any>(collectionName: string, count?: number, maxDepth?: number): Promise<T[]>;
|
||||
/**
|
||||
* @param collectionName - 数据表名称
|
||||
* @param data - 指定生成的数据
|
||||
* @param maxDepth - 生成的数据的最大深度,默认为 4,当不想生成太多数据时可以设置一个较低的值
|
||||
* @param maxDepth - 生成的数据的最大深度,默认为 1,当想生成多层级数据时可以设置一个较高的值
|
||||
*/
|
||||
<T = any>(collectionName: string, data?: any[], maxDepth?: number): Promise<T[]>;
|
||||
};
|
||||
|
@ -281,6 +281,7 @@ test.describe('table column & table', () => {
|
||||
await showSettingsMenu(page, 'attachment');
|
||||
},
|
||||
supportedOptions: ['Custom column title', 'Column width', 'Delete'],
|
||||
unsupportedOptions: ['Size'],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -0,0 +1,678 @@
|
||||
import { expect, test } from '@nocobase/test/e2e';
|
||||
|
||||
test.describe('file collection block', () => {
|
||||
test('What blocks are supported', async ({ page, mockPage }) => {
|
||||
await mockPage({
|
||||
collections: [
|
||||
{
|
||||
name: 'files',
|
||||
template: 'file',
|
||||
},
|
||||
],
|
||||
}).goto();
|
||||
|
||||
const supportedBlocks = async (blockNameList: string[]) => {
|
||||
for (const blockName of blockNameList) {
|
||||
await page.getByLabel('schema-initializer-Grid-page:').hover();
|
||||
await page.getByRole('menuitem', { name: ` ${blockName} right` }).hover();
|
||||
await expect(page.getByRole('menuitem', { name: 'files' })).toBeVisible();
|
||||
await page.mouse.move(300, 0);
|
||||
}
|
||||
};
|
||||
const unsupportedBlocks = async (blockNameList: string[]) => {
|
||||
for (const blockName of blockNameList) {
|
||||
await page.getByLabel('schema-initializer-Grid-page:').hover();
|
||||
if (blockName === 'Filter form') {
|
||||
await page.getByRole('menuitem', { name: ` Form right` }).nth(1).hover();
|
||||
} else {
|
||||
await page
|
||||
.getByRole('menuitem', { name: ` ${blockName} right` })
|
||||
.first()
|
||||
.hover();
|
||||
}
|
||||
await expect(page.getByRole('menuitem', { name: 'files' })).not.toBeVisible();
|
||||
await page.mouse.move(300, 0);
|
||||
}
|
||||
};
|
||||
|
||||
await supportedBlocks(['Table', 'List', 'Details', 'Grid Card', 'Map', 'Gantt']);
|
||||
await unsupportedBlocks(['Form', 'Calendar', 'Kanban', 'Filter form']);
|
||||
});
|
||||
|
||||
test('correctly size', async ({ page, mockPage, mockRecord }) => {
|
||||
const nocoPage = await mockPage({
|
||||
collections: [
|
||||
{
|
||||
name: 'files',
|
||||
template: 'file',
|
||||
},
|
||||
],
|
||||
pageSchema: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Page',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
wwro4dlw5z4: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'page:addBlock',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
rmicwcxvg20: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
q1zio1glrlv: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
s81y458aw3z: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'TableBlockProvider',
|
||||
'x-acl-action': 'files:list',
|
||||
'x-use-decorator-props': 'useTableBlockDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
collection: 'files',
|
||||
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.15',
|
||||
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.15',
|
||||
properties: {
|
||||
'5jd25vufv4c': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-action': 'create',
|
||||
title: "{{t('Upload')}}",
|
||||
'x-designer': 'Action.Designer',
|
||||
'x-component': 'Action',
|
||||
'x-decorator': 'ACLActionProvider',
|
||||
'x-component-props': {
|
||||
openMode: 'drawer',
|
||||
type: 'primary',
|
||||
icon: 'UploadOutlined',
|
||||
},
|
||||
'x-align': 'right',
|
||||
'x-acl-action-props': {
|
||||
skipScopeCheck: true,
|
||||
},
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
drawer: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
title: '{{ t("Upload files") }}',
|
||||
'x-component': 'Action.Container',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
upload: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
title: '{{ t("Upload files") }}',
|
||||
'x-component': 'Upload.DraggerV2',
|
||||
'x-use-component-props': 'useUploadFiles',
|
||||
'x-component-props': {
|
||||
height: '50vh',
|
||||
multiple: true,
|
||||
listType: 'picture',
|
||||
},
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': '78szpjgvsdd',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'ukcboyk7lvd',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '0ztmt5lqupg',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
fxdalnlkfu2: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
title: '{{ t("Refresh") }}',
|
||||
'x-action': 'refresh',
|
||||
'x-component': 'Action',
|
||||
'x-use-component-props': 'useRefreshActionProps',
|
||||
'x-toolbar': 'ActionSchemaToolbar',
|
||||
'x-settings': 'actionSettings:refresh',
|
||||
'x-component-props': {
|
||||
icon: 'ReloadOutlined',
|
||||
},
|
||||
'x-align': 'right',
|
||||
type: 'void',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': 'n4wj5dah2q5',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'mv96b9p9evn',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
udpxydv6won: {
|
||||
_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.15',
|
||||
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.15',
|
||||
properties: {
|
||||
e2tsz0ma2tu: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'DndContext',
|
||||
'x-component': 'Space',
|
||||
'x-component-props': {
|
||||
split: '|',
|
||||
},
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
pfqfjnvom21: {
|
||||
'x-uid': '5nm9q24py65',
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
title: 'View record',
|
||||
'x-action': 'view',
|
||||
'x-toolbar': 'ActionSchemaToolbar',
|
||||
'x-settings': 'actionSettings:view',
|
||||
'x-component': 'Action.Link',
|
||||
'x-component-props': {
|
||||
openMode: 'drawer',
|
||||
danger: false,
|
||||
},
|
||||
'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': 'popup:addTab',
|
||||
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': 'popup:common:addBlock',
|
||||
properties: {
|
||||
zfx6jwsh2px: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
ctt6x9ye302: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
lk6ha5ivn6a: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-acl-action': 'files:get',
|
||||
'x-decorator': 'DetailsBlockProvider',
|
||||
'x-use-decorator-props': 'useDetailsDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
dataSource: 'main',
|
||||
collection: 'files',
|
||||
readPretty: true,
|
||||
action: 'get',
|
||||
},
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:details',
|
||||
'x-component': 'CardItem',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
oqj95jew00z: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Details',
|
||||
'x-read-pretty': true,
|
||||
'x-use-component-props': 'useDetailsProps',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
rmh89kta0hf: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-initializer': 'details:configureActions',
|
||||
'x-component': 'ActionBar',
|
||||
'x-component-props': {
|
||||
style: {
|
||||
marginBottom: 24,
|
||||
},
|
||||
},
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': 'tkbp2h8w1cb',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
grid: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'details:configureFields',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
s3f1ea1t2u2: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
'7toegj7j80s': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
url: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'string',
|
||||
'x-toolbar':
|
||||
'FormItemSchemaToolbar',
|
||||
'x-settings':
|
||||
'fieldSettings:FormItem',
|
||||
'x-component':
|
||||
'CollectionField',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-collection-field':
|
||||
'files.url',
|
||||
'x-component-props': {},
|
||||
'x-read-pretty': true,
|
||||
'x-app-version':
|
||||
'0.21.0-alpha.15',
|
||||
'x-uid': 'gw6ycf9v9ck',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'ez3kik8rxh5',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'bwlyo0c4lws',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
'70iulv6ohmn': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
jbfkqnfdn2t: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
preview: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'string',
|
||||
'x-toolbar':
|
||||
'FormItemSchemaToolbar',
|
||||
'x-settings':
|
||||
'fieldSettings:FormItem',
|
||||
'x-component':
|
||||
'CollectionField',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-collection-field':
|
||||
'files.preview',
|
||||
'x-component-props': {},
|
||||
'x-read-pretty': true,
|
||||
'x-app-version':
|
||||
'0.21.0-alpha.15',
|
||||
'x-uid': 'banact1d7ul',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'j0vyqltznqj',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '1qxmx7wh972',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
ezht5tlzcyo: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
ehtzpty1p3n: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
title: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'string',
|
||||
'x-toolbar':
|
||||
'FormItemSchemaToolbar',
|
||||
'x-settings':
|
||||
'fieldSettings:FormItem',
|
||||
'x-component':
|
||||
'CollectionField',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-collection-field':
|
||||
'files.title',
|
||||
'x-component-props': {},
|
||||
'x-app-version':
|
||||
'0.21.0-alpha.15',
|
||||
'x-uid': 'sfx8flbjouu',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'woyeu6p657c',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '1t97xmqbmmc',
|
||||
'x-async': false,
|
||||
'x-index': 3,
|
||||
},
|
||||
cous2frggb8: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
ujbv7ewhh02: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
filename: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'string',
|
||||
'x-toolbar':
|
||||
'FormItemSchemaToolbar',
|
||||
'x-settings':
|
||||
'fieldSettings:FormItem',
|
||||
'x-component':
|
||||
'CollectionField',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-collection-field':
|
||||
'files.filename',
|
||||
'x-component-props': {},
|
||||
'x-read-pretty': true,
|
||||
'x-app-version':
|
||||
'0.21.0-alpha.15',
|
||||
'x-uid': 'igx2cic3z3s',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'v2262zi9s0y',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'mtsr0vhvhev',
|
||||
'x-async': false,
|
||||
'x-index': 4,
|
||||
},
|
||||
},
|
||||
'x-uid': 'h9wowg4qxn9',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'abgy70jw6bh',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'd6tclnc3x23',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '0mdhu8myu0t',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'tj8uc5x6zpo',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'pg8y0y4tfec',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '41f7jmnvqfr',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '9vfhihve2qu',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'u877bdnvwkd',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'z4ivtq1l8eu',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'o1jn2s0q214',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
l0n1yivozlj: {
|
||||
_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.15',
|
||||
properties: {
|
||||
preview: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
'x-collection-field': 'files.preview',
|
||||
'x-component': 'CollectionField',
|
||||
'x-component-props': {
|
||||
size: 'small',
|
||||
},
|
||||
'x-read-pretty': true,
|
||||
'x-decorator': null,
|
||||
'x-decorator-props': {
|
||||
labelStyle: {
|
||||
display: 'none',
|
||||
},
|
||||
},
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': 'qfdgjele52k',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'xupdn9xh709',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': '1y8n3yv9ldo',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'l6g95h45jvn',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'vmavmabildh',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '4tbjevh15ob',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'wa1dmifukx3',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'wj7bzobpx0q',
|
||||
'x-async': true,
|
||||
'x-index': 1,
|
||||
},
|
||||
}).waitForInit();
|
||||
await mockRecord('files');
|
||||
await nocoPage.goto();
|
||||
|
||||
// 1. Table 中没有 size 选项,并且应该显示小尺寸的图片
|
||||
await page.getByRole('button', { name: 'Preview' }).hover();
|
||||
await page.getByLabel('designer-schema-settings-TableV2.Column-fieldSettings:TableColumn-files').hover();
|
||||
await expect(page.getByRole('menuitem', { name: 'Custom column title' })).toBeVisible();
|
||||
await expect(page.getByRole('menuitem', { name: 'Column width' })).toBeVisible();
|
||||
await expect(page.getByRole('menuitem', { name: 'Size' })).not.toBeVisible();
|
||||
|
||||
const imgBox = await page.getByLabel('block-item-CardItem-').locator('.ant-upload-list-item-image').boundingBox();
|
||||
expect(imgBox.width).toBeLessThanOrEqual(24);
|
||||
|
||||
// 2. 弹窗中应该可以配置图片尺寸
|
||||
await page.getByLabel('action-Action.Link-View').click();
|
||||
await page.getByLabel('block-item-CollectionField-files-details-files.preview-Preview').hover();
|
||||
await page
|
||||
.getByLabel('designer-schema-settings-CollectionField-fieldSettings:FormItem-files-files.preview', {
|
||||
exact: true,
|
||||
})
|
||||
.hover();
|
||||
await expect(page.getByRole('menuitem', { name: 'Size' })).toBeVisible();
|
||||
});
|
||||
});
|
@ -0,0 +1,50 @@
|
||||
import { expect, test } from '@nocobase/test/e2e';
|
||||
import { oneTableWithMap } from './templates';
|
||||
|
||||
test.afterEach(async ({ page }) => {
|
||||
await page.goto('/admin/settings/map');
|
||||
await page.getByRole('button', { name: 'Edit' }).click();
|
||||
await page.getByLabel('Access key').clear();
|
||||
await page.getByLabel('securityJsCode or serviceHost').clear();
|
||||
await page.getByRole('button', { name: 'Save' }).click();
|
||||
await expect(page.locator('.ant-message-notice').getByText('Saved successfully')).toBeVisible();
|
||||
});
|
||||
|
||||
test.describe('where map block can be added', () => {
|
||||
test('page & popup', async ({ page, mockPage }) => {
|
||||
const nocoPage = await mockPage(oneTableWithMap).waitForInit();
|
||||
await nocoPage.goto();
|
||||
|
||||
// 1. 在页面中添加地图区块,因为没有配置 Access key 等信息,所以会显示错误提示
|
||||
await page.getByLabel('schema-initializer-Grid-page:').hover();
|
||||
await page.getByRole('menuitem', { name: 'table Map right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'map', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
||||
await expect(
|
||||
page
|
||||
.getByLabel('block-item-CardItem-map-map')
|
||||
.getByText('Please configure the AccessKey and SecurityJsCode first'),
|
||||
).toBeVisible();
|
||||
|
||||
// 2. 点击跳转按钮去配置页面,配置好后返回刚才的页面,应该能正常显示地图
|
||||
await page.getByRole('button', { name: 'Go to the configuration page' }).click();
|
||||
await page.waitForLoadState('networkidle');
|
||||
if (await page.getByRole('button', { name: 'Edit' }).isVisible()) {
|
||||
await page.getByRole('button', { name: 'Edit' }).click();
|
||||
}
|
||||
await page.getByLabel('Access key').click();
|
||||
await page.getByLabel('Access key').fill('9717a70e44273882bcf5489f72b4e261');
|
||||
await page.getByLabel('securityJsCode or serviceHost').click();
|
||||
await page.getByLabel('securityJsCode or serviceHost').fill('6876ed2d3a6168b75c4fba852e16c99c');
|
||||
await page.getByRole('button', { name: 'Save' }).click();
|
||||
await expect(page.locator('.ant-message-notice').getByText('Saved successfully')).toBeVisible();
|
||||
await nocoPage.goto();
|
||||
await expect(page.getByLabel('block-item-CardItem-map-map').locator('.amap-layer')).toBeAttached();
|
||||
|
||||
// 3. 在弹窗中添加地图区块,应该能正常显示地图
|
||||
await page.getByLabel('block-item-CardItem-map-table').getByLabel('action-Action-Add new-create-').click();
|
||||
await page.getByLabel('schema-initializer-Grid-form:').hover();
|
||||
await page.getByRole('menuitem', { name: 'point' }).click();
|
||||
await expect(page.getByLabel('block-item-CollectionField-').locator('.amap-layer')).toBeAttached();
|
||||
});
|
||||
});
|
@ -0,0 +1,52 @@
|
||||
import { expect, expectSettingsMenu, test } from '@nocobase/test/e2e';
|
||||
import { oneMapUsedToTestSettings } from './templates';
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/admin/settings/map');
|
||||
await page.waitForLoadState('networkidle');
|
||||
if (await page.getByRole('button', { name: 'Edit' }).isVisible()) {
|
||||
await page.getByRole('button', { name: 'Edit' }).click();
|
||||
}
|
||||
await page.getByLabel('Access key').click();
|
||||
await page.getByLabel('Access key').fill('9717a70e44273882bcf5489f72b4e261');
|
||||
await page.getByLabel('securityJsCode or serviceHost').click();
|
||||
await page.getByLabel('securityJsCode or serviceHost').fill('6876ed2d3a6168b75c4fba852e16c99c');
|
||||
await page.getByRole('button', { name: 'Save' }).click();
|
||||
await expect(page.locator('.ant-message-notice').getByText('Saved successfully')).toBeVisible();
|
||||
});
|
||||
|
||||
test.afterEach(async ({ page }) => {
|
||||
await page.goto('/admin/settings/map');
|
||||
await page.getByRole('button', { name: 'Edit' }).click();
|
||||
await page.getByLabel('Access key').clear();
|
||||
await page.getByLabel('securityJsCode or serviceHost').clear();
|
||||
await page.getByRole('button', { name: 'Save' }).click();
|
||||
await expect(page.locator('.ant-message-notice').getByText('Saved successfully')).toBeVisible();
|
||||
});
|
||||
|
||||
test.describe('schema settings', () => {
|
||||
test('what settings can be used in map block', async ({ page, mockPage }) => {
|
||||
await mockPage(oneMapUsedToTestSettings).goto();
|
||||
|
||||
await expectSettingsMenu({
|
||||
page,
|
||||
showMenu: async () => {
|
||||
await page.getByLabel('block-item-CardItem-map-map').hover();
|
||||
await page.getByLabel('designer-schema-settings-CardItem-blockSettings:map-map').hover();
|
||||
},
|
||||
supportedOptions: [
|
||||
'Edit block title',
|
||||
'Fix block',
|
||||
'Map field',
|
||||
'Marker field',
|
||||
'Concatenation order field',
|
||||
'Set data loading mode',
|
||||
'The default zoom level of the map',
|
||||
'Set the data scope',
|
||||
'Connect data blocks',
|
||||
'Save as template',
|
||||
'Delete',
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,511 @@
|
||||
export const oneTableWithMap = {
|
||||
collections: [
|
||||
{
|
||||
name: 'map',
|
||||
fields: [
|
||||
{
|
||||
name: 'point',
|
||||
interface: 'point',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
pageSchema: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Page',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
kkw0yhoj2v7: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'page:addBlock',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
'9i8fyfb05dd': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
'608qygaww2u': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
nokibo5w37z: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'TableBlockProvider',
|
||||
'x-acl-action': 'map:list',
|
||||
'x-use-decorator-props': 'useTableBlockDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
collection: 'map',
|
||||
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.15',
|
||||
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.15',
|
||||
properties: {
|
||||
uip6al0wpnq: {
|
||||
_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.15',
|
||||
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.15',
|
||||
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.15',
|
||||
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.15',
|
||||
properties: {
|
||||
grid: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'popup:addNew:addBlock',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
kb4pfm2qld1: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
hoexd0g3zng: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
'3dmeorgypjr': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-acl-action-props': {
|
||||
skipScopeCheck: true,
|
||||
},
|
||||
'x-acl-action': 'map:create',
|
||||
'x-decorator': 'FormBlockProvider',
|
||||
'x-use-decorator-props': 'useCreateFormBlockDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
dataSource: 'main',
|
||||
collection: 'map',
|
||||
},
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:createForm',
|
||||
'x-component': 'CardItem',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
'8ijqvnv7ipr': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'FormV2',
|
||||
'x-use-component-props': 'useCreateFormBlockProps',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
grid: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'form:configureFields',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': 'nhb5ckrojg8',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
cn3spxefyf0: {
|
||||
_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.15',
|
||||
'x-uid': 'rowvzprfdip',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 't3zwje8con4',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'hzqxhqtd8md',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'q6urn5p0yw4',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '5209bo4teha',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '50pylphuf3x',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '45exb2qrbi9',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'ut9rhesppap',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'aiwsk6sq0wx',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'f04owvm9t0f',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'nmpjxsgfxgc',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
fll1bh8w93y: {
|
||||
_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.15',
|
||||
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.15',
|
||||
properties: {
|
||||
qyh8y3u567i: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'DndContext',
|
||||
'x-component': 'Space',
|
||||
'x-component-props': {
|
||||
split: '|',
|
||||
},
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': 'suuyf9afqcg',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'l49nwyyppfy',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'vrdlfpoa7c6',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'ifxjep3ugit',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'tnw8n4rbwhh',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'yrjjp3jl2rg',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'sp05st5arhk',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '4h4z7pw7j7v',
|
||||
'x-async': true,
|
||||
'x-index': 1,
|
||||
},
|
||||
};
|
||||
export const oneMapUsedToTestSettings = {
|
||||
collections: [
|
||||
{
|
||||
name: 'map',
|
||||
fields: [
|
||||
{
|
||||
name: 'point',
|
||||
interface: 'point',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
pageSchema: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Page',
|
||||
properties: {
|
||||
'8d5kk0rt54w': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'page:addBlock',
|
||||
properties: {
|
||||
'8sia51xaucx': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
elij0klumzf: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
'05gsh93kbeg': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-acl-action': 'map:list',
|
||||
'x-decorator': 'MapBlockProvider',
|
||||
'x-decorator-props': {
|
||||
collection: 'map',
|
||||
dataSource: 'main',
|
||||
action: 'list',
|
||||
fieldNames: {
|
||||
field: ['point'],
|
||||
},
|
||||
params: {
|
||||
paginate: false,
|
||||
},
|
||||
},
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:map',
|
||||
'x-component': 'CardItem',
|
||||
'x-filter-targets': [],
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
actions: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-initializer': 'map:configureActions',
|
||||
'x-component': 'ActionBar',
|
||||
'x-component-props': {
|
||||
style: {
|
||||
marginBottom: 16,
|
||||
},
|
||||
},
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': 'je3ohoqzqt6',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
vdsw8i32n94: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'MapBlock',
|
||||
'x-use-component-props': 'useMapBlockProps',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
properties: {
|
||||
drawer: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Action.Drawer',
|
||||
'x-component-props': {
|
||||
className: 'nb-action-popup',
|
||||
},
|
||||
title: '{{ t("View record") }}',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
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.15',
|
||||
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.15',
|
||||
properties: {
|
||||
grid: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'popup:common:addBlock',
|
||||
'x-app-version': '0.21.0-alpha.15',
|
||||
'x-uid': 'g5d6t1hpvo8',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'hq5j3w8d8db',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'x0ne9tq1bdf',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'micohua87kv',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'e7hfatz8fxx',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'g2n2rqidaem',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'zmrjvgpsgeh',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'q81voyltwkn',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'lyadz9knnnm',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '5b3qaiczmyv',
|
||||
'x-async': true,
|
||||
'x-index': 1,
|
||||
},
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user