Chore: Change Youtube test to verify if has an iframe with max-width (#19863)

pull/19841/head
Diego Sampaio 5 years ago committed by GitHub
parent 43fe12d775
commit 9cd2c0ca40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 30
      tests/end-to-end/api/05-chat.js

@ -735,7 +735,7 @@ describe('[Chat]', function() {
imgUrlMsgId = imgUrlResponse.body.message._id;
});
it('should embed an youtube preview if message has a youtube url', (done) => {
it('should have an iframe oembed with style max-width', (done) => {
setTimeout(() => {
request.get(api('chat.getMessage'))
.set(credentials)
@ -745,10 +745,16 @@ describe('[Chat]', function() {
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
const msgMetadataUrl = res.body.message.urls[0].meta;
const expectedOembedHtml = '<iframe style="max-width: 100%" width="267" height="200" src="https://www.youtube.com/embed/T2v29gK8fP4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
expect(msgMetadataUrl).to.have.property('oembedHtml', expectedOembedHtml);
expect(res.body)
.to.have.property('message')
.to.have.property('urls')
.to.be.an('array')
.that.is.not.empty;
expect(res.body.message.urls[0])
.to.have.property('meta')
.to.have.property('oembedHtml')
.to.have.string('<iframe style="max-width: 100%"');
})
.end(done);
}, 200);
@ -764,11 +770,15 @@ describe('[Chat]', function() {
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
const msgHeaders = res.body.message.urls[0].headers;
console.log('msg urls object: ');
const expectedContentType = 'image/jpeg';
expect(msgHeaders).to.have.property('contentType', expectedContentType);
expect(res.body)
.to.have.property('message')
.to.have.property('urls')
.to.be.an('array')
.that.is.not.empty;
expect(res.body.message.urls[0])
.to.have.property('headers')
.to.have.property('contentType', 'image/jpeg');
})
.end(done);
}, 200);

Loading…
Cancel
Save