Merge pull request #52489 from nextcloud/backport/52250/stable30

[stable30] fix(settings): allow to clear twitter and fediverse
This commit is contained in:
Ferdinand Thiessen 2025-04-29 11:39:24 +02:00 committed by GitHub
commit e08ffe2187
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 31 additions and 7 deletions

View file

@ -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 {

View file

@ -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>

View file

@ -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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long