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.
virt/web/tests/UserCopyFeedbackContractTes...

40 lines
1.8 KiB
JavaScript

import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
const root = new URL('../', import.meta.url);
const sources = new Map(await Promise.all([
'public/cloud/runtime.js',
'public/cloud/instances.js',
'public/cloud/detail.js',
'public/cloud/invoice-detail-runtime.js',
'public/theme/venix/js/user-home.js',
].map(async path => [path, await readFile(new URL(path, root), 'utf8')])));
for (const [path, source] of sources) {
assert.doesNotMatch(source, /已复制|复制成功|已复制到剪贴板/,
`${path} still displays a success message after copying.`);
}
const runtime = sources.get('public/cloud/runtime.js');
const instances = sources.get('public/cloud/instances.js');
const detail = sources.get('public/cloud/detail.js');
const invoice = sources.get('public/cloud/invoice-detail-runtime.js');
const account = sources.get('public/theme/venix/js/user-home.js');
assert.match(runtime, /t\('common\.error\.copy'\)/,
'Shared VM copy failures no longer explain how to recover.');
assert.match(instances, /t\('instances\.error\.copy_short'\)/,
'Instance-list copy failures no longer notify the user.');
assert.match(detail, /copyText\([^)]+\)[\s\S]{0,160}t\('common\.error\.copy'\)/,
'Instance-detail copy failures are no longer surfaced.');
assert.doesNotMatch(detail, /toast\(error\.message/,
'Instance-detail feedback exposed an untranslatable runtime error.');
assert.match(invoice, /t\('billing\.error\.copy'\)/,
'Invoice copy failures no longer explain how to recover.');
assert.doesNotMatch(invoice, /task\.error|payload\?\.(?:detail|message|msg|error)/,
'Invoice feedback exposed a raw backend error instead of stable copy.');
assert.match(account, /common\.copy\.failed/,
'Account-page copy failures are no longer surfaced.');
console.log('User copy actions stay silent on success and visible on failure.');