208 lines
6.2 KiB
Rust
208 lines
6.2 KiB
Rust
use makepad_widgets::makepad_test::{makepad_test, Selector, TestApp};
|
|
|
|
/// Skip test when NIGIG_TEST_MODE is not set (used for tests that need
|
|
/// the home screen to be visible, bypassing login).
|
|
fn require_test_mode() -> bool {
|
|
std::env::var("NIGIG_TEST_MODE").is_ok()
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn app_launches_and_shows_login_screen(app: TestApp) {
|
|
app.locator(Selector::id("login_button"))
|
|
.wait_visible();
|
|
app.locator(Selector::id("user_id_input"))
|
|
.wait_visible();
|
|
app.locator(Selector::id("password_input"))
|
|
.wait_visible();
|
|
app.locator(Selector::id("homeserver_input"))
|
|
.wait_visible();
|
|
app.locator(Selector::id("signup_button"))
|
|
.wait_visible();
|
|
app.locator(Selector::all().text_exact("Login to Robrix"))
|
|
.wait_visible();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn login_form_accepts_input(app: TestApp) {
|
|
app.locator(Selector::id("user_id_input"))
|
|
.wait_visible()
|
|
.fill("@testuser:matrix.org")
|
|
.wait_value("@testuser:matrix.org");
|
|
app.locator(Selector::id("password_input"))
|
|
.wait_visible()
|
|
.fill("my_password")
|
|
.wait_value("my_password");
|
|
app.locator(Selector::id("homeserver_input"))
|
|
.wait_visible()
|
|
.fill("matrix.example.com")
|
|
.wait_value("matrix.example.com");
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn show_password_toggle_works(app: TestApp) {
|
|
let pw = app.locator(Selector::id("password_input")).wait_visible();
|
|
let show_btn = app.locator(Selector::id("show_password_button")).wait_visible();
|
|
show_btn.click();
|
|
let hide_btn = app.locator(Selector::id("hide_password_button")).wait_visible();
|
|
hide_btn.click();
|
|
show_btn.wait_visible();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn login_with_empty_fields_shows_modal(app: TestApp) {
|
|
app.locator(Selector::id("login_button"))
|
|
.wait_visible()
|
|
.click();
|
|
app.locator(Selector::all().text_exact("Missing User ID"))
|
|
.wait_visible();
|
|
app.locator(Selector::id("login_status_modal_inner"))
|
|
.wait_visible();
|
|
app.locator(Selector::all().text_exact("Please enter a valid User ID."))
|
|
.wait_visible();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn login_with_password_only_shows_missing_user_id(app: TestApp) {
|
|
app.locator(Selector::id("password_input"))
|
|
.wait_visible()
|
|
.fill("some_password");
|
|
app.locator(Selector::id("login_button"))
|
|
.wait_visible()
|
|
.click();
|
|
app.locator(Selector::all().text_exact("Missing User ID"))
|
|
.wait_visible();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn login_with_user_id_only_shows_missing_password(app: TestApp) {
|
|
app.locator(Selector::id("user_id_input"))
|
|
.wait_visible()
|
|
.fill("@test:matrix.org");
|
|
app.locator(Selector::id("login_button"))
|
|
.wait_visible()
|
|
.click();
|
|
app.locator(Selector::all().text_exact("Missing Password"))
|
|
.wait_visible();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn login_status_modal_can_be_closed(app: TestApp) {
|
|
app.locator(Selector::id("login_button")).wait_visible().click();
|
|
let modal = app.locator(Selector::id("login_status_modal_inner")).wait_visible();
|
|
let close_btn = app.locator(Selector::widget_type("Button").text_exact("Okay")).wait_visible();
|
|
close_btn.click();
|
|
modal.wait_not_visible();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn signup_button_fires_correctly(app: TestApp) {
|
|
app.locator(Selector::id("signup_button"))
|
|
.wait_visible()
|
|
.click();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn sso_buttons_are_present(app: TestApp) {
|
|
let sso_providers = [
|
|
"apple_button",
|
|
"facebook_button",
|
|
"github_button",
|
|
"gitlab_button",
|
|
"google_button",
|
|
"twitter_button",
|
|
];
|
|
for provider_id in &sso_providers {
|
|
app.locator(Selector::id(provider_id)).wait_visible();
|
|
}
|
|
}
|
|
|
|
// ── Home screen tab tests (require NIGIG_TEST_MODE=1) ──
|
|
|
|
#[makepad_test]
|
|
fn home_screen_tab_buttons_visible_in_test_mode(app: TestApp) {
|
|
if !require_test_mode() {
|
|
return;
|
|
}
|
|
// Desktop nav rail buttons
|
|
app.locator(Selector::id("home_button")).wait_visible();
|
|
app.locator(Selector::id("chats_button")).wait_visible();
|
|
app.locator(Selector::id("shop_button")).wait_visible();
|
|
app.locator(Selector::id("mobility_button")).wait_visible();
|
|
app.locator(Selector::id("work_button")).wait_visible();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn home_screen_home_tab_active_by_default(app: TestApp) {
|
|
if !require_test_mode() {
|
|
return;
|
|
}
|
|
// Home tab should be visible and active
|
|
app.locator(Selector::id("home_button")).wait_visible();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn home_tab_switches_to_chats(app: TestApp) {
|
|
if !require_test_mode() {
|
|
return;
|
|
}
|
|
app.locator(Selector::id("chats_button"))
|
|
.wait_visible()
|
|
.click();
|
|
// After clicking Chats, the chats button should still be visible
|
|
app.locator(Selector::id("chats_button")).wait_visible();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn home_tab_switches_to_shop(app: TestApp) {
|
|
if !require_test_mode() {
|
|
return;
|
|
}
|
|
app.locator(Selector::id("shop_button"))
|
|
.wait_visible()
|
|
.click();
|
|
app.locator(Selector::id("shop_button")).wait_visible();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn home_tab_switches_to_mobility(app: TestApp) {
|
|
if !require_test_mode() {
|
|
return;
|
|
}
|
|
app.locator(Selector::id("mobility_button"))
|
|
.wait_visible()
|
|
.click();
|
|
app.locator(Selector::id("mobility_button")).wait_visible();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn home_tab_switches_to_work(app: TestApp) {
|
|
if !require_test_mode() {
|
|
return;
|
|
}
|
|
app.locator(Selector::id("work_button"))
|
|
.wait_visible()
|
|
.click();
|
|
app.locator(Selector::id("work_button")).wait_visible();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn home_sub_tabs_visible_in_test_mode(app: TestApp) {
|
|
if !require_test_mode() {
|
|
return;
|
|
}
|
|
// Mobile pull-up sheet sub-tabs
|
|
app.locator(Selector::id("home_content_tab_btn")).wait_visible();
|
|
app.locator(Selector::id("home_profile_tab_btn")).wait_visible();
|
|
app.locator(Selector::id("home_preferences_tab_btn")).wait_visible();
|
|
}
|
|
|
|
#[makepad_test]
|
|
fn home_sub_tab_profile_click(app: TestApp) {
|
|
if !require_test_mode() {
|
|
return;
|
|
}
|
|
app.locator(Selector::id("home_profile_tab_btn"))
|
|
.wait_visible()
|
|
.click();
|
|
app.locator(Selector::id("home_profile_tab_btn")).wait_visible();
|
|
}
|