进行了一些小修复

This commit is contained in:
kate522 committed 2026-08-26 18:25:42 +08:00
1 parent 7c0c21e984
commit ee4e599f2d
13 files changed
+496 -75

No files matched your search

+20
View File
@@ -86,6 +86,26 @@ final class FrontSubmitPayTest extends TestCase {
self::assertSame('0.00', $meta['vip2_price']);
}
public function test_download_resource_modal_fields_are_sanitized_as_one_payload(): void {
$downloads = DomainModel::sanitize_downloads([
[
'url' => 'https://example.com/file.zip',
'label' => '<b>镜像下载</b>',
'extract_code' => ' 提取码:1234 ',
'copy_key' => '<i>提取码</i>',
'copy_val' => ' 1234 ',
'class' => 'jb-blue',
],
]);
self::assertCount(1, $downloads);
self::assertSame('镜像下载', $downloads[0]['label']);
self::assertSame('提取码:1234', $downloads[0]['extract_code']);
self::assertSame('提取码', $downloads[0]['copy_key']);
self::assertSame('1234', $downloads[0]['copy_val']);
self::assertSame('jb-blue', $downloads[0]['class']);
}
private function settings(bool $vip1_enabled, bool $vip2_enabled): array {
return [
'pay_free_s' => true,
@@ -49,6 +49,32 @@ test('front submit follows the reference newposts shell and cards', () => {
assert.match(submit, /new-posts-submit/);
});
test('front submit paid resources use the reference modal editor and compact list', () => {
const page = read('templates/pages/page-submit.php');
const pay = read('templates/parts/submit/sidebar-pay.php');
const submit = read('assets/js/front-submit.js');
const downloads = read('assets/js/front-submit-pay-download.js');
const model = read('src/Core/DomainModel.php');
assert.match(page, /aksrt-front-submit-pay-download/);
assert.match(submit, /aksrtSubmitPayDownloads\.init/);
assert.match(pay, /data-pay-download-add/);
assert.match(pay, /data-pay-download-edit/);
assert.match(pay, /data-pay-download-remove/);
assert.match(pay, /class="hidden-input"/);
assert.doesNotMatch(pay, /data-pay-download-upload|data-pay-download-tpl/);
['url', 'extract_code', 'copy_key', 'copy_val', 'label', 'class'].forEach((field) => {
assert.match(downloads, new RegExp(`['"]${field}['"]`));
assert.match(model, new RegExp(`['"]${field}['"]`));
});
assert.match(downloads, /pay-dawnload-edit-modal/);
assert.match(downloads, /data-pay-resource-upload/);
assert.match(downloads, /data-pay-resource-classes/);
assert.match(downloads, /提取码\|密码/);
assert.doesNotMatch(downloads, /shop|forum|bbs_/i);
});
test('front submit image and visibility actions live in the TinyMCE toolbar', () => {
const main = read('templates/parts/submit/editor-main.php');
const page = read('templates/pages/page-submit.php');
+3 -2
View File
@@ -370,7 +370,8 @@ test('settings actions use rehydrated fixed-id notyf flows', () => {
test('front submit actions use direct fixed-id notyf flows', () => {
const submit = read('assets/js/front-submit.js');
const editor = read('assets/js/front-submit-editor.js');
const source = submit + '\n' + editor;
const downloads = read('assets/js/front-submit-pay-download.js');
const source = submit + '\n' + editor + '\n' + downloads;
const page = read('templates/pages/page-submit.php');
[
@@ -399,7 +400,7 @@ test('front submit actions use direct fixed-id notyf flows', () => {
assert.match(submit, new RegExp("notyf\\([^;]+?'danger'[^;]+?" + variable + "\\);"));
});
assert.match(submit, /aksrt-front-submit-resource-upload-toast[\s\S]*?'load'[\s\S]*?'success'[\s\S]*?'danger'/);
assert.match(downloads, /aksrt-front-submit-resource-upload-toast[\s\S]*?'load'[\s\S]*?'success'[\s\S]*?'danger'/);
assert.match(editor, /aksrt-front-submit-editor-media-toast[\s\S]*?'load'[\s\S]*?'success'[\s\S]*?'danger'/);
assert.match(submit, /aksrt-front-submit-ai-tags-toast[\s\S]*?aksrt-front-submit-ai-summary-toast[\s\S]*?'load'[\s\S]*?'success'[\s\S]*?'danger'/);
assert.match(submit, /needContent[^;]+?'warning'/);