Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
287f2f56
Commit
287f2f56
authored
Apr 21, 2026
by
IanShaw027
Browse files
Show embedded avatar preview after selection
parent
525a3204
Changes
2
Show whitespace changes
Inline
Side-by-side
frontend/src/components/user/profile/ProfileAvatarCard.vue
View file @
287f2f56
...
...
@@ -14,11 +14,13 @@
<div
:class=
"props.embedded ? 'space-y-3' : 'flex flex-col gap-5 px-6 py-6 sm:flex-row sm:items-start'"
>
<div
v-if=
"!props.embedded"
class=
"flex h-24 w-24 shrink-0 items-center justify-center overflow-hidden rounded-2xl bg-gradient-to-br from-primary-500 to-primary-600 text-3xl font-bold text-white shadow-lg shadow-primary-500/20"
:class=
"props.embedded
? 'flex h-16 w-16 shrink-0 items-center justify-center overflow-hidden rounded-2xl bg-gradient-to-br from-primary-500 to-primary-600 text-xl font-bold text-white shadow-lg shadow-primary-500/20'
: 'flex h-24 w-24 shrink-0 items-center justify-center overflow-hidden rounded-2xl bg-gradient-to-br from-primary-500 to-primary-600 text-3xl font-bold text-white shadow-lg shadow-primary-500/20'"
>
<img
v-if=
"avatarPreviewUrl"
data-testid=
"profile-avatar-preview"
:src=
"avatarPreviewUrl"
:alt=
"displayName"
class=
"h-full w-full object-cover"
...
...
frontend/src/components/user/profile/__tests__/ProfileAvatarCard.spec.ts
View file @
287f2f56
...
...
@@ -208,6 +208,35 @@ describe('ProfileAvatarCard', () => {
expect
(
showErrorMock
).
not
.
toHaveBeenCalled
()
})
it
(
'
shows a preview after selecting an avatar in embedded mode
'
,
async
()
=>
{
installAvatarCompressionMocks
()
authStoreState
.
user
=
createUser
()
const
wrapper
=
mount
(
ProfileAvatarCard
,
{
props
:
{
user
:
authStoreState
.
user
,
embedded
:
true
},
global
:
{
stubs
:
{
Icon
:
true
}
}
})
const
fileInput
=
wrapper
.
get
(
'
[data-testid="profile-avatar-file-input"]
'
)
Object
.
defineProperty
(
fileInput
.
element
,
'
files
'
,
{
value
:
[
new
File
([
new
Uint8Array
(
220
*
1024
)],
'
avatar.png
'
,
{
type
:
'
image/png
'
})],
configurable
:
true
})
await
fileInput
.
trigger
(
'
change
'
)
await
flushAsyncWork
()
const
preview
=
wrapper
.
get
(
'
[data-testid="profile-avatar-preview"]
'
)
expect
(
preview
.
attributes
(
'
src
'
)).
toBe
(
'
data:image/webp;base64,Y29tcHJlc3NlZC1hdmF0YXI=
'
)
})
it
(
'
deletes the current avatar
'
,
async
()
=>
{
const
updatedUser
=
createUser
({
avatar_url
:
null
})
updateProfileMock
.
mockResolvedValue
(
updatedUser
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment