From 6fc644d50697f9ddc7e46b54d1fbb21c8dc8d79e Mon Sep 17 00:00:00 2001 From: Zeke Zhang <958414905@qq.com> Date: Fri, 1 Dec 2023 14:58:45 +0800 Subject: [PATCH] feat(e2e): support for custom data when using mockRecords --- packages/core/test/src/client/e2eUtils.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/core/test/src/client/e2eUtils.ts b/packages/core/test/src/client/e2eUtils.ts index 33b3bf798..54f7e8df8 100644 --- a/packages/core/test/src/client/e2eUtils.ts +++ b/packages/core/test/src/client/e2eUtils.ts @@ -173,7 +173,18 @@ const _test = base.extend<{ mockCollections: (collectionSettings: CollectionSetting[]) => Promise; mockCollection: (collectionSetting: CollectionSetting) => Promise; mockRecord: (collectionName: string, data?: any) => Promise; - mockRecords: (collectionName: string, count?: number, data?: any) => Promise; + mockRecords: { + /** + * @param collectionName - 数据表名称 + * @param count - 生成的数据条数 + */ + (collectionName: string, count?: number): Promise; + /** + * @param collectionName - 数据表名称 + * @param data - 指定生成的数据 + */ + (collectionName: string, data?: any[]): Promise; + }; createCollections: (collectionSettings: CollectionSetting | CollectionSetting[]) => Promise; }>({ mockPage: async ({ page }, use) => { @@ -242,7 +253,11 @@ const _test = base.extend<{ } }, mockRecords: async ({ page }, use) => { - const mockRecords = async (collectionName: string, count = 3, data?: any) => { + const mockRecords = async (collectionName: string, count: any = 3, data?: any) => { + if (_.isArray(count)) { + data = count; + count = data.length; + } return createRandomData(collectionName, count, data); };