/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see
正文
', related: [], }, ], }, }; } test('save validation requires an article even when default categories exist', () => { assert.deepEqual(model.validateSettings(validValues()), {}); for (const insights of [ model.emptySettings().insights, { categories: [], articles: [] }, ]) { assert.deepEqual(model.validateSettings({ ...validValues(), insights }), { insights: '请完善动态与洞察的配置', }); } const invalid = validValues(); invalid.insights.articles[0].body = ''; assert.ok(model.validateSettings(invalid).insights); }); test('saving incomplete insights cannot send uploads or a configuration write', async () => { const requests = []; const api = await loadFrontendModule( new URL('../../src/pages/WebsiteSettings/settingsApi.js', import.meta.url), { '../../helpers/websiteApi': { requestWebsite: async (...args) => requests.push(args), }, './model': model, '../../components/common/ui/richTextImages': richTextImages, }, ); await assert.rejects( api.saveWebsiteSettings( model.serializeSettings({ ...validValues(), insights: model.emptySettings().insights, }), ), /请完整填写并检查官网设置/, ); assert.deepEqual(requests, []); await api.saveWebsiteSettings(model.serializeSettings(validValues())); assert.equal(requests.length, 1); assert.equal(requests[0][0], 'post'); assert.equal(requests[0][1], '/api/website/page-config'); });