mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-03-25 07:50:33 -05:00
Added "Always show task count on Kanban buckets" setting in user preferences to control the visibility of task counts on Kanban bucket headers
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import type {APIRequestContext} from '@playwright/test'
|
|
import {objectToSnakeCase} from '../../src/helpers/case'
|
|
|
|
export async function updateUserSettings(apiContext: APIRequestContext, token: string, settings: any) {
|
|
const apiUrl = process.env.API_URL || 'http://localhost:3456/api/v1'
|
|
|
|
const userResponse = await apiContext.get(`${apiUrl}/user`, {
|
|
headers: {
|
|
'Authorization': `Bearer ${token}`,
|
|
},
|
|
})
|
|
|
|
const userData = await userResponse.json()
|
|
// GET /user returns { settings: { frontend_settings: ... }, ... }
|
|
// POST /user/settings/general expects { frontend_settings: ... } at the top level
|
|
const oldSettings = userData.settings || {}
|
|
|
|
const snakeSettings = objectToSnakeCase(settings)
|
|
|
|
// Deep merge frontend_settings if provided
|
|
const mergedSettings = {
|
|
...oldSettings,
|
|
...snakeSettings,
|
|
}
|
|
|
|
if (snakeSettings.frontend_settings) {
|
|
mergedSettings.frontend_settings = {
|
|
...(oldSettings.frontend_settings || {}),
|
|
...snakeSettings.frontend_settings,
|
|
}
|
|
}
|
|
|
|
await apiContext.post(`${apiUrl}/user/settings/general`, {
|
|
headers: {
|
|
'Authorization': `Bearer ${token}`,
|
|
},
|
|
data: mergedSettings,
|
|
})
|
|
}
|