mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
test: custom action e2e (#4956)
This commit is contained in:
parent
6c079d7435
commit
f411fe5902
@ -12,6 +12,8 @@ export class CreateWorkFlow {
|
|||||||
readonly page: Page;
|
readonly page: Page;
|
||||||
name: Locator;
|
name: Locator;
|
||||||
triggerType: Locator;
|
triggerType: Locator;
|
||||||
|
synchronouslyRadio: Locator;
|
||||||
|
asynchronouslyRadio: Locator;
|
||||||
description: Locator;
|
description: Locator;
|
||||||
autoDeleteHistory: Locator;
|
autoDeleteHistory: Locator;
|
||||||
submitButton: Locator;
|
submitButton: Locator;
|
||||||
@ -20,6 +22,8 @@ export class CreateWorkFlow {
|
|||||||
this.page = page;
|
this.page = page;
|
||||||
this.name = page.getByLabel('block-item-CollectionField-workflows-Name').getByRole('textbox');
|
this.name = page.getByLabel('block-item-CollectionField-workflows-Name').getByRole('textbox');
|
||||||
this.triggerType = page.getByTestId('select-single');
|
this.triggerType = page.getByTestId('select-single');
|
||||||
|
this.synchronouslyRadio = page.getByLabel('Synchronously', { exact: true });
|
||||||
|
this.asynchronouslyRadio = page.getByLabel('Asynchronously', { exact: true });
|
||||||
this.description = page.getByTestId('description-item').getByRole('textbox');
|
this.description = page.getByTestId('description-item').getByRole('textbox');
|
||||||
this.autoDeleteHistory = page.getByTestId('select-multiple');
|
this.autoDeleteHistory = page.getByTestId('select-multiple');
|
||||||
this.submitButton = page.getByLabel('action-Action-Submit-workflows');
|
this.submitButton = page.getByLabel('action-Action-Submit-workflows');
|
||||||
@ -118,7 +122,9 @@ export class ApprovalTriggerNode {
|
|||||||
this.addBlockButton = page.getByLabel(`schema-initializer-Grid-ApprovalApplyAddBlockButton-${collectionName}`);
|
this.addBlockButton = page.getByLabel(`schema-initializer-Grid-ApprovalApplyAddBlockButton-${collectionName}`);
|
||||||
this.addApplyFormMenu = page.getByRole('menuitem', { name: 'Apply form' });
|
this.addApplyFormMenu = page.getByRole('menuitem', { name: 'Apply form' });
|
||||||
this.configureFieldsButton = page.getByLabel(`schema-initializer-Grid-form:configureFields-${collectionName}`);
|
this.configureFieldsButton = page.getByLabel(`schema-initializer-Grid-form:configureFields-${collectionName}`);
|
||||||
this.configureActionsButton = page.getByLabel(`schema-initializer-ActionBar-ApprovalApplyAddActionButton-${collectionName}`);
|
this.configureActionsButton = page.getByLabel(
|
||||||
|
`schema-initializer-ActionBar-ApprovalApplyAddActionButton-${collectionName}`,
|
||||||
|
);
|
||||||
this.saveDraftSwitch = page.getByRole('menuitem', { name: 'Save draft' }).getByRole('switch');
|
this.saveDraftSwitch = page.getByRole('menuitem', { name: 'Save draft' }).getByRole('switch');
|
||||||
this.preloadAssociationsDropDown = page.getByTestId('select-field-Preload associations');
|
this.preloadAssociationsDropDown = page.getByTestId('select-field-Preload associations');
|
||||||
this.submitButton = page.getByLabel('action-Action-Submit-workflows');
|
this.submitButton = page.getByLabel('action-Action-Submit-workflows');
|
||||||
@ -170,13 +176,17 @@ export class ApprovalPassthroughModeNode {
|
|||||||
this.OrRadio = page.getByLabel('Or', { exact: true });
|
this.OrRadio = page.getByLabel('Or', { exact: true });
|
||||||
this.AndRadio = page.getByLabel('And', { exact: true });
|
this.AndRadio = page.getByLabel('And', { exact: true });
|
||||||
this.votingRadio = page.getByLabel('Voting', { exact: true });
|
this.votingRadio = page.getByLabel('Voting', { exact: true });
|
||||||
this.votingThresholdEditBox = page.getByLabel('block-item-NegotiationConfig-workflows-Negotiation mode').getByRole('spinbutton');
|
this.votingThresholdEditBox = page
|
||||||
|
.getByLabel('block-item-NegotiationConfig-workflows-Negotiation mode')
|
||||||
|
.getByRole('spinbutton');
|
||||||
this.parallellyRadio = page.getByLabel('Parallelly', { exact: true });
|
this.parallellyRadio = page.getByLabel('Parallelly', { exact: true });
|
||||||
this.sequentiallyRadio = page.getByLabel('Sequentially', { exact: true });
|
this.sequentiallyRadio = page.getByLabel('Sequentially', { exact: true });
|
||||||
this.goToconfigureButton = page.getByRole('button', { name: 'Go to configure' });
|
this.goToconfigureButton = page.getByRole('button', { name: 'Go to configure' });
|
||||||
this.addBlockButton = page.getByLabel('schema-initializer-Grid-ApprovalProcessAddBlockButton-workflows');
|
this.addBlockButton = page.getByLabel('schema-initializer-Grid-ApprovalProcessAddBlockButton-workflows');
|
||||||
this.addDetailsMenu = page.getByRole('menuitem', { name: 'Details' });
|
this.addDetailsMenu = page.getByRole('menuitem', { name: 'Details' });
|
||||||
this.detailsConfigureFieldsButton = page.getByLabel(`schema-initializer-Grid-details:configureFields-${collectionName}`);
|
this.detailsConfigureFieldsButton = page.getByLabel(
|
||||||
|
`schema-initializer-Grid-details:configureFields-${collectionName}`,
|
||||||
|
);
|
||||||
this.addActionsMenu = page.getByRole('menuitem', { name: 'Actions' }).getByRole('switch');
|
this.addActionsMenu = page.getByRole('menuitem', { name: 'Actions' }).getByRole('switch');
|
||||||
this.actionsConfigureFieldsButton = page.getByLabel('schema-initializer-Grid-FormItemInitializers-approvalRecords');
|
this.actionsConfigureFieldsButton = page.getByLabel('schema-initializer-Grid-FormItemInitializers-approvalRecords');
|
||||||
this.actionsConfigureActionsButton = page.getByLabel(
|
this.actionsConfigureActionsButton = page.getByLabel(
|
||||||
@ -239,13 +249,17 @@ export class ApprovalBranchModeNode {
|
|||||||
this.OrRadio = page.getByLabel('Or', { exact: true });
|
this.OrRadio = page.getByLabel('Or', { exact: true });
|
||||||
this.AndRadio = page.getByLabel('And', { exact: true });
|
this.AndRadio = page.getByLabel('And', { exact: true });
|
||||||
this.votingRadio = page.getByLabel('Voting', { exact: true });
|
this.votingRadio = page.getByLabel('Voting', { exact: true });
|
||||||
this.votingThresholdEditBox = page.getByLabel('block-item-NegotiationConfig-workflows-Negotiation mode').getByRole('spinbutton');
|
this.votingThresholdEditBox = page
|
||||||
|
.getByLabel('block-item-NegotiationConfig-workflows-Negotiation mode')
|
||||||
|
.getByRole('spinbutton');
|
||||||
this.parallellyRadio = page.getByLabel('Parallelly', { exact: true });
|
this.parallellyRadio = page.getByLabel('Parallelly', { exact: true });
|
||||||
this.sequentiallyRadio = page.getByLabel('Sequentially', { exact: true });
|
this.sequentiallyRadio = page.getByLabel('Sequentially', { exact: true });
|
||||||
this.goToconfigureButton = page.getByRole('button', { name: 'Go to configure' });
|
this.goToconfigureButton = page.getByRole('button', { name: 'Go to configure' });
|
||||||
this.addBlockButton = page.getByLabel('schema-initializer-Grid-ApprovalProcessAddBlockButton-workflows');
|
this.addBlockButton = page.getByLabel('schema-initializer-Grid-ApprovalProcessAddBlockButton-workflows');
|
||||||
this.addDetailsMenu = page.getByRole('menuitem', { name: 'Details' });
|
this.addDetailsMenu = page.getByRole('menuitem', { name: 'Details' });
|
||||||
this.detailsConfigureFieldsButton = page.getByLabel(`schema-initializer-Grid-details:configureFields-${collectionName}`);
|
this.detailsConfigureFieldsButton = page.getByLabel(
|
||||||
|
`schema-initializer-Grid-details:configureFields-${collectionName}`,
|
||||||
|
);
|
||||||
this.addActionsMenu = page.getByRole('menuitem', { name: 'Actions' }).getByRole('switch');
|
this.addActionsMenu = page.getByRole('menuitem', { name: 'Actions' }).getByRole('switch');
|
||||||
this.actionsConfigureFieldsButton = page.getByLabel('schema-initializer-Grid-FormItemInitializers-approvalRecords');
|
this.actionsConfigureFieldsButton = page.getByLabel('schema-initializer-Grid-FormItemInitializers-approvalRecords');
|
||||||
this.actionsConfigureActionsButton = page.getByLabel(
|
this.actionsConfigureActionsButton = page.getByLabel(
|
||||||
@ -353,6 +367,30 @@ export class FormEventTriggerNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class CustomActionEventTriggerNode {
|
||||||
|
readonly page: Page;
|
||||||
|
node: Locator;
|
||||||
|
nodeTitle: Locator;
|
||||||
|
nodeConfigure: Locator;
|
||||||
|
collectionDropDown: Locator;
|
||||||
|
relationalDataDropdown: Locator;
|
||||||
|
submitButton: Locator;
|
||||||
|
cancelButton: Locator;
|
||||||
|
addNodeButton: Locator;
|
||||||
|
constructor(page: Page, triggerName: string, collectionName: string) {
|
||||||
|
this.page = page;
|
||||||
|
this.node = page.getByLabel(`Trigger-${triggerName}`);
|
||||||
|
this.nodeTitle = page.getByLabel(`Trigger-${triggerName}`).getByRole('textbox');
|
||||||
|
this.nodeConfigure = page.getByLabel(`Trigger-${triggerName}`).getByRole('button', { name: 'Configure' });
|
||||||
|
this.collectionDropDown = page
|
||||||
|
.getByLabel('block-item-DataSourceCollectionCascader-workflows-Collection')
|
||||||
|
.locator('.ant-select-selection-search-input');
|
||||||
|
this.relationalDataDropdown = page.getByTestId('select-field-Preload associations');
|
||||||
|
this.submitButton = page.getByLabel('action-Action-Submit-workflows');
|
||||||
|
this.cancelButton = page.getByLabel('action-Action-Cancel-workflows');
|
||||||
|
this.addNodeButton = page.getByLabel('add-button', { exact: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
export class CalculationNode {
|
export class CalculationNode {
|
||||||
readonly page: Page;
|
readonly page: Page;
|
||||||
node: Locator;
|
node: Locator;
|
||||||
@ -733,5 +771,6 @@ export default module.exports = {
|
|||||||
ConditionBranchNode,
|
ConditionBranchNode,
|
||||||
SQLNode,
|
SQLNode,
|
||||||
ParallelBranchNode,
|
ParallelBranchNode,
|
||||||
ApprovalBranchModeNode
|
ApprovalBranchModeNode,
|
||||||
|
CustomActionEventTriggerNode,
|
||||||
};
|
};
|
||||||
|
@ -808,6 +808,57 @@ export const apiCreateRecordTriggerActionEvent = async (
|
|||||||
return (await result.json()).data;
|
return (await result.json()).data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 添加业务表单条数据触发工作流表单事件,triggerWorkflows=key1!field,key2,key3!field.subfield
|
||||||
|
export const apiTriggerCustomActionEvent = async (collectionName: string, triggerWorkflows: string, data: any) => {
|
||||||
|
const api = await request.newContext({
|
||||||
|
storageState: process.env.PLAYWRIGHT_AUTH_FILE,
|
||||||
|
});
|
||||||
|
const state = await api.storageState();
|
||||||
|
const headers = getHeaders(state);
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"title": "a11",
|
||||||
|
"enabled": true,
|
||||||
|
"description": null
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
const result = await api.post(`/api/${collectionName}:trigger?triggerWorkflows=${triggerWorkflows}`, {
|
||||||
|
headers,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!result.ok()) {
|
||||||
|
throw new Error(await result.text());
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"id": 1,
|
||||||
|
"createdAt": "2023-12-12T02:43:53.793Z",
|
||||||
|
"updatedAt": "2023-12-12T05:41:33.300Z",
|
||||||
|
"key": "fzk3j2oj4el",
|
||||||
|
"title": "a11",
|
||||||
|
"enabled": true,
|
||||||
|
"description": null
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"allowedActions": {
|
||||||
|
"view": [
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"update": [
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"destroy": [
|
||||||
|
1
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return (await result.json()).data;
|
||||||
|
};
|
||||||
|
|
||||||
// 审批中心发起审批
|
// 审批中心发起审批
|
||||||
export const apiApplyApprovalEvent = async (data: any) => {
|
export const apiApplyApprovalEvent = async (data: any) => {
|
||||||
const api = await request.newContext({
|
const api = await request.newContext({
|
||||||
@ -1020,5 +1071,6 @@ export default module.exports = {
|
|||||||
apiCreateRecordTriggerActionEvent,
|
apiCreateRecordTriggerActionEvent,
|
||||||
apiApplyApprovalEvent,
|
apiApplyApprovalEvent,
|
||||||
userLogin,
|
userLogin,
|
||||||
apiCreateField
|
apiCreateField,
|
||||||
|
apiTriggerCustomActionEvent,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user