const generateUsersThreads = (threadId, userId) => { const createdAt = faker.date.past(2); return { id: uuid(), createdAt, threadId, userId, isParticipant: true, receiveNotifications: true, }; }
const generateReaction = (userId, messageId) => { return { id: uuid(), messageId, userId, timestamp: faker.date.past(2), type: 'like', }; }
const generateCommunity = () => { const name = faker.company.companyName(); return { id: uuid(), createdAt: faker.date.past(2), name, description: casual.short_description(), website: faker.internet.url(), profilePhoto: faker.image.business(), coverPhoto: faker.image.image(), slug: slugify(name), }; }
const generateMessage = (senderId, threadId, threadType) => { return { id: uuid(), threadType, threadId, senderId, content: { body: casual.text(), }, messageType: 'text', timestamp: faker.date.past(2), }; }
it('should not interfere with calls of different request ID', async () => { let counter = 0; Parse.Cloud.afterSave('MyClass', () => { counter++; }); const promises = [...Array(100).keys()].map(() => { const params = { method: 'POST', url: 'http://localhost:8378/1/classes/MyClass', headers: { 'X-Parse-Application-Id': Parse.applicationId, 'X-Parse-Master-Key': Parse.masterKey, 'X-Parse-Request-Id': uuid.v4() } }; return request(params); }); await expectAsync(Promise.all(promises)).toBeResolved(); expect(counter).toBe(100); });
const generateUsersCommunities = (communityId, userId) => { const isOwner = faker.random.boolean(); // for ease of use, set to false const isModerator = false; // if user is either an admin or moderator, they have to be a member // otherwise random chance const isMember = isOwner || isModerator ? true : faker.random.boolean(); // might be blocked as long as they aren't an admin, mod, or member const isBlocked = isOwner || isModerator || isMember ? false : faker.random.boolean(); return { id: uuid(), createdAt: faker.date.past(2), communityId, userId, isOwner, isModerator, isMember, isBlocked, receiveNotifications: true, reputation: 1, }; }
const generateThread = (communityId, channelId, creatorId) => { const content = { title: casual.title(), body: JSON.stringify(toJSON(fromPlainText(casual.text()))), }; const createdAt = faker.date.past(2); return { id: uuid(), createdAt, creatorId, channelId, communityId, isPublished: faker.random.boolean(), content, type: 'DRAFTJS', lastActive: faker.date.between(createdAt, new Date()), edits: [ { timestamp: createdAt, content, }, ], modifiedAt: faker.date.between(createdAt, new Date()), }; }
const generateUsersDirectMessageThreads = (threadId, userId) => { const createdAt = faker.date.past(2); const lastActive = faker.date.between(createdAt, faker.date.recent()); const lastSeen = faker.date.between(createdAt, new Date()); return { id: uuid(), createdAt, threadId, userId, lastActive, lastSeen, receiveNotifications: true, }; }
const clientId = (0, _uuid.v4)(); const client = new _Client.Client(clientId, parseWebsocket, hasMasterKey, request.sessionToken, request.installationId);
const generateChannel = communityId => { const name = faker.commerce.department(); return { id: uuid(), communityId, createdAt: faker.date.past(2), name, description: casual.short_description(), slug: slugify(name), isPrivate: faker.random.boolean(), isDefault: false, }; }
function addToQueue (db, data) { var id = uuid() var createdAt = utils.getCurrentDateTimeAsString() var defaults = { meta: {} } if (!data.url || !utils.isValidUrl(data.url)) { return error.createErrorResponse(error.ERROR_INVALID_URL) } if (data.meta && typeof data.meta !== 'object') { return error.createErrorResponse(error.ERROR_META_IS_NOT_OBJECT) } data = Object.assign(defaults, data, { id: id, created_at: createdAt, completed_at: null, generations: [], pings: [], storage: {} }) debug('Pushing job to queue with data %s', JSON.stringify(data)) return db.pushToQueue(data) }
it('can be called', async () => { try { const clientMutationId = uuidv4();
const generateUser = () => { const createdAt = faker.date.past(2); const name = faker.name.findName(); return { id: uuid(), name, description: casual.short_description(), website: faker.internet.url(), username: faker.internet.userName(name), profilePhoto: faker.internet.avatar(), coverPhoto: faker.image.image(), email: faker.internet.email(name), providerId: uuid(), createdAt, // Make sure lastSeen is > createdAt lastSeen: faker.date.between(createdAt, new Date()), }; }
const generateUsersSettings = userId => { return { id: uuid(), userId, notifications: { types: { newMessageInThreads: { email: true, }, newThreadCreated: { email: true, }, dailyDigest: { email: true, }, weeklyDigest: { email: true, }, }, }, }; }
const generateDirectMessageThread = users => { const createdAt = faker.date.past(2); const threadLastActive = faker.date.between(createdAt, faker.date.recent()); return { id: uuid(), name: null, createdAt, threadLastActive, }; }