From b609db2621e992355747c850feedf44912204228 Mon Sep 17 00:00:00 2001 From: Katherine Date: Sun, 13 Oct 2024 16:06:55 +0800 Subject: [PATCH] test: after successful submission (#5398) --- .../__e2e__/submit/refreshData.test.ts | 37 +- .../actions/__e2e__/submit/templates.ts | 357 ++++++++++++++++++ 2 files changed, 393 insertions(+), 1 deletion(-) diff --git a/packages/core/client/src/modules/actions/__e2e__/submit/refreshData.test.ts b/packages/core/client/src/modules/actions/__e2e__/submit/refreshData.test.ts index d15e3d7f8e..89b7c5ce7c 100644 --- a/packages/core/client/src/modules/actions/__e2e__/submit/refreshData.test.ts +++ b/packages/core/client/src/modules/actions/__e2e__/submit/refreshData.test.ts @@ -8,7 +8,11 @@ */ import { expect, test } from '@nocobase/test/e2e'; -import { shouldRefreshDataWhenSubpageIsClosedByPageMenu, submitInReferenceTemplateBlock } from './templates'; +import { + shouldRefreshDataWhenSubpageIsClosedByPageMenu, + submitInReferenceTemplateBlock, + createFormSubmit, +} from './templates'; test.describe('Submit: should refresh data after submit', () => { test('submit in reference template block', async ({ page, mockPage, clearBlockTemplates, mockRecord }) => { @@ -108,3 +112,34 @@ test.describe('Submit: should refresh data after submit', () => { await page.getByRole('button', { name: '1234567890', exact: true }).click(); }); }); + +test.describe('Submit: After successful submission', () => { + test('return to the previous popup or page as default value', async ({ page, mockPage, mockRecord }) => { + const nocoPage = await mockPage(createFormSubmit).waitForInit(); + await nocoPage.goto(); + + await page.getByLabel('action-Action-Add new-create-').click(); + await page.getByLabel('action-Action-Submit-submit-').click(); + await expect(page.getByTestId('drawer-Action.Container-users-Add record')).not.toBeVisible(); + }); + + test('return to the previous popup or page change to stay on the current popup or page', async ({ + page, + mockPage, + mockRecord, + }) => { + const nocoPage = await mockPage(createFormSubmit).waitForInit(); + await nocoPage.goto(); + + await page.getByLabel('action-Action-Add new-create-').click(); + + await page.getByLabel('action-Action-Submit-submit-').hover(); + await page.getByLabel('designer-schema-settings-Action-actionSettings:createSubmit-users').hover(); + + await page.getByText('After successful submission').click(); + await page.getByLabel('Stay on the current popup or').check(); + await page.getByRole('button', { name: 'OK' }).click(); + await page.getByLabel('action-Action-Submit-submit-').click(); + await expect(page.getByTestId('drawer-Action.Container-users-Add record')).toBeVisible(); + }); +}); diff --git a/packages/core/client/src/modules/actions/__e2e__/submit/templates.ts b/packages/core/client/src/modules/actions/__e2e__/submit/templates.ts index 39c76a3ed0..004d6a42b1 100644 --- a/packages/core/client/src/modules/actions/__e2e__/submit/templates.ts +++ b/packages/core/client/src/modules/actions/__e2e__/submit/templates.ts @@ -1602,3 +1602,360 @@ export const shouldRefreshDataWhenSubpageIsClosedByPageMenu = { 'x-index': 1, }, }; + +export const createFormSubmit = { + pageSchema: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Page', + 'x-app-version': '1.4.0-alpha', + properties: { + c9ar217262w: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'page:addBlock', + 'x-app-version': '1.4.0-alpha', + properties: { + '943651fwz8t': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Row', + 'x-app-version': '1.4.0-alpha', + properties: { + g9fq98c2s4n: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Col', + 'x-app-version': '1.4.0-alpha', + properties: { + '4d3afoagc5g': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-decorator': 'TableBlockProvider', + 'x-acl-action': 'users:list', + 'x-use-decorator-props': 'useTableBlockDecoratorProps', + 'x-decorator-props': { + collection: 'users', + 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': '1.4.0-alpha', + 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': '1.4.0-alpha', + properties: { + afp94e3l423: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-action': 'create', + 'x-acl-action': 'create', + title: "{{t('Add new')}}", + 'x-toolbar': 'ActionSchemaToolbar', + 'x-settings': 'actionSettings:addNew', + 'x-component': 'Action', + 'x-decorator': 'ACLActionProvider', + 'x-component-props': { + openMode: 'drawer', + type: 'primary', + component: 'CreateRecordAction', + icon: 'PlusOutlined', + }, + 'x-action-context': { + dataSource: 'main', + collection: 'users', + }, + 'x-align': 'right', + 'x-acl-action-props': { + skipScopeCheck: true, + }, + 'x-app-version': '1.4.0-alpha', + properties: { + drawer: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{ t("Add record") }}', + 'x-component': 'Action.Container', + 'x-component-props': { + className: 'nb-action-popup', + }, + 'x-app-version': '1.4.0-alpha', + properties: { + tabs: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Tabs', + 'x-component-props': {}, + 'x-initializer': 'popup:addTab', + 'x-initializer-props': { + gridInitializer: 'popup:addNew:addBlock', + }, + 'x-app-version': '1.4.0-alpha', + properties: { + tab1: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{t("Add new")}}', + 'x-component': 'Tabs.TabPane', + 'x-designer': 'Tabs.Designer', + 'x-component-props': {}, + 'x-app-version': '1.4.0-alpha', + properties: { + grid: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'popup:addNew:addBlock', + 'x-app-version': '1.4.0-alpha', + properties: { + umjudxvb3ri: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Row', + 'x-app-version': '1.4.0-alpha', + properties: { + to6yrk48a1e: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Col', + 'x-app-version': '1.4.0-alpha', + properties: { + zfuiyepfpo8: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-acl-action-props': { + skipScopeCheck: true, + }, + 'x-acl-action': 'users:create', + 'x-decorator': 'FormBlockProvider', + 'x-use-decorator-props': 'useCreateFormBlockDecoratorProps', + 'x-decorator-props': { + dataSource: 'main', + collection: 'users', + }, + 'x-toolbar': 'BlockSchemaToolbar', + 'x-settings': 'blockSettings:createForm', + 'x-component': 'CardItem', + 'x-app-version': '1.4.0-alpha', + properties: { + '67zq3yb6rg0': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'FormV2', + 'x-use-component-props': 'useCreateFormBlockProps', + 'x-app-version': '1.4.0-alpha', + properties: { + grid: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'form:configureFields', + 'x-app-version': '1.4.0-alpha', + 'x-uid': 'tyztr48d01m', + 'x-async': false, + 'x-index': 1, + }, + '1cslc0bzwan': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-initializer': 'createForm:configureActions', + 'x-component': 'ActionBar', + 'x-component-props': { + layout: 'one-column', + }, + 'x-app-version': '1.4.0-alpha', + properties: { + rjfxzva092d: { + _isJSONSchemaObject: true, + version: '2.0', + title: '{{ t("Submit") }}', + 'x-action': 'submit', + 'x-component': 'Action', + 'x-use-component-props': 'useCreateActionProps', + 'x-toolbar': 'ActionSchemaToolbar', + 'x-settings': 'actionSettings:createSubmit', + 'x-component-props': { + type: 'primary', + htmlType: 'submit', + }, + 'x-action-settings': { + triggerWorkflows: [], + }, + type: 'void', + 'x-app-version': '1.4.0-alpha', + 'x-uid': 'jpbq9zyexb9', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'xsv37mjii6o', + 'x-async': false, + 'x-index': 2, + }, + }, + 'x-uid': '2j67lyyth1f', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'zcli14m52d6', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '63hxohd7td3', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'm6uu6mtlopn', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'x5nqkk6whbz', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'kaxuorp0kwz', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'qka0657zo5s', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '857bxboz38t', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'qxh2sf5itxw', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '3nsvi44j20t', + 'x-async': false, + 'x-index': 1, + }, + bk1pbg52rcs: { + _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': '1.4.0-alpha', + 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-toolbar': 'TableColumnSchemaToolbar', + 'x-initializer': 'table:configureItemActions', + 'x-settings': 'fieldSettings:TableColumn', + 'x-toolbar-props': { + initializer: 'table:configureItemActions', + }, + 'x-app-version': '1.4.0-alpha', + properties: { + '9tql6edotky': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-decorator': 'DndContext', + 'x-component': 'Space', + 'x-component-props': { + split: '|', + }, + 'x-app-version': '1.4.0-alpha', + 'x-uid': 'zrlg6n04kd0', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'uv7q2tnh9mc', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'g76idw88ik8', + 'x-async': false, + 'x-index': 2, + }, + }, + 'x-uid': 'h0mnhu6ihsd', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '3xdo6vt2c07', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'et8gznfo7r7', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '18w03j8qcv6', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'qvl1ar53zpz', + 'x-async': true, + 'x-index': 1, + }, +};