Skip to content

Commit

Permalink
Web console: reset spec before looking for tile (#15396)
Browse files Browse the repository at this point in the history
* reset spec before looking for tile

* improve logging

* log screenshots

* get and log jpeg

* other test tidy up
  • Loading branch information
vogievetsky authored Nov 18, 2023
1 parent a95c22c commit ba1b6fa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions web-console/e2e-tests/component/load-data/data-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion web-console/e2e-tests/component/workbench/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
3 changes: 2 additions & 1 deletion web-console/e2e-tests/multi-stage-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
11 changes: 10 additions & 1 deletion web-console/e2e-tests/util/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* limitations under the License.
*/

import { resolve } from 'path';
import type * as playwright from 'playwright-chromium';

export async function saveScreenshotIfError(
Expand All @@ -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;
}
}

0 comments on commit ba1b6fa

Please sign in to comment.