Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
07f2f285
Commit
07f2f285
authored
Sep 29, 2020
by
Christoph Scholz
Committed by
JC Brand
Oct 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue #2168
parent
383b6a27
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
13 deletions
+25
-13
spec/http-file-upload.js
spec/http-file-upload.js
+15
-5
spec/messages.js
spec/messages.js
+5
-4
src/utils/html.js
src/utils/html.js
+5
-4
No files found.
spec/http-file-upload.js
View file @
07f2f285
...
...
@@ -224,7 +224,9 @@ describe("XEP-0363: HTTP File Upload", function () {
describe
(
"
when clicked and a file chosen
"
,
function
()
{
it
(
"
is uploaded and sent out
"
,
mock
.
initConverse
(
async
(
done
,
_converse
)
=>
{
it
(
"
is uploaded and sent out
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{}
,
async
(
done
,
_converse
)
=>
{
const
base_url
=
'
https://conversejs.org
'
;
await
mock
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
domain
,
...
...
@@ -316,11 +318,15 @@ describe("XEP-0363: HTTP File Upload", function () {
`</x>`
+
`<origin-id id="
${
sent_stanza
.
nodeTree
.
querySelector
(
'
origin-id
'
).
getAttribute
(
"
id
"
)}
" xmlns="urn:xmpp:sid:0"/>`
+
`</message>`
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-image
'
),
1000
);
const
img_link_el
=
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
converse-chat-message-body .chat-image__link
'
),
1000
);
// Check that the image renders
expect
(
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__media
'
).
inn
erHTML
.
replace
(
/<!---->/g
,
''
).
trim
()).
toEqual
(
expect
(
img_link_el
.
out
erHTML
.
replace
(
/<!---->/g
,
''
).
trim
()).
toEqual
(
`<a class="chat-image__link" target="_blank" rel="noopener" href="
${
base_url
}
/logo/conversejs-filled.svg">`
+
`<img class="chat-image img-thumbnail" src="
${
base_url
}
/logo/conversejs-filled.svg"></a>`
);
expect
(
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__media
'
).
innerHTML
.
replace
(
/<!---->/g
,
''
).
trim
()).
toEqual
(
`<a target="_blank" rel="noopener" href="
${
base_url
}
/logo/conversejs-filled.svg">`
+
`Download image file "conversejs-filled.svg"</a>`
);
XMLHttpRequest
.
prototype
.
send
=
send_backup
;
done
();
}));
...
...
@@ -420,12 +426,16 @@ describe("XEP-0363: HTTP File Upload", function () {
`</x>`
+
`<origin-id id="
${
sent_stanza
.
nodeTree
.
querySelector
(
'
origin-id
'
).
getAttribute
(
"
id
"
)}
" xmlns="urn:xmpp:sid:0"/>`
+
`</message>`
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-image
'
),
1000
);
const
img_link_el
=
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
converse-chat-message-body .chat-image__link
'
),
1000
);
// Check that the image renders
expect
(
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__media
'
).
inn
erHTML
.
replace
(
/<!---->/g
,
''
).
trim
()).
toEqual
(
expect
(
img_link_el
.
out
erHTML
.
replace
(
/<!---->/g
,
''
).
trim
()).
toEqual
(
`<a class="chat-image__link" target="_blank" rel="noopener" href="
${
base_url
}
/logo/conversejs-filled.svg">`
+
`<img class="chat-image img-thumbnail" src="
${
base_url
}
/logo/conversejs-filled.svg"></a>`
);
expect
(
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__media
'
).
innerHTML
.
replace
(
/<!---->/g
,
''
).
trim
()).
toEqual
(
`<a target="_blank" rel="noopener" href="
${
base_url
}
/logo/conversejs-filled.svg">`
+
`Download image file "conversejs-filled.svg"</a>`
);
XMLHttpRequest
.
prototype
.
send
=
send_backup
;
done
();
}));
...
...
spec/messages.js
View file @
07f2f285
...
...
@@ -1876,15 +1876,16 @@ describe("A Chat Message", function () {
<x xmlns="jabber:x:oob"><url>
${
url
}
</url></x>
</message>`
);
_converse
.
connection
.
_dataRecv
(
mock
.
createRequest
(
stanza
));
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-content .chat-msg img
'
).
length
,
2000
);
_converse
.
connection
.
_dataRecv
(
mock
.
createRequest
(
stanza
));
await
new
Promise
(
resolve
=>
view
.
model
.
messages
.
once
(
'
rendered
'
,
resolve
));
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-content .chat-msg a
'
).
length
,
1000
);
const
msg
=
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__text
'
);
expect
(
u
.
hasClass
(
'
chat-msg__text
'
,
msg
)).
toBe
(
true
);
expect
(
msg
.
textContent
).
toEqual
(
'
Have you seen this funny image?
'
);
const
media
=
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__media
'
);
expect
(
media
.
innerHTML
.
replace
(
/<!---->/g
,
''
).
replace
(
/
(\r\n
|
\n
|
\r)
/gm
,
""
)).
toEqual
(
`<a
class="chat-image__link"
target="_blank" rel="noopener" href="
${
base_url
}
/logo/conversejs-filled.svg">`
+
`
<img class="chat-image img-thumbnail" src="
${
base_url
}
/logo/conversejs-filled.svg">
</a>`
);
`<a target="_blank" rel="noopener" href="
${
base_url
}
/logo/conversejs-filled.svg">`
+
`
Download image file "conversejs-filled.svg"
</a>`
);
done
();
}));
});
...
...
src/utils/html.js
View file @
07f2f285
...
...
@@ -115,10 +115,11 @@ function renderAudioURL (_converse, uri) {
}
function
renderImageURL
(
_converse
,
uri
)
{
if
(
!
_converse
.
api
.
settings
.
get
(
'
show_images_inline
'
))
{
return
u
.
convertURIoHyperlink
(
uri
);
}
return
tpl_image
({
'
url
'
:
uri
.
toString
()});
const
{
__
}
=
_converse
;
return
tpl_file
({
'
url
'
:
uri
.
toString
(),
'
label_download
'
:
__
(
'
Download image file "%1$s"
'
,
getFileName
(
uri
))
})
}
function
renderFileURL
(
_converse
,
uri
)
{
...
...
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