fix(auth): rename credential file labels and highlight enable action
- Use credential-file terminology in Simplified and Traditional Chinese - Highlight the Enable button for disabled credentials without dimming actions - Add regression tests for terminology and button styling
This commit is contained in:
1 parent
82268cfa6f
commit
0e5b4b00ad
8 files changed
+61
-26
No files matched your search
@@ -4,6 +4,18 @@ import { en, ja, zhCN, zhTW, type MessageKey } from '../src/i18n/resources';
|
||||
import { jaOverrides } from '../src/i18n/ja';
|
||||
|
||||
describe('i18n', () => {
|
||||
it('uses credential-file terminology throughout both Chinese locales', () => {
|
||||
for (const key of ['app.nav.authFiles', 'authFiles.title'] as const) {
|
||||
expect(translate('zh-CN', key)).toBe('凭证文件');
|
||||
expect(translate('zh-TW', key)).toBe('憑證檔案');
|
||||
}
|
||||
expect(translate('zh-CN', 'authFiles.uploaded', { count: 2 })).toBe('已上传 2 个凭证文件');
|
||||
expect(translate('zh-TW', 'authFiles.uploaded', { count: 2 })).toBe('已上傳 2 個憑證檔案');
|
||||
expect(translate('zh-CN', 'quota.fileDisabled')).toBe('凭证文件已停用');
|
||||
expect(Object.values(zhCN).filter((message) => message.includes('认证文件'))).toEqual([]);
|
||||
expect(Object.values(zhTW).filter((message) => /認證(?:檔案|文件)/.test(message))).toEqual([]);
|
||||
});
|
||||
|
||||
it('normalizes English variants and keeps Chinese as the fallback', () => {
|
||||
expect(normalizeLocale('en-US')).toBe('en');
|
||||
expect(normalizeLocale('en')).toBe('en');
|
||||
|
||||
@@ -37,10 +37,32 @@ describe('控件自身反馈', () => {
|
||||
expect(nonEmptyCalls[0].arguments[1].getText()).toBe("'error'");
|
||||
});
|
||||
|
||||
it('认证文件的启用停用由按钮与状态标签反馈', () => {
|
||||
it('凭证文件的启用停用由按钮与状态标签反馈', () => {
|
||||
expect(actionCalls('AuthFileManagementPage.tsx', 'toggleStatus', 'showNotice').calls).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('停用凭证的启用按钮使用主题高亮,停用操作仍使用次要样式', () => {
|
||||
const file = 'AuthFileManagementPage.tsx';
|
||||
const source = ts.createSourceFile(file, readFileSync(new URL(`../src/pages/${file}`, import.meta.url), 'utf8'), ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
||||
let button: ts.JsxOpeningElement | undefined;
|
||||
const visit = (node: ts.Node) => {
|
||||
if (ts.isJsxOpeningElement(node) && node.tagName.getText(source) === 'button'
|
||||
&& node.attributes.properties.some((attribute) => ts.isJsxAttribute(attribute)
|
||||
&& attribute.name.getText(source) === 'onClick'
|
||||
&& attribute.initializer?.getText(source).includes('toggleStatus(file)'))) button = node;
|
||||
ts.forEachChild(node, visit);
|
||||
};
|
||||
visit(source);
|
||||
const attributes = button?.attributes.properties.filter(ts.isJsxAttribute);
|
||||
expect(attributes?.find((attribute) => attribute.name.getText(source) === 'className')?.initializer?.getText(source))
|
||||
.toBe("{`${disabled ? 'primary-button' : 'secondary-button'} compact-button`}");
|
||||
expect(attributes?.find((attribute) => attribute.name.getText(source) === 'disabled')?.initializer?.getText(source))
|
||||
.toBe('{busy}');
|
||||
const styles = readFileSync(new URL('../src/styles.css', import.meta.url), 'utf8');
|
||||
expect(styles).toMatch(/\.real-auth-file-row\.disabled\s*>\s*:not\(\.auth-file-actions\)\s*\{\s*opacity:\s*0\.68;/);
|
||||
expect(styles).not.toMatch(/\.real-auth-file-row\.disabled\s*\{[^}]*opacity:/);
|
||||
});
|
||||
|
||||
it('开关切换只后台刷新数据,不卸载整张列表和焦点控件', () => {
|
||||
for (const [file, action, callback] of [
|
||||
['ApiAccessPage.tsx', 'toggleProvider', 'loadProviders'],
|
||||
|
||||
Reference in new issue
Block a user