mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-02 12:18:15 +08:00
fix(subTable): should not display Allow add new data option (#4086)
* fix(subTable): should not display Allow add new data option * chore: make e2e more stable
This commit is contained in:
parent
3445001540
commit
8f17456d93
@ -81,7 +81,7 @@ test.describe('creation form block schema settings', () => {
|
||||
await page.getByRole('option', { name: 'Disabled' }).click();
|
||||
|
||||
// 保存规则
|
||||
await page.getByRole('button', { name: 'OK' }).click();
|
||||
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
||||
|
||||
// 验证第一组规则 --------------------------------------------------------------------------
|
||||
// 初始状态下,longText 字段是可编辑的
|
||||
@ -117,7 +117,7 @@ test.describe('creation form block schema settings', () => {
|
||||
await page.getByLabel('variable-button').click();
|
||||
await page.getByRole('menuitemcheckbox', { name: 'Current form' }).click();
|
||||
await page.getByRole('menuitemcheckbox', { name: 'longText' }).click();
|
||||
await page.getByRole('button', { name: 'OK' }).click();
|
||||
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
||||
|
||||
// singleLineText 字段和 longText 字段都为空的情况下,longText 字段应该是可编辑的
|
||||
await expect(
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { expect, expectSettingsMenu, test } from '@nocobase/test/e2e';
|
||||
import dayjs from 'dayjs';
|
||||
import { oneTableBlockWithDatetimeFields, oneFormBlockWithDatetimeFields } from './utils';
|
||||
import { oneFormBlockWithDatetimeFields, oneTableBlockWithDatetimeFields } from './utils';
|
||||
|
||||
test('Date display format in form', async ({ page, mockPage }) => {
|
||||
await mockPage(oneFormBlockWithDatetimeFields).goto();
|
||||
@ -27,7 +27,7 @@ test('Date display format in form', async ({ page, mockPage }) => {
|
||||
await page.getByText('Date display format').click();
|
||||
await page.getByLabel('Show time').check();
|
||||
await page.getByRole('button', { name: 'HH:mm:ss', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'OK' }).click();
|
||||
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
||||
await page.getByPlaceholder('Select date').click();
|
||||
await page.getByText('Now').click();
|
||||
const value = await page.getByPlaceholder('Select date').inputValue();
|
||||
@ -49,6 +49,6 @@ test('Date display format in table', async ({ page, mockPage, mockRecord }) => {
|
||||
await page.getByText('Date display format').click();
|
||||
await page.getByLabel('Show time').check();
|
||||
await page.getByRole('button', { name: 'hh:mm:ss a' }).click();
|
||||
await page.getByRole('button', { name: 'OK' }).click();
|
||||
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
||||
await expect(page.getByRole('button', { name: dayjs(date).format('YYYY-MM-DD hh:mm:ss a') })).toBeVisible();
|
||||
});
|
||||
|
@ -12,6 +12,7 @@ import {
|
||||
useCollectionManager_deprecated,
|
||||
useCollection_deprecated,
|
||||
} from '../../../collection-manager';
|
||||
import { useFlag } from '../../../flag-provider';
|
||||
import { useRecord } from '../../../record-provider';
|
||||
import { useColumnSchema } from '../../../schema-component/antd/table-v2/Table.Column.Decorator';
|
||||
import { generalSettingsItems } from '../../../schema-items/GeneralSettings';
|
||||
@ -36,10 +37,11 @@ export const allowAddNew: SchemaSettingsItemType = {
|
||||
name: 'allowAddNew',
|
||||
type: 'switch',
|
||||
useVisible() {
|
||||
const flag = useFlag();
|
||||
const readPretty = useIsFieldReadPretty();
|
||||
const isAssociationField = useIsAssociationField();
|
||||
const fieldMode = useFieldMode();
|
||||
return !readPretty && isAssociationField && ['Picker'].includes(fieldMode);
|
||||
return !flag?.isInSubTable && !readPretty && isAssociationField && ['Picker'].includes(fieldMode);
|
||||
},
|
||||
useComponentProps() {
|
||||
const { t } = useTranslation();
|
||||
|
@ -34,12 +34,12 @@ test.describe('data will be updated && Assign field values && after successful s
|
||||
await page.getByLabel('action-Action-Bulk update-customize:bulkUpdate-general-table').click();
|
||||
const [request] = await Promise.all([
|
||||
page.waitForRequest((request) => request.url().includes('api/general:update')),
|
||||
page.getByRole('button', { name: 'OK' }).click(),
|
||||
page.getByRole('button', { name: 'OK', exact: true }).click(),
|
||||
]);
|
||||
const postData = request.postDataJSON();
|
||||
//更新的数据符合预期
|
||||
expect(postData.singleSelect).toEqual('option3');
|
||||
await page.getByRole('button', { name: 'OK' }).click();
|
||||
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
||||
//成功后跳转路由
|
||||
expect(page.url()).toContain('/admin/pm/list/local/');
|
||||
});
|
||||
|
@ -67,7 +67,7 @@ test.describe('direct duplicate & copy into the form and continue to fill in', (
|
||||
];
|
||||
//选中的字段符合预期
|
||||
expect(expectedArray).toEqual(expect.arrayContaining(defaultCheckedNodesText));
|
||||
await page.getByRole('button', { name: 'OK' }).click();
|
||||
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
||||
|
||||
await page.getByLabel('action-Action.Link-Duplicate-duplicate-general-table-0').click();
|
||||
await expect(
|
||||
|
@ -255,6 +255,24 @@ test.describe('form item & create form', () => {
|
||||
.getByLabel('schema-initializer-AssociationField.SubTable-table:configureColumns-users'),
|
||||
).toBeVisible();
|
||||
|
||||
// https://nocobase.height.app/T-4025/description -------------------------------
|
||||
// 1. 把 roles 字段在子表格中显示出来
|
||||
await page.getByLabel('schema-initializer-AssociationField.SubTable-table:configureColumns-users').hover();
|
||||
await page.getByRole('menuitem', { name: 'Roles' }).click();
|
||||
await page.mouse.move(300, 0);
|
||||
|
||||
// 2. 将其 field component 设置为 Record picker
|
||||
await page.getByRole('button', { name: 'Roles' }).hover();
|
||||
await page.getByLabel('designer-schema-settings-TableV2.Column-fieldSettings:TableColumn-users').hover();
|
||||
await page.getByRole('menuitem', { name: 'Field component Select' }).click();
|
||||
await page.getByRole('option', { name: 'Record picker' }).click();
|
||||
|
||||
// 3. 此时 settings 列表中不应该显示 Allow add new data 选项
|
||||
await expect(page.getByRole('menuitem', { name: 'Allow add new data' })).toBeHidden();
|
||||
await page.mouse.move(300, 0);
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
|
||||
// 选择 Sub-form
|
||||
await page.getByLabel(`block-item-CollectionField-general-form-general.manyToMany-manyToMany`).hover();
|
||||
await page
|
||||
|
Loading…
Reference in New Issue
Block a user