feat: 版本号按分支轨道分开管理,版本号配置收归管理员
master/develop 共用 release 轨(App_Store 打包构建号自增),feature 分支走
feature 轨(构建号永不自增,始终使用手填值),两条轨道的 App_Ver 各自独立。
- versions 改为 tracks 结构,旧的单轨/单值配置在加载时自动迁移进 release 轨
- 新增 config["branch_track"] 记录分支归属,缺省按分支名推断,可在分支管理页改
- 新增 PUT /api/config/branches/track;分支名含 / 时走请求体而非路径参数
- 修复 DELETE /api/config/branches/{name} 无法删除含 / 的分支(405)
- 版本号接口不再对普通用户开放,打包设置页整页改为管理员可见
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,15 @@ function mockFetch(url) {
|
||||
'/api/config/servers': { '测试环境': { api: 'https://test.com', assDom: '', universalLink: '' } },
|
||||
'/api/config/branches': ['main', 'dev'],
|
||||
'/api/config/build': { max_concurrent_builds: 2, build_dir_retention_hours: 24, build_base_dir: '/tmp' },
|
||||
'/api/config/versions': { app_ver: '2.195.0', build_ver: '2.195.0.0' },
|
||||
'/api/config/versions': {
|
||||
app_ver: '2.195.0',
|
||||
build_ver: '2.195.0.0',
|
||||
tracks: {
|
||||
release: { app_ver: '2.195.0', build_ver: '2.195.0.0', build_map: {} },
|
||||
feature: { app_ver: '2.100.0', build_ver: '2.100.0.0', build_map: {} },
|
||||
},
|
||||
branch_track: { main: 'release', dev: 'release' },
|
||||
},
|
||||
'/api/config': { apps: {}, schemes: {}, branches: ['main'] },
|
||||
}
|
||||
return Promise.resolve({
|
||||
@@ -168,20 +176,76 @@ describe('ConfigView.vue', () => {
|
||||
expect(window.alert).toHaveBeenCalledWith('设置已保存')
|
||||
})
|
||||
|
||||
it('普通账号可修改版本号但看不到打包参数', async () => {
|
||||
it('普通账号只能管理 Apps,看不到打包设置与版本号', async () => {
|
||||
const wrapper = mountConfigView({ admin: false })
|
||||
await flushPromises()
|
||||
|
||||
const menuTexts = wrapper.findAll('.sidebar-menu li').map(li => li.text())
|
||||
expect(menuTexts).toEqual(['Apps 配置', '打包设置'])
|
||||
expect(menuTexts).toEqual(['Apps 配置'])
|
||||
|
||||
expect(wrapper.text()).not.toContain('上架版本号')
|
||||
expect(wrapper.text()).not.toContain('自测版本号')
|
||||
expect(wrapper.text()).not.toContain('打包参数')
|
||||
// 版本号接口为管理员专属,普通账号不再请求
|
||||
expect(fetch).not.toHaveBeenCalledWith('/api/config/versions', expect.anything())
|
||||
expect(fetch.mock.calls.map(c => c[0])).toEqual(['/api/config/apps'])
|
||||
})
|
||||
|
||||
it('两条版本轨道各自独立展示与保存', async () => {
|
||||
const calls = []
|
||||
fetch.mockImplementation((url, opts) => {
|
||||
if (url === '/api/config/versions' && opts?.method === 'PUT') {
|
||||
calls.push(JSON.parse(opts.body))
|
||||
return Promise.resolve({
|
||||
ok: true,
|
||||
json: () => Promise.resolve({ app_ver: '2.101.0', build_ver: '2.101.0.0' }),
|
||||
})
|
||||
}
|
||||
return mockFetch(url)
|
||||
})
|
||||
window.alert = vi.fn()
|
||||
|
||||
const wrapper = mountConfigView()
|
||||
await flushPromises()
|
||||
|
||||
const buildMenu = wrapper.findAll('.sidebar-menu li').find(li => li.text() === '打包设置')
|
||||
await buildMenu.trigger('click')
|
||||
await wrapper.vm.$nextTick()
|
||||
|
||||
expect(wrapper.text()).toContain('应用版本号')
|
||||
expect(wrapper.text()).not.toContain('打包参数')
|
||||
// 非管理员在打包设置页可见 App_Ver 与 Build_Ver 两个输入框
|
||||
expect(wrapper.findAll('input').length).toBe(2)
|
||||
const inputs = wrapper.findAll('input[type="text"]')
|
||||
expect(inputs[0].element.value).toBe('2.195.0') // release App_Ver
|
||||
expect(inputs[2].element.value).toBe('2.100.0') // feature App_Ver
|
||||
|
||||
await inputs[2].setValue('2.101.0')
|
||||
const saveBtn = wrapper.findAll('.btn-primary').find(b => b.text() === '保存自测版本号')
|
||||
await saveBtn.trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(calls).toEqual([{ track: 'feature', app_ver: '2.101.0', build_ver: '2.101.0.0' }])
|
||||
})
|
||||
|
||||
it('分支管理可切换版本轨道', async () => {
|
||||
const calls = []
|
||||
fetch.mockImplementation((url, opts) => {
|
||||
if (url === '/api/config/branches/track' && opts?.method === 'PUT') {
|
||||
calls.push(JSON.parse(opts.body))
|
||||
return Promise.resolve({ ok: true, json: () => Promise.resolve({ message: 'ok' }) })
|
||||
}
|
||||
return mockFetch(url)
|
||||
})
|
||||
|
||||
const wrapper = mountConfigView()
|
||||
await flushPromises()
|
||||
|
||||
const branchesMenu = wrapper.findAll('.sidebar-menu li').find(li => li.text() === '分支管理')
|
||||
await branchesMenu.trigger('click')
|
||||
await wrapper.vm.$nextTick()
|
||||
|
||||
const select = wrapper.find('.config-table select')
|
||||
expect(select.element.value).toBe('release')
|
||||
await select.setValue('feature')
|
||||
await flushPromises()
|
||||
|
||||
expect(calls).toEqual([{ branch: 'main', track: 'feature' }])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user