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

test: fix API test flakiness #30657

Merged
merged 6 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions apps/meteor/packages/rocketchat-mongo-config/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
};
}
6 changes: 2 additions & 4 deletions apps/meteor/server/lib/dataExport/uploadZipFile.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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');

Expand Down
Loading