Browse Source

test: support attach multiple files in one go

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/4931/head
Raju Udava 2 years ago
parent
commit
46f19c86b5
  1. 2
      tests/playwright/pages/Base.ts
  2. 5
      tests/playwright/pages/Dashboard/common/Cell/AttachmentCell.ts
  3. 6
      tests/playwright/tests/columnAttachments.spec.ts

2
tests/playwright/pages/Base.ts

@ -49,7 +49,7 @@ export default abstract class BasePage {
]); ]);
} }
async attachFile({ filePickUIAction, filePath }: { filePickUIAction: Promise<any>; filePath: string }) { async attachFile({ filePickUIAction, filePath }: { filePickUIAction: Promise<any>; filePath: string[] }) {
const [fileChooser] = await Promise.all([ const [fileChooser] = await Promise.all([
// It is important to call waitForEvent before click to set up waiting. // It is important to call waitForEvent before click to set up waiting.
this.rootPage.waitForEvent('filechooser'), this.rootPage.waitForEvent('filechooser'),

5
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(); 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 }) const attachFileAction = this.get({ index, columnHeader })
.locator('[data-testid="attachment-cell-file-picker-button"]') .locator('[data-testid="attachment-cell-file-picker-button"]')
.click(); .click();

6
tests/playwright/tests/columnAttachments.spec.ts

@ -20,7 +20,7 @@ test.describe('Attachment column', () => {
}); });
for (let i = 4; i <= 6; i++) { 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({ await dashboard.grid.cell.attachment.addFile({
index: i, index: i,
columnHeader: 'testAttach', columnHeader: 'testAttach',
@ -34,7 +34,7 @@ test.describe('Attachment column', () => {
await dashboard.grid.cell.attachment.addFile({ await dashboard.grid.cell.attachment.addFile({
index: 7, index: 7,
columnHeader: 'testAttach', columnHeader: 'testAttach',
filePath: `${process.cwd()}/fixtures/sampleFiles/sampleImage.jpeg`, filePath: [`${process.cwd()}/fixtures/sampleFiles/sampleImage.jpeg`],
}); });
await dashboard.grid.cell.attachment.verifyFile({ await dashboard.grid.cell.attachment.verifyFile({
index: 7, index: 7,
@ -60,7 +60,7 @@ test.describe('Attachment column', () => {
}); });
await sharedForm.cell.attachment.addFile({ await sharedForm.cell.attachment.addFile({
columnHeader: 'testAttach', columnHeader: 'testAttach',
filePath: `${process.cwd()}/fixtures/sampleFiles/1.json`, filePath: [`${process.cwd()}/fixtures/sampleFiles/1.json`],
}); });
await sharedForm.submit(); await sharedForm.submit();
await sharedForm.verifySuccessMessage(); await sharedForm.verifySuccessMessage();

Loading…
Cancel
Save