feat(custom): CNY native billing, daily check-in button, subscription plans page, usage docs and promo banner
Based on QuantumNous/new-api v1.0.0-rc.36 (shallow history squashed). - CNY quota display mode: RMB-denominated top-up and crediting across Epay/Waffo channels - New CheckinButton in both authenticated and public headers (Turnstile supported) - New /subscribe page with public plan snapshot, Alipay/balance payment, auto group upgrade/reset - New /docs 12-section beginner guide with anchor navigation - New home PromoBanner linking to /docs; i18n synced (en/zh/zh-TW/fr/ja/ru/vi) - README: document custom features, live demo https://ai.88531.cn
This commit is contained in:
commit
14a9acd368
2368 files changed
+551035
No files matched your search
@@ -0,0 +1,65 @@
|
||||
package setting
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/QuantumNous/new-api/common"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func setupTaskPluginDisabledFactoryKeysTest(t *testing.T) {
|
||||
t.Helper()
|
||||
originalMap := common.OptionMap
|
||||
common.OptionMapRWMutex.Lock()
|
||||
common.OptionMap = map[string]string{}
|
||||
common.OptionMapRWMutex.Unlock()
|
||||
t.Cleanup(func() {
|
||||
common.OptionMapRWMutex.Lock()
|
||||
common.OptionMap = originalMap
|
||||
common.OptionMapRWMutex.Unlock()
|
||||
})
|
||||
}
|
||||
|
||||
func TestTaskPluginDisabledFactoryKeysRoundTripAndDedupe(t *testing.T) {
|
||||
setupTaskPluginDisabledFactoryKeysTest(t)
|
||||
|
||||
assert.Empty(t, GetTaskPluginDisabledFactoryKeys())
|
||||
assert.False(t, IsTaskPluginFactoryDisabled("kling"))
|
||||
|
||||
require.NoError(t, SetTaskPluginDisabledFactoryKeysOption([]string{"kling", "sora", "kling", " hailuo "}))
|
||||
assert.Equal(t, []string{"hailuo", "kling", "sora"}, GetTaskPluginDisabledFactoryKeys())
|
||||
assert.Equal(t, `["hailuo","kling","sora"]`, common.OptionMap[TaskPluginDisabledFactoryKeysKey])
|
||||
assert.True(t, IsTaskPluginFactoryDisabled("kling"))
|
||||
assert.True(t, IsTaskPluginFactoryDisabled("hailuo"))
|
||||
assert.False(t, IsTaskPluginFactoryDisabled("google"))
|
||||
}
|
||||
|
||||
func TestTaskPluginDisabledFactoryKeysBadJSONReturnsEmpty(t *testing.T) {
|
||||
setupTaskPluginDisabledFactoryKeysTest(t)
|
||||
|
||||
for _, testCase := range []struct {
|
||||
name string
|
||||
raw string
|
||||
}{
|
||||
{name: "absent", raw: ""},
|
||||
{name: "null", raw: "null"},
|
||||
{name: "object", raw: "{}"},
|
||||
{name: "number", raw: "1"},
|
||||
{name: "truncated", raw: `["kling"`},
|
||||
{name: "not json", raw: "kling"},
|
||||
} {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
common.OptionMapRWMutex.Lock()
|
||||
if testCase.raw == "" {
|
||||
delete(common.OptionMap, TaskPluginDisabledFactoryKeysKey)
|
||||
} else {
|
||||
common.OptionMap[TaskPluginDisabledFactoryKeysKey] = testCase.raw
|
||||
}
|
||||
common.OptionMapRWMutex.Unlock()
|
||||
|
||||
assert.Empty(t, GetTaskPluginDisabledFactoryKeys())
|
||||
assert.False(t, IsTaskPluginFactoryDisabled("kling"))
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user