mirror of
https://github.com/beekeeper-studio/beekeeper-studio.git
synced 2026-03-13 10:12:54 +08:00
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>
47 lines
1.6 KiB
TypeScript
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();
|
|
});
|
|
});
|