mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-15 13:46:16 -08:00
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
This commit is contained in:
1 parent
0c451b0dd7
commit
81c2aab829
23 files changed
+955
-443
No files matched your search
@@ -6,3 +6,4 @@
|
||||
|
||||
export * from './lib/schema';
|
||||
export * from './lib/connection';
|
||||
export * from './lib/path-utils';
|
||||
@@ -1,7 +1,8 @@
|
||||
/**
|
||||
* Database connection and initialization for IPTVnator
|
||||
* Uses Drizzle ORM with better-sqlite3
|
||||
* Stores database file under ~/.iptvnator/databases/
|
||||
* Stores database file under ~/.iptvnator/databases/ by default.
|
||||
* E2E tests can override the root with IPTVNATOR_E2E_DATA_DIR.
|
||||
*
|
||||
* Provides two connection modes:
|
||||
* - Full access (for electron-backend): creates tables, read-write
|
||||
@@ -11,10 +12,8 @@
|
||||
import Database from 'better-sqlite3';
|
||||
import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
||||
import { drizzle } from 'drizzle-orm/better-sqlite3';
|
||||
import { existsSync, mkdirSync } from 'fs';
|
||||
import { homedir } from 'os';
|
||||
import { join } from 'path';
|
||||
import * as schema from './schema';
|
||||
import { getIptvnatorDatabasePath } from './path-utils';
|
||||
|
||||
export type DatabaseInstance = BetterSQLite3Database<typeof schema>;
|
||||
|
||||
@@ -26,14 +25,7 @@ let initPromise: Promise<DatabaseInstance> | null = null;
|
||||
* Get the database file path
|
||||
*/
|
||||
export function getDatabasePath(): string {
|
||||
const dbDir = join(homedir(), '.iptvnator', 'databases');
|
||||
|
||||
// Ensure the directory exists
|
||||
if (!existsSync(dbDir)) {
|
||||
mkdirSync(dbDir, { recursive: true });
|
||||
}
|
||||
|
||||
return join(dbDir, 'iptvnator.db');
|
||||
return getIptvnatorDatabasePath();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
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'));
|
||||
}
|
||||
Reference in new issue
Block a user