Skip to content

Commit 0b146ff

Browse files
Add smoketest for login --token fix
Verifies that `spacetime login --token <token>` exits immediately after saving the token, without falling through to the interactive web login flow. Without the fix, this test would hang or fail in CI.
1 parent 241d543 commit 0b146ff

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use spacetimedb_smoketests::Smoketest;
2+
3+
/// Test that `spacetime login --token <token>` exits immediately after saving
4+
/// the token, without falling through to the interactive web login flow.
5+
///
6+
/// Without the fix in PR #4579, the command would fall through to the web
7+
/// login flow, which tries to open a browser and fails in CI.
8+
#[test]
9+
fn test_login_with_token_does_not_fallthrough() {
10+
let test = Smoketest::builder()
11+
.autopublish(false)
12+
.build();
13+
14+
// A dummy token that won't decode to a valid identity.
15+
let output = test.spacetime_cmd(&["login", "--token", "test-dummy-token"]);
16+
let stdout = String::from_utf8_lossy(&output.stdout);
17+
let stderr = String::from_utf8_lossy(&output.stderr);
18+
19+
assert!(
20+
output.status.success(),
21+
"Expected `spacetime login --token` to succeed, but it failed.\nstdout: {stdout}\nstderr: {stderr}"
22+
);
23+
assert!(
24+
stdout.contains("Token saved."),
25+
"Expected 'Token saved.' in output, got: {stdout}"
26+
);
27+
}

crates/smoketests/tests/smoketests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod domains;
1818
mod fail_initial_publish;
1919
mod filtering;
2020
mod http_egress;
21+
mod login;
2122
mod logs_level_filter;
2223
mod module_nested_op;
2324
mod modules;

0 commit comments

Comments
 (0)