Add tauri e2e test for auth on Linux (#1040)
* WIP: Add tauri e2e test for auth on Linux Fixes #968 * WIP * WIP * Working of through /tmp file for user code sharing * rust int * User code only in /tmp, fixes * Longer timeout for github actions * Remove timeout * Fmt * Fmt, 30sec timeout * Test BUILD_RELEASE true * Revert "Test BUILD_RELEASE true" This reverts commitd3b59d4a6c
. * Disable concurrency limit for faster iterations on this PR * Add logs for responses * Test manual tauri build before e2e * WIP * Catch error on tauri::api:🐚:open * Clean up * Clean up * timeout * Force BUILD_RELEASE: true * Back to debug, longer timeout * Print if url opens ok too * Check default browser in actions * Remote shell call on linux (aka e2e for now) * Fix fmt * Move to data-testid, clean up * Add log out section * Clean up * Fix typo * Fix text detection * Test AppImage * Revert "Test AppImage" This reverts commitcf126b1aa6
. * Add comments * Change to env var * Clean up * Fmt fix * Better package json name * Add import @wdio/globals * Back to require * Update wdio, fix globals * Move to typescript * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::io::Read;
|
||||
|
||||
use anyhow::Result;
|
||||
@ -70,8 +72,24 @@ async fn login(app: tauri::AppHandle, host: &str) -> Result<String, InvokeError>
|
||||
// Open the system browser with the auth_uri.
|
||||
// We do this in the browser and not a separate window because we want 1password and
|
||||
// other crap to work well.
|
||||
tauri::api::shell::open(&app.shell_scope(), auth_uri.secret(), None)
|
||||
.map_err(|e| InvokeError::from_anyhow(e.into()))?;
|
||||
// TODO: find a better way to share this value with tauri e2e tests
|
||||
// Here we're using an env var to enable the /tmp file (windows not supported for now)
|
||||
// and bypass the shell::open call as it fails on GitHub Actions.
|
||||
let e2e_tauri_enabled = env::var("E2E_TAURI_ENABLED").is_ok();
|
||||
if (e2e_tauri_enabled) {
|
||||
println!(
|
||||
"E2E_TAURI_ENABLED is set, won't open {} externally",
|
||||
auth_uri.secret()
|
||||
);
|
||||
fs::write(
|
||||
"/tmp/kittycad_user_code",
|
||||
details.user_code().secret().to_string(),
|
||||
)
|
||||
.expect("Unable to write /tmp/kittycad_user_code file");
|
||||
} else {
|
||||
tauri::api::shell::open(&app.shell_scope(), auth_uri.secret(), None)
|
||||
.map_err(|e| InvokeError::from_anyhow(e.into()))?;
|
||||
}
|
||||
|
||||
// Wait for the user to login.
|
||||
let token = auth_client
|
||||
|
Reference in New Issue
Block a user