fix(NocoBaseRecursionField): ignore x-read-pretty when merging schemas (#5885)

* fix(NocoBaseRecursionField): ignore x-read-pretty when merging schemas

* test: add e2e test
This commit is contained in:
Zeke Zhang 2024-12-16 09:46:19 +08:00 committed by GitHub
parent a623362ac5
commit 5ff8b19e57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 2 deletions

View File

@ -152,12 +152,12 @@ const createMergedSchemaInstance = (schema: Schema, uiSchema: ISchema, onlyRende
const firstPropertyKey = Object.keys(clonedSchema.properties)[0];
const firstPropertyValue = Object.values(clonedSchema.properties)[0];
// Some uiSchema's type value is "void", which can cause exceptions, so we need to ignore the type field
clonedSchema.properties[firstPropertyKey] = merge(_.omit(uiSchema, 'type'), firstPropertyValue);
clonedSchema.properties[firstPropertyKey] = merge(_.omit(uiSchema, 'type', 'x-read-pretty'), firstPropertyValue);
return new Schema(clonedSchema);
}
// Some uiSchema's type value is "void", which can cause exceptions, so we need to ignore the type field
return new Schema(merge(_.omit(uiSchema, 'type'), clonedSchema));
return new Schema(merge(_.omit(uiSchema, 'type', 'x-read-pretty'), clonedSchema));
};
const propertiesToReactElement = ({

View File

@ -62,6 +62,25 @@ test.describe('form item & edit form', () => {
});
});
test.describe('form item & filter form', () => {
test('should be editable', async ({ page, mockPage, mockRecord }) => {
await mockPage().goto();
// 1. 添加一个 filter form 区块
await page.getByLabel('schema-initializer-Grid-page:').hover();
await page.getByRole('menuitem', { name: 'Form right' }).nth(1).hover();
await page.getByRole('menuitem', { name: 'Users' }).click();
// 2. 为 filter form 添加一个 createdAt 字段
await page.getByLabel('schema-initializer-Grid-filterForm:configureFields-users').hover();
await page.getByRole('menuitem', { name: 'Created at' }).first().click();
await page.mouse.move(300, 0);
// 3. createdAt 字段字段应该是可编辑的
await expect(page.getByPlaceholder('Select date')).toBeVisible();
});
});
test.describe('form item & view form', () => {
test('configure fields', async ({ page, mockPage, mockRecord }) => {
const nocoPage = await mockPage(oneTableBlockWithAddNewAndViewAndEditAndSystemInfoFields).waitForInit();