-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathtest-xdg-cache.cjs
More file actions
69 lines (58 loc) · 2.18 KB
/
test-xdg-cache.cjs
File metadata and controls
69 lines (58 loc) · 2.18 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
#!/usr/bin/env node
/**
* Test XDG cache directory functionality
*/
const chromeLib = require('./skills/browsing/chrome-ws-lib.js');
const path = require('path');
console.log('Testing XDG cache directory...\n');
// Test 1: getXdgCacheHome
console.log('Test 1: getXdgCacheHome()');
const cacheHome = chromeLib.getXdgCacheHome();
console.log(` Cache home: ${cacheHome}`);
console.log(` Platform: ${process.platform}`);
console.log(` ✓ Pass\n`);
// Test 2: initializeSession
console.log('Test 2: initializeSession()');
const sessionDir = chromeLib.initializeSession();
console.log(` Session directory: ${sessionDir}`);
// Verify structure: {cacheHome}/superpowers/browser/YYYY-MM-DD/session-{timestamp}
const parts = sessionDir.split(path.sep);
const hasSuperpowers = parts.includes('superpowers');
const hasBrowser = parts.includes('browser');
const hasDatePattern = parts.some(p => /^\d{4}-\d{2}-\d{2}$/.test(p));
const hasSessionPattern = parts.some(p => /^session-\d+$/.test(p));
console.log(` Has 'superpowers' in path: ${hasSuperpowers ? '✓' : '✗'}`);
console.log(` Has 'browser' in path: ${hasBrowser ? '✓' : '✗'}`);
console.log(` Has YYYY-MM-DD date: ${hasDatePattern ? '✓' : '✗'}`);
console.log(` Has session-{timestamp}: ${hasSessionPattern ? '✓' : '✗'}`);
if (hasSuperpowers && hasBrowser && hasDatePattern && hasSessionPattern) {
console.log(' ✓ Pass\n');
} else {
console.log(' ✗ FAIL\n');
process.exit(1);
}
// Test 3: Check directory exists
console.log('Test 3: Directory existence');
const fs = require('fs');
const exists = fs.existsSync(sessionDir);
console.log(` Directory exists: ${exists ? '✓' : '✗'}`);
if (exists) {
const stat = fs.statSync(sessionDir);
console.log(` Is directory: ${stat.isDirectory() ? '✓' : '✗'}`);
console.log(' ✓ Pass\n');
} else {
console.log(' ✗ FAIL\n');
process.exit(1);
}
// Cleanup
console.log('Test 4: Cleanup');
chromeLib.cleanupSession();
const stillExists = fs.existsSync(sessionDir);
console.log(` Directory removed: ${!stillExists ? '✓' : '✗'}`);
if (!stillExists) {
console.log(' ✓ Pass\n');
} else {
console.log(' ✗ FAIL\n');
process.exit(1);
}
console.log('All tests passed! ✓');