fix(settings): allow to clear twitter and fediverse

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/52489/head
Ferdinand Thiessen 2025-04-17 13:11:32 +07:00
parent 35dc74bc1a
commit 5c945560b1
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
3 changed files with 28 additions and 4 deletions

@ -19,7 +19,7 @@ import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.js'
import AccountPropertySection from './shared/AccountPropertySection.vue'
const { fediverse } = loadState<AccountProperties>('settings', 'personalInfoParameters', {})
const { fediverse } = loadState<AccountProperties>('settings', 'personalInfoParameters')
const value = ref({ ...fediverse })
const readable = NAME_READABLE_ENUM[fediverse.name]
@ -29,11 +29,18 @@ const readable = NAME_READABLE_ENUM[fediverse.name]
* @param text The potential fediverse handle
*/
function onValidate(text: string): boolean {
// allow to clear the value
if (text === '') {
return true
}
// check its in valid format
const result = text.match(/^@?([^@/]+)@([^@/]+)$/)
if (result === null) {
return false
}
// check its a valid URL
try {
return URL.parse(`https://${result[2]}/`) !== null
} catch {

@ -19,7 +19,7 @@ import { ref } from 'vue'
import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.ts'
import AccountPropertySection from './shared/AccountPropertySection.vue'
const { twitter } = loadState<AccountProperties>('settings', 'personalInfoParameters', {})
const { twitter } = loadState<AccountProperties>('settings', 'personalInfoParameters')
const value = ref({ ...twitter })
const readable = NAME_READABLE_ENUM[twitter.name]
@ -29,6 +29,6 @@ const readable = NAME_READABLE_ENUM[twitter.name]
* @param text The potential twitter handle
*/
function onValidate(text: string): boolean {
return text.match(/^@?([a-zA-Z0-9_]{2,15})$/) !== null
return text === '' || text.match(/^@?([a-zA-Z0-9_]{2,15})$/) !== null
}
</script>

@ -109,7 +109,7 @@ describe('Settings: Change personal information', { testIsolation: true }, () =>
before(() => {
// make sure the fediverse check does not do http requests
cy.runOccCommand('config:system:set has_internet_connection --value false')
cy.runOccCommand('config:system:set has_internet_connection --type bool --value false')
// ensure we can set locale and language
cy.runOccCommand('config:system:delete force_language')
cy.runOccCommand('config:system:delete force_locale')
@ -354,6 +354,23 @@ describe('Settings: Change personal information', { testIsolation: true }, () =>
inputForLabel('Phone number').should('have.value', '')
})
it('Can reset social media property', () => {
cy.contains('label', 'Fediverse').scrollIntoView()
inputForLabel('Fediverse').type('{selectAll}@nextcloud@mastodon.social')
handlePasswordConfirmation(user.password)
cy.wait('@submitSetting')
cy.reload()
inputForLabel('Fediverse').should('have.value', 'nextcloud@mastodon.social')
inputForLabel('Fediverse').clear()
handlePasswordConfirmation(user.password)
cy.wait('@submitSetting')
cy.reload()
inputForLabel('Fediverse').should('have.value', '')
})
it('Can set Website and change its visibility', () => {
cy.contains('label', 'Website').scrollIntoView()
// Check invalid input