From ba1b6fa5a937e2f676e3c18944f6edec5b04d328 Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Sat, 18 Nov 2023 09:57:29 -0800 Subject: [PATCH] Web console: reset spec before looking for tile (#15396) * reset spec before looking for tile * improve logging * log screenshots * get and log jpeg * other test tidy up --- .../e2e-tests/component/load-data/data-loader.ts | 8 ++++++++ web-console/e2e-tests/component/workbench/overview.ts | 2 +- web-console/e2e-tests/multi-stage-query.spec.ts | 3 ++- web-console/e2e-tests/util/debug.ts | 11 ++++++++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/web-console/e2e-tests/component/load-data/data-loader.ts b/web-console/e2e-tests/component/load-data/data-loader.ts index 71601467f562..4462641cb9a1 100644 --- a/web-console/e2e-tests/component/load-data/data-loader.ts +++ b/web-console/e2e-tests/component/load-data/data-loader.ts @@ -42,6 +42,7 @@ export class DataLoader { */ async load() { await this.page.goto(this.baseUrl); + await this.startNewSpecIfNeeded(); await this.start(); await this.connect(this.connector, this.connectValidator); if (this.connector.needParse) { @@ -57,6 +58,13 @@ export class DataLoader { await this.editSpec(); } + private async startNewSpecIfNeeded() { + const startNewSpecLocator = this.page.locator(`//*[contains(text(),"Start a new")]`); + if (await startNewSpecLocator.count()) { + await startNewSpecLocator.click(); + } + } + private async start() { const cardSelector = `//*[contains(@class,"bp4-card")][p[contains(text(),"${this.connector.name}")]]`; await this.page.click(cardSelector); diff --git a/web-console/e2e-tests/component/workbench/overview.ts b/web-console/e2e-tests/component/workbench/overview.ts index 9660cd354dcd..b33e57fbc79a 100644 --- a/web-console/e2e-tests/component/workbench/overview.ts +++ b/web-console/e2e-tests/component/workbench/overview.ts @@ -40,7 +40,7 @@ export class WorkbenchOverview { const input = await this.page.waitForSelector('div.flexible-query-input textarea'); await input.fill(query); await clickButton(this.page, 'Run'); - await this.page.waitForSelector('div.result-table-pane', { timeout: 5 * 60 * 1000 }); + await this.page.waitForSelector('div.result-table-pane', { timeout: 4 * 60 * 1000 }); return await extractTable(this.page, 'div.result-table-pane div.rt-tr-group', 'div.rt-td'); } diff --git a/web-console/e2e-tests/multi-stage-query.spec.ts b/web-console/e2e-tests/multi-stage-query.spec.ts index 7e4168392f8a..4647764266ac 100644 --- a/web-console/e2e-tests/multi-stage-query.spec.ts +++ b/web-console/e2e-tests/multi-stage-query.spec.ts @@ -44,8 +44,9 @@ describe('Multi-stage query', () => { }); it('runs a query that reads external data', async () => { + const workbench = new WorkbenchOverview(page, UNIFIED_CONSOLE_URL); + await saveScreenshotIfError('multi-stage-query', page, async () => { - const workbench = new WorkbenchOverview(page, UNIFIED_CONSOLE_URL); const results = await workbench.runQuery(`WITH ext AS (SELECT * FROM TABLE( EXTERN( diff --git a/web-console/e2e-tests/util/debug.ts b/web-console/e2e-tests/util/debug.ts index fee93a39a727..bfd2e2db7006 100644 --- a/web-console/e2e-tests/util/debug.ts +++ b/web-console/e2e-tests/util/debug.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import { resolve } from 'path'; import type * as playwright from 'playwright-chromium'; export async function saveScreenshotIfError( @@ -26,7 +27,15 @@ export async function saveScreenshotIfError( try { await test(); } catch (e) { - await page.screenshot({ path: filenamePrefix + 'error-screenshot.png' }); + console.log(`Grabbing error screenshot for: ${filenamePrefix}`); + const resolvedPath = resolve(filenamePrefix + '-error-screenshot.jpeg'); + try { + const imageBuffer = await page.screenshot({ path: resolvedPath, type: 'jpeg', quality: 80 }); + console.log(`Image: data:image/jpeg;base64,${imageBuffer.toString('base64')}`); + console.log(`Written error screenshot to: ${resolvedPath}`); + } catch (screenshotError) { + console.log(`Failed to capture screenshot due to: ${screenshotError.message}`); + } throw e; } }