diff --git a/tests/playwright/pages/Dashboard/common/Cell/index.ts b/tests/playwright/pages/Dashboard/common/Cell/index.ts index 22052a2ca6..4e1ddb538e 100644 --- a/tests/playwright/pages/Dashboard/common/Cell/index.ts +++ b/tests/playwright/pages/Dashboard/common/Cell/index.ts @@ -51,7 +51,20 @@ export class CellPageObject extends BasePage { index, columnHeader, }); - await this.get({ index, columnHeader }).locator('input').fill(text); + const isInputBox = async () => (await this.get({ index, columnHeader }).locator('input').count()) > 0; + + for (let i = 0; i < 10; i++) { + if (await isInputBox()) { + break; + } + await this.rootPage.waitForTimeout(200); + } + + if (await isInputBox()) { + await this.get({ index, columnHeader }).locator('input').fill(text); + } else { + await this.get({ index, columnHeader }).locator('textarea').fill(text); + } } async inCellExpand({ index, columnHeader }: { index: number; columnHeader: string }) { @@ -192,7 +205,9 @@ export class CellPageObject extends BasePage { ...clickOptions: Parameters ) { await this.get({ index, columnHeader }).click(...clickOptions); + await (await this.get({ index, columnHeader }).elementHandle()).waitForElementState('stable'); await this.get({ index, columnHeader }).press((await this.isMacOs()) ? 'Meta+C' : 'Control+C'); + await this.verifyToast({ message: 'Copied to clipboard' }); } } diff --git a/tests/playwright/tests/gridOperations.spec.ts b/tests/playwright/tests/gridOperations.spec.ts deleted file mode 100644 index d05b9fcc54..0000000000 --- a/tests/playwright/tests/gridOperations.spec.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { expect, test } from '@playwright/test'; -import { DashboardPage } from '../pages/Dashboard'; -import setup from '../setup'; - -test.describe('Grid operations', () => { - let dashboard: DashboardPage; - let context: any; - - test.beforeEach(async ({ page }) => { - context = await setup({ page }); - dashboard = new DashboardPage(page, context.project); - }); - - test('Clipboard support', async () => { - // close 'Team & Auth' tab - await dashboard.closeTab({ title: 'Team & Auth' }); - - await dashboard.treeView.createTable({ title: 'Sheet1' }); - - await dashboard.grid.column.create({ - title: 'Number', - type: 'Number', - }); - await dashboard.grid.column.create({ - title: 'Checkbox', - type: 'Checkbox', - }); - await dashboard.grid.column.create({ - title: 'Date', - type: 'Date', - }); - await dashboard.grid.column.create({ - title: 'Attachment', - type: 'Attachment', - }); - - await dashboard.grid.addNewRow({ - index: 0, - }); - await dashboard.grid.cell.click({ - index: 0, - columnHeader: 'Number', - }); - await dashboard.grid.cell.fillText({ - index: 0, - columnHeader: 'Number', - text: '123', - }); - await dashboard.grid.cell.click({ - index: 0, - columnHeader: 'Checkbox', - }); - - const today = new Date().toISOString().slice(0, 10); - await dashboard.grid.cell.date.open({ - index: 0, - columnHeader: 'Date', - }); - await dashboard.grid.cell.date.selectDate({ - date: today, - }); - await dashboard.grid.cell.date.close(); - - await dashboard.grid.cell.attachment.addFile({ - index: 0, - columnHeader: 'Attachment', - filePath: `${process.cwd()}/fixtures/sampleFiles/1.json`, - }); - - await dashboard.grid.cell.copyToClipboard({ - index: 0, - columnHeader: 'Title', - }); - expect(await dashboard.grid.cell.getClipboardText()).toBe('Row 0'); - - await dashboard.grid.cell.copyToClipboard({ - index: 0, - columnHeader: 'Number', - }); - expect(await dashboard.grid.cell.getClipboardText()).toBe('123'); - - await dashboard.grid.cell.copyToClipboard( - { - index: 0, - columnHeader: 'Checkbox', - }, - { position: { x: 1, y: 1 } } - ); - await new Promise(resolve => setTimeout(resolve, 5000)); - expect(await dashboard.grid.cell.getClipboardText()).toBe('true'); - - await dashboard.grid.cell.click({ - index: 0, - columnHeader: 'Checkbox', - }); - await dashboard.grid.cell.copyToClipboard( - { - index: 0, - columnHeader: 'Checkbox', - }, - { position: { x: 1, y: 1 } } - ); - expect(await dashboard.grid.cell.getClipboardText()).toBe('false'); - - await dashboard.grid.cell.copyToClipboard({ - index: 0, - columnHeader: 'Date', - }); - expect(await dashboard.grid.cell.getClipboardText()).toBe(today); - - await dashboard.grid.cell.copyToClipboard({ - index: 0, - columnHeader: 'Attachment', - }); - // expect(await dashboard.grid.cell.getClipboardText()).toBe('1.json'); - }); -}); diff --git a/tests/playwright/tests/keyboardShortcuts.spec.ts b/tests/playwright/tests/keyboardShortcuts.spec.ts index 168bbe948c..fe21e61855 100644 --- a/tests/playwright/tests/keyboardShortcuts.spec.ts +++ b/tests/playwright/tests/keyboardShortcuts.spec.ts @@ -101,4 +101,196 @@ test.describe('Verify shortcuts', () => { await page.waitForTimeout(2000); await grid.cell.verify({ index: 1, columnHeader: 'Country', value: 'NewAlgeria' }); }); + + test('Clipboard support for cells', async () => { + // close 'Team & Auth' tab + await dashboard.closeTab({ title: 'Team & Auth' }); + + await dashboard.treeView.createTable({ title: 'Sheet1' }); + + await dashboard.grid.column.create({ + title: 'SingleLineText', + type: 'SingleLineText', + }); + await dashboard.grid.column.create({ + title: 'LongText', + type: 'LongText', + }); + await dashboard.grid.column.create({ + title: 'Number', + type: 'Number', + }); + await dashboard.grid.column.create({ + title: 'SingleSelect', + type: 'SingleSelect', + }); + await dashboard.grid.column.create({ + title: 'MultiSelect', + type: 'MultiSelect', + }); + await dashboard.grid.column.create({ + title: 'Checkbox', + type: 'Checkbox', + }); + await dashboard.grid.column.create({ + title: 'Date', + type: 'Date', + }); + await dashboard.grid.column.create({ + title: 'Attachment', + type: 'Attachment', + }); + + // ######################################## + + await dashboard.grid.addNewRow({ + index: 0, + }); + await dashboard.grid.cell.click({ + index: 0, + columnHeader: 'SingleLineText', + }); + await dashboard.grid.cell.fillText({ + index: 0, + columnHeader: 'SingleLineText', + text: 'SingleLineText', + }); + + await dashboard.grid.cell.click({ + index: 0, + columnHeader: 'LongText', + }); + await dashboard.grid.cell.fillText({ + index: 0, + columnHeader: 'LongText', + text: 'LongText', + }); + + await grid.cell.selectOption.select({ index: 0, columnHeader: 'SingleSelect', option: 'Option 1' }); + await grid.cell.selectOption.select({ + index: 0, + columnHeader: 'MultiSelect', + option: 'Option 2', + multiSelect: true, + }); + await grid.cell.selectOption.select({ + index: 0, + columnHeader: 'MultiSelect', + option: 'Option 1', + multiSelect: true, + }); + await dashboard.grid.cell.click({ + index: 0, + columnHeader: 'Number', + }); + await dashboard.grid.cell.fillText({ + index: 0, + columnHeader: 'Number', + text: '123', + }); + await dashboard.grid.cell.click({ + index: 0, + columnHeader: 'Checkbox', + }); + + const today = new Date().toISOString().slice(0, 10); + await dashboard.grid.cell.date.open({ + index: 0, + columnHeader: 'Date', + }); + await dashboard.grid.cell.date.selectDate({ + date: today, + }); + await dashboard.grid.cell.date.close(); + + await dashboard.grid.cell.attachment.addFile({ + index: 0, + columnHeader: 'Attachment', + filePath: `${process.cwd()}/fixtures/sampleFiles/1.json`, + }); + + // ######################################## + + await dashboard.grid.cell.copyToClipboard({ + index: 0, + columnHeader: 'SingleLineText', + }); + expect(await dashboard.grid.cell.getClipboardText()).toBe('SingleLineText'); + + await dashboard.grid.cell.copyToClipboard({ + index: 0, + columnHeader: 'LongText', + }); + expect(await dashboard.grid.cell.getClipboardText()).toBe('LongText'); + + await dashboard.grid.cell.copyToClipboard( + { + index: 0, + columnHeader: 'SingleSelect', + }, + { position: { x: 1, y: 1 } } + ); + expect(await dashboard.grid.cell.getClipboardText()).toBe('Option 1'); + + await dashboard.grid.cell.copyToClipboard( + { + index: 0, + columnHeader: 'MultiSelect', + }, + { position: { x: 1, y: 1 } } + ); + expect(await dashboard.grid.cell.getClipboardText()).toContain('Option 1'); + expect(await dashboard.grid.cell.getClipboardText()).toContain('Option 2'); + + await dashboard.grid.cell.copyToClipboard({ + index: 0, + columnHeader: 'Title', + }); + expect(await dashboard.grid.cell.getClipboardText()).toBe('Row 0'); + + await dashboard.grid.cell.copyToClipboard({ + index: 0, + columnHeader: 'Number', + }); + expect(await dashboard.grid.cell.getClipboardText()).toBe('123'); + + await dashboard.grid.cell.copyToClipboard( + { + index: 0, + columnHeader: 'Checkbox', + }, + { position: { x: 1, y: 1 } } + ); + await new Promise(resolve => setTimeout(resolve, 5000)); + expect(await dashboard.grid.cell.getClipboardText()).toBe('true'); + + await dashboard.grid.cell.click({ + index: 0, + columnHeader: 'Checkbox', + }); + await dashboard.grid.cell.copyToClipboard( + { + index: 0, + columnHeader: 'Checkbox', + }, + { position: { x: 1, y: 1 } } + ); + expect(await dashboard.grid.cell.getClipboardText()).toBe('false'); + + await dashboard.grid.cell.copyToClipboard({ + index: 0, + columnHeader: 'Date', + }); + expect(await dashboard.grid.cell.getClipboardText()).toBe(today); + + await dashboard.grid.cell.copyToClipboard( + { + index: 0, + columnHeader: 'Attachment', + }, + { position: { x: 1, y: 1 } } + ); + const attachmentsInfo = JSON.parse(await dashboard.grid.cell.getClipboardText()); + expect(attachmentsInfo[0]['title']).toBe('1.json'); + }); });