Files
beekeeper-studio/apps/studio/e2e/tests/newConnection.test.ts
Matthew Rathbone 19eafa6c0b fix(e2e): guard afterEach against missing electronApp
When a test or beforeEach fails before electronApp is assigned,
the afterEach would crash trying to call .close() on undefined,
masking the real error. Add a null check in all 9 e2e test files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 15:34:36 -06:00

47 lines
1.6 KiB
TypeScript

import { _electron as electron } from 'playwright';
import { test, expect } from '@playwright/test';
import { NewDatabaseConnection } from '../pageComponents/NewDatabaseConnection';
import { QueryTab } from '../pageComponents/QueryTab';
import { userActions } from "../pageActions/index";
import { POSTGRES_CONFIG } from './config/postgresDbConfig';
let electronApp;
let window;
let newDatabaseConnection;
let queryTab;
let userAttemptsTo;
test.describe('New Connection Tests', () => {
test.beforeEach(async () => {
electronApp = await electron.launch({ args: ['dist/main.js'] });
window = await electronApp.firstWindow();
userAttemptsTo = userActions(window);
newDatabaseConnection = new NewDatabaseConnection(window);
queryTab = new QueryTab(window);
});
test.afterEach(async () => {
if (electronApp) {
await electronApp.close();
}
});
test('Test a Postgres connection', async () => {
await userAttemptsTo.selectNewConnection(POSTGRES_CONFIG.connectionType);
await userAttemptsTo.insertDatabaseDetails(POSTGRES_CONFIG);
await userAttemptsTo.testDatabaseConnection();
await expect(newDatabaseConnection.testConnectionButton).toBeVisible();
});
test('Connect with a Postgres database', async () => {
await userAttemptsTo.selectNewConnection(POSTGRES_CONFIG.connectionType);
await userAttemptsTo.insertDatabaseDetails(POSTGRES_CONFIG);
await userAttemptsTo.testDatabaseConnection();
await userAttemptsTo.connectWithDatabase();
await expect(queryTab.queryTabTextArea).toBeVisible();
});
});