You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.0 KiB
JavaScript
58 lines
2.0 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
|
|
const presentationUrl = new URL(
|
|
'../public/cloud/operation-presentation.js',
|
|
import.meta.url,
|
|
);
|
|
const { operationTitle } = await import(
|
|
`${presentationUrl.href}?test=${Date.now()}`
|
|
);
|
|
|
|
const translations = {
|
|
'common.operation.kind.service_compensation': 'Instance Availability Compensation',
|
|
'common.operation.action.shutdown': 'Shut Down',
|
|
'common.operation.kind.firewall_apply': 'Apply Firewall',
|
|
'common.operation.setting.hostname': 'Change Hostname',
|
|
'common.operation.setting.password': 'Reset root Password',
|
|
'common.operation.list_separator': ', ',
|
|
'common.tasks.fallback_title': 'Background Task',
|
|
'instance_detail.operation_log.category.instance': 'Instance Operation',
|
|
};
|
|
const text = key => translations[key] || key;
|
|
|
|
for (const [entry, expected] of [
|
|
[{
|
|
kind: 'service_compensation', kind_label: '实例可用时间补偿',
|
|
operation_copy_keys: ['common.operation.kind.service_compensation'],
|
|
}, 'Instance Availability Compensation'],
|
|
[{
|
|
kind: 'action', action: 'shutdown', kind_label: '关机', action_label: '关机',
|
|
operation_copy_keys: ['common.operation.action.shutdown'],
|
|
}, 'Shut Down'],
|
|
[{
|
|
kind: 'firewall_apply', kind_label: '应用防火墙',
|
|
operation_copy_keys: ['common.operation.kind.firewall_apply'],
|
|
}, 'Apply Firewall'],
|
|
]) {
|
|
const actual = operationTitle(
|
|
entry,
|
|
text,
|
|
'instance_detail.operation_log.category.instance',
|
|
);
|
|
assert.equal(actual, expected);
|
|
assert.doesNotMatch(actual, /[\u3400-\u9fff]/u);
|
|
}
|
|
|
|
assert.equal(operationTitle({
|
|
kind: 'instance_settings', kind_label: '修改主机名、重置 root 密码',
|
|
operation_copy_keys: [
|
|
'common.operation.setting.hostname',
|
|
'common.operation.setting.password',
|
|
],
|
|
}, text, 'instance_detail.operation_log.category.instance'),
|
|
'Change Hostname, Reset root Password');
|
|
|
|
assert.equal(operationTitle({
|
|
kind: 'unknown_internal_job', kind_label: '未知内部任务',
|
|
}, text, 'common.tasks.fallback_title'), 'Background Task');
|