-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwdio.conf.js
More file actions
112 lines (98 loc) · 3.3 KB
/
wdio.conf.js
File metadata and controls
112 lines (98 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { spawn, spawnSync } from 'child_process';
import path from 'path';
import fs from 'fs';
let tauriDriver;
// Database paths
const APP_DATA_DIR = path.join(process.env.HOME, '.local/share/net.kurowski.potasko');
const APP_DB = path.join(APP_DATA_DIR, 'potasko.db');
const CLI_PATH = './src-tauri/target/debug/potasko';
export const config = {
specs: ['./tests/e2e/**/*.spec.js'],
maxInstances: 1,
// Connect to tauri-driver running on port 4444
protocol: 'http',
hostname: '127.0.0.1',
port: 4444,
path: '/',
capabilities: [{
'tauri:options': {
application: './src-tauri/target/debug/potasko-gui'
}
}],
framework: 'mocha',
mochaOpts: {
timeout: 60000
},
reporters: ['spec'],
// Start tauri-driver and build app before tests
onPrepare: async () => {
// Build the app first
console.log('Building Tauri app (debug)...');
const result = spawnSync('pnpm', ['tauri', 'build', '--debug', '--no-bundle'], {
stdio: 'inherit',
cwd: process.cwd()
});
if (result.status !== 0) {
throw new Error('Failed to build Tauri app');
}
// Clean up database BEFORE starting the app
console.log('Cleaning up database...');
try {
if (fs.existsSync(APP_DB)) {
fs.unlinkSync(APP_DB);
console.log('Removed existing app database');
}
// Initialize database via CLI (runs migrations)
spawnSync(CLI_PATH, ['--database', APP_DB, 'list', 'list'], { stdio: 'inherit' });
console.log('Initialized fresh database via CLI');
} catch (e) {
console.log('Could not cleanup/init app database:', e.message);
}
// Ensure Radicale is running for CalDAV tests
console.log('Starting Radicale...');
spawnSync('sudo', ['service', 'radicale', 'start'], { stdio: 'inherit' });
// Create a test calendar on Radicale for sync tests
console.log('Creating test calendar on Radicale...');
const calendarXml = `<?xml version="1.0" encoding="UTF-8"?>
<mkcalendar xmlns="urn:ietf:params:xml:ns:caldav">
<set xmlns="DAV:">
<prop>
<displayname>Test Tasks</displayname>
<supported-calendar-component-set xmlns="urn:ietf:params:xml:ns:caldav">
<comp name="VTODO"/>
</supported-calendar-component-set>
</prop>
</set>
</mkcalendar>`;
const mkCalResult = spawnSync('curl', [
'-s', '-X', 'MKCALENDAR',
'-u', 'test:test',
'-H', 'Content-Type: application/xml',
'-d', calendarXml,
'http://localhost:5232/test/tasks/'
], { stdio: 'pipe' });
console.log('Calendar creation result:', mkCalResult.status === 0 ? 'success' : 'failed');
// Then start tauri-driver
console.log('Starting tauri-driver...');
tauriDriver = spawn('tauri-driver', [], {
stdio: ['ignore', 'pipe', 'pipe']
});
// Log tauri-driver output for debugging
tauriDriver.stdout.on('data', (data) => {
console.log(`tauri-driver stdout: ${data}`);
});
tauriDriver.stderr.on('data', (data) => {
console.error(`tauri-driver stderr: ${data}`);
});
// Wait for tauri-driver to start
await new Promise((resolve) => setTimeout(resolve, 2000));
console.log('tauri-driver started');
},
// Clean up after all tests
onComplete: () => {
console.log('Stopping tauri-driver...');
if (tauriDriver) {
tauriDriver.kill();
}
}
};