mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-02 12:18:15 +08:00
parent
803ea80e4b
commit
285f719f9f
@ -35,7 +35,7 @@ describe('SchemaToolbar', () => {
|
||||
});
|
||||
|
||||
describe('useSchemaToolbarRender()', () => {
|
||||
const renderApp = (demoSchema: any, designable = true) => {
|
||||
const renderAppOptions = (demoSchema: any, designable = true) => {
|
||||
const Demo = () => <div data-testid="demo">Demo</div>;
|
||||
|
||||
const CustomToolbar = (props) => {
|
||||
@ -81,7 +81,7 @@ describe('SchemaToolbar', () => {
|
||||
};
|
||||
|
||||
test('Render x-designer if x-designer has a value', () => {
|
||||
renderApp({
|
||||
renderAppOptions({
|
||||
'x-designer': 'CustomToolbar',
|
||||
});
|
||||
|
||||
@ -91,7 +91,7 @@ describe('SchemaToolbar', () => {
|
||||
});
|
||||
|
||||
test('Render x-toolbar if it has a value', () => {
|
||||
renderApp({
|
||||
renderAppOptions({
|
||||
'x-toolbar': 'CustomToolbar',
|
||||
});
|
||||
|
||||
@ -99,7 +99,7 @@ describe('SchemaToolbar', () => {
|
||||
});
|
||||
|
||||
test('Render x-toolbar if both x-toolbar and x-designer have values', () => {
|
||||
renderApp({
|
||||
renderAppOptions({
|
||||
'x-toolbar': 'CustomToolbar',
|
||||
'x-designer': 'CustomToolbar',
|
||||
});
|
||||
@ -108,7 +108,7 @@ describe('SchemaToolbar', () => {
|
||||
});
|
||||
|
||||
test('Render the default SchemaToolbar component if x-toolbar and x-designer have no values and x-settings has a value', () => {
|
||||
renderApp({
|
||||
renderAppOptions({
|
||||
'x-settings': 'DemoSettings',
|
||||
});
|
||||
|
||||
@ -117,14 +117,14 @@ describe('SchemaToolbar', () => {
|
||||
});
|
||||
|
||||
test('Do not render if x-toolbar and x-designer have no values and x-settings also has no value', () => {
|
||||
renderApp({});
|
||||
renderAppOptions({});
|
||||
|
||||
expect(screen.getByTestId('toolbar')).toHaveTextContent('');
|
||||
expect(screen.getByTestId('toolbar-exists')).toHaveTextContent('false');
|
||||
});
|
||||
|
||||
test('Do not render if the component corresponding to x-toolbar cannot be found', () => {
|
||||
renderApp({
|
||||
renderAppOptions({
|
||||
'x-toolbar': 'NotFound',
|
||||
});
|
||||
|
||||
@ -132,7 +132,7 @@ describe('SchemaToolbar', () => {
|
||||
});
|
||||
|
||||
test('Do not render if designable is false', () => {
|
||||
renderApp(
|
||||
renderAppOptions(
|
||||
{
|
||||
'x-designer': 'CustomToolbar',
|
||||
},
|
||||
@ -143,7 +143,7 @@ describe('SchemaToolbar', () => {
|
||||
});
|
||||
|
||||
test('x-toolbar-props and custom Props', () => {
|
||||
renderApp({
|
||||
renderAppOptions({
|
||||
'x-toolbar': 'CustomToolbar',
|
||||
'x-toolbar-props': {
|
||||
test: '123',
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
import React from 'react';
|
||||
import { observer } from '@formily/reactive-react';
|
||||
import { renderApp } from '@nocobase/test/client';
|
||||
import { renderAppOptions } from '@nocobase/test/client';
|
||||
import {
|
||||
SchemaComponent,
|
||||
SchemaInitializer,
|
||||
@ -83,7 +83,7 @@ export async function createApp(options = {}, appOptions = {}) {
|
||||
/>
|
||||
);
|
||||
};
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
appOptions: {
|
||||
providers: [Root],
|
||||
schemaInitializers: [testInitializers],
|
||||
|
@ -22,7 +22,7 @@ import { render, screen } from '@nocobase/test/client';
|
||||
import React from 'react';
|
||||
import collections from '../collections.json';
|
||||
|
||||
function renderApp(fieldName: string, components = {}) {
|
||||
function renderAppOptions(fieldName: string, components = {}) {
|
||||
const noUiSchema = {
|
||||
key: 'no-ui-schema',
|
||||
name: 'no-ui-schema',
|
||||
@ -99,7 +99,7 @@ function renderApp(fieldName: string, components = {}) {
|
||||
|
||||
describe('CollectionField', () => {
|
||||
it('works', () => {
|
||||
renderApp('nickname');
|
||||
renderAppOptions('nickname');
|
||||
expect(screen.getByText('Nickname')).toBeInTheDocument();
|
||||
expect(screen.getByRole('textbox')).toHaveClass('ant-input');
|
||||
});
|
||||
@ -109,18 +109,18 @@ describe('CollectionField', () => {
|
||||
const field = useCollectionField();
|
||||
return <div className={'input-test-1'}>{field?.name}</div>;
|
||||
};
|
||||
renderApp('nickname', { Input });
|
||||
renderAppOptions('nickname', { Input });
|
||||
expect(document.querySelector('.input-test-1')).toHaveTextContent('nickname');
|
||||
});
|
||||
|
||||
it('useComponentProps', () => {
|
||||
renderApp('dynamic-props');
|
||||
renderAppOptions('dynamic-props');
|
||||
expect(document.querySelector('.ant-input')).toHaveAttribute('placeholder', 'placeholder');
|
||||
expect(screen.queryByText('addonBefore')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('no schema', () => {
|
||||
renderApp('no-ui-schema');
|
||||
renderAppOptions('no-ui-schema');
|
||||
expect(document.querySelector('.ant-formily-item-control-content-component')).toHaveTextContent('');
|
||||
});
|
||||
});
|
||||
|
@ -19,7 +19,7 @@ import {
|
||||
} from '@nocobase/client';
|
||||
import collections from '../collections.json';
|
||||
|
||||
function renderApp(Demo: ComponentType, name?: string) {
|
||||
function renderAppOptions(Demo: ComponentType, name?: string) {
|
||||
const app = new Application({
|
||||
dataSourceManager: {
|
||||
collections: collections as any,
|
||||
@ -51,7 +51,7 @@ describe('CollectionFieldProvider', () => {
|
||||
);
|
||||
};
|
||||
|
||||
renderApp(Demo, 'nickname');
|
||||
renderAppOptions(Demo, 'nickname');
|
||||
|
||||
expect(screen.getByTestId('demo')).toHaveTextContent('nickname');
|
||||
});
|
||||
@ -61,7 +61,7 @@ describe('CollectionFieldProvider', () => {
|
||||
return <div>children</div>;
|
||||
};
|
||||
|
||||
renderApp(Demo, 'not-exists');
|
||||
renderAppOptions(Demo, 'not-exists');
|
||||
|
||||
expect(document.body.innerHTML).toContain('ant-typography');
|
||||
expect(document.body.innerHTML).not.toContain('children');
|
||||
|
@ -21,7 +21,7 @@ import {
|
||||
} from '@nocobase/client';
|
||||
import collections from '../collections.json';
|
||||
|
||||
function renderApp(Demo: ComponentType, props: any = {}) {
|
||||
function renderAppOptions(Demo: ComponentType, props: any = {}) {
|
||||
const app = new Application({
|
||||
dataSourceManager: {
|
||||
collections: collections as any,
|
||||
@ -69,7 +69,7 @@ describe('AssociationProvider', () => {
|
||||
);
|
||||
};
|
||||
|
||||
renderApp(Demo, { name: 'users.roles' });
|
||||
renderAppOptions(Demo, { name: 'users.roles' });
|
||||
|
||||
expect(screen.getByTestId('collection')).toHaveTextContent('roles');
|
||||
expect(screen.getByTestId('parent-collection')).toHaveTextContent('users');
|
||||
@ -90,7 +90,7 @@ describe('AssociationProvider', () => {
|
||||
);
|
||||
};
|
||||
|
||||
renderApp(Demo, { name: 'users.roles', dataSource: 'a' });
|
||||
renderAppOptions(Demo, { name: 'users.roles', dataSource: 'a' });
|
||||
|
||||
expect(screen.getByTestId('collection')).toHaveTextContent('roles');
|
||||
expect(screen.getByTestId('parent-collection')).toHaveTextContent('users');
|
||||
@ -101,7 +101,7 @@ describe('AssociationProvider', () => {
|
||||
const Demo = () => {
|
||||
return <div>Demo</div>;
|
||||
};
|
||||
renderApp(Demo, { name: 'users.not-exists' });
|
||||
renderAppOptions(Demo, { name: 'users.not-exists' });
|
||||
|
||||
expect(screen.getByText('Delete')).toBeInTheDocument();
|
||||
expect(
|
||||
|
@ -20,7 +20,7 @@ import {
|
||||
} from '@nocobase/client';
|
||||
import collections from '../collections.json';
|
||||
|
||||
function renderApp(Demo: ComponentType, dataSource?: string) {
|
||||
function renderAppOptions(Demo: ComponentType, dataSource?: string) {
|
||||
const app = new Application({
|
||||
dataSourceManager: {
|
||||
collections: collections as any,
|
||||
@ -50,7 +50,7 @@ describe('CollectionManagerProvider', () => {
|
||||
const users = cm.getCollection('users');
|
||||
return <div data-testid="demo">{users.name}</div>;
|
||||
};
|
||||
renderApp(Demo);
|
||||
renderAppOptions(Demo);
|
||||
|
||||
expect(screen.getByTestId('demo')).toHaveTextContent('users');
|
||||
});
|
||||
@ -60,7 +60,7 @@ describe('CollectionManagerProvider', () => {
|
||||
const collections = useCollections();
|
||||
return <div data-testid="demo">{collections.length}</div>;
|
||||
};
|
||||
renderApp(Demo);
|
||||
renderAppOptions(Demo);
|
||||
|
||||
expect(screen.getByTestId('demo')).toHaveTextContent('2');
|
||||
});
|
||||
@ -70,7 +70,7 @@ describe('CollectionManagerProvider', () => {
|
||||
const collections = useCollections((collection) => collection.name === 'users');
|
||||
return <div data-testid="demo">{collections.length}</div>;
|
||||
};
|
||||
renderApp(Demo);
|
||||
renderAppOptions(Demo);
|
||||
|
||||
expect(screen.getByTestId('demo')).toHaveTextContent('1');
|
||||
});
|
||||
@ -80,7 +80,7 @@ describe('CollectionManagerProvider', () => {
|
||||
const collections = useCollections();
|
||||
return <div data-testid="demo">{collections.length}</div>;
|
||||
};
|
||||
renderApp(Demo, 'a');
|
||||
renderAppOptions(Demo, 'a');
|
||||
|
||||
expect(screen.getByTestId('demo')).toHaveTextContent('1');
|
||||
});
|
||||
@ -99,7 +99,7 @@ describe('CollectionManagerProvider', () => {
|
||||
);
|
||||
};
|
||||
|
||||
renderApp(Wrapper, 'a');
|
||||
renderAppOptions(Wrapper, 'a');
|
||||
|
||||
expect(screen.getByTestId('demo')).toHaveTextContent('2');
|
||||
});
|
||||
@ -120,7 +120,7 @@ describe('CollectionManagerProvider', () => {
|
||||
);
|
||||
};
|
||||
|
||||
renderApp(Wrapper, 'a');
|
||||
renderAppOptions(Wrapper, 'a');
|
||||
|
||||
expect(screen.getByTestId('demo')).toHaveTextContent('2');
|
||||
});
|
||||
|
@ -20,7 +20,7 @@ import {
|
||||
} from '@nocobase/client';
|
||||
import collections from '../collections.json';
|
||||
|
||||
function renderApp(Demo: ComponentType, props: any = {}) {
|
||||
function renderAppOptions(Demo: ComponentType, props: any = {}) {
|
||||
const app = new Application({
|
||||
dataSourceManager: {
|
||||
collections: collections as any,
|
||||
@ -58,7 +58,7 @@ describe('CollectionProvider', () => {
|
||||
);
|
||||
};
|
||||
|
||||
renderApp(Demo, { name: 'users' });
|
||||
renderAppOptions(Demo, { name: 'users' });
|
||||
|
||||
expect(screen.getByTestId('name')).toHaveTextContent('users');
|
||||
|
||||
@ -74,7 +74,7 @@ describe('CollectionProvider', () => {
|
||||
return <div data-testid="children">children</div>;
|
||||
};
|
||||
|
||||
renderApp(Demo, { name: 'not-exists', allowNull: true });
|
||||
renderAppOptions(Demo, { name: 'not-exists', allowNull: true });
|
||||
|
||||
expect(screen.getByTestId('children')).toHaveTextContent('children');
|
||||
});
|
||||
@ -87,7 +87,7 @@ describe('CollectionProvider', () => {
|
||||
return <div>children</div>;
|
||||
};
|
||||
|
||||
renderApp(Demo, { name: 'not-exists', allowNull: false });
|
||||
renderAppOptions(Demo, { name: 'not-exists', allowNull: false });
|
||||
|
||||
expect(screen.getByText('Delete')).toBeInTheDocument();
|
||||
});
|
||||
@ -98,7 +98,7 @@ describe('CollectionProvider', () => {
|
||||
return <div data-testid="fields">{fields.length}</div>;
|
||||
};
|
||||
|
||||
renderApp(Demo, { name: 'users' });
|
||||
renderAppOptions(Demo, { name: 'users' });
|
||||
|
||||
expect(screen.getByTestId('fields')).toHaveTextContent('1');
|
||||
});
|
||||
|
@ -13,7 +13,7 @@ import { render, screen, userEvent, waitFor } from '@nocobase/test/client';
|
||||
import { CollectionDeletedPlaceholder, SchemaComponent, SchemaComponentProvider } from '@nocobase/client';
|
||||
import { App } from 'antd';
|
||||
|
||||
function renderApp(name?: any, designable?: boolean) {
|
||||
function renderAppOptions(name?: any, designable?: boolean) {
|
||||
const schema = {
|
||||
name: 'root',
|
||||
type: 'void',
|
||||
@ -37,7 +37,7 @@ function renderApp(name?: any, designable?: boolean) {
|
||||
|
||||
describe('CollectionDeletedPlaceholder', () => {
|
||||
test('name is undefined, render `Result` component', async () => {
|
||||
renderApp(undefined, true);
|
||||
renderAppOptions(undefined, true);
|
||||
|
||||
expect(screen.getByText('Delete')).toBeInTheDocument();
|
||||
expect(screen.getByText('Collection name is required')).toBeInTheDocument();
|
||||
@ -55,7 +55,7 @@ describe('CollectionDeletedPlaceholder', () => {
|
||||
});
|
||||
|
||||
test('designable: true, render `Result` component', () => {
|
||||
renderApp('test', true);
|
||||
renderAppOptions('test', true);
|
||||
expect(screen.getByText('Delete')).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText('The collection "test" may have been deleted. Please remove this block.'),
|
||||
@ -63,7 +63,7 @@ describe('CollectionDeletedPlaceholder', () => {
|
||||
});
|
||||
|
||||
test('designable: false, render nothing', () => {
|
||||
renderApp('test', false);
|
||||
renderAppOptions('test', false);
|
||||
|
||||
expect(screen.queryByText('Delete')).not.toBeInTheDocument();
|
||||
});
|
||||
|
@ -51,6 +51,7 @@ export const useTableBlockProps = () => {
|
||||
}, [field, ctx?.service?.data, isLoading, ctx?.field?.data?.selectedRowKeys]);
|
||||
|
||||
return {
|
||||
bordered: ctx.bordered,
|
||||
childrenColumnName: ctx.childrenColumnName,
|
||||
loading: ctx?.service?.loading,
|
||||
showIndex: ctx.showIndex,
|
||||
|
@ -8,12 +8,12 @@
|
||||
*/
|
||||
|
||||
import { ACLMenuItemProvider, AdminLayout, BlockSchemaComponentPlugin, CurrentUserProvider } from '@nocobase/client';
|
||||
import { renderApp, waitFor, screen } from '@nocobase/test/client';
|
||||
import { renderAppOptions, waitFor, screen } from '@nocobase/test/client';
|
||||
import React from 'react';
|
||||
|
||||
describe('AdminLayout', () => {
|
||||
it('should render correctly', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
designable: true,
|
||||
noWrapperSchema: true,
|
||||
appOptions: {
|
||||
|
@ -8,12 +8,12 @@
|
||||
*/
|
||||
|
||||
import { RouteSchemaComponent } from '@nocobase/client';
|
||||
import { renderApp, waitFor, screen } from '@nocobase/test/client';
|
||||
import { renderAppOptions, waitFor, screen } from '@nocobase/test/client';
|
||||
import React from 'react';
|
||||
|
||||
describe('route-schema-component', () => {
|
||||
it('should render correctly', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
designable: true,
|
||||
noWrapperSchema: true,
|
||||
appOptions: {
|
||||
|
@ -7,12 +7,12 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { renderApp, screen, userEvent, waitFor } from '@nocobase/test/client';
|
||||
import { renderAppOptions, screen, userEvent, waitFor } from '@nocobase/test/client';
|
||||
import { DataSourceCollectionCascader } from '../CollectionSelect';
|
||||
|
||||
describe('DataSourceCollectionCascader', () => {
|
||||
test('should works', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
enableMultipleDataSource: true,
|
||||
schema: {
|
||||
type: 'string',
|
||||
|
@ -7,12 +7,12 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { renderApp, screen, userEvent, waitFor, renderReadPrettyApp } from '@nocobase/test/client';
|
||||
import { renderAppOptions, screen, userEvent, waitFor, renderReadPrettyApp } from '@nocobase/test/client';
|
||||
import { DataSourceSelect } from '../CollectionSelect';
|
||||
|
||||
describe('DataSourceSelect', () => {
|
||||
test('single', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
Component: DataSourceSelect,
|
||||
});
|
||||
|
||||
@ -23,7 +23,7 @@ describe('DataSourceSelect', () => {
|
||||
});
|
||||
|
||||
test('multiple', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
enableMultipleDataSource: true,
|
||||
schema: {
|
||||
type: 'string',
|
||||
@ -39,7 +39,7 @@ describe('DataSourceSelect', () => {
|
||||
});
|
||||
|
||||
test('change', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
enableMultipleDataSource: true,
|
||||
schema: {
|
||||
type: 'string',
|
||||
@ -54,7 +54,7 @@ describe('DataSourceSelect', () => {
|
||||
});
|
||||
|
||||
test('filter', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
enableMultipleDataSource: true,
|
||||
schema: {
|
||||
type: 'string',
|
||||
|
@ -7,12 +7,12 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { renderReadPrettyApp, renderApp, screen, userEvent, waitFor } from '@nocobase/test/client';
|
||||
import { renderReadPrettyApp, renderAppOptions, screen, userEvent, waitFor } from '@nocobase/test/client';
|
||||
import { FormItem, CollectionSelect } from '@nocobase/client';
|
||||
|
||||
describe('CollectionSelect', () => {
|
||||
it('should works', async () => {
|
||||
const { container } = await renderApp({
|
||||
const { container } = await renderAppOptions({
|
||||
schema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
|
@ -8,11 +8,11 @@
|
||||
*/
|
||||
|
||||
import { ColorPicker } from '@nocobase/client';
|
||||
import { renderApp, screen, renderReadPrettyApp, userEvent, waitFor } from '@nocobase/test/client';
|
||||
import { renderAppOptions, screen, renderReadPrettyApp, userEvent, waitFor } from '@nocobase/test/client';
|
||||
|
||||
describe('ColorPicker', () => {
|
||||
test('basic', async () => {
|
||||
const { container } = await renderApp({
|
||||
const { container } = await renderAppOptions({
|
||||
Component: ColorPicker,
|
||||
value: 'rgb(139, 187, 17)',
|
||||
});
|
||||
@ -53,7 +53,7 @@ describe('ColorPicker', () => {
|
||||
});
|
||||
|
||||
test('change', async () => {
|
||||
const { container } = await renderApp({
|
||||
const { container } = await renderAppOptions({
|
||||
Component: ColorPicker,
|
||||
value: 'rgb(139, 187, 17)',
|
||||
});
|
||||
|
@ -8,13 +8,13 @@
|
||||
*/
|
||||
|
||||
import { BlockSchemaComponentPlugin, FormBlockProvider, VariablesProvider } from '@nocobase/client';
|
||||
import { checkSettings, renderApp } from '@nocobase/test/client';
|
||||
import { checkSettings, renderAppOptions } from '@nocobase/test/client';
|
||||
import { withSchema } from '@nocobase/test/web';
|
||||
|
||||
describe('form.settings', () => {
|
||||
test('new schema version', async () => {
|
||||
const FormBlockProviderWithSchema = withSchema(FormBlockProvider);
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
designable: true,
|
||||
schema: {
|
||||
_isJSONSchemaObject: true,
|
||||
|
@ -1,10 +1,8 @@
|
||||
|
||||
|
||||
import { BlockSchemaComponentPlugin, VariablesProvider } from '@nocobase/client';
|
||||
import { renderApp } from '@nocobase/test/client';
|
||||
import { renderAppOptions } from '@nocobase/test/client';
|
||||
|
||||
export const renderDemo9 = () =>
|
||||
renderApp({
|
||||
renderAppOptions({
|
||||
designable: true,
|
||||
schema: {
|
||||
_isJSONSchemaObject: true,
|
||||
|
@ -8,11 +8,11 @@
|
||||
*/
|
||||
|
||||
import { BlockSchemaComponentPlugin } from '@nocobase/client';
|
||||
import { renderApp, waitFor, screen, userEvent } from '@nocobase/test/client';
|
||||
import { renderAppOptions, waitFor, screen, userEvent } from '@nocobase/test/client';
|
||||
|
||||
describe('GridCard', () => {
|
||||
it('should render correctly', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
designable: true,
|
||||
schema: {
|
||||
_isJSONSchemaObject: true,
|
||||
|
@ -8,11 +8,11 @@
|
||||
*/
|
||||
|
||||
import { BlockSchemaComponentPlugin } from '@nocobase/client';
|
||||
import { renderApp, waitFor, screen, userEvent } from '@nocobase/test/client';
|
||||
import { renderAppOptions, waitFor, screen, userEvent } from '@nocobase/test/client';
|
||||
|
||||
describe('List', () => {
|
||||
it('should render correctly', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
designable: true,
|
||||
schema: {
|
||||
type: 'void',
|
||||
|
@ -8,11 +8,11 @@
|
||||
*/
|
||||
|
||||
import { BlockSchemaComponentPlugin } from '@nocobase/client';
|
||||
import { screen, renderApp, renderReadPrettyApp, userEvent, waitFor } from '@nocobase/test/client';
|
||||
import { screen, renderAppOptions, renderReadPrettyApp, userEvent, waitFor } from '@nocobase/test/client';
|
||||
|
||||
describe('NanoIDInput', () => {
|
||||
test('basic', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
designable: true,
|
||||
enableUserListDataBlock: true,
|
||||
schema: {
|
||||
|
@ -7,7 +7,7 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { render, screen, waitFor, renderApp, userEvent } from '@nocobase/test/client';
|
||||
import { render, screen, waitFor, renderAppOptions, userEvent } from '@nocobase/test/client';
|
||||
import React from 'react';
|
||||
import App1 from '../demos/demo1';
|
||||
import { Page } from '../Page';
|
||||
@ -31,7 +31,7 @@ describe('Page', () => {
|
||||
describe('Page Component', () => {
|
||||
const title = 'Test Title';
|
||||
test('schema title', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
schema: {
|
||||
type: 'void',
|
||||
title,
|
||||
@ -43,7 +43,7 @@ describe('Page', () => {
|
||||
});
|
||||
|
||||
test('hide title', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
schema: {
|
||||
type: 'void',
|
||||
title,
|
||||
@ -58,7 +58,7 @@ describe('Page', () => {
|
||||
});
|
||||
|
||||
test('should request remote schema when no title', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
schema: {
|
||||
type: 'void',
|
||||
'x-uid': 'test',
|
||||
@ -80,7 +80,7 @@ describe('Page', () => {
|
||||
});
|
||||
|
||||
test('enablePageTabs', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
schema: {
|
||||
type: 'void',
|
||||
title,
|
||||
@ -118,7 +118,7 @@ describe('Page', () => {
|
||||
});
|
||||
|
||||
test('add tab', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
schema: {
|
||||
type: 'void',
|
||||
title,
|
||||
|
@ -7,12 +7,12 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { renderApp } from '@nocobase/test/client';
|
||||
import { renderAppOptions } from '@nocobase/test/client';
|
||||
import { Pagination } from '@nocobase/client';
|
||||
|
||||
describe('Pagination', () => {
|
||||
it('renders without errors', async () => {
|
||||
const { container } = await renderApp({
|
||||
const { container } = await renderAppOptions({
|
||||
Component: Pagination,
|
||||
props: {
|
||||
total: 20,
|
||||
@ -122,7 +122,7 @@ describe('Pagination', () => {
|
||||
});
|
||||
|
||||
it('hides when hidden prop is true', async () => {
|
||||
const { container } = await renderApp({
|
||||
const { container } = await renderAppOptions({
|
||||
Component: Pagination,
|
||||
props: {
|
||||
hidden: true,
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import { BlockSchemaComponentPlugin } from '@nocobase/client';
|
||||
import { screen, renderApp, sleep, userEvent, waitFor } from '@nocobase/test/client';
|
||||
import { screen, renderAppOptions, sleep, userEvent, waitFor } from '@nocobase/test/client';
|
||||
|
||||
describe('QuickEdit', () => {
|
||||
function getRenderOptions(readPretty = false) {
|
||||
@ -119,7 +119,7 @@ describe('QuickEdit', () => {
|
||||
}
|
||||
|
||||
it('basic', async () => {
|
||||
await renderApp(getRenderOptions());
|
||||
await renderAppOptions(getRenderOptions());
|
||||
|
||||
await waitFor(() => {
|
||||
expect(document.querySelector('.ant-table-footer button')).toBeInTheDocument();
|
||||
@ -143,7 +143,7 @@ describe('QuickEdit', () => {
|
||||
});
|
||||
|
||||
it('read pretty', async () => {
|
||||
await renderApp(getRenderOptions(true));
|
||||
await renderAppOptions(getRenderOptions(true));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(document.querySelector('.ant-table-footer button')).toBeInTheDocument();
|
||||
|
@ -7,12 +7,12 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { screen, renderApp, userEvent, waitFor, renderReadPrettyApp } from '@nocobase/test/client';
|
||||
import { screen, renderAppOptions, userEvent, waitFor, renderReadPrettyApp } from '@nocobase/test/client';
|
||||
import { UnixTimestamp } from '@nocobase/client';
|
||||
|
||||
describe('UnixTimestamp', () => {
|
||||
it('renders without errors', async () => {
|
||||
const { container } = await renderApp({
|
||||
const { container } = await renderAppOptions({
|
||||
Component: UnixTimestamp,
|
||||
props: {
|
||||
accuracy: 'millisecond',
|
||||
@ -70,7 +70,7 @@ describe('UnixTimestamp', () => {
|
||||
});
|
||||
|
||||
it('millisecond', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
Component: UnixTimestamp,
|
||||
value: 1712819630000,
|
||||
props: {
|
||||
@ -83,7 +83,7 @@ describe('UnixTimestamp', () => {
|
||||
});
|
||||
|
||||
it('second', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
Component: UnixTimestamp,
|
||||
value: 1712819630,
|
||||
props: {
|
||||
@ -97,7 +97,7 @@ describe('UnixTimestamp', () => {
|
||||
});
|
||||
|
||||
it('string', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
Component: UnixTimestamp,
|
||||
value: '2024-04-11',
|
||||
props: {
|
||||
@ -112,7 +112,7 @@ describe('UnixTimestamp', () => {
|
||||
|
||||
it('change', async () => {
|
||||
const onChange = vitest.fn();
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
Component: UnixTimestamp,
|
||||
value: '2024-04-11',
|
||||
onChange,
|
||||
|
@ -13,7 +13,7 @@ import App1 from '../demos/demo1';
|
||||
import App2 from '../demos/demo2';
|
||||
|
||||
import { BlockSchemaComponentPlugin } from '@nocobase/client';
|
||||
import { screen, renderApp, renderReadPrettyApp, userEvent, waitFor } from '@nocobase/test/client';
|
||||
import { screen, renderAppOptions, renderReadPrettyApp, userEvent, waitFor } from '@nocobase/test/client';
|
||||
|
||||
describe('Upload', () => {
|
||||
it('basic', () => {
|
||||
@ -25,7 +25,7 @@ describe('Upload', () => {
|
||||
});
|
||||
|
||||
it('upload single', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
designable: true,
|
||||
enableUserListDataBlock: true,
|
||||
schema: {
|
||||
@ -124,7 +124,7 @@ describe('Upload', () => {
|
||||
});
|
||||
|
||||
it('upload multi', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
designable: true,
|
||||
enableUserListDataBlock: true,
|
||||
schema: {
|
||||
@ -214,7 +214,7 @@ describe('Upload', () => {
|
||||
});
|
||||
|
||||
it('delete', async () => {
|
||||
await renderApp({
|
||||
await renderAppOptions({
|
||||
designable: true,
|
||||
enableUserListDataBlock: true,
|
||||
schema: {
|
||||
|
@ -40,7 +40,7 @@ export { default as userEvent } from '@testing-library/user-event';
|
||||
// override render export
|
||||
export { customRender as render, sleep };
|
||||
|
||||
export * from './renderApp';
|
||||
export * from './renderAppOptions';
|
||||
export * from './renderHookWithApp';
|
||||
export * from './renderSettings';
|
||||
export * from './renderSingleSettings';
|
||||
|
@ -12,7 +12,7 @@ import { render } from '@testing-library/react';
|
||||
import { GetAppComponentOptions, addXReadPrettyToEachLayer, getAppComponent } from '../web';
|
||||
import { WaitApp } from './utils';
|
||||
|
||||
export const renderApp = async (options: GetAppComponentOptions) => {
|
||||
export const renderAppOptions = async (options: GetAppComponentOptions) => {
|
||||
const App = getAppComponent(options);
|
||||
|
||||
const res = render(<App />);
|
||||
@ -23,5 +23,5 @@ export const renderApp = async (options: GetAppComponentOptions) => {
|
||||
};
|
||||
|
||||
export const renderReadPrettyApp = (options: GetAppComponentOptions) => {
|
||||
return renderApp({ ...options, schema: addXReadPrettyToEachLayer(options.schema) });
|
||||
return renderAppOptions({ ...options, schema: addXReadPrettyToEachLayer(options.schema) });
|
||||
};
|
@ -10,7 +10,7 @@
|
||||
import { waitFor, screen } from '@testing-library/react';
|
||||
import { GetAppComponentOptions } from '../web';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { renderApp, renderReadPrettyApp } from './renderApp';
|
||||
import { renderAppOptions, renderReadPrettyApp } from './renderAppOptions';
|
||||
import { expectNoTsError } from './utils';
|
||||
|
||||
export async function showSettingsMenu(container: HTMLElement | Document = document) {
|
||||
@ -30,7 +30,7 @@ export interface RenderSettingsOptions extends GetAppComponentOptions {
|
||||
}
|
||||
export const renderSettings = async (options: RenderSettingsOptions = {}) => {
|
||||
const { container = () => document, ...appOptions } = options;
|
||||
const result = await renderApp({ ...appOptions, designable: true });
|
||||
const result = await renderAppOptions({ ...appOptions, designable: true });
|
||||
|
||||
const containerElement = container();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user