test: check avatar loading for all providers

This commit is contained in:
kolaente 2025-06-14 17:36:59 +02:00
parent 719cb11d44
commit 8d026821e5
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
1 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,38 @@
import {UserFactory, type UserAttributes} from '../../factories/user'
import {login} from '../../support/authenticateUser'
const avatarProviders = ['initials', 'gravatar', 'marble', 'upload', 'ldap'] as const
describe('User avatars', () => {
avatarProviders.forEach(provider => {
describe(`Avatar provider ${provider}`, () => {
let user: UserAttributes
beforeEach(() => {
const overrides: Partial<UserAttributes & {avatar_provider?: string; avatar_file_id?: number; email?: string}> = {
username: `user_${provider}`,
avatar_provider: provider,
}
if (provider === 'gravatar') {
overrides.email = `user_${provider}@example.com`
}
if (provider === 'upload' || provider === 'ldap') {
overrides.avatar_file_id = 1
}
user = UserFactory.create(1, overrides)[0] as UserAttributes
login(user)
})
it('Shows the avatar image', () => {
cy.visit('/')
cy.get('.username-dropdown-trigger img.avatar')
.should('be.visible')
.and(($img) => {
expect($img[0].naturalWidth).to.be.greaterThan(0)
})
})
})
})
})