mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 09:38:51 +00:00
fix(Sub-details): the initializer button is not displayed when the field value is empty (#4019)
* test: add e2e * fix: remove return
This commit is contained in:
parent
0f0ccfa9da
commit
beab81818f
@ -1,10 +1,10 @@
|
||||
import { Field } from '@formily/core';
|
||||
import { observer, useField, useFieldSchema } from '@formily/react';
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { AssociationFieldContext } from './context';
|
||||
import { markRecordAsNew } from '../../../data-source/collection-record/isNewRecord';
|
||||
import { useCollection, useCollectionManager } from '../../../data-source/collection';
|
||||
import { markRecordAsNew } from '../../../data-source/collection-record/isNewRecord';
|
||||
import { useSchemaComponentContext } from '../../hooks';
|
||||
import { AssociationFieldContext } from './context';
|
||||
|
||||
export const AssociationFieldProvider = observer(
|
||||
(props) => {
|
||||
@ -40,10 +40,6 @@ export const AssociationFieldProvider = observer(
|
||||
const [loading, setLoading] = useState(!field.readPretty);
|
||||
|
||||
useEffect(() => {
|
||||
if (field.readPretty) {
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
if (!collectionField) {
|
||||
setLoading(false);
|
||||
|
@ -670,6 +670,16 @@ test.describe('form item & view form', () => {
|
||||
await expect(page.getByRole('option', { name: 'Tag', exact: true })).toBeVisible();
|
||||
await expect(page.getByRole('option', { name: 'Sub-details', exact: true })).toBeVisible();
|
||||
await expect(page.getByRole('option', { name: 'Sub-table', exact: true })).toBeVisible();
|
||||
|
||||
// 切换到 Sub-details,应该显示 Initializer 按钮
|
||||
await page.getByRole('option', { name: 'Sub-details', exact: true }).click();
|
||||
await page.mouse.move(300, 0);
|
||||
await expect(
|
||||
page
|
||||
.getByLabel('block-item-CollectionField-general-form-general.manyToMany-manyToMany')
|
||||
.getByLabel('schema-initializer-Grid-form:')
|
||||
.first(),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('title field', async ({ page, mockPage, mockRecords }) => {
|
||||
|
@ -509,6 +509,16 @@ test.describe('form item & view form', () => {
|
||||
await expect(page.getByRole('option', { name: 'Title', exact: true })).toBeVisible();
|
||||
await expect(page.getByRole('option', { name: 'Tag', exact: true })).toBeVisible();
|
||||
await expect(page.getByRole('option', { name: 'Sub-details', exact: true })).toBeVisible();
|
||||
|
||||
// 切换到 Sub-details
|
||||
await page.getByRole('option', { name: 'Sub-details' }).click();
|
||||
await page.mouse.move(300, 0);
|
||||
// 需要显示 Initializer 按钮
|
||||
await expect(
|
||||
page
|
||||
.getByLabel('block-item-CollectionField-general-form-general.manyToOne-manyToOne')
|
||||
.getByLabel('schema-initializer-Grid-form:'),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('title field', async ({ page, mockPage, mockRecords }) => {
|
||||
|
@ -513,6 +513,16 @@ test.describe('form item & view form', () => {
|
||||
await expect(page.getByRole('option', { name: 'Tag', exact: true })).toBeVisible();
|
||||
await expect(page.getByRole('option', { name: 'Sub-table', exact: true })).toBeVisible();
|
||||
await expect(page.getByRole('option', { name: 'Sub-details', exact: true })).toBeVisible();
|
||||
|
||||
// 切换到 Sub-details,应该显示 Initializer 按钮
|
||||
await page.getByRole('option', { name: 'Sub-details', exact: true }).click();
|
||||
await page.mouse.move(300, 0);
|
||||
await expect(
|
||||
page
|
||||
.getByLabel('block-item-CollectionField-general-form-general.oneToMany-oneToMany')
|
||||
.getByLabel('schema-initializer-Grid-form:')
|
||||
.first(),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('title field', async ({ page, mockPage, mockRecords }) => {
|
||||
|
Loading…
Reference in New Issue
Block a user