test: fix API test flakiness (#30657)

pull/30827/head
Diego Sampaio 2 years ago
parent da416dc8d4
commit d39aa0469c
No known key found for this signature in database
GPG Key ID: B71D302EB7F5183C
  1. 19
      apps/meteor/packages/rocketchat-mongo-config/server/index.js
  2. 6
      apps/meteor/server/lib/dataExport/uploadZipFile.ts

@ -34,20 +34,19 @@ if (Object.keys(mongoConnectionOptions).length > 0) {
process.env.HTTP_FORWARDED_COUNT = process.env.HTTP_FORWARDED_COUNT || '1';
// Send emails to a "fake" stream instead of print them in console in case MAIL_URL or SMTP is not configured
if (process.env.NODE_ENV !== 'development') {
const { sendAsync } = Email;
// Just print to logs if in TEST_MODE due to a bug in Meteor 2.5: TypeError: Cannot read property '_syncSendMail' of null
if (process.env.TEST_MODE === 'true') {
Email.sendAsync = function _sendAsync(options) {
console.log('Email.sendAsync', options);
};
} else if (process.env.NODE_ENV !== 'development') {
// Send emails to a "fake" stream instead of print them in console in case MAIL_URL or SMTP is not configured
const stream = new PassThrough();
stream.on('data', () => {});
stream.on('end', () => {});
Email.sendAsync = function _sendAsync(options) {
return sendAsync.call(this, { stream, ...options });
};
}
// Just print to logs if in TEST_MODE due to a bug in Meteor 2.5: TypeError: Cannot read property '_syncSendMail' of null
if (process.env.TEST_MODE === 'true') {
const { sendAsync } = Email;
Email.sendAsync = function _sendAsync(options) {
console.log('Email.sendAsync', options);
return sendAsync.call(this, { stream, ...options });
};
}

@ -1,5 +1,5 @@
import { createReadStream } from 'fs';
import { open, stat } from 'fs/promises';
import { stat } from 'fs/promises';
import type { IUser } from '@rocket.chat/core-typings';
import { Users } from '@rocket.chat/models';
@ -28,9 +28,7 @@ export const uploadZipFile = async (filePath: string, userId: IUser['_id'], expo
name: newFileName,
};
const { fd } = await open(filePath);
const stream = createReadStream('', { fd }); // @todo once upgrades to Node.js v16.x, use createReadStream from fs.promises.open
const stream = createReadStream(filePath);
const userDataStore = FileUpload.getStore('UserDataFiles');

Loading…
Cancel
Save