Files
iptvnator/libs/shared/database/src/lib/path-utils.ts
T
4gray 81c2aab829 test(e2e): add end-to-end tests for playlist import, providers, and settings persistence
- Implemented tests for importing M3U playlists via native dialog.
- Added smoke tests for loading Xtream and Stalker content through IPC.
- Created tests to verify persistence of remote control settings across app restarts.
- Updated smoke tests to check for main window properties and workspace content rendering.

refactor(electron-backend): enhance store service and database path handling

- Modified store service to use a dynamic configuration directory based on environment.
- Refactored database connection to utilize new path utility functions for better path management.

fix(e2e): improve test selectors and structure for better reliability

- Updated test selectors in web-e2e tests to use role-based queries for better accessibility.
- Refactored settings tests to reduce redundancy and improve clarity.

chore(e2e): update TypeScript configuration for better inclusion of test files

- Adjusted tsconfig.json to ensure proper inclusion of e2e test files.

Entire-Checkpoint: bb9a8e2e351e
2026-03-17 23:30:16 +01:00

52 lines
1.3 KiB
TypeScript

import { existsSync, mkdirSync } from 'fs';
import { homedir } from 'os';
import { join } from 'path';
export const IPTVNATOR_E2E_DATA_DIR_ENV = 'IPTVNATOR_E2E_DATA_DIR';
function ensureDirectory(dirPath: string): string {
if (!existsSync(dirPath)) {
mkdirSync(dirPath, { recursive: true });
}
return dirPath;
}
export function getIptvnatorDataRoot(): string {
const e2eDataDir = process.env[IPTVNATOR_E2E_DATA_DIR_ENV]?.trim();
if (e2eDataDir) {
return ensureDirectory(e2eDataDir);
}
return ensureDirectory(join(homedir(), '.iptvnator'));
}
export function getIptvnatorDatabaseDirectory(): string {
return ensureDirectory(join(getIptvnatorDataRoot(), 'databases'));
}
export function getIptvnatorDatabasePath(): string {
return join(getIptvnatorDatabaseDirectory(), 'iptvnator.db');
}
export function getElectronUserDataPath(): string | null {
const e2eDataDir = process.env[IPTVNATOR_E2E_DATA_DIR_ENV]?.trim();
if (!e2eDataDir) {
return null;
}
return ensureDirectory(join(e2eDataDir, 'user-data'));
}
export function getElectronConfigDirectory(): string | null {
const e2eDataDir = process.env[IPTVNATOR_E2E_DATA_DIR_ENV]?.trim();
if (!e2eDataDir) {
return null;
}
return ensureDirectory(join(e2eDataDir, 'config'));
}