frontend/cypress/support/updateUserSettings.js
konrad efed128f03 fix: rely on api to properly sort tasks on home page (#1997)
This PR changes the behaviour of how tasks are sorted. Before, the frontend would sort tasks but this resulted in some cases where tasks were not sorted properly. Most of this is test code to reliably reproduce the problem and make fixing it easier.
The actual bug was in Vikunja's api, therefore I've removed all sorting of tasks in the frontend and ensured the api properly sorts tasks.

Fixes https://github.com/go-vikunja/frontend/issues/54

Depends on vikunja/api#1177

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: vikunja/frontend#1997
Reviewed-by: Dominik Pschenitschni <dpschen@noreply.kolaente.de>
2022-06-01 16:59:59 +00:00

26 lines
506 B
JavaScript

export function updateUserSettings(settings) {
const token = `Bearer ${window.localStorage.getItem('token')}`
return cy.request({
method: 'GET',
url: `${Cypress.env('API_URL')}/user`,
headers: {
'Authorization': token,
},
})
.its('body')
.then(oldSettings => {
return cy.request({
method: 'POST',
url: `${Cypress.env('API_URL')}/user/settings/general`,
headers: {
'Authorization': token,
},
body: {
...oldSettings,
...settings,
},
})
})
}