feat(admin): upgrade invite code management with dialogs
Replace standalone add and export views with accessible dialogs, refine list interactions, and remove obsolete paths and unused counts. Fix filtered totals and reject oversized imports without truncation, with regression coverage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1cd19434d1
commit
a6776ffe0a
8 files changed
+884
-400
No files matched your search
@@ -59,20 +59,25 @@ test('invite-code surfaces: form field, admin page, menus and both schemas', ()
|
||||
assert.match(template, /name="invite_code"/)
|
||||
assert.match(template, /get_invite_code_registration_settings/)
|
||||
|
||||
// 管理页为服务端渲染三视图(列表/添加/导出),通过 page-title-action 切换。
|
||||
const page = read('src', 'Admin', 'Native', 'UsersMenusInviteCode.php')
|
||||
const forms = read('src', 'Admin', 'Native', 'UsersMenusInviteForms.php')
|
||||
assert.match(page, /render_invite_codes_page/)
|
||||
assert.match(page, /page-title-action/)
|
||||
assert.match(page, /use UsersMenusInviteForms;/)
|
||||
assert.match(page, /render_invite_codes_list\(\$service, \$this_url, \$nonce\)/)
|
||||
assert.match(page, /render_invite_codes_add\(\$nonce\)/)
|
||||
assert.match(page, /render_invite_codes_export\(\$nonce\)/)
|
||||
assert.match(page, /subsubsub/)
|
||||
assert.match(page, /data-clipboard-text/)
|
||||
assert.match(page, /orderby-but/)
|
||||
assert.match(page, /bulk_action/)
|
||||
assert.match(page, /aksrt_invite_delete/)
|
||||
assert.match(page, /aksrt_invite_add/)
|
||||
assert.match(page, /aksrt_invite_export/)
|
||||
assert.match(page, /paginate_links/)
|
||||
assert.match(page, /aksrt_invite_delete/)
|
||||
assert.match(forms, /aksrt_invite_add/)
|
||||
assert.match(forms, /aksrt_invite_export/)
|
||||
// 列表内不再有列表/添加/导出三视图路由;状态筛选仍是独立的列表筛选器。
|
||||
assert.doesNotMatch(page + forms, /page-title-action|[?&](?:tab|view)=(?:add|export)|tab=(?:list|add|export)/)
|
||||
// 管理页不再依赖 REST 与 wp_rest nonce。
|
||||
assert.doesNotMatch(page, /wp_rest|\$\{endpoint\}/)
|
||||
assert.doesNotMatch(page + forms, /wp_rest|\$\{endpoint\}/)
|
||||
|
||||
const menus = read('src', 'Admin', 'Native', 'UsersMenus.php')
|
||||
assert.match(menus, /use UsersMenusInviteCode/)
|
||||
@@ -121,15 +126,19 @@ test('import accepts Zibll-compatible lines with per-code rewards', () => {
|
||||
assert.match(service, /level_integral/)
|
||||
assert.match(service, /vip_time/)
|
||||
assert.match(service, /in_array\(\$reward, \['无', 'none', '0'\]/)
|
||||
// 单次导入上限与重复码不计入成功。
|
||||
assert.match(service, /array_slice\(preg_split\('\/\\r\\n\|\\r\|\\n\/', \$raw\) \?: \[\], 0, 1000\)/)
|
||||
// 空行先剔除,超过 1000 个非空行时拒绝,而不是静默截断。
|
||||
assert.match(service, /array_filter\(array_map\('trim', \$lines\), static fn\(\$line\) => \$line !== ''\)/)
|
||||
assert.match(service, /count\(\$lines\) > 1000/)
|
||||
assert.doesNotMatch(service, /array_slice\(preg_split\('\/\\r\\n\|\\r\|\\n\/', \$raw\) \?: \[\], 0, 1000\)/)
|
||||
const adminScript = read('assets', 'js', 'admin-invite-codes.js')
|
||||
assert.match(adminScript, /split\(\/\\r\\n\|\\r\|\\n\/\)\.filter\(function \(line\) \{ return line\.trim\(\) !== ''; \}\)/)
|
||||
assert.match(service, /\$exists !== null/)
|
||||
assert.match(service, /\$failed_codes\[\] = \$code/)
|
||||
// 导入走添加视图表单提交(add_type=import),textarea + 分隔符。
|
||||
const page = read('src', 'Admin', 'Native', 'UsersMenusInviteCode.php')
|
||||
assert.match(page, /name="import_data"/)
|
||||
assert.match(page, /name="import_division"/)
|
||||
assert.match(page, /name="add_type"/)
|
||||
// 导入表单由独立 Forms trait 渲染,并走添加操作的 add_type=import。
|
||||
const forms = read('src', 'Admin', 'Native', 'UsersMenusInviteForms.php')
|
||||
assert.match(forms, /name="import_data"/)
|
||||
assert.match(forms, /name="import_division"/)
|
||||
assert.match(forms, /name="add_type"/)
|
||||
})
|
||||
|
||||
test('per-code remark persists through generate/import and both exports round-trip', () => {
|
||||
@@ -151,10 +160,11 @@ test('per-code remark persists through generate/import and both exports round-tr
|
||||
assert.match(service, /__\('邀请码', 'aksrt'\), __\('使用奖励', 'aksrt'\)/)
|
||||
assert.match(service, /\$used > 0 \? __\('已使用', 'aksrt'\) : __\('未使用', 'aksrt'\)/)
|
||||
|
||||
const forms = read('src', 'Admin', 'Native', 'UsersMenusInviteForms.php')
|
||||
// 自动生成标识字段默认 invita_YmdHis;列表标识列可点击定位。
|
||||
assert.match(forms, /name="auto_remarks"/)
|
||||
assert.match(forms, /invita_' \. current_time\('YmdHis'\)/)
|
||||
const page = read('src', 'Admin', 'Native', 'UsersMenusInviteCode.php')
|
||||
// 添加表单标识字段(默认 invita_YmdHis);列表标识列可点击定位。
|
||||
assert.match(page, /name="auto_remarks"/)
|
||||
assert.match(page, /invita_' \. current_time\('YmdHis'\)/)
|
||||
assert.match(page, /add_query_arg\('remark', \$item\['remark'\], \$this_url\)/)
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user