Fix 5 wrong API endpoints + stop swallowing JS errors in E2E
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 10s
Test / e2e-test (push) Successful in 4m24s

Endpoint fixes:
- AuditLog: /api/audit-logs → /api/audit-log
- BugTracker: /api/bugs → /api/bug-reports, create → /api/bug-report
- BugTracker: fix create body (content+priority, not title/description)
- MyDiary: /api/brand-settings → /api/brand
- MyDiary: /api/me/display-name → PUT /api/me
- RecipeSearch: /api/category-modules → /api/categories

Test improvements:
- Remove blanket uncaught:exception swallow (only ignore ResizeObserver)
- Add endpoint-parity.cy.js: intercept-based test that verifies correct
  API endpoints are called and wrong ones are NOT called

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-06 21:30:54 +00:00
parent cd65fd35be
commit 8443f1a564
6 changed files with 95 additions and 18 deletions

View File

@@ -188,7 +188,7 @@ function toggleComments(bug) {
async function loadBugs() {
try {
const res = await api('/api/bugs')
const res = await api('/api/bug-reports')
if (res.ok) {
bugs.value = await res.json()
}
@@ -200,14 +200,11 @@ async function loadBugs() {
async function createBug() {
if (!bugForm.title.trim()) return
try {
const res = await api('/api/bugs', {
const res = await api('/api/bug-report', {
method: 'POST',
body: JSON.stringify({
title: bugForm.title.trim(),
description: bugForm.description.trim(),
priority: bugForm.priority,
status: 'open',
reporter: auth.user.display_name || auth.user.username,
content: bugForm.title.trim() + (bugForm.description.trim() ? '\n' + bugForm.description.trim() : ''),
priority: bugForm.priority === 'urgent' ? 0 : bugForm.priority === 'high' ? 1 : 2,
}),
})
if (res.ok) {
@@ -226,7 +223,7 @@ async function createBug() {
async function updateStatus(bug, newStatus) {
const id = bug._id || bug.id
try {
const res = await api(`/api/bugs/${id}`, {
const res = await api(`/api/bug-reports/${id}`, {
method: 'PUT',
body: JSON.stringify({ status: newStatus }),
})
@@ -244,7 +241,7 @@ async function removeBug(bug) {
if (!ok) return
const id = bug._id || bug.id
try {
const res = await api(`/api/bugs/${id}`, { method: 'DELETE' })
const res = await api(`/api/bug-reports/${id}`, { method: 'DELETE' })
if (res.ok) {
bugs.value = bugs.value.filter(b => (b._id || b.id) !== id)
ui.showToast('已删除')
@@ -258,7 +255,7 @@ async function addComment(bug) {
if (!newComment.value.trim()) return
const id = bug._id || bug.id
try {
const res = await api(`/api/bugs/${id}/comments`, {
const res = await api(`/api/bug-reports/${id}/comments`, {
method: 'POST',
body: JSON.stringify({
text: newComment.value.trim(),