From e9661a113566c9c76af469838c5ee00792c47842 Mon Sep 17 00:00:00 2001 From: Daniel Spaude Date: Mon, 21 Nov 2022 21:18:13 +0300 Subject: [PATCH] qrcode: playwright tests (WIP) --- .../nc-gui/components/virtual-cell/QrCode.vue | 2 +- .../pages/Dashboard/common/Cell/index.ts | 20 +++++++-- tests/playwright/tests/columnQrCode.spec.ts | 45 ++++++++++++------- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/packages/nc-gui/components/virtual-cell/QrCode.vue b/packages/nc-gui/components/virtual-cell/QrCode.vue index 45509a6674..373c0b901e 100644 --- a/packages/nc-gui/components/virtual-cell/QrCode.vue +++ b/packages/nc-gui/components/virtual-cell/QrCode.vue @@ -28,7 +28,7 @@ const handleModalOkClick = () => (modalVisible.value = false) - QR Code + QR Code QR Code diff --git a/tests/playwright/pages/Dashboard/common/Cell/index.ts b/tests/playwright/pages/Dashboard/common/Cell/index.ts index 2087d4efbe..34fab81d2c 100644 --- a/tests/playwright/pages/Dashboard/common/Cell/index.ts +++ b/tests/playwright/pages/Dashboard/common/Cell/index.ts @@ -91,16 +91,28 @@ export class CellPageObject extends BasePage { columnHeader: string; expectedSrcValue: string; }) { + console.log('FOOBAR!!!'); const _verify = async text => { await expect .poll(async () => { - const innerTexts = await this.get({ + const FOO = await this.get({ index, columnHeader, - }).allInnerTexts(); - return typeof innerTexts === 'string' ? [innerTexts] : innerTexts; + }); + console.log('index: ', index); + console.log('columnHeader: ', columnHeader); + console.log('expectedSrcValue: ', expectedSrcValue); + const img = await FOO.getByRole('img'); + console.log('img: ', img); + const src = await img.getAttribute('src'); + console.log('src: ', src); + // const innerTexts = FOO.allInnerTexts(); + // console.log('innerTexts', innerTexts); + console.log('--------------------------'); + // return typeof innerTexts === 'string' ? [innerTexts] : innerTexts; + return src; }) - .toContain(text); + .toEqual(text); }; await _verify(expectedSrcValue); diff --git a/tests/playwright/tests/columnQrCode.spec.ts b/tests/playwright/tests/columnQrCode.spec.ts index 2893b25c69..222a6550cc 100644 --- a/tests/playwright/tests/columnQrCode.spec.ts +++ b/tests/playwright/tests/columnQrCode.spec.ts @@ -2,6 +2,7 @@ import { test } from '@playwright/test'; import { DashboardPage } from '../pages/Dashboard'; import setup, { NcContext } from '../setup'; import { isPg, isSqlite } from '../setup/db'; +import { expect, Locator } from '@playwright/test'; // Add formula to be verified here & store expected results for 5 rows // Column data from City table (Sakila DB) @@ -71,21 +72,15 @@ test.describe('Virtual Columns', () => { dashboard = new DashboardPage(page, context.project); }); - async function formulaResultVerify({ - qrColumnTitle, - expectedQrCodes, - }: { - qrColumnTitle: string; - expectedQrCodes: string[]; - }) { - for (let i = 0; i < expectedQrCodes.length; i++) { - await dashboard.grid.cell.verify({ - index: i, - columnHeader: qrColumnTitle, - value: expectedQrCodes[i], - }); - } - } + // async function qrCodeVerify(qrColumnTitle: string, expectedQrCodes: string[]) { + // for (let i = 0; i < expectedQrCodes.length; i++) { + // await dashboard.grid.cell.verifyQrCodeCell({ + // index: i, + // columnHeader: qrColumnTitle, + // expectedSrcValue: expectedQrCodes[i], + // }); + // } + // } test('QrCode', async () => { // close 'Team & Auth' tab @@ -100,6 +95,26 @@ test.describe('Virtual Columns', () => { qrCodeValueColumnTitle: 'City', }); + + await dashboard.grid.cell.verifyQrCodeCell({ + index: 0, + columnHeader: 'QrCode1', + expectedSrcValue: expectedQrCodeCellValues[0], + }); + + + // expect + // .poll(async () => { + + // const FOO = await this.get({ + // index, + // columnHeader, + // }); + + // for (let i = 1; i < expectedQrCodeCellValues.length; i++) { + // await qrCodeVerify('QrCode1', expectedQrCodeCellValues); + // } + // verify different formula's // for (let i = 1; i < formulaData.length; i++) { // // Sqlite does not support log function