mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-06 05:59:25 +08:00
test: refresh on action e2e test (#4147)
This commit is contained in:
parent
d5ed2d5037
commit
e96e9aea6e
@ -0,0 +1,39 @@
|
|||||||
|
import { expect, test } from '@nocobase/test/e2e';
|
||||||
|
import { OneTableWithDelete } from './templates';
|
||||||
|
test.describe('action settings', () => {
|
||||||
|
test('refresh data on action', async ({ page, mockPage, mockRecords }) => {
|
||||||
|
await mockPage(OneTableWithDelete).goto();
|
||||||
|
await mockRecords('general', 2);
|
||||||
|
await page.getByLabel('block-item-CardItem-general-').hover();
|
||||||
|
await page.getByLabel('action-Action.Link-Delete-').first().hover();
|
||||||
|
await page.getByLabel('designer-schema-settings-Action.Link-actionSettings:delete-general').first().hover();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
await page.getByRole('menuitem', { name: 'Refresh data on action' }).getByRole('switch').isChecked(),
|
||||||
|
).toBeTruthy();
|
||||||
|
// 默认开启执行后刷新
|
||||||
|
const [request] = await Promise.all([
|
||||||
|
page.waitForRequest((request) => request.url().includes('api/general:list')),
|
||||||
|
page.getByLabel('action-Action.Link-Delete-').first().click(),
|
||||||
|
page.getByRole('button', { name: 'OK' }).click(),
|
||||||
|
]);
|
||||||
|
expect(request).toBeTruthy();
|
||||||
|
|
||||||
|
await page.getByLabel('action-Action.Link-Delete-').first().hover();
|
||||||
|
await page.getByLabel('designer-schema-settings-Action.Link-actionSettings:delete-general').first().hover();
|
||||||
|
|
||||||
|
//关闭则执行后不刷新数据
|
||||||
|
await page.getByRole('menuitem', { name: 'Refresh data on action' }).click();
|
||||||
|
|
||||||
|
let requestMade = false;
|
||||||
|
// 监听所有网络请求
|
||||||
|
page.on('request', (request) => {
|
||||||
|
if (request.url().includes('api/general:list')) {
|
||||||
|
requestMade = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await page.getByLabel('action-Action.Link-Delete-').click();
|
||||||
|
await page.getByRole('button', { name: 'OK' }).click();
|
||||||
|
expect(requestMade).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
189
packages/core/client/src/modules/actions/__e2e__/templates.ts
Normal file
189
packages/core/client/src/modules/actions/__e2e__/templates.ts
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
export const OneTableWithDelete = {
|
||||||
|
collections: [
|
||||||
|
{
|
||||||
|
name: 'general',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'singleLineText',
|
||||||
|
interface: 'input',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
pageSchema: {
|
||||||
|
_isJSONSchemaObject: true,
|
||||||
|
version: '2.0',
|
||||||
|
type: 'void',
|
||||||
|
'x-component': 'Page',
|
||||||
|
'x-app-version': '0.21.0-alpha.15',
|
||||||
|
properties: {
|
||||||
|
lkxdltdha16: {
|
||||||
|
_isJSONSchemaObject: true,
|
||||||
|
version: '2.0',
|
||||||
|
type: 'void',
|
||||||
|
'x-component': 'Grid',
|
||||||
|
'x-initializer': 'page:addBlock',
|
||||||
|
'x-app-version': '0.21.0-alpha.15',
|
||||||
|
properties: {
|
||||||
|
gv2g50cqboq: {
|
||||||
|
_isJSONSchemaObject: true,
|
||||||
|
version: '2.0',
|
||||||
|
type: 'void',
|
||||||
|
'x-component': 'Grid.Row',
|
||||||
|
'x-app-version': '0.21.0-alpha.15',
|
||||||
|
properties: {
|
||||||
|
qttwyoosjfp: {
|
||||||
|
_isJSONSchemaObject: true,
|
||||||
|
version: '2.0',
|
||||||
|
type: 'void',
|
||||||
|
'x-component': 'Grid.Col',
|
||||||
|
'x-app-version': '0.21.0-alpha.15',
|
||||||
|
properties: {
|
||||||
|
t5zn88zei2h: {
|
||||||
|
_isJSONSchemaObject: true,
|
||||||
|
version: '2.0',
|
||||||
|
type: 'void',
|
||||||
|
'x-decorator': 'TableBlockProvider',
|
||||||
|
'x-acl-action': 'general:list',
|
||||||
|
'x-use-decorator-props': 'useTableBlockDecoratorProps',
|
||||||
|
'x-decorator-props': {
|
||||||
|
collection: 'general',
|
||||||
|
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': 'ktkeeuxg6pi',
|
||||||
|
'x-async': false,
|
||||||
|
'x-index': 1,
|
||||||
|
},
|
||||||
|
'0i8niaetq5x': {
|
||||||
|
_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: {
|
||||||
|
j4rat1z1o7f: {
|
||||||
|
_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: {
|
||||||
|
iraglv9h1sl: {
|
||||||
|
_isJSONSchemaObject: true,
|
||||||
|
version: '2.0',
|
||||||
|
title: '{{ t("Delete") }}',
|
||||||
|
'x-action': 'destroy',
|
||||||
|
'x-component': 'Action.Link',
|
||||||
|
'x-use-component-props': 'useDestroyActionProps',
|
||||||
|
'x-toolbar': 'ActionSchemaToolbar',
|
||||||
|
'x-settings': 'actionSettings:delete',
|
||||||
|
'x-component-props': {
|
||||||
|
icon: 'DeleteOutlined',
|
||||||
|
confirm: {
|
||||||
|
title: "{{t('Delete record')}}",
|
||||||
|
content: "{{t('Are you sure you want to delete it?')}}",
|
||||||
|
},
|
||||||
|
refreshDataBlockRequest: true,
|
||||||
|
},
|
||||||
|
'x-action-settings': {
|
||||||
|
triggerWorkflows: [],
|
||||||
|
},
|
||||||
|
'x-decorator': 'ACLActionProvider',
|
||||||
|
'x-designer-props': {
|
||||||
|
linkageAction: true,
|
||||||
|
},
|
||||||
|
type: 'void',
|
||||||
|
'x-uid': '41vvzswpcrl',
|
||||||
|
'x-async': false,
|
||||||
|
'x-index': 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'x-uid': '88lg65527kr',
|
||||||
|
'x-async': false,
|
||||||
|
'x-index': 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'x-uid': '4gj0sxfajz7',
|
||||||
|
'x-async': false,
|
||||||
|
'x-index': 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'x-uid': 'du9l3dpxv3l',
|
||||||
|
'x-async': false,
|
||||||
|
'x-index': 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'x-uid': '254kdo5vqjo',
|
||||||
|
'x-async': false,
|
||||||
|
'x-index': 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'x-uid': '8ofzfmchujz',
|
||||||
|
'x-async': false,
|
||||||
|
'x-index': 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'x-uid': '0y5ftvbwjop',
|
||||||
|
'x-async': false,
|
||||||
|
'x-index': 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'x-uid': 'nf4sg144317',
|
||||||
|
'x-async': false,
|
||||||
|
'x-index': 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'x-uid': 'crrg2fymbz0',
|
||||||
|
'x-async': true,
|
||||||
|
'x-index': 1,
|
||||||
|
},
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user