Skip to content

Commit f6aa17f

Browse files
committed
chore: add debug
1 parent 6393b86 commit f6aa17f

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

e2e/test/tauri/api.spec.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,25 @@ describe('Tauri API', () => {
2121

2222
it('should execute commands with parameters', async () => {
2323
// Test file write command with parameters
24-
const testPath = `/tmp/tauri-test-${Date.now()}.txt`;
24+
// Use a path in the current working directory instead of /tmp
25+
const testPath = `./tauri-test-${Date.now()}.txt`;
2526
const testContent = 'Hello, Tauri!';
27+
28+
console.log('🔍 Testing write_file command with path:', testPath);
2629
const result = await browser.tauri.execute('write_file', testPath, testContent);
30+
console.log('🔍 write_file result:', JSON.stringify(result, null, 2));
2731
expect(result.success).to.be.true;
2832

2933
// Verify with read
34+
console.log('🔍 Testing read_file command with path:', testPath);
3035
const readResult = await browser.tauri.execute('read_file', testPath);
36+
console.log('🔍 read_file result:', JSON.stringify(readResult, null, 2));
3137
expect(readResult.success).to.be.true;
3238
expect(readResult.data).to.equal(testContent);
3339

3440
// Cleanup
35-
await browser.tauri.execute('delete_file', testPath);
41+
console.log('🔍 Testing delete_file command with path:', testPath);
42+
const deleteResult = await browser.tauri.execute('delete_file', testPath);
43+
console.log('🔍 delete_file result:', JSON.stringify(deleteResult, null, 2));
3644
});
3745
});

fixtures/tauri-apps/basic/src-tauri/src/main.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,39 @@ async fn take_screenshot(_options: Option<ScreenshotOptions>) -> Result<String,
108108

109109
#[tauri::command]
110110
async fn read_file(path: String, _options: Option<FileOperationOptions>) -> Result<String, String> {
111-
std::fs::read_to_string(&path).map_err(|e| e.to_string())
111+
println!("🔍 Rust: read_file called with path: '{}'", path);
112+
let result = std::fs::read_to_string(&path).map_err(|e| {
113+
let error_msg = format!("Failed to read file '{}': {}", path, e);
114+
println!("🔍 Rust: read_file error: {}", error_msg);
115+
error_msg
116+
});
117+
if result.is_ok() {
118+
println!("🔍 Rust: read_file succeeded for path: '{}', content length: {}", path, result.as_ref().unwrap().len());
119+
}
120+
result
112121
}
113122

114123
#[tauri::command]
115124
async fn write_file(path: String, contents: String, _options: Option<FileOperationOptions>) -> Result<(), String> {
116-
std::fs::write(&path, contents).map_err(|e| e.to_string())?;
125+
println!("🔍 Rust: write_file called with path: '{}', contents length: {}", path, contents.len());
126+
std::fs::write(&path, contents).map_err(|e| {
127+
let error_msg = format!("Failed to write file '{}': {}", path, e);
128+
println!("🔍 Rust: write_file error: {}", error_msg);
129+
error_msg
130+
})?;
131+
println!("🔍 Rust: write_file succeeded for path: '{}'", path);
117132
Ok(())
118133
}
119134

120135
#[tauri::command]
121136
async fn delete_file(path: String) -> Result<(), String> {
122-
std::fs::remove_file(&path).map_err(|e| e.to_string())?;
137+
println!("🔍 Rust: delete_file called with path: '{}'", path);
138+
std::fs::remove_file(&path).map_err(|e| {
139+
let error_msg = format!("Failed to delete file '{}': {}", path, e);
140+
println!("🔍 Rust: delete_file error: {}", error_msg);
141+
error_msg
142+
})?;
143+
println!("🔍 Rust: delete_file succeeded for path: '{}'", path);
123144
Ok(())
124145
}
125146

0 commit comments

Comments
 (0)