- Add the event results page with schedule, rankings, Battle bracket, athletes, records, bilingual labels, and navigation entry. - Add the read/write competition data service, a complete Excel example, empty public state, and validation smoke tests. - Handle Furion statusCode/data responses from the production API and retain static fallback for the public page. - Document Docker sidecar deployment beside test_eventapi, persistent storage, private admin access, Nginx routing, and OSS asset rewriting. Verification: - node server/competition-api.smoke.mjs - node scripts/competition-response-test.mjs - node scripts/battle-layout-test.mjs - npm run build -- --base=https://assets.example.test/static/test/ - npm run rewrite:oss -- https://assets.example.test/static/test/ - Production /api/competition/state returned HTTP 200 after the sidecar started. Deployment note: publish the updated YD-WEB static build before public results can consume the unwrapped API response. The event remains unpublished until an administrator saves and publishes data.
19 lines
726 B
JavaScript
19 lines
726 B
JavaScript
import assert from 'node:assert/strict';
|
|
import { unwrapCompetitionState } from '../src/data/competition-response.js';
|
|
|
|
const state = {
|
|
published: true,
|
|
competition: {},
|
|
notice: {},
|
|
schedule: { items: [] },
|
|
results: { overall: [], challenge: [], battle: [] },
|
|
players: [],
|
|
records: [],
|
|
};
|
|
|
|
assert.deepEqual(unwrapCompetitionState(state), state);
|
|
assert.deepEqual(unwrapCompetitionState({ statusCode: 200, data: JSON.stringify(state) }), state);
|
|
assert.throws(() => unwrapCompetitionState({ statusCode: 502, errors: '上游连接失败' }), /上游连接失败/);
|
|
assert.throws(() => unwrapCompetitionState({ statusCode: 200, data: '{}' }), /结构不正确/);
|
|
console.log('Competition response parsing passed');
|