From 46f19c86b5c8b8a3a9478a0661f0f9056544dad0 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Wed, 18 Jan 2023 19:52:25 +0530 Subject: [PATCH] test: support attach multiple files in one go Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- tests/playwright/pages/Base.ts | 2 +- .../pages/Dashboard/common/Cell/AttachmentCell.ts | 5 ++++- tests/playwright/tests/columnAttachments.spec.ts | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/playwright/pages/Base.ts b/tests/playwright/pages/Base.ts index 4aeed1e144..783f6c51ca 100644 --- a/tests/playwright/pages/Base.ts +++ b/tests/playwright/pages/Base.ts @@ -49,7 +49,7 @@ export default abstract class BasePage { ]); } - async attachFile({ filePickUIAction, filePath }: { filePickUIAction: Promise; filePath: string }) { + async attachFile({ filePickUIAction, filePath }: { filePickUIAction: Promise; filePath: string[] }) { const [fileChooser] = await Promise.all([ // It is important to call waitForEvent before click to set up waiting. this.rootPage.waitForEvent('filechooser'), diff --git a/tests/playwright/pages/Dashboard/common/Cell/AttachmentCell.ts b/tests/playwright/pages/Dashboard/common/Cell/AttachmentCell.ts index 9e186aa862..34ffc416be 100644 --- a/tests/playwright/pages/Dashboard/common/Cell/AttachmentCell.ts +++ b/tests/playwright/pages/Dashboard/common/Cell/AttachmentCell.ts @@ -18,7 +18,10 @@ export class AttachmentCellPageObject extends BasePage { return this.get({ index, columnHeader }).locator('[data-testid="attachment-cell-file-picker-button"]').click(); } - async addFile({ index, columnHeader, filePath }: { index?: number; columnHeader: string; filePath: string }) { + // filePath: to attach multiple files, pass an array of file paths + // e.g. ['path/to/file1', 'path/to/file2'] + // + async addFile({ index, columnHeader, filePath }: { index?: number; columnHeader: string; filePath: string[] }) { const attachFileAction = this.get({ index, columnHeader }) .locator('[data-testid="attachment-cell-file-picker-button"]') .click(); diff --git a/tests/playwright/tests/columnAttachments.spec.ts b/tests/playwright/tests/columnAttachments.spec.ts index f4ef56049e..3a378bd9e2 100644 --- a/tests/playwright/tests/columnAttachments.spec.ts +++ b/tests/playwright/tests/columnAttachments.spec.ts @@ -20,7 +20,7 @@ test.describe('Attachment column', () => { }); for (let i = 4; i <= 6; i++) { - const filepath = `${process.cwd()}/fixtures/sampleFiles/${i}.json`; + const filepath = [`${process.cwd()}/fixtures/sampleFiles/${i}.json`]; await dashboard.grid.cell.attachment.addFile({ index: i, columnHeader: 'testAttach', @@ -34,7 +34,7 @@ test.describe('Attachment column', () => { await dashboard.grid.cell.attachment.addFile({ index: 7, columnHeader: 'testAttach', - filePath: `${process.cwd()}/fixtures/sampleFiles/sampleImage.jpeg`, + filePath: [`${process.cwd()}/fixtures/sampleFiles/sampleImage.jpeg`], }); await dashboard.grid.cell.attachment.verifyFile({ index: 7, @@ -60,7 +60,7 @@ test.describe('Attachment column', () => { }); await sharedForm.cell.attachment.addFile({ columnHeader: 'testAttach', - filePath: `${process.cwd()}/fixtures/sampleFiles/1.json`, + filePath: [`${process.cwd()}/fixtures/sampleFiles/1.json`], }); await sharedForm.submit(); await sharedForm.verifySuccessMessage();