test: 确认e2e测试用例可行性
This commit is contained in:
parent
3793bb6cb7
commit
ef1b07e6a3
@ -0,0 +1,43 @@
|
|||||||
|
import { expect, test } from '@nocobase/test/client';
|
||||||
|
import { CreateLocalStorage } from './pageobject/localStorage';
|
||||||
|
import { dayjs } from '@nocobase/utils';
|
||||||
|
|
||||||
|
test.describe('file manager', () => {
|
||||||
|
test('add new local storage', async ({ page }) => {
|
||||||
|
//用例编号
|
||||||
|
const caseNum = 'FM01AA';
|
||||||
|
//用例标题
|
||||||
|
const caseTitle = 'add new local storage';
|
||||||
|
|
||||||
|
// 1、前置条件:已登录
|
||||||
|
|
||||||
|
// 2、测试步骤:进入“文件管理器”-“新建”按钮,填写表单,点击“确定”按钮
|
||||||
|
await page.goto('/admin/settings/file-manager/storages');
|
||||||
|
await page.waitForLoadState('networkidle');
|
||||||
|
await page.getByTestId('create-action').click();
|
||||||
|
const createLocalStorage = new CreateLocalStorage(page);
|
||||||
|
await createLocalStorage.title.fill(caseTitle);
|
||||||
|
const storageName = caseNum + dayjs().format('YYYYMMDDHHmmss.SSS').toString();
|
||||||
|
await createLocalStorage.storageName.fill(storageName);
|
||||||
|
await createLocalStorage.storagebaseURL.fill('/storage/uploadsFM01AA');
|
||||||
|
await createLocalStorage.storageType.click();
|
||||||
|
await page.getByText('Local storage').click();
|
||||||
|
await createLocalStorage.destination.fill('storage/uploadsFM01AA');
|
||||||
|
// await createLocalStorage.path.fill('');
|
||||||
|
// await createLocalStorage.defaultStorage.check();
|
||||||
|
// await createLocalStorage.deleteRecordRetentionFile.check();
|
||||||
|
await page.getByTestId('submit-action').click();
|
||||||
|
|
||||||
|
// 3、预期结果:新建成功,列表中出现新建的文件管理器
|
||||||
|
await expect(page.getByText(storageName)).toBeAttached();
|
||||||
|
// await page.waitForTimeout(5000);
|
||||||
|
|
||||||
|
// 4、后置处理:删除新建的文件管理器
|
||||||
|
await page
|
||||||
|
.getByRole('row', { name: '2 ' + caseTitle + ' ' + storageName + ' Edit Delete' })
|
||||||
|
.getByTestId('delete-action')
|
||||||
|
.click();
|
||||||
|
await page.getByRole('button', { name: 'OK' }).click();
|
||||||
|
await expect(page.getByText(storageName)).toBeHidden();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,57 @@
|
|||||||
|
import { expect, test } from '@nocobase/test/client';
|
||||||
|
import { CreateLocalStorage, EditLocalStorage } from './pageobject/localStorage';
|
||||||
|
import { dayjs } from '@nocobase/utils';
|
||||||
|
|
||||||
|
test.describe('File manager', () => {
|
||||||
|
test('edit local storage title', async ({ page }) => {
|
||||||
|
//用例编号
|
||||||
|
const caseNum = 'FM02AA';
|
||||||
|
//用例标题
|
||||||
|
let caseTitle = 'edit local storage title';
|
||||||
|
|
||||||
|
// 1、前置条件:1.1已登录;1.2存在一个文件管理器
|
||||||
|
await page.goto('/admin/settings/file-manager/storages');
|
||||||
|
await page.waitForLoadState('networkidle');
|
||||||
|
await page.getByTestId('create-action').click();
|
||||||
|
|
||||||
|
const createLocalStorage = new CreateLocalStorage(page);
|
||||||
|
await createLocalStorage.title.fill(caseTitle);
|
||||||
|
const storageName = caseNum + dayjs().format('YYYYMMDDHHmmss.SSS').toString();
|
||||||
|
await createLocalStorage.storageName.fill(storageName);
|
||||||
|
await createLocalStorage.storagebaseURL.fill('/storage/uploadsFM02AA');
|
||||||
|
await createLocalStorage.storageType.click();
|
||||||
|
await page.getByText('Local storage').click();
|
||||||
|
await createLocalStorage.destination.fill('storage/uploadsFM02AA');
|
||||||
|
// await createLocalStorage.path.fill('');
|
||||||
|
// await createLocalStorage.defaultStorage.check();
|
||||||
|
// await createLocalStorage.deleteRecordRetentionFile.check();
|
||||||
|
await page.getByTestId('submit-action').click();
|
||||||
|
await expect(page.getByText(storageName)).toBeAttached();
|
||||||
|
await page.waitForTimeout(5000);
|
||||||
|
|
||||||
|
// 2、测试步骤:点击“文件管理器”-“编辑”按钮,编辑标题,点击“确定”按钮
|
||||||
|
await page
|
||||||
|
.getByRole('row', { name: '2 ' + caseTitle + ' ' + storageName + ' Edit Delete' })
|
||||||
|
.getByTestId('update-action')
|
||||||
|
.click();
|
||||||
|
const editLocalStorage = new EditLocalStorage(page);
|
||||||
|
caseTitle = caseTitle + dayjs().format('YYYYMMDDHHmmss.SSS').toString();
|
||||||
|
await editLocalStorage.title.fill(caseTitle);
|
||||||
|
// await editLocalStorage.path.fill('');
|
||||||
|
// await editLocalStorage.defaultStorage.check();
|
||||||
|
// await editLocalStorage.deleteRecordRetentionFile.check();
|
||||||
|
await page.getByTestId('submit-action').click();
|
||||||
|
// await page.waitForTimeout(5000);
|
||||||
|
|
||||||
|
// 3、预期结果:编辑成功,列表中出现编辑后的文件管理器
|
||||||
|
await expect(page.getByText(caseTitle)).toBeAttached();
|
||||||
|
|
||||||
|
// 4、后置处理:删除文件管理器
|
||||||
|
await page
|
||||||
|
.getByRole('row', { name: '2 ' + caseTitle + ' ' + storageName + ' Edit Delete' })
|
||||||
|
.getByTestId('delete-action')
|
||||||
|
.click();
|
||||||
|
await page.getByRole('button', { name: 'OK' }).click();
|
||||||
|
await expect(page.getByText(storageName)).toBeHidden();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,49 @@
|
|||||||
|
import type { Page, Locator } from '@nocobase/test/client';
|
||||||
|
|
||||||
|
export class CreateLocalStorage {
|
||||||
|
readonly page: Page;
|
||||||
|
title: Locator;
|
||||||
|
storageName: Locator;
|
||||||
|
storagebaseURL: Locator;
|
||||||
|
storageType: Locator;
|
||||||
|
destination: Locator;
|
||||||
|
path: Locator;
|
||||||
|
defaultStorage: Locator;
|
||||||
|
deleteRecordRetentionFile: Locator;
|
||||||
|
|
||||||
|
constructor(page: Page) {
|
||||||
|
this.page = page;
|
||||||
|
this.title = page.getByTestId('title-item').getByRole('textbox');
|
||||||
|
this.storageName = page.getByTestId('name-item').getByRole('textbox');
|
||||||
|
this.storagebaseURL = page.getByTestId('baseUrl-item').getByRole('textbox');
|
||||||
|
this.storageType = page.getByTestId('type-item').getByLabel('Search');
|
||||||
|
this.destination = page.getByTestId('documentRoot-item').getByRole('textbox');
|
||||||
|
this.path = page.getByTestId('path-item').getByRole('textbox');
|
||||||
|
this.defaultStorage = page.getByLabel('Default storage');
|
||||||
|
this.deleteRecordRetentionFile = page.getByLabel('Keep file in storage when destroy record');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class EditLocalStorage {
|
||||||
|
readonly page: Page;
|
||||||
|
title: Locator;
|
||||||
|
storageName: Locator;
|
||||||
|
storagebaseURL: Locator;
|
||||||
|
storageType: Locator;
|
||||||
|
destination: Locator;
|
||||||
|
path: Locator;
|
||||||
|
defaultStorage: Locator;
|
||||||
|
deleteRecordRetentionFile: Locator;
|
||||||
|
|
||||||
|
constructor(page: Page) {
|
||||||
|
this.page = page;
|
||||||
|
this.title = page.getByTestId('title-item').getByRole('textbox');
|
||||||
|
this.storageName = page.getByTestId('name-item').getByRole('textbox');
|
||||||
|
this.storagebaseURL = page.getByTestId('baseUrl-item').getByRole('textbox');
|
||||||
|
this.storageType = page.getByTestId('type-item').getByLabel('Search');
|
||||||
|
this.destination = page.getByTestId('documentRoot-item').getByRole('textbox');
|
||||||
|
this.path = page.getByTestId('path-item').getByRole('textbox');
|
||||||
|
this.defaultStorage = page.getByLabel('Default storage');
|
||||||
|
this.deleteRecordRetentionFile = page.getByLabel('Keep file in storage when destroy record');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
import { expect, test } from '@nocobase/test/client';
|
||||||
|
import { dayjs } from '@nocobase/utils';
|
||||||
|
import { CreateWorkFlow } from './pageobject/workFlow';
|
||||||
|
|
||||||
|
test.describe('workflow manage', () => {
|
||||||
|
test('add new from event', async ({ page }) => {
|
||||||
|
//用例编号
|
||||||
|
const caseNum = 'WF02AA';
|
||||||
|
//用例标题
|
||||||
|
const caseTitle = 'add new from event';
|
||||||
|
|
||||||
|
// 1、前置条件:已登录
|
||||||
|
|
||||||
|
// 2、测试步骤:进入“工作流管理”-“新建”按钮,填写表单,点击“确定”按钮
|
||||||
|
await page.goto('/admin/settings/workflow/workflows');
|
||||||
|
await page.waitForLoadState('networkidle');
|
||||||
|
await page.getByTestId('create-action').click();
|
||||||
|
const createWorkFlow = new CreateWorkFlow(page);
|
||||||
|
const workFlowName = caseTitle + dayjs().format('YYYYMMDDHHmmss.SSS').toString();
|
||||||
|
await createWorkFlow.name.fill(workFlowName);
|
||||||
|
await createWorkFlow.triggerType.click();
|
||||||
|
await page.getByText('Form event').click();
|
||||||
|
await page.getByTestId('submit-action').click();
|
||||||
|
|
||||||
|
// 3、预期结果:新建成功,列表中出现新建的工作流
|
||||||
|
await expect(page.getByText(workFlowName)).toBeAttached();
|
||||||
|
|
||||||
|
// 4、后置处理:删除新建的工作流
|
||||||
|
await page.getByTestId('filter-action').click();
|
||||||
|
await page.getByRole('textbox').fill(workFlowName);
|
||||||
|
await page.getByRole('button', { name: 'Submit' }).click();
|
||||||
|
await page.getByRole('cell', { name: 'View Edit Duplicate Delete' }).getByTestId('delete-action').click();
|
||||||
|
await page.getByRole('button', { name: 'OK' }).click();
|
||||||
|
await expect(page.getByText(workFlowName)).toBeHidden();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,43 @@
|
|||||||
|
import { expect, test } from '@nocobase/test/client';
|
||||||
|
import { CreateWorkFlow, EditWorkFlow } from './pageobject/workFlow';
|
||||||
|
import { dayjs } from '@nocobase/utils';
|
||||||
|
|
||||||
|
test.describe('workflow manage', () => {
|
||||||
|
test('edit from event name', async ({ page }) => {
|
||||||
|
//用例编号
|
||||||
|
const caseNum = 'WF05AA';
|
||||||
|
//用例标题
|
||||||
|
const caseTitle = 'edit from event name';
|
||||||
|
|
||||||
|
// 1、前置条件:1.1、已登录,1.2、存在一个工作流
|
||||||
|
await page.goto('/admin/settings/workflow/workflows');
|
||||||
|
await page.waitForLoadState('networkidle');
|
||||||
|
await page.getByTestId('create-action').click();
|
||||||
|
const createWorkFlow = new CreateWorkFlow(page);
|
||||||
|
let workFlowName = caseTitle + dayjs().format('YYYYMMDDHHmmss.SSS').toString();
|
||||||
|
await createWorkFlow.name.fill(workFlowName);
|
||||||
|
await createWorkFlow.triggerType.click();
|
||||||
|
await page.getByText('Form event').click();
|
||||||
|
await page.getByTestId('submit-action').click();
|
||||||
|
|
||||||
|
await expect(page.getByText(workFlowName)).toBeAttached();
|
||||||
|
|
||||||
|
// 2、测试步骤:进入“工作流管理”-“编辑”按钮,编辑名称,点击“确定”按钮
|
||||||
|
await page.getByTestId('update-action').click();
|
||||||
|
const editWorkFlow = new EditWorkFlow(page);
|
||||||
|
workFlowName = caseTitle + dayjs().format('YYYYMMDDHHmmss.SSS').toString();
|
||||||
|
await createWorkFlow.name.fill(workFlowName);
|
||||||
|
await page.getByTestId('submit-action').click();
|
||||||
|
|
||||||
|
// 3、预期结果:编辑成功,列表中出现编辑后的工作流
|
||||||
|
await expect(page.getByText(workFlowName)).toBeAttached();
|
||||||
|
|
||||||
|
// 4、后置处理:删除工作流
|
||||||
|
await page.getByTestId('filter-action').click();
|
||||||
|
await page.getByRole('textbox').fill(workFlowName);
|
||||||
|
await page.getByRole('button', { name: 'Submit' }).click();
|
||||||
|
await page.getByRole('cell', { name: 'View Edit Duplicate Delete' }).getByTestId('delete-action').click();
|
||||||
|
await page.getByRole('button', { name: 'OK' }).click();
|
||||||
|
await expect(page.getByText(workFlowName)).toBeHidden();
|
||||||
|
});
|
||||||
|
});
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,43 @@
|
|||||||
|
import type { Page, Locator } from '@nocobase/test/client';
|
||||||
|
|
||||||
|
export class CreateWorkFlow {
|
||||||
|
readonly page: Page;
|
||||||
|
name: Locator;
|
||||||
|
triggerType: Locator;
|
||||||
|
description: Locator;
|
||||||
|
autoDeleteHistory: Locator;
|
||||||
|
|
||||||
|
constructor(page: Page) {
|
||||||
|
this.page = page;
|
||||||
|
this.name = page.getByTestId('title-item').getByRole('textbox');
|
||||||
|
this.triggerType = page.getByTestId('type-item').getByLabel('Search');
|
||||||
|
this.description = page.getByTestId('description-item').getByRole('textbox');
|
||||||
|
this.autoDeleteHistory = page
|
||||||
|
.getByTestId('deleteExecutionOnStatus-item')
|
||||||
|
.getByTestId('antd-select')
|
||||||
|
.locator('div')
|
||||||
|
.nth(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class EditWorkFlow {
|
||||||
|
readonly page: Page;
|
||||||
|
name: Locator;
|
||||||
|
statusIsOn: Locator;
|
||||||
|
statusIisOff: Locator;
|
||||||
|
description: Locator;
|
||||||
|
autoDeleteHistory: Locator;
|
||||||
|
|
||||||
|
constructor(page: Page) {
|
||||||
|
this.page = page;
|
||||||
|
this.name = page.getByTestId('title-item').getByRole('textbox');
|
||||||
|
this.statusIsOn = page.getByTestId('enabled-item').getByLabel('On');
|
||||||
|
this.statusIisOff = page.getByLabel('Off');
|
||||||
|
this.description = page.getByTestId('description-item').getByRole('textbox');
|
||||||
|
this.autoDeleteHistory = page
|
||||||
|
.getByTestId('deleteExecutionOnStatus-item')
|
||||||
|
.getByTestId('antd-select')
|
||||||
|
.locator('div')
|
||||||
|
.nth(1);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,106 @@
|
|||||||
|
import { expect, test } from '@nocobase/test/client';
|
||||||
|
import { CreateWorkFlow, EditWorkFlow } from './pageobject/workFlow';
|
||||||
|
import { dayjs } from '@nocobase/utils';
|
||||||
|
import { e2e_GeneralFormsTable, appendJsonCollectionName, generateRandomLetters } from './pageobject/e2eTemplateJson';
|
||||||
|
|
||||||
|
test.describe('trigger collection events', () => {
|
||||||
|
test('add data to trigger collection events', async ({ page, mockPage }) => {
|
||||||
|
//用例编号
|
||||||
|
const caseNum = 'WF20AA';
|
||||||
|
//后缀标识,用于不同用例调用e2eTemplateJson.ts中相同模板JSON生成不同的数据表标识、名称
|
||||||
|
const appendText = caseNum.toLowerCase() + generateRandomLetters().toString();
|
||||||
|
//用例标题
|
||||||
|
const caseTitle = 'add data to trigger collection events';
|
||||||
|
|
||||||
|
// 1、前置条件:1.1、已登录;1.2、存在一个配置好数据表的表单事件工作流;1.3、存在一个添加数据的区块
|
||||||
|
//创建数据表
|
||||||
|
const e2eJsonCollectionDisplayName = '自动>组织[普通表]';
|
||||||
|
const e2eJsonCollectionName = 'tt_amt_org';
|
||||||
|
|
||||||
|
const collectionDisplayName = e2eJsonCollectionDisplayName + appendText;
|
||||||
|
const collectionName = e2eJsonCollectionName + appendText;
|
||||||
|
const fieldName = 'orgname';
|
||||||
|
const fieldDisplayName = '公司名称(单行文本)';
|
||||||
|
|
||||||
|
const newPage = mockPage(appendJsonCollectionName(e2e_GeneralFormsTable, appendText));
|
||||||
|
//配置工作流
|
||||||
|
await page.goto('/admin/settings/workflow/workflows');
|
||||||
|
await page.waitForLoadState('networkidle');
|
||||||
|
await page.getByTestId('create-action').click();
|
||||||
|
const createWorkFlow = new CreateWorkFlow(page);
|
||||||
|
const workFlowName = caseTitle + dayjs().format('YYYYMMDDHHmmss.SSS').toString();
|
||||||
|
await createWorkFlow.name.fill(workFlowName);
|
||||||
|
await createWorkFlow.triggerType.click();
|
||||||
|
await page.getByTitle('Collection event').getByText('Collection event').click();
|
||||||
|
await page.getByTestId('submit-action').click();
|
||||||
|
await expect(page.getByText(workFlowName)).toBeAttached();
|
||||||
|
|
||||||
|
//配置工作流触发器
|
||||||
|
await page
|
||||||
|
.getByRole('row', { name: '1 ' + workFlowName + ' Collection event Off 0 View Edit Duplicate Delete' })
|
||||||
|
.getByRole('link')
|
||||||
|
.click();
|
||||||
|
await page.getByRole('button', { name: 'Configure' }).click();
|
||||||
|
await page.getByTestId('antd-select').getByLabel('Search').click();
|
||||||
|
await page.getByText('自动>组织[普通表]').click();
|
||||||
|
await page.getByTestId('mode-item').getByLabel('Search').click();
|
||||||
|
await page.getByText('After record added', { exact: true }).click();
|
||||||
|
await page.getByTestId('submit-action').click();
|
||||||
|
await page.getByRole('link', { name: 'Workflow' }).click();
|
||||||
|
await page
|
||||||
|
.getByRole('row', { name: '1 ' + workFlowName + ' Collection event Off 0 View Edit Duplicate Delete' })
|
||||||
|
.getByTestId('update-action')
|
||||||
|
.click();
|
||||||
|
await page.getByTestId('enabled-item').getByLabel('On').check();
|
||||||
|
await page.getByTestId('submit-action').click();
|
||||||
|
|
||||||
|
//配置录入数据区块
|
||||||
|
await newPage.goto();
|
||||||
|
await page.getByRole('button', { name: 'plus Add block' }).hover();
|
||||||
|
await page.getByRole('menuitem', { name: 'table Table right' }).hover();
|
||||||
|
await page.getByRole('menuitem', { name: collectionDisplayName }).click();
|
||||||
|
await page.getByRole('button', { name: 'setting Configure columns' }).click();
|
||||||
|
await page.getByRole('menuitem', { name: fieldDisplayName }).getByRole('switch').click();
|
||||||
|
await page.getByRole('button', { name: 'setting Configure actions' }).hover();
|
||||||
|
await page.getByRole('menuitem', { name: 'Add new' }).getByRole('switch').click();
|
||||||
|
await expect(page.getByRole('menuitem', { name: 'Add new' }).getByRole('switch')).toBeEnabled();
|
||||||
|
await page.getByRole('button', { name: 'setting Configure columns' }).hover();
|
||||||
|
await page.getByRole('button', { name: 'Add new' }).click();
|
||||||
|
await page.getByLabel('Add new').getByRole('button', { name: 'plus Add block' }).hover();
|
||||||
|
await page.getByRole('menuitem', { name: 'form Form' }).click();
|
||||||
|
await page.getByRole('button', { name: 'plus Add tab' }).click();
|
||||||
|
await page.getByRole('button', { name: 'Cancel' }).click();
|
||||||
|
await page.getByLabel('Add new').getByRole('button', { name: 'setting Configure actions' }).click();
|
||||||
|
await page.getByRole('group').getByText('Submit').click();
|
||||||
|
await page.getByRole('button', { name: 'setting Configure fields' }).click();
|
||||||
|
await page.getByRole('menuitem', { name: fieldDisplayName }).getByRole('switch').click();
|
||||||
|
await page.getByRole('button', { name: 'plus Add tab' }).click();
|
||||||
|
await page.getByRole('button', { name: 'Cancel' }).click();
|
||||||
|
|
||||||
|
// 2、测试步骤:进入“数据区块”-“添加”按钮,填写表单,点击“确定”按钮
|
||||||
|
await page
|
||||||
|
.getByTestId(collectionName + '.' + fieldName + '-field')
|
||||||
|
.getByRole('textbox')
|
||||||
|
.click();
|
||||||
|
const fieldData = fieldDisplayName + dayjs().format('YYYYMMDDHHmmss.SSS').toString();
|
||||||
|
await page
|
||||||
|
.getByTestId(collectionName + '.' + fieldName + '-field')
|
||||||
|
.getByRole('textbox')
|
||||||
|
.fill(fieldData);
|
||||||
|
await page.getByRole('button', { name: 'Submit' }).click();
|
||||||
|
await expect(page.getByText(fieldData)).toBeAttached();
|
||||||
|
|
||||||
|
// 3、预期结果:数据添加成功,工作流成功触发
|
||||||
|
await expect(page.getByText(fieldData)).toBeAttached();
|
||||||
|
await page.goto('/admin/settings/workflow/workflows');
|
||||||
|
await expect(page.getByRole('table').locator('a').filter({ hasText: '1' })).toBeAttached();
|
||||||
|
|
||||||
|
// 4、后置处理:删除工作流
|
||||||
|
await page.getByTestId('filter-action').click();
|
||||||
|
await page.getByRole('textbox').fill(workFlowName);
|
||||||
|
await page.getByRole('button', { name: 'Submit' }).click();
|
||||||
|
await page.getByRole('cell', { name: 'View Edit Duplicate Delete' }).getByTestId('delete-action').click();
|
||||||
|
await page.getByRole('button', { name: 'OK' }).click();
|
||||||
|
await expect(page.getByText(workFlowName)).toBeHidden();
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user