test(app-iced, presenter): M114 出图补三个取证态(第三方站失败 / 离线失败 / 中文错误码)
- mock 增 `authlib-failed` 场景:AuthlibLoginChanged(Failed, NotAuthlibServer),原文只进日志 - `ULL_ACCOUNT_STATE=notice` 现在同时打开离线面板(截图能看到「表单 + 失败横幅」同屏) - 新增**截图专用**语言开关 `ULL_LANG=zh`(仅在 `--screenshot` 下生效):D30 要求错误码文案 中英各一张图,交互模式仍钉死 Lang::En(与产品行为一致)
This commit is contained in:
1 parent
9d0d985b1b
commit
73badb8a02
7 files changed
+128
-81
No files matched your search
@@ -37,6 +37,9 @@ pub mod widgets;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
#[cfg(test)]
|
||||
#[path = "account/tests_text.rs"]
|
||||
mod tests_text;
|
||||
|
||||
pub use model::{Form, Hint, Notice, Page, Panel, Track};
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ use unlucky_presenter::dto::{
|
||||
use unlucky_presenter::state::AppState;
|
||||
|
||||
use super::avatar::Cache;
|
||||
use super::login::failure_body_key;
|
||||
use super::model::{AuthlibPanel, DevicePanel, Form, Hint, Page, Panel, Track};
|
||||
use super::tests_text::{has_cjk, on_screen};
|
||||
|
||||
fn account(name: &str, kind: AccountKind, active: bool) -> AccountView {
|
||||
AccountView {
|
||||
@@ -37,84 +37,6 @@ fn build(state: &AppState, form: &Form) -> Page {
|
||||
Page::build(state, form, &mut Cache::default(), Lang::En, 1180.0)
|
||||
}
|
||||
|
||||
/// 页面**会画什么**:模型里的数据 + 视图层对码的 i18n 查表结果。
|
||||
fn on_screen(page: &Page) -> String {
|
||||
let catalog = Lang::En.catalog();
|
||||
let mut out = String::new();
|
||||
for row in &page.rows {
|
||||
out.push_str(&row.name);
|
||||
out.push_str(&row.monogram);
|
||||
out.push_str(&row.kind_label);
|
||||
out.push_str(&row.added);
|
||||
out.push_str(&row.detail);
|
||||
}
|
||||
out.push_str(&page.form.offline_name);
|
||||
out.push_str(&page.form.server);
|
||||
if let Some(notice) = &page.notice {
|
||||
// 与 `widgets::banner` 同源:码 → i18n(主题名拼进去)
|
||||
out.push_str(match notice.code {
|
||||
AccountNoticeCode::OfflineNameInvalid => {
|
||||
catalog.text(Key::AccountNoticeOfflineNameInvalid)
|
||||
}
|
||||
AccountNoticeCode::AccountExists => catalog.text(Key::AccountNoticeAccountExists),
|
||||
AccountNoticeCode::StoreFailed => catalog.text(Key::AccountNoticeStoreFailed),
|
||||
AccountNoticeCode::NotFound => catalog.text(Key::AccountNoticeNotFound),
|
||||
AccountNoticeCode::Other => catalog.text(Key::AccountNoticeOther),
|
||||
AccountNoticeCode::Added => catalog.text(Key::AccountNoticeAdded),
|
||||
AccountNoticeCode::Removed => catalog.text(Key::AccountNoticeRemoved),
|
||||
AccountNoticeCode::Switched => catalog.text(Key::AccountNoticeSwitched),
|
||||
});
|
||||
out.push_str(¬ice.subject);
|
||||
}
|
||||
if let Some(hint) = page.hint {
|
||||
out.push_str(match hint {
|
||||
Hint::AuthlibReauth => catalog.text(Key::AccountHintAuthlibReauth),
|
||||
Hint::OfflineNoRelogin => catalog.text(Key::AccountHintOfflineNoRelogin),
|
||||
});
|
||||
}
|
||||
match &page.device {
|
||||
DevicePanel::Hidden => {}
|
||||
DevicePanel::Requesting { .. } => out.push_str(catalog.text(Key::AccountDeviceRequesting)),
|
||||
DevicePanel::Code {
|
||||
code,
|
||||
link,
|
||||
remaining,
|
||||
expired,
|
||||
..
|
||||
} => {
|
||||
out.push_str(code);
|
||||
out.push_str(link);
|
||||
if *expired {
|
||||
out.push_str(catalog.text(Key::AccountDeviceExpired));
|
||||
} else if let Some(secs) = remaining {
|
||||
let clock = format!("{:02}:{:02}", secs / 60, secs % 60);
|
||||
out.push_str(&catalog.render(Key::AccountDeviceCountdown, &[("time", &clock)]));
|
||||
}
|
||||
}
|
||||
DevicePanel::Browser { link, .. } => out.push_str(link),
|
||||
DevicePanel::Failed { failure, .. } => {
|
||||
out.push_str(catalog.text(failure_body_key(*failure)));
|
||||
out.push_str(&catalog.render(Key::AccountFailureCode, &[("code", failure.code())]));
|
||||
}
|
||||
DevicePanel::Succeeded { name } => {
|
||||
out.push_str(&catalog.render(Key::AccountLoginSucceeded, &[("name", name)]));
|
||||
}
|
||||
}
|
||||
match &page.authlib {
|
||||
AuthlibPanel::Idle => {}
|
||||
AuthlibPanel::Running { .. } => out.push_str(catalog.text(Key::AccountServerChecking)),
|
||||
AuthlibPanel::Ready { server_name, .. } => out.push_str(server_name),
|
||||
AuthlibPanel::Failed { failure, .. } => out.push_str(failure.code()),
|
||||
AuthlibPanel::Succeeded { name } => out.push_str(name),
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// 有没有中日韩统一表意文字(语言泄漏的最直接判据)。
|
||||
fn has_cjk(text: &str) -> bool {
|
||||
text.chars().any(|c| matches!(c, '\u{3400}'..='\u{4DBF}' | '\u{4E00}'..='\u{9FFF}' | '\u{3000}'..='\u{303F}' | '\u{FF00}'..='\u{FFEF}'))
|
||||
}
|
||||
|
||||
const JWT: &str =
|
||||
"eyJhbGciOiJSUzI1NiIsIng1dCI6IkFCQyJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.c2lnbmF0dXJlLXZhbHVl";
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
//! 「**页面会画什么**」的取样器:把视图模型 + 视图层对码的 i18n 查表结果拼成一串。
|
||||
//!
|
||||
//! 为什么单独一个文件:`pages/account/tests.rs` 贴着 400 行硬线,而这段是**纯取样**
|
||||
//! (不给任何断言)——断言都在 `tests.rs` 里。语言泄漏(复审 r1 P1-1)与凭据红线两条判据
|
||||
//! 都依赖它:只有把「模型字段 + i18n 文案」一起取样,才能证明「英文界面里没有中文」。
|
||||
|
||||
use unlucky_i18n::{Key, Lang};
|
||||
use unlucky_presenter::dto::AccountNoticeCode;
|
||||
|
||||
use super::login::failure_body_key;
|
||||
use super::model::{AuthlibPanel, DevicePanel, Hint, Page};
|
||||
|
||||
/// 页面**会画什么**:模型里的数据 + 视图层对码的 i18n 查表结果。
|
||||
pub(super) fn on_screen(page: &Page) -> String {
|
||||
let catalog = Lang::En.catalog();
|
||||
let mut out = String::new();
|
||||
for row in &page.rows {
|
||||
out.push_str(&row.name);
|
||||
out.push_str(&row.monogram);
|
||||
out.push_str(&row.kind_label);
|
||||
out.push_str(&row.added);
|
||||
out.push_str(&row.detail);
|
||||
}
|
||||
out.push_str(&page.form.offline_name);
|
||||
out.push_str(&page.form.server);
|
||||
if let Some(notice) = &page.notice {
|
||||
// 与 `widgets::banner` 同源:码 → i18n(主题名拼进去)
|
||||
out.push_str(match notice.code {
|
||||
AccountNoticeCode::OfflineNameInvalid => {
|
||||
catalog.text(Key::AccountNoticeOfflineNameInvalid)
|
||||
}
|
||||
AccountNoticeCode::AccountExists => catalog.text(Key::AccountNoticeAccountExists),
|
||||
AccountNoticeCode::StoreFailed => catalog.text(Key::AccountNoticeStoreFailed),
|
||||
AccountNoticeCode::NotFound => catalog.text(Key::AccountNoticeNotFound),
|
||||
AccountNoticeCode::Other => catalog.text(Key::AccountNoticeOther),
|
||||
AccountNoticeCode::Added => catalog.text(Key::AccountNoticeAdded),
|
||||
AccountNoticeCode::Removed => catalog.text(Key::AccountNoticeRemoved),
|
||||
AccountNoticeCode::Switched => catalog.text(Key::AccountNoticeSwitched),
|
||||
});
|
||||
out.push_str(¬ice.subject);
|
||||
}
|
||||
if let Some(hint) = page.hint {
|
||||
out.push_str(match hint {
|
||||
Hint::AuthlibReauth => catalog.text(Key::AccountHintAuthlibReauth),
|
||||
Hint::OfflineNoRelogin => catalog.text(Key::AccountHintOfflineNoRelogin),
|
||||
});
|
||||
}
|
||||
match &page.device {
|
||||
DevicePanel::Hidden => {}
|
||||
DevicePanel::Requesting { .. } => out.push_str(catalog.text(Key::AccountDeviceRequesting)),
|
||||
DevicePanel::Code {
|
||||
code,
|
||||
link,
|
||||
remaining,
|
||||
expired,
|
||||
..
|
||||
} => {
|
||||
out.push_str(code);
|
||||
out.push_str(link);
|
||||
if *expired {
|
||||
out.push_str(catalog.text(Key::AccountDeviceExpired));
|
||||
} else if let Some(secs) = remaining {
|
||||
let clock = format!("{:02}:{:02}", secs / 60, secs % 60);
|
||||
out.push_str(&catalog.render(Key::AccountDeviceCountdown, &[("time", &clock)]));
|
||||
}
|
||||
}
|
||||
DevicePanel::Browser { link, .. } => out.push_str(link),
|
||||
DevicePanel::Failed { failure, .. } => {
|
||||
out.push_str(catalog.text(failure_body_key(*failure)));
|
||||
out.push_str(&catalog.render(Key::AccountFailureCode, &[("code", failure.code())]));
|
||||
}
|
||||
DevicePanel::Succeeded { name } => {
|
||||
out.push_str(&catalog.render(Key::AccountLoginSucceeded, &[("name", name)]));
|
||||
}
|
||||
}
|
||||
match &page.authlib {
|
||||
AuthlibPanel::Idle => {}
|
||||
AuthlibPanel::Running { .. } => out.push_str(catalog.text(Key::AccountServerChecking)),
|
||||
AuthlibPanel::Ready { server_name, .. } => out.push_str(server_name),
|
||||
AuthlibPanel::Failed { failure, .. } => out.push_str(failure.code()),
|
||||
AuthlibPanel::Succeeded { name } => out.push_str(name),
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// 有没有中日韩统一表意文字(语言泄漏的最直接判据)。
|
||||
pub(super) fn has_cjk(text: &str) -> bool {
|
||||
text.chars().any(|c| matches!(c, '\u{3400}'..='\u{4DBF}' | '\u{4E00}'..='\u{9FFF}' | '\u{3000}'..='\u{303F}' | '\u{FF00}'..='\u{FFEF}'))
|
||||
}
|
||||
Reference in new issue
Block a user