Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Do not rely on external service on tests #27874

Merged
merged 2 commits into from
Jan 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 16 additions & 6 deletions apps/meteor/tests/end-to-end/api/05-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,27 +749,37 @@ describe('[Chat]', function () {
let ytEmbedMsgId;
let imgUrlMsgId;

before(async () => {
await Promise.all([updateSetting('API_EmbedIgnoredHosts', ''), updateSetting('API_EmbedSafePorts', '80, 443, 3000')]);
});
after(async () => {
await Promise.all([
updateSetting('API_EmbedIgnoredHosts', 'localhost, 127.0.0.1, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16'),
updateSetting('API_EmbedSafePorts', '80, 443'),
]);
});

before(async () => {
const ytEmbedMsgPayload = {
_id: `id-${Date.now()}`,
rid: 'GENERAL',
msg: 'https://www.youtube.com/watch?v=T2v29gK8fP4',
emoji: ':smirk:',
};
const ytPostResponse = await request.post(api('chat.sendMessage')).set(credentials).send({ message: ytEmbedMsgPayload });
ytEmbedMsgId = ytPostResponse.body.message._id;
});

before(async () => {
const imgUrlMsgPayload = {
_id: `id-${Date.now()}1`,
rid: 'GENERAL',
msg: 'https://i.picsum.photos/id/671/200/200.jpg?hmac=F8KUqkSzkLxagDZW5rOEHLjzFVxRZWnkrFPvq2BlnhE',
msg: 'http://localhost:3000/images/logo/logo.png',
emoji: ':smirk:',
};

const ytPostResponse = await request.post(api('chat.sendMessage')).set(credentials).send({ message: ytEmbedMsgPayload });

const imgUrlResponse = await request.post(api('chat.sendMessage')).set(credentials).send({ message: imgUrlMsgPayload });

ytEmbedMsgId = ytPostResponse.body.message._id;
imgUrlMsgId = imgUrlResponse.body.message._id;
imgUrlMsgId = imgUrlResponse.body.message._id;
});

Expand Down Expand Up @@ -808,7 +818,7 @@ describe('[Chat]', function () {
.expect((res) => {
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');
expect(res.body.message.urls[0]).to.have.property('headers').to.have.property('contentType', 'image/png');
})
.end(done);
}, 200);
Expand Down